AmosSondaggi.php 5.07 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
<?php
Aster's avatar
Aster committed
2

Marcello Pivanti's avatar
Marcello Pivanti committed
3
/**
Aster's avatar
Aster committed
4
5
 * Emilia Romagna Open Innovation
 * Arter
Marcello Pivanti's avatar
Marcello Pivanti committed
6
7
 *
 *
Aster's avatar
Aster committed
8
 * @package    arter\amos\sondaggi
Marcello Pivanti's avatar
Marcello Pivanti committed
9
10
11
 * @category   CategoryName
 */

Aster's avatar
Aster committed
12
namespace arter\amos\sondaggi;
Marcello Pivanti's avatar
Marcello Pivanti committed
13

Aster's avatar
Aster committed
14
15
16
17
18
19
20
use arter\amos\core\interfaces\CmsModuleInterface;
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
21
22
23
24
25
26
use Yii;
use yii\db\Connection;
use yii\helpers\ArrayHelper;

/**
 * Class AmosSondaggi
Aster's avatar
Aster committed
27
 * @package arter\amos\sondaggi
Marcello Pivanti's avatar
Marcello Pivanti committed
28
 */
Aster's avatar
Aster committed
29
class AmosSondaggi extends AmosModule implements ModuleInterface, CmsModuleInterface
Marcello Pivanti's avatar
Marcello Pivanti committed
30
31
{
    public static $CONFIG_FOLDER = 'config';
Aster's avatar
Aster committed
32
    public $controllerNamespace = 'arter\amos\sondaggi\controllers';
Marcello Pivanti's avatar
Marcello Pivanti committed
33
34
35
36
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
    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
84
85
86
87
88
    
    /**
     * @var array $viewPathEmailSummary
     */
    public $viewPathEmailSummary = [
Aster's avatar
Aster committed
89
        'arter\amos\sondaggi\models\Sondaggi' => '@vendor/arter/amos-sondaggi/src/views/email/notify_summary'
Aster's avatar
Aster committed
90
91
92
93
94
95
    ];
    
    /**
     * @var array $viewPathEmailSummaryNetwork
     */
    public $viewPathEmailSummaryNetwork = [
Aster's avatar
Aster committed
96
        'arter\amos\sondaggi\models\Sondaggi' => '@vendor/arter/amos-sondaggi/src/views/email/notify_summary_network'
Aster's avatar
Aster committed
97
    ];
Marcello Pivanti's avatar
Marcello Pivanti committed
98
99
100
101
102
103
104
105
106

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

Aster's avatar
Aster committed
107
        \Yii::setAlias('@arter/amos/' . static::getModuleName() . '/controllers/', __DIR__ . '/controllers/');
Marcello Pivanti's avatar
Marcello Pivanti committed
108
109
110
111
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
        // 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
149
150
151
152
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
        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
188
189
    }
}