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 to the databases
  *
  * @permissions right1
  * @return string
  */
 protected function actionPostComment()
 {
     if (!$this->validateForm()) {
         return $this->actionList();
     }
     $strSystemidfilter = "";
     if ($this->getSystemid() != "") {
         $strSystemidfilter = $this->getSystemid();
     }
     if (class_module_pages_page::getPageByName($this->getPagename()) !== null) {
         $strPagefilter = class_module_pages_page::getPageByName($this->getPagename())->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;
         }
     }
     $objMessage = new class_module_messaging_message();
     $objMessage->setStrBody($strMailtext);
     $objMessage->setObjMessageProvider(new class_messageprovider_postacomment());
     $objMessageHandler->sendMessageObject($objMessage, $arrGroups);
     $this->portalReload(_indexpath_ . "?" . $this->getHistory(1));
     return "";
 }
 /**
  * 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;
 }
 /**
  * @return bool
  */
 protected function onInsertToDb()
 {
     //send a message to all registered editors
     $objEvent = new class_module_eventmanager_event($this->getStrPrevId());
     $strMailtext = $this->getLang("new_participant_mail") . "\n\n";
     $strMailtext .= $this->getLang("new_participant_participant") . " " . $this->getStrDisplayName() . "\n";
     $strMailtext .= $this->getLang("new_participant_event") . " " . $objEvent->getStrDisplayName() . "\n";
     $strMailtext .= $this->getLang("new_participant_details") . " " . class_link::getLinkAdminHref("eventmanager", "listParticipant", "&systemid=" . $this->getStrPrevId(), 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->getSystemid())) {
             $arrGroups[] = $objOneGroup;
         }
     }
     $objMessage = new class_module_messaging_message();
     $objMessage->setStrBody(strip_tags($strMailtext));
     $objMessage->setObjMessageProvider(new class_messageprovider_eventmanager());
     $objMessageHandler->sendMessageObject($objMessage, $arrGroups);
     return true;
 }
 /**
  * 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;
 }
 /**
  * @return string
  */
 protected function actionSave()
 {
     $this->setArrModuleEntry("template", "/folderview.tpl");
     /** @var $objMessage class_module_messaging_message */
     $objMessage = null;
     $objMessage = new class_module_messaging_message();
     $objForm = $this->getAdminForm($objMessage);
     if (!$objForm->validateForm()) {
         if ($this->getParam("mode") === "new") {
             return $this->actionNew();
         }
     }
     $objForm->updateSourceObject();
     $objMessageHandler = new class_module_messaging_messagehandler();
     $objMessage->setObjMessageProvider(new class_messageprovider_personalmessage());
     $objMessageHandler->sendMessageObject($objMessage, new class_module_user_user($objMessage->getStrUser()));
     return $this->objToolkit->warningBox($this->getLang("message_sent_success")) . $this->objToolkit->formHeader("") . $this->objToolkit->formInputSubmit($this->getLang("commons_ok"), "", "onclick=parent.KAJONA.admin.folderview.dialog.hide();") . $this->objToolkit->formClose();
 }
