Exemplo n.º 1
0
 /**
  * @param string $scenario
  * @param int $iSurveyId
  */
 public function __construct($iSurveyId = null, $scenario = 'insert')
 {
     if (!isset($iSurveyId)) {
         $iSurveyId = Response::getLastSurveyId();
     }
     $this->surveyId = $iSurveyId;
     parent::__construct($scenario);
 }
Exemplo n.º 2
0
 /**
  * @param string $scenario
  * @param string $sTableName
  */
 public function __construct($sTableName = null, $scenario = 'insert')
 {
     if (!isset($sTableName)) {
         //Yii::trace('sTableName missing.');
         throw new Exception('sTableName missing.');
     }
     $this->tableName = $sTableName;
     parent::__construct($scenario);
 }
Exemplo n.º 3
0
 /**
  * See example usage at manual page: https://manual.limesurvey.org/Notifications#Examples
  * @param array<string, mixed>|string|null $options If string then scenario
  */
 public function __construct($options = null)
 {
     // Don't do anything if this is called from self::model()
     if (is_string($options) || is_null($options)) {
         parent::__construct($options);
         // $options = scenario in this case
         return;
     } else {
         // Why not Zoidberg? (\/) (°,,,°) (\/)
         parent::__construct();
     }
     $options = $this->checkShortcuts($options);
     $this->checkMandatoryFields($options, array('entity', 'entity_id', 'title', 'message'));
     // Only allow 'survey' or 'user' as entity
     if ($options['entity'] != 'survey' && $options['entity'] != 'user') {
         throw new InvalidArgumentException('Invalid entity: ' . $options['entity']);
     }
     // Default to 'default' display class
     if (!isset($options['display_class'])) {
         $options['display_class'] = 'default';
     }
     // Default to 'log' notification importance
     if (!isset($options['importance'])) {
         $options['importance'] = self::NORMAL_IMPORTANCE;
     }
     // importance must be between 1 and 3
     if ($options['importance'] < 1 && $options['importance'] > 3) {
         throw new InvalidArgumentException('Invalid importance: ' . $options['importance']);
     }
     // Set everything up
     $this->entity = $options['entity'];
     $this->entity_id = $options['entity_id'];
     $this->title = $options['title'];
     $this->message = $options['message'];
     $this->display_class = $options['display_class'];
     $this->importance = $options['importance'];
     $this->status = 'new';
     $this->created = date('Y-m-d H:i:s', time());
     $this->first_read = null;
 }
Exemplo n.º 4
0
 public function __construct($scenario = 'insert')
 {
     list(, $this->dynamicId) = explode('_', get_class($this));
     parent::__construct($scenario);
 }