* @package doc * @version $Id: model.php 881 2010-06-22 06:50:32Z chencongzhi520 $ * @link http://www.zentao.net */ ?> "; $selectHtml .= html::a(helper::createLink('doc', 'index'), $this->lang->doc->index, '', "class='btn'"); $selectHtml .= ''; if($type) { $fastLib = in_array($type, array_keys($this->lang->doc->fastMenuList)) ? $this->lang->doc->fastMenuList[$type] : $this->lang->doc->fast; if($libID) { $lib = $this->getLibById($libID); if(!$this->checkPrivLib($lib)) { echo(js::alert($this->lang->doc->accessDenied)); $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(inlink('index'))); die(js::locate('back')); } $type = $lib->type; } if(isset($this->lang->doc->libTypeList[$type])) { $mainLib = $this->lang->doc->libTypeList[$type]; $selectHtml .= "
| ", " | ", $doc->content); $doc->content = str_replace(" | ", " | ", $doc->content); } /* Get action info. */ $action = $this->loadModel('action')->getById($actionID); $history = $this->action->getHistory($actionID); $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); /* Get mail content. */ $modulePath = $this->app->getModulePath($appName = '', 'doc'); $oldcwd = getcwd(); $viewFile = $modulePath . 'view/sendmail.html.php'; chdir($modulePath . 'view'); if(file_exists($modulePath . 'ext/view/sendmail.html.php')) { $viewFile = $modulePath . 'ext/view/sendmail.html.php'; chdir($modulePath . 'ext/view'); } ob_start(); include $viewFile; foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; $mailContent = ob_get_contents(); ob_end_clean(); chdir($oldcwd); /* Get sender and subject. */ $sendUsers = $this->getToAndCcList($doc); if(!$sendUsers) return; list($toList, $ccList) = $sendUsers; $subject = $this->getSubject($doc, $action->action); /* Send mail. */ $this->mail->send($toList, $subject, $mailContent, $ccList); if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); } /** * Get mail subject. * * @param object $doc * @param string $actionType created|edited * @access public * @return string */ public function getSubject($doc, $actionType) { /* Set email title. */ if($actionType == 'created') { return sprintf($this->lang->doc->mail->create->title, $this->app->user->realname, $doc->id, $doc->title); } else { return sprintf($this->lang->doc->mail->edit->title, $this->app->user->realname, $doc->id, $doc->title); } } /** * Get toList and ccList. * * @param object $doc * @access public * @return bool|array */ public function getToAndCcList($doc) { /* Set toList and ccList. */ $toList = ''; $ccList = str_replace(' ', '', trim($doc->mailto, ',')); if(empty($toList)) { if(empty($ccList)) return false; if(strpos($ccList, ',') === false) { $toList = $ccList; $ccList = ''; } else { $commaPos = strpos($ccList, ','); $toList = substr($ccList, 0, $commaPos); $ccList = substr($ccList, $commaPos + 1); } } return array($toList, $ccList); } } |
|---|