예제 #1
0
 public function formatStoreRecord($record, $model, $store)
 {
     $r = new \GO\Base\Mail\EmailRecipients();
     $r->addRecipient($model->email, $model->name);
     $record['from'] = (string) $r;
     $record['html_signature'] = \GO\Base\Util\String::text_to_html($model->signature);
     $record['plain_signature'] = $model->signature;
     $record['signature_below_reply'] = $model->account->signature_below_reply;
     $record['template_id'] = 0;
     if (\GO::modules()->addressbook) {
         $defaultAccountTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->account_id);
         if ($defaultAccountTemplateModel) {
             $record['template_id'] = $defaultAccountTemplateModel->template_id;
         } else {
             $defaultUserTemplateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id);
             if (!$defaultUserTemplateModel) {
                 $defaultUserTemplateModel = new \GO\Addressbook\Model\DefaultTemplateForAccount();
                 $defaultUserTemplateModel->account_id = $model->account_id;
                 $defaultUserTemplateModel->save();
             }
             $record['template_id'] = $defaultUserTemplateModel->template_id;
         }
     }
     unset($record['signature']);
     return parent::formatStoreRecord($record, $model, $store);
 }
예제 #2
0
 protected function actionDefaultTemplateId($params)
 {
     $templateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($params['account_id']);
     if (!$templateModel) {
         $templateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id);
     }
     if (!$templateModel) {
         return array('success' => true, 'data' => array('template_id' => 0));
     } else {
         return array('success' => true, 'data' => array('template_id' => $templateModel->template_id));
     }
 }
예제 #3
0
파일: Account.php 프로젝트: ajaboa/crmpuan
 public function getDefaultTemplate()
 {
     if (\GO::modules()->addressbook) {
         $defaultAccountTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($this->id);
         if (!$defaultAccountTemplateModel) {
             $defaultUserTemplateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id);
             if (!$defaultUserTemplateModel) {
                 return false;
             } else {
                 return $defaultUserTemplateModel;
             }
         } else {
             return $defaultAccountTemplateModel;
         }
     } else {
         return false;
     }
 }
예제 #4
0
 protected function afterSubmit(&$response, &$model, &$params, $modifiedAttributes)
 {
     if (empty($params['id'])) {
         $model->addAlias($params['email'], $params['name']);
     } else {
         $alias = $model->getDefaultAlias();
         $alias->name = $params['name'];
         if (isset($params['email'])) {
             $alias->email = $params['email'];
         }
         $alias->signature = $params['signature'];
         $alias->save();
     }
     if (\GO::modules()->addressbook && isset($params['default_account_template_id'])) {
         if ($params['default_account_template_id'] == -1 || empty($params['default_account_template_id'])) {
             $defaultTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->id);
             if ($defaultTemplateModel) {
                 $defaultTemplateModel->delete();
             }
         } elseif ($params['default_account_template_id'] > 0) {
             $defaultTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->id);
             if (!$defaultTemplateModel) {
                 $defaultTemplateModel = new \GO\Addressbook\Model\DefaultTemplateForAccount();
                 $defaultTemplateModel->account_id = $model->id;
             }
             $defaultTemplateModel->template_id = $params['default_account_template_id'];
             $defaultTemplateModel->save();
         }
     }
     return parent::afterSubmit($response, $model, $params, $modifiedAttributes);
 }