AmosSondaggi.php 5.36 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
<?php
/**
3
4
5
 * Copyright 2020 Art-ER S. Cons. P.A.
 * EROI - Emilia Romagna Open Innovation is based on:
 * https://www.open2.0.regione.lombardia.it
Marcello Pivanti's avatar
Marcello Pivanti committed
6
 *
Aster's avatar
Aster committed
7
 * @see http://example.com Developers'community
8
9
 * @license GPLv3
 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
Marcello Pivanti's avatar
Marcello Pivanti committed
10
 *
waltermazza's avatar
waltermazza committed
11
 * @package    arter\amos\sondaggi
Marcello Pivanti's avatar
Marcello Pivanti committed
12
13
14
15
 * @category   CategoryName
 * @author     Elite Division S.r.l.
 */

waltermazza's avatar
waltermazza committed
16
namespace arter\amos\sondaggi;
Marcello Pivanti's avatar
Marcello Pivanti committed
17

Aster's avatar
Aster committed
18
use arter\amos\core\interfaces\CmsModuleInterface;
waltermazza's avatar
waltermazza committed
19
20
21
22
23
24
use arter\amos\core\module\AmosModule;
use arter\amos\core\module\ModuleInterface;
use arter\amos\sondaggi\widgets\icons\WidgetIconAmministraSondaggi;
use arter\amos\sondaggi\widgets\icons\WidgetIconCompilaSondaggi;
use arter\amos\sondaggi\widgets\icons\WidgetIconPubblicaSondaggi;
use arter\amos\sondaggi\widgets\icons\WidgetIconSondaggi;
Marcello Pivanti's avatar
Marcello Pivanti committed
25
26
27
28
29
30
use Yii;
use yii\db\Connection;
use yii\helpers\ArrayHelper;

/**
 * Class AmosSondaggi
waltermazza's avatar
waltermazza committed
31
 * @package arter\amos\sondaggi
Marcello Pivanti's avatar
Marcello Pivanti committed
32
 */
Aster's avatar
Aster committed
33
class AmosSondaggi extends AmosModule implements ModuleInterface, CmsModuleInterface
Marcello Pivanti's avatar
Marcello Pivanti committed
34
35
{
    public static $CONFIG_FOLDER = 'config';
waltermazza's avatar
waltermazza committed
36
    public $controllerNamespace = 'arter\amos\sondaggi\controllers';
Marcello Pivanti's avatar
Marcello Pivanti committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    public $newFileMode = 0666;
    public $newDirMode = 0777;

    /**
     * In the case of a private poll for role, it is possible to send the notification to the users who can fill out the survey.
     * @var boolean
     */
    public $enableNotificationEmailByRoles = false;

    /**
     * Default email for the sender
     * @var string
     */
    public $defaultEmailSender;

    /**
     * It allows to show in the first page of the results the geoChart based on the province of domicile.
     * @var boolean
     */
    public $enableGeoChart = false;

    /**
     * It allows to show in the first page of the results a partecipant report if available.
     * @var boolean
     */
    public $enablePartecipantsReport = false;

    /**
     * The fields that will be displayed in the participant's //TO-DO
     * @var array
     */
    public $fieldsByPartecipants = [];

    /**
     * @var string|boolean the layout that should be applied for views within this module. This refers to a view name
     * relative to [[layoutPath]]. If this is not set, it means the layout value of the [[module|parent module]]
     * will be taken. If this is false, layout will be disabled within this module.
     */
    public $layout = 'main';
    public $name = 'Sondaggi';

    /**
     * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
     */
    public $db = 'db';
    
    /**
     * Hide the Option wheel in the graphic widget
     * @var bool|false $hideWidgetGraphicsActions
     */
    public $hideWidgetGraphicsActions = false;
Aster's avatar
Aster committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    
    /**
     * @var array $viewPathEmailSummary
     */
    public $viewPathEmailSummary = [
        'arter\amos\sondaggi\models\Sondaggi' => '@vendor/arter/amos-sondaggi/src/views/email/notify_summary'
    ];
    
    /**
     * @var array $viewPathEmailSummaryNetwork
     */
    public $viewPathEmailSummaryNetwork = [
        'arter\amos\sondaggi\models\Sondaggi' => '@vendor/arter/amos-sondaggi/src/views/email/notify_summary_network'
    ];
Marcello Pivanti's avatar
Marcello Pivanti committed
102
103
104
105
106
107
108
109
110

    /**
     * @inheritdoc
     */
    public function init()
    {
        parent::init();
        $this->db = Yii::$app->db;

waltermazza's avatar
waltermazza committed
111
        \Yii::setAlias('@arter/amos/' . static::getModuleName() . '/controllers/', __DIR__ . '/controllers/');
Marcello Pivanti's avatar
Marcello Pivanti committed
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
        // initialize the module with the configuration loaded from config.php
        $config = require(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
        Yii::configure($this, ArrayHelper::merge($config, $this));
    }
    

    /**
     * @inheritdoc
     */
    public static function getModuleName()
    {
        return "sondaggi";
    }

    /**
     * @inheritdoc
     */
    public function getWidgetIcons()
    {
        return [
            WidgetIconSondaggi::className(),
            WidgetIconCompilaSondaggi::className(),
            WidgetIconPubblicaSondaggi::className(),
            WidgetIconAmministraSondaggi::className(),
        ];
    }

    /**
     * @inheritdoc
     */
    public function getWidgetGraphics()
    {
        return [
        ];
    }

    /**
     * @inheritdoc
     */
    protected function getDefaultModels()
    {
Aster's avatar
Aster committed
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
        return [
            'Sondaggi' => __NAMESPACE__ . '\\' . 'models\Sondaggi',
            'SondaggiSearch' => __NAMESPACE__ . '\\' . 'models\search\SondaggiSearch',
        ];
    }


    /**
     *
     * @return string
     */
    public static function getModelClassName()
    {
        return AmosSondaggi::instance()->model('Sondaggi');
    }

    /**
     *
     * @return string
     */
    public static function getModelSearchClassName()
    {
        return AmosSondaggi::instance()->model('SondaggiSearch');
    }

    /**
     *
     * @return string
     */
    public function getFrontEndMenu($dept = 1)
    {
        $menu = "";
        $app  = \Yii::$app;
        if ((is_null($app->user) || $app->user->id == $app->params['platformConfigurations']['guestUserId'])) {
            //$menu .= $this->addFrontEndMenu(AmosSondaggi::t('amossondaggi','Gestione sondaggi'), AmosSondaggi::toUrlModule('/sondaggi'));
        }else{
            $menu .= $this->addFrontEndMenu(AmosSondaggi::t('amossondaggi','#menu_front_sondaggi'), AmosSondaggi::toUrlModule('/sondaggi'));
        }
        return $menu;
Marcello Pivanti's avatar
Marcello Pivanti committed
192
193
    }
}