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();
 }
 /**
  * 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;
 }