/**
  * The before save event, sets the time joined value if necessary
  * @return boolean whether the save should continue or not
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->timeJoined = isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time();
     }
     return parent::beforeSave();
 }
 function getDbConnection()
 {
     if (self::$db !== null) {
         return self::$db;
     } else {
         self::$db = Yii::app()->userDb;
         if (self::$db instanceof CDbConnection) {
             return self::$db;
         } else {
             throw new CDbException(Yii::t('yii', 'Frontend Active Record requires a "userDb" CDbConnection application component.'));
         }
     }
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return UserStatusChain the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Beispiel #4
0
 /**
  * This method is invoked after a user is saved
  * The default implementation raises the {@link onAfterRegister} and {@link onAfterSave} events.
  * @see CActiveRecord::afterSave()
  */
 protected function afterSave()
 {
     if ($this->scenario == "register") {
         $this->afterRegister();
     }
     parent::afterSave();
 }
Beispiel #5
0
 /**
  * Deletes the file after a resource is deleted.
  * @see CActiveRecord::afterDelete()
  */
 public function afterDelete()
 {
     if (file_exists($this->path)) {
         unlink($this->path);
     }
     parent::afterDelete();
 }