Example #7
0
 /**
  * Used to handle the current exception.
  * Decides, if the execution should be stopped, or continued.
  * Therefore the errorlevel defines the "weight" of the exception
  *
  * @return void
  */
 public function processException()
 {
     //set which POST parameters should read out
     $arrPostParams = array("module", "action", "page", "systemid");
     $objHistory = new class_history();
     //send an email to the admin?
     $strAdminMail = "";
     try {
         if (class_db::getInstance()->getBitConnected()) {
             $strAdminMail = class_module_system_setting::getConfigValue("_system_admin_email_");
         }
     } catch (Exception $objEx) {
     }
     if ($strAdminMail != "") {
         $strMailtext = "";
         $strMailtext .= "The system installed at " . _webpath_ . " registered an error!\n\n";
         $strMailtext .= "The error message was:\n";
         $strMailtext .= "\t" . $this->getMessage() . "\n\n";
         $strMailtext .= "The level of this error was:\n";
         $strMailtext .= "\t";
         if ($this->getErrorlevel() == self::$level_FATALERROR) {
             $strMailtext .= "FATAL ERROR";
         }
         if ($this->getErrorlevel() == self::$level_ERROR) {
             $strMailtext .= "REGULAR ERROR";
         }
         $strMailtext .= "\n\n";
         $strMailtext .= "File and line number the error was thrown:\n";
         $strMailtext .= "\t" . basename($this->getFile()) . " in line " . $this->getLine() . "\n\n";
         $strMailtext .= "Callstack / Backtrace:\n\n";
         $strMailtext .= $this->getTraceAsString();
         $strMailtext .= "\n\n";
         $strMailtext .= "User: "******" (" . class_carrier::getInstance()->getObjSession()->getUsername() . ")\n";
         $strMailtext .= "Source host: " . getServer("REMOTE_ADDR") . " (" . @gethostbyaddr(getServer("REMOTE_ADDR")) . ")\n";
         $strMailtext .= "Query string: " . getServer("REQUEST_URI") . "\n";
         $strMailtext .= "POST data (selective):\n";
         foreach ($arrPostParams as $strParam) {
             if (getPost($strParam) != "") {
                 $strMailtext .= "\t" . $strParam . ": " . getPost($strParam) . "\n";
             }
         }
         $strMailtext .= "\n\n";
         $strMailtext .= "Last actions called:\n";
         $strMailtext .= "Admin:\n";
         $arrHistory = $objHistory->getArrAdminHistory();
         if (is_array($arrHistory)) {
             foreach ($arrHistory as $intIndex => $strOneUrl) {
                 $strMailtext .= " #" . $intIndex . ": " . $strOneUrl . "\n";
             }
         }
         $strMailtext .= "Portal:\n";
         $arrHistory = $objHistory->getArrPortalHistory();
         if (is_array($arrHistory)) {
             foreach ($arrHistory as $intIndex => $strOneUrl) {
                 $strMailtext .= " #" . $intIndex . ": " . $strOneUrl . "\n";
             }
         }
         $strMailtext .= "\n\n";
         $strMailtext .= "If you don't know what to do, feel free to open a ticket.\n\n";
         $strMailtext .= "For more help visit http://www.kajona.de.\n\n";
         $objMail = new class_mail();
         $objMail->setSubject("Error on website " . _webpath_ . " occured!");
         $objMail->setSender($strAdminMail);
         $objMail->setText($strMailtext);
         $objMail->addTo($strAdminMail);
         $objMail->sendMail();
         $objMessageHandler = new class_module_messaging_messagehandler();
         $objMessage = new class_module_messaging_message();
         $objMessage->setStrBody($strMailtext);
         $objMessage->setObjMessageProvider(new class_messageprovider_exceptions());
         $objMessageHandler->sendMessageObject($objMessage, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")));
     }
     if ($this->intErrorlevel == class_exception::$level_FATALERROR) {
         //Handle fatal errors.
         $strLogMessage = basename($this->getFile()) . ":" . $this->getLine() . " -- " . $this->getMessage();
         class_logger::getInstance()->addLogRow($strLogMessage, class_logger::$levelError);
         //fatal errors are displayed in every case
         if (_xmlLoader_ === true) {
             $strErrormessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
             $strErrormessage .= "<error>" . xmlSafeString($this->getMessage()) . "</error>";
         } else {
             $strErrormessage = "<html><head></head><body><div style=\"border: 1px solid red; padding: 5px; margin: 20px; font-family: arial,verdana,sans-serif; font-size: 12px;  \">\n";
             $strErrormessage .= "<div style=\"background-color: #cccccc; color: #000000; font-weight: bold; \">A fatal error occurred:</div>\n";
             $strErrormessage .= "<pre>" . htmlspecialchars($this->getMessage(), ENT_QUOTES, "UTF-8", false) . "</pre><br />";
             $strErrormessage .= "Please inform the administration about the error above.";
             $strErrormessage .= "</div></body></html>";
         }
         print $strErrormessage;
         //Execution has to be stopped here!
         if (class_response_object::getInstance()->getStrStatusCode() == "" || class_response_object::getInstance()->getStrStatusCode() == class_http_statuscodes::SC_OK) {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR);
         }
         class_response_object::getInstance()->sendHeaders();
         die;
     } elseif ($this->intErrorlevel == class_exception::$level_ERROR) {
         //handle regular errors
         $strLogMessage = basename($this->getFile()) . ":" . $this->getLine() . " -- " . $this->getMessage();
         class_logger::getInstance()->addLogRow($strLogMessage, class_logger::$levelWarning);
         //check, if regular errors should be displayed:
         if ($this->intDebuglevel >= 1) {
             if (_xmlLoader_ === true) {
                 $strErrormessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                 $strErrormessage .= "<error>" . xmlSafeString($this->getMessage()) . "</error>";
             } else {
                 $strErrormessage = "<html><head></head><body><div style=\"border: 1px solid red; padding: 5px; margin: 20px; font-family: arial,verdana,sans-serif; font-size: 12px; \">\n";
                 $strErrormessage .= "<div style=\"background-color: #cccccc; color: #000000; font-weight: bold; \">An error occurred:</div>\n";
                 $strErrormessage .= "<pre>" . htmlspecialchars($this->getMessage(), ENT_QUOTES, "UTF-8", false) . "</pre><br />";
                 //$strErrormessage .= basename($this->getFile()) ." in Line ".$this->getLine();
                 $strErrormessage .= "Please inform the administration about the error above.";
                 $strErrormessage .= "</div></body></html>";
             }
             print $strErrormessage;
             //if error was displayed, stop execution
             //die();
         }
     }
 }
 /**
  * @param interface_packagemanager_packagemanager $objPackage
  * @param string $strLatestVersion
  * @return void
  */
 private function sendUpdateAvailableMessage(interface_packagemanager_packagemanager $objPackage, $strLatestVersion)
 {
     //check, if not already sent
     $strIdentifier = sha1(__CLASS__ . $objPackage->getObjMetadata()->getStrTitle() . $strLatestVersion);
     if (count(class_module_messaging_message::getMessagesByIdentifier($strIdentifier)) == 0) {
         $strMailtext = class_carrier::getInstance()->getObjLang()->getLang("update_notification_package", "packagemanager") . " " . $objPackage->getObjMetadata()->getStrTitle() . "\n";
         $strMailtext .= class_carrier::getInstance()->getObjLang()->getLang("update_notification_verinst", "packagemanager") . " " . $objPackage->getObjMetadata()->getStrVersion() . "\n";
         $strMailtext .= class_carrier::getInstance()->getObjLang()->getLang("update_notification_verav", "packagemanager") . " " . $strLatestVersion . "\n";
         $objMessageHandler = new class_module_messaging_messagehandler();
         $objMessage = new class_module_messaging_message();
         $objMessage->setStrTitle(class_carrier::getInstance()->getObjLang()->getLang("update_notification_intro", "packagemanager"));
         $objMessage->setStrBody($strMailtext);
         $objMessage->setObjMessageProvider(new class_messageprovider_packageupdate());
         $objMessage->setStrInternalIdentifier($strIdentifier);
         $objMessageHandler->sendMessageObject($objMessage, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")));
     }
 }
 /**
  * @param class_module_user_user $objUser
  * @param class_module_messaging_message[] $arrMessages
  *
  * @return void
  */
 private function createMessageForUser(class_module_user_user $objUser, array $arrMessages)
 {
     $objLang = class_carrier::getInstance()->getObjLang();
     $objLang->setStrTextLanguage($objUser->getStrAdminlanguage());
     $strBody = $objLang->getLang("message_messagesummary_intro", "workflows", array(count($arrMessages))) . "\n\n";
     $intI = 0;
     foreach ($arrMessages as $objOneMessage) {
         $strBody .= $objLang->getLang("message_messagesummary_body_indicator", "workflows", array(++$intI, count($arrMessages))) . "\n";
         $strBody .= $objLang->getLang("message_subject", "messaging") . ": " . $objOneMessage->getStrTitle() . "\n";
         $strBody .= $objLang->getLang("message_link", "messaging") . ": " . class_link::getLinkAdminHref("messaging", "view", "&systemid=" . $objOneMessage->getSystemid(), false) . "\n";
         $strBody .= $objLang->getLang("message_body", "messaging") . ":\n" . $objOneMessage->getStrBody() . "\n";
         $strBody .= "\n";
         $strBody .= "-------------------------------------------\n";
         $strBody .= "\n";
     }
     $strSubject = $objLang->getLang("message_messagesummary_subject", "workflows", array(count($arrMessages)));
     $objSummary = new class_module_messaging_message();
     $objSummary->setStrTitle($strSubject);
     $objSummary->setStrBody($strBody);
     $objSummary->setObjMessageProvider(new class_messageprovider_summary());
     $objMessaging = new class_module_messaging_messagehandler();
     $objMessaging->sendMessageObject($objSummary, $objUser);
 }