コード例 #1
0
 public function test()
 {
     $objDB = class_carrier::getInstance()->getObjDB();
     echo "\tmodul_guestbook...\n";
     echo "creating a new guestbook, moderated...\n";
     $objGuestbook = new class_module_guestbook_guestbook();
     $objGuestbook->setStrGuestbookTitle("test guestbook");
     $objGuestbook->setIntGuestbookModerated(1);
     $objGuestbook->updateObjectToDb();
     $strGBId = $objGuestbook->getSystemid();
     echo "adding a new post...\n";
     $objPost = new class_module_guestbook_post();
     $objPost->setStrGuestbookPostName("subject");
     $objPost->setStrGuestbookPostText("test");
     $objPost->updateObjectToDb($strGBId);
     $objDB->flushQueryCache();
     $this->assertEquals(0, count(class_module_guestbook_post::getPosts($strGBId, true)), __FILE__ . " check nr of posts portal");
     $this->assertEquals(1, count(class_module_guestbook_post::getPosts($strGBId)), __FILE__ . " check nr of posts total");
     echo "setting guestbook non-moderated...\n";
     $objGuestbook->setIntGuestbookModerated(0);
     $objGuestbook->updateObjectToDb();
     $objDB->flushQueryCache();
     echo "adding a new post...\n";
     $objPost = new class_module_guestbook_post();
     $objPost->setStrGuestbookPostName("subject2");
     $objPost->setStrGuestbookPostText("test2");
     $objPost->updateObjectToDb($strGBId);
     $this->assertEquals(1, count(class_module_guestbook_post::getPosts($strGBId, true)), __FILE__ . " check nr of posts portal");
     $this->assertEquals(2, count(class_module_guestbook_post::getPosts($strGBId)), __FILE__ . " check nr of posts total");
     $objDB->flushQueryCache();
     echo "deleting the guestbook...\n";
     $objGuestbook->deleteObjectFromDatabase();
 }
コード例 #2
0
 /**
  * Return an on-lick link for the passed object.
  * This link is rendered by the portal search result generator, so
  * make sure the link is a valid portal page.
  * If you want to suppress the entry from the result, return an empty string instead.
  * If you want to add additional entries to the result set, clone the result and modify
  * the new instance to your needs. Pack them in an array and they'll be merged
  * into the result set afterwards.
  * Make sure to return the passed result-object in this array, too.
  *
  * @param class_search_result $objResult
  *
  * @see getLinkPortalHref()
  * @return mixed
  */
 public function updateSearchResult(class_search_result $objResult)
 {
     $objORM = new class_orm_objectlist();
     $strQuery = "SELECT page_name, guestbook_amount, page_id\n                       FROM " . _dbprefix_ . "element_guestbook,\n                            " . _dbprefix_ . "page_element,\n                            " . _dbprefix_ . "page,\n                            " . _dbprefix_ . "system\n                      WHERE guestbook_id = ?\n                        AND content_id = page_element_id\n                        AND content_id = system_id\n                        AND system_prev_id = page_id\n                        AND system_status = 1\n                        " . $objORM->getDeletedWhereRestriction() . "\n                        AND page_element_ph_language = ? ";
     $arrRows = $this->objDB->getPArray($strQuery, array($this->getPrevId(), $objResult->getObjSearch()->getStrPortalLangFilter()));
     $arrReturn = array();
     foreach ($arrRows as $arrOnePage) {
         //check, if the post is available on a page using the current language
         if (!isset($arrOnePage["page_name"]) || $arrOnePage["page_name"] == "") {
             continue;
         }
         //search pv position
         $intAmount = $arrOnePage["guestbook_amount"];
         $arrPostsInGB = class_module_guestbook_post::getPosts($this->getPrevId(), true);
         $intCounter = 0;
         foreach ($arrPostsInGB as $objOnePostInGb) {
             $intCounter++;
             if ($objOnePostInGb->getSystemid() == $this->getSystemid()) {
                 break;
             }
         }
         //calculate pv
         $intPvPos = ceil($intCounter / $intAmount);
         $objNewResult = clone $objResult;
         $objNewResult->setStrPagelink(class_link::getLinkPortal($arrOnePage["page_name"], "", "_self", $arrOnePage["page_name"], "", "&highlight=" . urlencode(html_entity_decode($objResult->getObjSearch()->getStrQuery(), ENT_QUOTES, "UTF-8")) . "&pv=" . $intPvPos));
         $objNewResult->setStrPagename($arrOnePage["page_name"]);
         $objNewResult->setStrDescription($this->getStrGuestbookPostText());
         $arrReturn[] = $objNewResult;
     }
     return $arrReturn;
 }
コード例 #3
0
 /**
  * Saves the passed values to db
  *
  * @throws class_exception
  * @return string "" in case of success
  */
 protected function actionSaveGuestbook()
 {
     $strReturn = "";
     if (!$this->validateData()) {
         $this->setParam("eintragen_fehler", $this->getLang("eintragen_fehler"));
         return $this->actionInsertGuestbook($this->getAllParams());
     }
     $objBook = new class_module_guestbook_guestbook($this->arrElementData["guestbook_id"]);
     //check rights
     if ($objBook->rightRight1()) {
         //create a post-object
         $objPost = new class_module_guestbook_post();
         $objPost->setStrGuestbookPostName($this->getParam("gb_post_name"));
         $objPost->setStrGuestbookPostEmail($this->getParam("gb_post_email"));
         $objPost->setStrGuestbookPostPage($this->getParam("gb_post_page"));
         $objPost->setStrGuestbookPostText($this->getParam("gb_post_text"));
         $objPost->setIntGuestbookPostDate(time());
         //save obj to db
         if (!$objPost->updateObjectToDb($objBook->getSystemid())) {
             throw new class_exception("Error saving entry", class_exception::$level_ERROR);
         }
         $strMailtext = $this->getLang("new_post_mail");
         $strMailtext .= getLinkAdminHref("guestbook", "edit", "&systemid=" . $objPost->getSystemid(), false);
         $objMessageHandler = new class_module_messaging_messagehandler();
         $arrGroups = array();
         $allGroups = class_module_user_group::getObjectList();
         foreach ($allGroups as $objOneGroup) {
             if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) {
                 $arrGroups[] = $objOneGroup;
             }
         }
         $objMessageHandler->sendMessage($strMailtext, $arrGroups, new class_messageprovider_guestbook());
         //Flush the page from cache
         $this->flushPageFromPagesCache($this->getPagename());
         $this->portalReload(getLinkPortalHref($this->getPagename()));
     } else {
         $strReturn = $this->getLang("commons_error_permissions");
     }
     return $strReturn;
 }