public function testUnreadCount() { $strText = generateSystemid() . " autotest"; $objMessageHandler = new class_module_messaging_messagehandler(); $objMessageHandler->sendMessage($strText, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")), new class_messageprovider_exceptions()); $bitFound = false; $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")); $arrUsers = $objGroup->getObjSourceGroup()->getUserIdsForGroup(); $arrMessages = class_module_messaging_message::getObjectList($arrUsers[0]); $intUnread = class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true); $this->assertTrue($intUnread > 0); $this->flushDBCache(); foreach ($arrMessages as $objOneMessage) { if ($objOneMessage->getStrBody() == $strText && $objOneMessage->getStrMessageProvider() == "class_messageprovider_exceptions") { $bitFound = true; $objOneMessage->setBitRead(true); $objOneMessage->updateObjectToDb(); $this->assertEquals($intUnread - 1, class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true)); $objOneMessage->deleteObjectFromDatabase(); } } $this->assertTrue($bitFound); $this->flushDBCache(); }
/** * saves a post in the database and returns the post as html. * In case of missing fields, the form is returned again * * @return string * @permissons right1 */ protected function actionSavePost() { $strXMLContent = ""; //validate needed fields if (!$this->validateForm()) { //Create form to reenter values $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_form"); $arrForm = array(); $arrForm["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "postComment", "", $this->getSystemid()); $arrForm["comment_name"] = $this->getParam("comment_name"); $arrForm["comment_subject"] = $this->getParam("comment_subject"); $arrForm["comment_message"] = $this->getParam("comment_message"); $arrForm["comment_template"] = $this->getParam("comment_template"); $arrForm["comment_systemid"] = $this->getParam("comment_systemid"); $arrForm["comment_page"] = $this->getParam("comment_page"); $arrForm["validation_errors"] = $this->strErrors; foreach ($arrForm as $strKey => $strValue) { if (uniStrpos($strKey, "comment_") !== false) { $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false); } } //texts $arrForm["postacomment_write_new"] = $this->getLang("postacomment_write_new"); $arrForm["form_name_label"] = $this->getLang("form_name_label"); $arrForm["form_subject_label"] = $this->getLang("form_subject_label"); $arrForm["form_message_label"] = $this->getLang("form_message_label"); $arrForm["form_captcha_label"] = $this->getLang("commons_captcha"); $arrForm["form_captcha_reload_label"] = $this->getLang("commons_captcha_reload"); $arrForm["form_submit_label"] = $this->getLang("form_submit_label"); $strXMLContent .= $this->fillTemplate($arrForm, $strTemplateID); } else { //save the post to the db //pageid or systemid to filter? $strSystemidfilter = $this->getParam("comment_systemid"); if (class_module_pages_page::getPageByName($this->getParam("comment_page")) !== null) { $strPagefilter = class_module_pages_page::getPageByName($this->getParam("comment_page"))->getSystemid(); } else { $strPagefilter = ""; } $objPost = new class_module_postacomment_post(); $objPost->setStrUsername($this->getParam("comment_name")); $objPost->setStrTitle($this->getParam("comment_subject")); $objPost->setStrComment($this->getParam("comment_message")); $objPost->setStrAssignedPage($strPagefilter); $objPost->setStrAssignedSystemid($strSystemidfilter); $objPost->setStrAssignedLanguage($this->getStrPortalLanguage()); $objPost->updateObjectToDb(); $this->flushPageFromPagesCache($this->getPagename()); $strMailtext = $this->getLang("new_comment_mail") . "\r\n\r\n" . $objPost->getStrComment() . "\r\n"; $strMailtext .= class_link::getLinkAdminHref("postacomment", "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_postacomment()); //reinit post -> encoded entities $objPost->initObject(); //load the post as a new post to add it at top of the list $arrOnePost = array(); $arrOnePost["postacomment_post_name"] = $objPost->getStrUsername(); $arrOnePost["postacomment_post_subject"] = $objPost->getStrTitle(); $arrOnePost["postacomment_post_message"] = $objPost->getStrComment(); $arrOnePost["postacomment_post_systemid"] = $objPost->getSystemid(); $arrOnePost["postacomment_post_date"] = timeToString($objPost->getIntDate(), true); $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_post"); $strXMLContent .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID); } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return $strXMLContent; }
/** * 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; }