当前位置: 首页>>代码示例>>PHP>>正文


PHP X2Model::afterUpdate方法代码示例

本文整理汇总了PHP中X2Model::afterUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::afterUpdate方法的具体用法?PHP X2Model::afterUpdate怎么用?PHP X2Model::afterUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X2Model的用法示例。


在下文中一共展示了X2Model::afterUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterUpdate

 /**
  * Responds when {@link X2Model::afterUpdate()} is called (record saved, but
  * not a new record). Sends a notification to anyone subscribed to this contact.
  *
  * Before executing this, the model must check whether the contact has the
  * "changelog" behavior. That is because the behavior is disabled
  * when checking for duplicates in {@link ContactsController}
  */
 public function afterUpdate()
 {
     if (!Yii::app()->params->noSession && $this->asa('changelog') && $this->asa('changelog')->enabled) {
         //$this->scenario != 'noChangelog') {
         // send subscribe emails if anyone has subscribed to this contact
         $result = Yii::app()->db->createCommand()->select('user_id')->from('x2_subscribe_contacts')->where('contact_id=:id', array(':id' => $this->id))->queryColumn();
         $datetime = Formatter::formatLongDateTime(time());
         $modelLink = CHtml::link($this->name, Yii::app()->controller->createAbsoluteUrl('/contacts/' . $this->id));
         $subject = 'X2Engine: ' . $this->name . ' updated';
         $message = "Hello,<br>\n<br>\n";
         $message .= 'You are receiving this email because you are subscribed to changes made to the contact ' . $modelLink . ' in X2Engine. ';
         $message .= 'The following changes were made on ' . $datetime . ":<br>\n<br>\n";
         foreach ($this->getChanges() as $attribute => $change) {
             if ($attribute != 'lastActivity') {
                 $old = $change[0] == '' ? '-----' : $change[0];
                 $new = $change[1] == '' ? '-----' : $change[1];
                 $label = $this->getAttributeLabel($attribute);
                 $message .= "{$label}: {$old} => {$new}<br>\n";
             }
         }
         $message .= "<br>\nYou can unsubscribe to these messages by going to {$modelLink} and clicking Unsubscribe.<br>\n<br>\n";
         $adminProfile = Yii::app()->params->adminProfile;
         foreach ($result as $subscription) {
             $subscription = array();
             if (isset($subscription['user_id'])) {
                 $profile = X2Model::model('Profile')->findByPk($subscription['user_id']);
                 if ($profile && $profile->emailAddress && $adminProfile && $adminProfile->emailAddress) {
                     $to = array('to' => array(array($profile->fullName, $profile->emailAddress)));
                     Yii::app()->controller->sendUserEmail($to, $subject, $message, null, Credentials::$sysUseId['systemNotificationEmail']);
                 }
             }
         }
     }
     parent::afterUpdate();
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:43,代码来源:Contacts.php


注:本文中的X2Model::afterUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。