예제 #1
0
 /**
  * Formats data for associatedContacts before saving
  * @return boolean whether or not to save
  */
 public function beforeSave()
 {
     if (isset($this->associatedContacts)) {
         $this->associatedContacts = self::parseContacts($this->associatedContacts);
     }
     return parent::beforeSave();
 }
예제 #2
0
 /**
  * Fixes up record association, parses dates (since this doesn't use 
  * {@link X2Model::setX2Fields()})
  * @return boolean whether or not to save
  */
 public function beforeSave()
 {
     if ($this->scenario !== 'workflow') {
         $association = self::getAssociationModel($this->associationType, $this->associationId);
         if ($association === null) {
             $this->associationName = 'None';
             $this->associationId = 0;
         } else {
             if ($association->hasAttribute('name')) {
                 $this->associationName = $association->name;
             }
             if ($association->asa('X2TimestampBehavior') !== null) {
                 if ($association->asa('changelog') !== null && Yii::app()->getSuName() == 'Guest') {
                     $association->disableBehavior('changelog');
                 }
                 $association->updateLastActivity();
                 $association->enableBehavior('changelog');
             }
         }
         if ($this->associationName == 'None' && $this->associationType != 'none') {
             $this->associationName = ucfirst($this->associationType);
         }
         $this->dueDate = Formatter::parseDateTime($this->dueDate);
         $this->completeDate = Formatter::parseDateTime($this->completeDate);
     }
     // Whether this is a "timed" action record:
     $timed = $this->isTimedType;
     if (empty($timeSpent) && !empty($this->completeDate) && !empty($this->dueDate) && $timed) {
         $this->timeSpent = $this->completeDate - $this->dueDate;
     }
     return parent::beforeSave();
 }
예제 #3
0
파일: Media.php 프로젝트: xl602/X2CRM
 public function beforeSave()
 {
     if (empty($this->associationType)) {
         $this->associationType = 'none';
     }
     if (empty($this->uploadedBy)) {
         $this->uploadedBy = Yii::app()->user->name;
     }
     if (empty($this->name)) {
         $this->name = $this->fileName;
     }
     if ($this->isNewRecord && $this->associationType !== 'theme' && empty($this->accessKey)) {
         $this->accessKey = bin2hex(openssl_random_pseudo_bytes(32));
     }
     $this->getPath();
     return parent::beforeSave();
 }
예제 #4
0
 public function beforeSave()
 {
     // backwards compatibility check for when leads didn't have first and last name fields
     if (!$this->isNewRecord && !$this->firstName && !$this->lastName && ($this->attributeChanged('firstName') || $this->attributeChanged('lastName'))) {
         $this->name = '';
     }
     return parent::beforeSave();
 }
예제 #5
0
파일: Contacts.php 프로젝트: dsyman2/X2CRM
 /**
  * @return boolean whether or not to save
  */
 public function beforeSave()
 {
     if ($this->trackingKey === null) {
         $this->trackingKey = self::getNewTrackingKey();
     }
     return parent::beforeSave();
 }