Exemple #1
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (!isset($this->originalAttributeValues['probability'])) {
             $this->resolveStageToProbability();
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (array_key_exists('value', $this->stage->originalAttributeValues)) {
             $this->resolveStageToProbability();
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #3
0
 /**
  * Update latestDateTime based on new related comments
  * (non-PHPdoc)
  * @see Item::beforeSave()
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->comments->isModified() || $this->getIsNewModel()) {
             $this->unrestrictedSet('latestDateTime', DateTimeUtil::convertTimestampToDbFormatDateTime(time()));
         }
         return true;
     } else {
         return false;
     }
 }
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $automaticMappingDisabled = OpportunitiesModule::isAutomaticProbabilityMappingDisabled();
         if (!isset($this->originalAttributeValues['probability']) && $automaticMappingDisabled === false) {
             $this->resolveStageToProbability();
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * Alter hasReadLatest and/or ownerHasReadLatest based on comments being added.
  * (non-PHPdoc)
  * @see Item::beforeSave()
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->comments->isModified() || $this->getIsNewModel()) {
             $this->unrestrictedSet('latestDateTime', DateTimeUtil::convertTimestampToDbFormatDateTime(time()));
             if ($this->getIsNewModel()) {
                 $this->ownerHasReadLatest = true;
             }
         }
         if ($this->comments->isModified()) {
             foreach ($this->comments as $comment) {
                 if ($comment->id < 0) {
                     if (Yii::app()->user->userModel != $this->owner) {
                         $this->ownerHasReadLatest = false;
                     }
                     foreach ($this->conversationParticipants as $position => $participant) {
                         //At this point the createdByUser is not populated yet in the comment, so we can
                         //use the current user.
                         if ($participant->person->getClassId('Item') != Yii::app()->user->userModel->getClassId('Item')) {
                             $this->conversationParticipants[$position]->hasReadLatest = false;
                         }
                     }
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * Alter takenByUserHasReadLatest and/or ownerHasReadLatest based on comments being added.
  * (non-PHPdoc)
  * @see Item::beforeSave()
  */
 protected function beforeSave()
 {
     $missionRules = new MissionMashableInboxRules();
     $personsToAddAsHaveNotReadLatest = array();
     if (parent::beforeSave()) {
         if ($this->getIsNewModel()) {
             $this->unrestrictedSet('latestDateTime', DateTimeUtil::convertTimestampToDbFormatDateTime(time()));
             $personsToAddAsHaveNotReadLatest = MissionsUtil::resolvePeopleToSendNotificationToOnNewMission($this);
         }
         if (isset($this->originalAttributeValues['status']) && $this->originalAttributeValues['status'] != $this->status && $this->status == self::STATUS_TAKEN) {
             MissionsUtil::markAllUserHasReadLatestExceptOwnerAndTakenBy($this);
         }
         if ($this->comments->isModified()) {
             $this->unrestrictedSet('latestDateTime', DateTimeUtil::convertTimestampToDbFormatDateTime(time()));
             foreach ($this->comments as $comment) {
                 if ($comment->id < 0) {
                     if (Yii::app()->user->userModel != $this->owner) {
                         $this->sendOwnerUnreadCommentNotification = true;
                     }
                     if (Yii::app()->user->userModel != $this->takenByUser && $this->takenByUser->id > 0) {
                         $this->sendTakenByUserUnreadCommentNotification = true;
                     }
                 }
             }
             $people = MissionsUtil::resolvePeopleToSendNotificationToOnNewComment($this, Yii::app()->user->userModel);
             foreach ($people as $person) {
                 if ($missionRules->hasUserReadLatest($this, $person)) {
                     if (!in_array($person, $personsToAddAsHaveNotReadLatest)) {
                         $personsToAddAsHaveNotReadLatest[] = $person;
                     }
                 }
             }
         }
         foreach ($personsToAddAsHaveNotReadLatest as $person) {
             $personWhoHaveNotReadLatest = $missionRules->makePersonWhoHasNotReadLatest($person);
             $personsToAddAsHaveNotReadLatest[] = $personWhoHaveNotReadLatest;
             $this->personsWhoHaveNotReadLatest->add($personWhoHaveNotReadLatest);
         }
         return true;
     } else {
         return false;
     }
 }
 protected function beforeSave()
 {
     if ($this->togglePausedStatusToActive() && $this->status == static::STATUS_PAUSED) {
         $this->status = static::STATUS_ACTIVE;
     }
     return parent::beforeSave();
 }