Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * Invoked after a user model is saved.
  * Invokes beforeRegister() and hashes the user's password if required.
  * @see CActiveRecord::beforeSave()
  * @see beforeRegister()
  * @return boolean whether the save should continue or not
  */
 protected function beforeSave()
 {
     if ($this->scenario == "register" && !$this->beforeRegister()) {
         return false;
     }
     if ($this->isNewRecord || $this->password != $this->_password) {
         if ($this->password == "") {
             $this->password = $this->_password;
         } else {
             $this->salt = $this->generateSalt();
             $this->password = $this->hashPassword($this->password, $this->salt);
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 3
0
 /**
  * Triggered before the resource is saved
  * @see CActiveRecord::beforeSave()
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->timeAdded = isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time();
         if (!Yii::app()->user->isGuest) {
             $this->userId = Yii::app()->user->id;
         }
         $path = Yii::app()->getModule("resources")->resourceDir . "/";
         $path .= $this->ownerModel . "/" . $this->ownerId . "/" . $this->ownerAttribute . "/";
         if (!file_exists($path)) {
             mkdir($path, 0755, true);
         }
         $path .= $this->name;
         $this->path = $path;
         if ($this->size === null) {
             $this->size = is_object($this->_uploadedFile) ? $this->_uploadedFile->size : strlen($this->content);
         }
     }
     return parent::beforeSave();
 }