Esempio n. 1
0
 /**
  * This method is invoked before saving a record (after validation, if any).
  * The default implementation raises the {@link onBeforeSave} event.
  * You may override this method to do any preparation work for record saving.
  * Use {@link isNewRecord} to determine whether the saving is
  * for inserting or updating record.
  * Make sure you call the parent implementation so that the event is raised properly.
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 public function beforeSave()
 {
     if ($this->usesleft > 0) {
         $this->completed = 'N';
     }
     return parent::beforeSave();
 }
Esempio n. 2
0
 /**
  * This method is invoked before saving a record (after validation, if any).
  * The default implementation raises the {@link onBeforeSave} event.
  * You may override this method to do any preparation work for record saving.
  * Use {@link isNewRecord} to determine whether the saving is
  * for inserting or updating record.
  * Make sure you call the parent implementation so that the event is raised properly.
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 public function beforeSave()
 {
     // Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected
     if (gettype($this->password) == 'resource') {
         $this->password = stream_get_contents($this->password, -1, 0);
     }
     return parent::beforeSave();
 }
Esempio n. 3
0
 /**
  * Make sure we don't save a new question group
  * while the survey is active.
  *
  * @return bool
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $surveyIsActive = Survey::model()->findByPk($this->sid)->active !== 'N';
         if ($surveyIsActive && $this->getIsNewRecord()) {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * This method is invoked before saving a record (after validation, if any).
  * The default implementation raises the {@link onBeforeSave} event.
  * You may override this method to do any preparation work for record saving.
  * Use {@link isNewRecord} to determine whether the saving is
  * for inserting or updating record.
  * Make sure you call the parent implementation so that the event is raised properly.
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 public function beforeSave()
 {
     // Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected
     if ($this->usesleft > 0) {
         $this->completed = 'N';
     }
     return parent::beforeSave();
 }