'doShow', 'insert' => 'doInsert', 'insert2' => 'doInsertFromSession', ); var $ipp = 10; var $pageNum = null; function setAction($action) { $this->action = $action; } function exec() { if ($this->action == '') { $this->action = $_REQUEST['action']; } if (!key_exists($this->action, $this->actions)) { $actionNames = array_keys($this->actions); $this->action = $actionNames[0]; } $function = $this->actions[$this->action]; if ($this->isXmlHttpRequest()) { $function .= 'Ajax'; } if (method_exists($this, $function)) { $this->$function(); } else { exit; } } function doEmpty() { return false; } function doShow() { //$this->doList(); //$this->doNew(); } function doList() { $this->_saveBackUrl(); $this->DBObj->setApproved(); $list = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $list->def_order_by = 'added DESC'; $list->tpl = BASE_PATH . '/tpl/Announcement/Reply/list.tpl'; if (!empty($this->ipp)) { $list->ipp = $this->ipp; } if (!empty($this->pageNum)) { $list->pageNum = $this->pageNum; } $list->setPagerLink(BASE_URL . '/blog/' . $this->DBObj->getAnnouncementAlias()); $list->exec(); } function _getNewForm() { $form = parent::_getNewForm(); $form->removeElement('member_name'); $form->removeElement('approved'); $form->removeElement('id_member'); return $form; } function doNew() { $memberData = $this->Doc->MemberAuth->getData(); //if (!empty($memberData)) { $moderationMessage = (bool) Session::getData(CURR_PAGE, 'showModerationMessage'); if (!empty($moderationMessage)) { Session::clearData(CURR_PAGE, 'showModerationMessage'); } $this->Doc->assign('_showModerationMessage', $moderationMessage); $form = $this->_getNewForm(); $this->renderForm($form); //} } function renderForm($form) { $this->Doc->addItemProp('JSs', 'js/jquery.scrollTo.js'); $form->tpl = BASE_PATH . '/tpl/Announcement/Reply/commentForm.tpl'; $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); $form->setCancelType(null); $form->setSubmitTitle('Submit Comment'); $form->exec(); } function doInsert() { $memberData = $this->Doc->MemberAuth->getData(); $form = $this->_getNewForm(); if ($form->validate()) { $data = $form->exportValues(); if (!empty($memberData)) { $data['id_member'] = $memberData['id']; $this->_insert($data); $this->doBack(); } else { Session::setData(CURR_PAGE_FULL, 'reply', $data); $this->Doc->MemberAuth->setLogin2(CURR_PAGE_FULL . '?action=insert2'); $this->_loginForm(); } } else { $this->doList(); $this->renderForm($form); } return true; } function doInsertFromSession() { $memberData = $this->Doc->MemberAuth->getData(); if (!empty($memberData)) { $data = Session::getData(CURR_PAGE_FULL, 'reply'); Session::clearData(CURR_PAGE_FULL, 'reply'); if (!empty($data)) { $data['id_member'] = $memberData['id']; $this->_insert($data); $this->doBack(); } } else { $this->_loginForm(); } return $this; } function _insert($data) { $this->DBObj->initFromArray($data); $this->DBObj->insert(); $this->_sendNottification(); Session::setData(CURR_PAGE, 'showModerationMessage', true); return $this; } function _loginForm() { skHTTP::redirect($this->Doc->MemberAuth->loginPage); } function _sendNottification() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); $recipients = Settings::get('admin_email'); $recipients = split("[, ;\n\r]", $recipients); foreach ($recipients as $k => $v) { $v = trim($v); if (empty($v)) { unset($recipients[$k]); } } $recipients = array_unique($recipients); if (!empty($data) && !empty($recipients)) { $data['link'] = htmlspecialchars(BASE_URL . '/admin/blog/reply/?action=edit&id=' . $data['id'] . '&id_announcement=' . $data['id_announcement'] . '&setBackUrl'); $data['comment'] = nl2br(htmlspecialchars($data['comment'])); $data['name'] = htmlspecialchars($this->DBObj->getMemberName($data['id_member'])); $data['title'] = htmlspecialchars($this->DBObj->getAnnouncementTitle()); $subject = 'New comments have been posted'; $body = "
New comments have been posted to \"{$data['title']}\" post.
" . "Name:{$data['name']}
Comments:
{$data['comment']}