Example #1
0
 public function templateNested(GWF_Guestbook $gb)
 {
     $gbid = $gb->getID();
     $ipp = $this->module->cfgItemsPerPage();
     $user = GWF_Session::getUser();
     $can_moderate = $gb->canModerate($user);
     $mod = GWF_GuestbookMSG::IN_MODERATION;
     $msgs = GDO::table('GWF_GuestbookMSG');
     $conditions = "gbm_gbid={$gbid} AND gbm_replyto=0";
     $conditions .= $can_moderate ? '' : " AND gbm_options&{$mod}=0";
     $nItems = $msgs->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(intval(Common::getGet('page', $nPages)), 1, $nPages);
     $gbid_app = $gbid === 1 ? '' : '/' . $gbid;
     # append
     $orderby = 'gbm_date ASC';
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $tVars = array('gb' => $gb, 'entries' => $this->getNestedEntries($gb, $msgs, $conditions, $ipp, $from), 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'guestbook/show' . $gbid_app . '/page-%PAGE%'), 'href_sign' => GWF_WEB_ROOT . 'guestbook/sign/' . $gbid, 'href_moderate' => GWF_WEB_ROOT . 'guestbook/edit/' . $gbid, 'can_moderate' => $can_moderate);
     return $this->module->templatePHP('show_nested.php', $tVars);
 }
Example #2
0
 public function execute()
 {
     if (false === ($mod_gb = GWF_Module::loadModuleDB('Guestbook', true))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array('Guestbook'));
     }
     $mod_gb instanceof Module_Guestbook;
     $user = GWF_Session::getUser();
     if (!$mod_gb->canCreateGuestbook($user)) {
         return $this->module->error('err_create_gb');
     }
     if (false !== ($gb = $mod_gb->getGuestbook($user->getID()))) {
         GWF_Website::redirect($gb->hrefEdit());
         return '';
         //			return $this->module->error('err_have_gb');
     }
     $options = GWF_Guestbook::DEFAULT_OPTIONS;
     $gb = new GWF_Guestbook(array('gb_uid' => $user->getID(), 'gb_title' => $user->getVar('user_name') . 's Guestbook', 'gb_descr' => $user->getVar('user_name') . 's Guestbook', 'gb_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'gb_options' => $options));
     if (false === $gb->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_created_gb', array(GWF_WEB_ROOT . 'guestbook/edit/' . $gb->getID()));
 }
Example #3
0
 public function onSetPublic(GWF_Guestbook $gb, $gbmid, $state)
 {
     if (false === ($gbm = GWF_GuestbookMSG::getByID($gbmid))) {
         return $this->module->error('err_gbm');
     }
     if ($gbm->getVar('gbm_gbid') !== $gb->getID()) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     if (!$gbm->isToggleAllowed()) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     if (false === $gbm->saveOption(GWF_GuestbookMSG::SHOW_PUBLIC, $state)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_gbm_pub_' . ($state ? '1' : '0'));
 }
Example #4
0
 private function sendEmailModerate(GWF_Guestbook $gb, GWF_GuestbookMSG $gbm)
 {
     $mail = new GWF_Mail();
     $mail->setSender(GWF_BOT_EMAIL);
     $owner = $gb->getUser();
     if ($owner === false || '' === ($rec = $owner->getValidMail())) {
         $rec = GWF_ADMIN_EMAIL;
         $cc = GWF_STAFF_EMAILS;
         $recname = 'Staff';
     } else {
         $cc = '';
         $recname = $owner->displayUsername();
     }
     $mail->setReceiver($rec);
     $mail->setSubject($this->module->langAdmin('mails_signed'));
     $link = Common::getAbsoluteURL('index.php?mo=Guestbook&me=Unlock&set_moderation=0&gbid=' . $gb->getID() . '&gbmid=' . $gbm->getID() . '&gbmtoken=' . $gbm->getHashcode());
     $link = GWF_HTML::anchor($link, $link);
     $mail->setBody($this->module->langAdmin('mailb_signed', array($recname, $gb->displayTitle(), $gbm->displayUsername(), $gbm->displayEMail(true), $gbm->display('gbm_message'), $link)));
     if ($owner === false) {
         $mail->sendAsHTML($cc);
     } else {
         $mail->sendToUser($owner);
     }
 }