public function create()
 {
     if ($this->mNeedCheckIn && !$this->prms['manage']) {
         $this->errorOutput(NO_OPRATION_PRIVILEGE);
     }
     $name = trim($this->input['name']);
     if (!$name) {
         $this->errorOutput('名称不能为空');
     }
     $appuniqueid = trim($this->input['appuniqueid']);
     if (!$appuniqueid || $appuniqueid == '-1') {
         $this->errorOutput('请选择应用标识');
     }
     $Object = new email_content_template();
     if (!$Object->check_appuniqueid_exists($appuniqueid)) {
         $this->errorOutput('请选择正确的邮件内容模版');
     }
     if ($this->mEmailSettings->check_appuniqueid_exists($appuniqueid)) {
         $this->errorOutput($appuniqueid . ' 标识已被占用');
     }
     $emailsend = trim($this->input['emailsend']);
     if (!$emailsend) {
         $this->errorOutput('邮箱地址不能为空');
     }
     $emailwrapbracket = intval($this->input['emailwrapbracket']);
     $smtpauth = intval($this->input['smtpauth']);
     $smtphost = trim($this->input['smtphost']);
     $smtpport = intval($this->input['smtpport']);
     $fromname = trim($this->input['fromname']);
     $smtpuser = trim($this->input['smtpuser']);
     $smtppassword = trim($this->input['smtppassword']);
     if ($smtppassword) {
         $smtppassword = hg_encript_str($smtppassword);
     }
     $brief = trim($this->input['brief']) == '这里输入描述' ? '' : trim($this->input['brief']);
     $data = array('name' => $name, 'brief' => $brief, 'appuniqueid' => $appuniqueid, 'emailsend' => $emailsend, 'emailwrapbracket' => $emailwrapbracket, 'emailtype' => trim($this->input['emailtype']), 'usessl' => trim($this->input['usessl']), 'smtpauth' => $smtpauth, 'smtphost' => $smtphost, 'smtpport' => $smtpport ? $smtpport : 25, 'fromname' => $fromname ? $fromname : '管理员', 'smtpuser' => $smtpuser, 'smtppassword' => $smtppassword, 'email_footer' => $this->settings['email_settings']['email_footer']);
     $htmlheader = '';
     $htmlfooter = '';
     $is_head_foot = intval($this->input['is_head_foot']);
     if ($is_head_foot) {
         $header = trim($this->input['header']);
         $footer = trim($this->input['footer']);
         if (!$header || !$footer) {
             $this->errorOutput('邮件头尾不能为空');
         }
         if (get_magic_quotes_gpc()) {
             $htmlheader = stripslashes($header);
             $htmlfooter = stripslashes($footer);
         } else {
             $htmlheader = $header;
             $htmlfooter = $footer;
         }
     }
     $info = $this->mEmailSettings->create($data, $is_head_foot, $htmlheader, $htmlfooter);
     $this->addItem($info);
     $this->output();
 }
Exemple #2
0
 public function getEmailContentField()
 {
     $condition = '';
     if ($sid = $this->input['id']) {
         $condition .= " AND id =" . $sid;
     }
     $object = new email_content_template();
     $contentField = $object->show('', 0, 100, '', '', 'name,appuniqueid');
     $setInfo = $this->mEmailSettings->show($condition, 0, 0, '', '', 'appuniqueid', 'appuniqueid');
     if (is_array($contentField)) {
         foreach ($contentField as $v) {
             if (!$sid && !array_key_exists($v['appuniqueid'], $setInfo)) {
                 $this->addItem_withkey($v['appuniqueid'], $v['name']);
             } elseif ($sid && array_key_exists($v['appuniqueid'], $setInfo)) {
                 $this->addItem_withkey($v['appuniqueid'], $v['name']);
             }
         }
     }
     $this->output();
 }