/**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     if (validateSystemid($this->getSystemid())) {
         $this->loadElementData();
     }
 }
 /**
  * @return string
  * @autoTestable
  * @permissions view
  */
 protected function actionBrowserChooser()
 {
     $strReturn = "";
     if ($this->getParam("CKEditorFuncNum") != "") {
         $strReturn .= "<script type=\"text/javascript\">window.opener.KAJONA.admin.folderview.selectCallbackCKEditorFuncNum = " . (int) $this->getParam("CKEditorFuncNum") . ";</script>";
     }
     $intCounter = 1;
     $strReturn .= $this->objToolkit->listHeader();
     if (class_module_system_module::getModuleByName("pages") !== null) {
         $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("pages", "pagesFolderBrowser", "&pages=1&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygPagesBrowser"), $this->getLang("wysiwygPagesBrowser"), "icon_folderActionOpen"));
         $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygPagesBrowser"), "", $strAction, $intCounter++);
     }
     $strRepoId = class_module_system_setting::getConfigValue("_mediamanager_default_filesrepoid_");
     if (validateSystemid($strRepoId) && class_module_system_module::getModuleByName("mediamanager") !== null && class_objectfactory::getInstance()->getObject($strRepoId) !== null) {
         $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&systemid=" . $strRepoId . "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygFilesBrowser"), $this->getLang("wysiwygFilesBrowser"), "icon_folderActionOpen"));
         $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygFilesBrowser"), "", $strAction, $intCounter++);
     }
     $strRepoId = class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_");
     if (validateSystemid($strRepoId) && class_module_system_module::getModuleByName("mediamanager") !== null && class_objectfactory::getInstance()->getObject($strRepoId) !== null) {
         $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&systemid=" . $strRepoId . "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygImagesBrowser"), $this->getLang("wysiwygImagesBrowser"), "icon_folderActionOpen"));
         $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygImagesBrowser"), "", $strAction, $intCounter++);
     }
     if (class_module_system_module::getModuleByName("mediamanager") !== null) {
         $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygRepoBrowser"), $this->getLang("wysiwygRepoBrowser"), "icon_folderActionOpen"));
         $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygRepoBrowser"), "", $strAction, $intCounter++);
     }
     $strReturn .= $this->objToolkit->listFooter();
     return $strReturn;
 }
 /**
  * Validates the passed chunk of data.
  * In most cases, this'll be a string-object.
  *
  * @param string $objValue
  * @return bool
  */
 public function validate($objValue)
 {
     if (!is_string($objValue)) {
         return false;
     }
     return validateSystemid($objValue);
 }
Example #4
0
 /**
  * Tests method getWorkflowsForSystemid with existing workflow objects
  */
 public function test_getWorkflowsForSystemid_1()
 {
     $arrWorkflows = class_module_workflows_workflow::getAllworkflows();
     $arrMap = array();
     //1. Collect all workflows for all objects
     /** @var  class_module_workflows_workflow */
     foreach ($arrWorkflows as $objWorkflow) {
         $strAffectedSystemId = $objWorkflow->getStrAffectedSystemid();
         if (!validateSystemid($strAffectedSystemId)) {
             continue;
         }
         $strWorkflowClass = $objWorkflow->getStrClass();
         if (!array_key_exists($strAffectedSystemId, $arrMap)) {
             $arrMap[$strAffectedSystemId] = array();
         }
         if (!array_key_exists($strWorkflowClass, $arrMap[$strAffectedSystemId])) {
             $arrMap[$strAffectedSystemId][$strWorkflowClass] = 1;
         } else {
             $arrMap[$strAffectedSystemId][$strWorkflowClass]++;
         }
     }
     //2. Now assert
     foreach ($arrMap as $strSystemId => $arrClasses) {
         $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId, false, array_keys($arrClasses));
         $this->assertEquals(count($arrWorkflows), array_sum($arrClasses));
         $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId, false);
         $this->assertEquals(count($arrWorkflows), array_sum($arrClasses));
         foreach ($arrMap[$strSystemId] as $strClass => $intCount) {
             $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId, false, $strClass);
             $this->assertEquals(count($arrWorkflows), $intCount);
             $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId, false, array($strClass));
             $this->assertEquals(count($arrWorkflows), $intCount);
         }
     }
 }
 /**
  * Returns a textual representation of the formentries' value.
  * May contain html, but should be stripped down to text-only.
  *
  * @return string
  */
 public function getValueAsText()
 {
     if (validateSystemid($this->getStrValue())) {
         $objUser = new class_module_user_user($this->getStrValue());
         return $objUser->getStrDisplayName();
     }
     return "";
 }
 /**
  * Converts the passed value to a formatted value.
  * In most scenarios, the value is written directly to the template.
  *
  * @param mixed $strValue
  *
  * @return string
  */
 public function format($strValue)
 {
     if (validateSystemid($strValue)) {
         $objUser = new class_module_user_user($strValue);
         return $objUser->getStrDisplayName();
     }
     return $strValue;
 }
Example #7
0
 /**
  * Sends the requested file to the browser
  * @return string
  */
 public function actionDownload()
 {
     //Load filedetails
     if (validateSystemid($this->getSystemid())) {
         /** @var $objFile class_module_mediamanager_file */
         $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid());
         //Succeeded?
         if ($objFile instanceof class_module_mediamanager_file && $objFile->getIntRecordStatus() == "1" && $objFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) {
             //Check rights
             if ($objFile->rightRight2()) {
                 //Log the download
                 class_module_mediamanager_logbook::generateDlLog($objFile);
                 //Send the data to the browser
                 $strBrowser = getServer("HTTP_USER_AGENT");
                 //Check the current browsertype
                 if (uniStrpos($strBrowser, "IE") !== false) {
                     //Internet Explorer
                     class_response_object::getInstance()->addHeader("Content-type: application/x-ms-download");
                     class_response_object::getInstance()->addHeader("Content-type: x-type/subtype\n");
                     class_response_object::getInstance()->addHeader("Content-type: application/force-download");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . preg_replace('/\\./', '%2e', saveUrlEncode(trim(basename($objFile->getStrFilename()))), substr_count(basename($objFile->getStrFilename()), '.') - 1));
                 } else {
                     //Good: another browser vendor
                     class_response_object::getInstance()->addHeader("Content-Type: application/octet-stream");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . saveUrlEncode(trim(basename($objFile->getStrFilename()))));
                 }
                 //Common headers
                 class_response_object::getInstance()->addHeader("Expires: Mon, 01 Jan 1995 00:00:00 GMT");
                 class_response_object::getInstance()->addHeader("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                 class_response_object::getInstance()->addHeader("Pragma: no-cache");
                 class_response_object::getInstance()->addHeader("Content-description: JustThum-Generated Data\n");
                 class_response_object::getInstance()->addHeader("Content-Length: " . filesize(_realpath_ . $objFile->getStrFilename()));
                 //End Session
                 $this->objSession->sessionClose();
                 class_response_object::getInstance()->sendHeaders();
                 //Loop the file
                 $ptrFile = @fopen(_realpath_ . $objFile->getStrFilename(), 'rb');
                 fpassthru($ptrFile);
                 @fclose($ptrFile);
                 ob_flush();
                 flush();
                 return "";
             } else {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN);
             }
         } else {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
         }
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
     }
     //if we reach up here, something gone wrong :/
     class_response_object::getInstance()->setStrRedirectUrl(str_replace(array("_indexpath_", "&amp;"), array(_indexpath_, "&"), class_link::getLinkPortalHref(class_module_system_setting::getConfigValue("_pages_errorpage_"))));
     class_response_object::getInstance()->sendHeaders();
     class_response_object::getInstance()->sendContent();
     return "";
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     if (validateSystemid($this->getField("userid")->getStrValue())) {
         $this->getField("userid")->setBitMandatory(true);
         $this->getField("forename")->setBitMandatory(false);
         $this->getField("lastname")->setBitMandatory(false);
         $this->getField("email")->setBitMandatory(false);
     }
 }
Example #9
0
 /**
  * Here happens the magic: creating the image and sending it to the browser
  * @return void
  */
 public function generateImage()
 {
     //switch the different modes - may be want to generate a detailed image-view
     if (validateSystemid($this->strSystemid) && validateSystemid($this->strElementId)) {
         class_carrier::getInstance()->getObjConfig()->loadConfigsDatabase(class_carrier::getInstance()->getObjDB());
         $this->generateMediamanagerImage();
     } else {
         class_carrier::getInstance()->getObjSession()->sessionClose();
         $this->resizeImage();
     }
 }
 /**
  * Creates a form in order to change the password - if the authcode is valid
  *
  * @return string
  */
 protected function actionPwdReset()
 {
     $strReturn = "";
     if (!validateSystemid($this->getParam("systemid"))) {
         return $this->getLang("login_change_error", "user");
     }
     $objUser = new class_module_user_user($this->getParam("systemid"));
     if ($objUser->getStrAuthcode() != "" && $this->getParam("authcode") == $objUser->getStrAuthcode() && $objUser->getStrUsername() != "") {
         if ($this->getParam("reset") == "") {
             //Loading a small form to change the password
             $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "login_form");
             $arrTemplate = array();
             $strForm = "";
             $strForm .= $this->objToolkit->getTextRow($this->getLang("login_password_form_intro", "user"));
             $strForm .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "pwdReset"));
             $strForm .= $this->objToolkit->formInputText("username", $this->getLang("login_loginUser", "user"), "", "inputTextShort");
             $strForm .= $this->objToolkit->formInputPassword("password1", $this->getLang("login_loginPass", "user"), "", "inputTextShort");
             $strForm .= $this->objToolkit->formInputPassword("password2", $this->getLang("login_loginPass2", "user"), "", "inputTextShort");
             $strForm .= $this->objToolkit->formInputSubmit($this->getLang("login_changeButton", "user"), "", "", "inputSubmitShort");
             $strForm .= $this->objToolkit->formInputHidden("reset", "reset");
             $strForm .= $this->objToolkit->formInputHidden("authcode", $this->getParam("authcode"));
             $strForm .= $this->objToolkit->formInputHidden("systemid", $this->getParam("systemid"));
             $strForm .= $this->objToolkit->formClose();
             $arrTemplate["form"] = $strForm;
             $arrTemplate["loginTitle"] = $this->getLang("login_loginTitle", "user");
             $arrTemplate["loginJsInfo"] = $this->getLang("login_loginJsInfo", "user");
             $arrTemplate["loginCookiesInfo"] = $this->getLang("login_loginCookiesInfo", "user");
             //An error occurred?
             if ($this->getParam("loginerror") == 1) {
                 $arrTemplate["error"] = $this->getLang("login_loginError", "user");
             }
             $strReturn = $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID);
         } else {
             //check the submitted passwords.
             $strPass1 = trim($this->getParam("password1"));
             $strPass2 = trim($this->getParam("password2"));
             if ($strPass1 == $strPass2 && checkText($strPass1, 3, 200) && $objUser->getStrUsername() == $this->getParam("username")) {
                 if ($objUser->getObjSourceUser()->isPasswordResettable() && method_exists($objUser->getObjSourceUser(), "setStrPass")) {
                     $objUser->getObjSourceUser()->setStrPass($strPass1);
                     $objUser->getObjSourceUser()->updateObjectToDb();
                 }
                 $objUser->setStrAuthcode("");
                 $objUser->updateObjectToDb();
                 class_logger::getInstance()->addLogRow("changed password of user " . $objUser->getStrUsername(), class_logger::$levelInfo);
                 $strReturn .= $this->getLang("login_change_success", "user");
             } else {
                 $strReturn .= $this->getLang("login_change_error", "user");
             }
         }
     } else {
         $strReturn .= $this->getLang("login_change_error", "user");
     }
     return $strReturn;
 }
 /**
  * Returns the ready switch-htmlcode
  *
  * @return string
  */
 public function loadData()
 {
     //fallback for old elements not yet using the template
     if (!isset($this->arrElementData["char1"]) || $this->arrElementData["char1"] == "") {
         $this->arrElementData["char1"] = "languageswitch.tpl";
     }
     $arrObjLanguages = class_module_languages_language::getObjectList(true);
     //load the languageset in order to generate more specific switches
     $objLanguageset = class_module_languages_languageset::getLanguagesetForSystemid($this->getParam("systemid"));
     //Iterate over all languages
     $strRows = "";
     foreach ($arrObjLanguages as $objOneLanguage) {
         //Check, if the current page has elements
         $objPage = class_module_pages_page::getPageByName($this->getPagename());
         $objPage->setStrLanguage($objOneLanguage->getStrName());
         if ($objPage === null) {
             continue;
         }
         if ((int) $objPage->getNumberOfElementsOnPage(true) == 0) {
             continue;
         }
         $strTargetSystemid = null;
         if ($objLanguageset != null) {
             $strTargetSystemid = $objLanguageset->getSystemidForLanguageid($objOneLanguage->getSystemid());
         }
         //the languageswitch is content aware. check if the target id is a news-entry
         $strSeoAddon = "";
         if (validateSystemid($strTargetSystemid)) {
             $objRecord = class_objectfactory::getInstance()->getObject($strTargetSystemid);
             $strSeoAddon = $objRecord->getStrDisplayName();
         }
         //and the link
         $arrTemplate = array();
         if ($strTargetSystemid === null) {
             $arrTemplate["href"] = getLinkPortalHref($objPage->getStrName(), "", "", "", "", $objOneLanguage->getStrName(), $strSeoAddon);
         } else {
             $arrTemplate["href"] = getLinkPortalHref($objPage->getStrName(), "", $this->getAction(), "", $strTargetSystemid, $objOneLanguage->getStrName(), $strSeoAddon);
         }
         $arrTemplate["langname_short"] = $objOneLanguage->getStrName();
         $arrTemplate["langname_long"] = $this->getLang("lang_" . $objOneLanguage->getStrName());
         $strTemplateRowID = $this->objTemplate->readTemplate("/element_languageswitch/" . $this->arrElementData["char1"], "languageswitch_entry");
         $strTemplateActiveRowID = $this->objTemplate->readTemplate("/element_languageswitch/" . $this->arrElementData["char1"], "languageswitch_entry_active");
         if ($objOneLanguage->getStrName() == $this->getStrPortalLanguage()) {
             $strRows .= $this->fillTemplate($arrTemplate, $strTemplateActiveRowID);
         } else {
             $strRows .= $this->fillTemplate($arrTemplate, $strTemplateRowID);
         }
     }
     $strTemplateWrapperID = $this->objTemplate->readTemplate("/element_languageswitch/" . $this->arrElementData["char1"], "languageswitch_wrapper");
     return $this->fillTemplate(array("languageswitch_entries" => $strRows), $strTemplateWrapperID);
 }
 /**
  * @see interface_admin_systemtask::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("system")->rightRight2()) {
         return $this->getLang("commons_error_permissions");
     }
     //try to load and update the systemrecord
     if (validateSystemid($this->getParam("systemstatus_systemid"))) {
         $objRecord = new class_module_system_common($this->getParam("systemstatus_systemid"));
         $objRecord->setIntRecordStatus($this->getParam("systemstatus_status"));
         $objRecord->updateObjectToDb();
         return $this->objToolkit->getTextRow($this->getLang("systemtask_status_success"));
     }
     return $this->objToolkit->getTextRow($this->getLang("systemtask_status_error"));
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     if (validateSystemid($this->getField("messagerefid")->getStrValue()) && $this->getField("body")->getStrValue() == "") {
         $objRefMessage = class_objectfactory::getInstance()->getObject($this->getField("messagerefid")->getStrValue());
         if ($objRefMessage instanceof class_module_messaging_message) {
             $arrBody = preg_split('/$\\R?^/m', $objRefMessage->getStrBody());
             array_walk($arrBody, function (&$strValue) {
                 $strValue = "> " . $strValue;
             });
             $this->getField("body")->setStrValue("\r\n\r\n\r\n" . implode("\r\n", $arrBody));
         }
     }
 }
 /**
  * Handles the processing of objects directly
  */
 private function processDirectly()
 {
     $objIndex = new class_module_search_indexwriter();
     //start by processing the records to be deleted
     foreach (self::$arrToDelete as $strOneId => $strObject) {
         $objIndex->removeRecordFromIndex($strOneId);
     }
     //add new records
     foreach (self::$arrToIndex as $strOneId => $objInstance) {
         if (!is_object($objIndex) && validateSystemid($objInstance)) {
             $objInstance = class_objectfactory::getInstance()->getObject($objInstance);
         }
         $objIndex->indexObject($objInstance);
     }
 }
 /**
  * Implementing callback to react on user-delete events
  *
  * Called whenever a record was deleted using the common methods.
  * Implement this method to be notified when a record is deleted, e.g. to to additional cleanups afterwards.
  * There's no need to register the listener, this is done automatically.
  *
  * Make sure to return a matching boolean-value, otherwise the transaction may be rolled back.
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     //unwrap arguments
     list($strSystemid, $strSourceClass) = $arrArguments;
     if ($strSourceClass == "class_module_user_user" && validateSystemid($strSystemid)) {
         $objORM = new class_orm_objectlist();
         $objORM->addWhereRestriction(new class_orm_objectlist_property_restriction("strUser", class_orm_comparator_enum::Equal(), $strSystemid));
         $objORM->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED());
         $arrWidgets = $objORM->getObjectList("class_module_dashboard_widget");
         foreach ($arrWidgets as $objWidget) {
             $objWidget->deleteObjectFromDatabase();
         }
     }
     return true;
 }
 protected function renderAdditionalActions(class_model $objListEntry)
 {
     $arrReturn = array();
     if ($objListEntry instanceof class_module_navigation_tree) {
         if (validateSystemid($objListEntry->getStrFolderId())) {
             $arrReturn[] = $this->objToolkit->listButton(getImageAdmin("icon_treeBranchOpenDisabled", $this->getLang("navigation_show_disabled")));
         } else {
             $arrReturn[] = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "list", "&systemid=" . $objListEntry->getSystemid() . $this->strPeAddon, "", $this->getLang("navigation_anzeigen"), "icon_treeBranchOpen"));
         }
     }
     if ($objListEntry instanceof class_module_navigation_point) {
         $arrReturn[] = $this->objToolkit->listButton(class_link::getLinkAdmin("navigation", "list", "&systemid=" . $objListEntry->getSystemid() . $this->strPeAddon, "", $this->getLang("navigationp_anzeigen"), "icon_treeBranchOpen"));
     }
     return $arrReturn;
 }
 /**
  * Checks what to do and invokes the proper method
  * Notice: In case of success, a location-header is sent, too. Needed, cause otherwise the rights would not
  * be checked during the login/-logout-loading against the new user-id!
  *
  * @return string the prepared html-output
  */
 public function loadData()
 {
     $strReturn = "";
     $strOldAction = "";
     if (validateSystemid($this->getParam("pl_systemid")) && $this->getParam("pl_systemid") != $this->arrElementData["content_id"]) {
         $strOldAction = $this->getParam("action");
         $this->setParam("action", "");
     }
     if ($this->getParam("action") == "portalLogin") {
         if ($this->doLogin()) {
             if ($this->arrElementData["portallogin_success"] != "") {
                 $this->portalReload(class_link::getLinkPortalHref($this->arrElementData["portallogin_success"]));
             } else {
                 $this->portalReload(class_link::getLinkPortalHref($this->getPagename()));
             }
         } else {
             if ($this->arrElementData["portallogin_error"] != "") {
                 $this->portalReload(class_link::getLinkPortalHref($this->arrElementData["portallogin_error"]));
             }
         }
     } elseif ($this->getParam("action") == "portalLogout") {
         $this->doLogout();
         if ($this->arrElementData["portallogin_logout_success"] != "") {
             $this->portalReload(class_link::getLinkPortalHref($this->arrElementData["portallogin_logout_success"]));
         } else {
             $this->portalReload(class_link::getLinkPortalHref($this->getPagename()));
         }
     }
     if (!$this->objSession->isLoggedin()) {
         if ($this->getAction() == "portalLoginReset") {
             $strReturn .= $this->resetForm();
         } elseif ($this->getAction() == "portalResetPwd") {
             $strReturn .= $this->newPwdForm();
         } else {
             $strReturn .= $this->loginForm();
         }
     } else {
         if ($this->getParam("action") == "portalEditProfile") {
             $strReturn .= $this->editUserData();
         } else {
             $strReturn .= $this->statusArea();
         }
     }
     if ($strOldAction != "") {
         $this->setParam("action", $strOldAction);
     }
     return $strReturn;
 }
 /**
  * Generic list of all packages available on the local filesystem
  * @return string
  * @permissions view
  * @autoTestable
  */
 protected function actionOpenFolder()
 {
     if (validateSystemid(class_module_system_setting::getConfigValue("_packageserver_repo_id_"))) {
         if ($this->getSystemid() == "") {
             $this->setSystemid(class_module_system_setting::getConfigValue("_packageserver_repo_id_"));
         }
         $objIterator = new class_array_section_iterator(class_module_mediamanager_file::getFileCount($this->getSystemid(), false, false, true));
         $objIterator->setPageNumber($this->getParam("pv"));
         $objIterator->setArraySection(class_module_mediamanager_file::loadFilesDB($this->getSystemid(), false, false, $objIterator->calculateStartPos(), $objIterator->calculateEndPos(), true));
     } else {
         $objIterator = new class_array_section_iterator(class_module_mediamanager_file::getFlatPackageListCount(false, false));
         $objIterator->setPageNumber($this->getParam("pv"));
         $objIterator->setArraySection(class_module_mediamanager_file::getFlatPackageList(false, false, $objIterator->calculateStartPos(), $objIterator->calculateEndPos()));
     }
     return $this->renderList($objIterator);
 }
Example #19
0
 public function testValidateSystemid()
 {
     $this->assertTrue(validateSystemid("12345678901234567890"));
     $this->assertTrue(validateSystemid("abcdefghijklmnopqrst"));
     $this->assertTrue(!validateSystemid("123456789012345678901"));
     $this->assertTrue(!validateSystemid("abcdefghijklmnopqrstu"));
     $this->assertTrue(!validateSystemid("1234567890123456789"));
     $this->assertTrue(!validateSystemid("abcdefghijklmnopqrs"));
     $this->assertTrue(!validateSystemid("12345678901234567890 123"));
     $this->assertTrue(!validateSystemid("abcdefghijklmnopqrst abc"));
     $this->assertTrue(!validateSystemid("abc 12345678901234567890 123"));
     $this->assertTrue(!validateSystemid("123 abcdefghijklmnopqrst abc"));
     $this->assertTrue(!validateSystemid("1234567890!234567890"));
     $this->assertTrue(!validateSystemid("abcdefghij!lmnopqrst"));
     $this->assertTrue(!validateSystemid("1234567890 234567890"));
     $this->assertTrue(!validateSystemid("abcdefghij lmnopqrst"));
 }
 /**
  * @see interface_admin_systemtask::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("navigation")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     $strReturn = "";
     //load all navigation points, tree by tree
     $arrTrees = class_module_navigation_tree::getObjectList();
     foreach ($arrTrees as $objOneTree) {
         $strReturn .= $this->getLang("systemtask_navigationcheck_treescan") . " \"" . $objOneTree->getStrName() . "\"...<br />";
         if (validateSystemid($objOneTree->getStrFolderId())) {
             $strReturn .= $this->getLang("systemtask_navigationcheck_autogenerated") . "<br />";
         } else {
             $strReturn .= $this->processLevel($objOneTree->getSystemid(), 0) . "<br />";
         }
     }
     return $strReturn;
 }
 /**
  * Deletes the current object from the system.
  * By default, all entries are delete from  all tables indicated by the class-doccomment.
  * If you want to trigger additional deletes, overwrite this method.
  * The system-record itself is being deleted automatically, too.
  *
  * @throws class_exception
  * @return bool
  */
 public function deleteObject()
 {
     if (!validateSystemid($this->getObjObject()->getSystemid()) || !$this->hasTargetTable()) {
         return true;
     }
     $objDB = class_carrier::getInstance()->getObjDB();
     $bitReturn = $this->deleteAssignments();
     $objAnnotations = new class_reflection($this->getObjObject());
     $arrTargetTables = $objAnnotations->getAnnotationValuesFromClass("@targetTable");
     if (count($arrTargetTables) > 0) {
         foreach ($arrTargetTables as $strOneTable) {
             $arrSingleTable = explode(".", $strOneTable);
             $strQuery = "DELETE FROM " . $objDB->encloseTableName(_dbprefix_ . $arrSingleTable[0]) . "\n                                   WHERE " . $objDB->encloseColumnName($arrSingleTable[1]) . " = ? ";
             $bitReturn = $bitReturn && $objDB->_pQuery($strQuery, array($this->getObjObject()->getSystemid()));
         }
     }
     return $bitReturn;
 }
 /**
  * Initializes the object from the database.
  * Loads all mapped columns to the properties.
  * Requires that the object is identified by its systemid.
  *
  * @return void
  */
 public function initObjectFromDb()
 {
     //try to do a default init
     $objReflection = new class_reflection($this->getObjObject());
     if (validateSystemid($this->getObjObject()->getSystemid()) && $this->hasTargetTable()) {
         if (class_orm_rowcache::getCachedInitRow($this->getObjObject()->getSystemid()) !== null) {
             $arrRow = class_orm_rowcache::getCachedInitRow($this->getObjObject()->getSystemid());
         } else {
             $strQuery = "SELECT *\n                          " . $this->getQueryBase() . "\n                           AND system.system_id = ? ";
             $arrRow = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($this->getObjObject()->getSystemid()));
         }
         if (method_exists($this->getObjObject(), "setArrInitRow")) {
             $this->getObjObject()->setArrInitRow($arrRow);
         }
         //get the mapped properties
         $arrProperties = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN);
         foreach ($arrProperties as $strPropertyName => $strColumn) {
             $arrColumn = explode(".", $strColumn);
             if (count($arrColumn) == 2) {
                 $strColumn = $arrColumn[1];
             }
             if (!isset($arrRow[$strColumn])) {
                 continue;
             }
             //skip columns from the system-table, they are set later on
             if (count($arrColumn) == 2 && $arrColumn[0] == "system") {
                 continue;
             }
             $strSetter = $objReflection->getSetter($strPropertyName);
             if ($strSetter !== null) {
                 call_user_func(array($this->getObjObject(), $strSetter), $arrRow[$strColumn]);
             }
         }
         $this->initAssignmentProperties();
     }
 }
 /**
  * Returns the list of pages and folders, so containing both object types, being located
  * under a given systemid.
  *
  * @param string $strFolderid
  * @param bool $bitOnlyActive
  *
  * @return int
  */
 public static function getPagesAndFolderListCount($strFolderid = "", $bitOnlyActive = false)
 {
     if (!validateSystemid($strFolderid)) {
         $strFolderid = class_module_system_module::getModuleByName("pages")->getSystemid();
     }
     $objORM = new class_orm_objectlist();
     $strQuery = "SELECT COUNT(*)\n\t\t\t\t\t\tFROM " . _dbprefix_ . "system\n\t\t\t\t\t\tWHERE system_prev_id=?\n                         AND (system_module_nr = ? OR system_module_nr = ? )\n                         " . $objORM->getDeletedWhereRestriction() . "\n\t                      " . ($bitOnlyActive ? " AND system_status = 1 " : "");
     $arrRow = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($strFolderid, _pages_modul_id_, _pages_folder_id_));
     return $arrRow["COUNT(*)"];
 }
Example #24
0
 /**
  * Renders the action to add a new record to the end of the list.
  * Make sure you have the lang-key "module_action_new" in the modules' lang-file.
  * If you overwrite this method, you can either return a string containing the new-link or an array if you want to
  * provide multiple new-action.
  *
  * @param string $strListIdentifier an internal identifier to check the current parent-list
  * @param bool $bitDialog opens the linked pages in a dialog
  *
  * @return string|array
  */
 protected function getNewEntryAction($strListIdentifier, $bitDialog = false)
 {
     $objObject = null;
     if (validateSystemid($this->getSystemid())) {
         $objObject = class_objectfactory::getInstance()->getObject($this->getSystemid());
     }
     if ($objObject == null) {
         $objObject = $this->getObjModule();
     }
     if ($objObject->rightEdit()) {
         if ($bitDialog) {
             return $this->objToolkit->listButton(class_link::getLinkAdminDialog($this->getArrModule("modul"), $this->getActionNameForClass("new", null), "&folderview=1&systemid=" . $this->getSystemid() . $this->strPeAddon, $this->getLang("commons_list_new"), $this->getLang("commons_list_new"), "icon_new"));
         } else {
             return $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), $this->getActionNameForClass("new", null), "&systemid=" . $this->getSystemid() . $this->strPeAddon, $this->getLang("commons_list_new"), $this->getLang("commons_list_new"), "icon_new"));
         }
     }
     return "";
 }
 /**
  * @see interface_admin_systemtask::executeTask()
  * @throws class_exception
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("pages")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     //load the page itself
     $objPage = class_module_pages_page::getPageByName($this->getParam("pageExport"));
     if ($objPage !== null) {
         $objSystem = class_module_system_module::getModuleByName("system");
         $objXmlWriter = new XMLWriter();
         $strExportFolder = $this->getParam("exportFolder");
         $strExportPrefix = $this->getParam("exportPrefix");
         if ($strExportFolder == "") {
             $strExportFolder = _realpath_ . _projectpath_ . "/temp";
         } else {
             $strExportFolder = _realpath_ . "/" . $strExportFolder;
         }
         if ($strExportPrefix != "") {
             $strExportPrefix = "_" . $strExportPrefix;
         }
         if (is_dir($strExportFolder)) {
             if (!$objXmlWriter->openUri($strExportFolder . "/" . $strExportPrefix . $objPage->getSystemid() . ".xml")) {
                 throw new class_exception("failed to open export file ", class_exception::$level_ERROR);
             }
             //$objXmlWriter->openMemory();
             $objXmlWriter->setIndent(true);
             $objXmlWriter->startDocument("1.0", "UTF-8");
             $objXmlWriter->startComment();
             $strComment = "\n   Kajona XML export\n";
             $strComment .= "   (c) Kajona, www.kajona.de\n";
             $strComment .= "   Kernel version:  " . $objSystem->getStrVersion() . "\n";
             $strComment .= "   Schema version:  1.0\n";
             $strComment .= "   Export Date:     " . dateToString(new class_date()) . "\n";
             $objXmlWriter->text($strComment);
             $objXmlWriter->endComment();
             $objXmlWriter->startElement("pages");
             $objXmlWriter->startElement("page");
             $objXmlWriter->startElement("metadata");
             $objXmlWriter->startElement("kernelVersion");
             $objXmlWriter->text($objSystem->getStrVersion());
             $objXmlWriter->endElement();
             $objXmlWriter->startElement("systemid");
             $objXmlWriter->text($objPage->getSystemid());
             $objXmlWriter->endElement();
             $objXmlWriter->startElement("previd");
             $objXmlWriter->text($objPage->getPrevId());
             $objXmlWriter->endElement();
             $objXmlWriter->startElement("pagename");
             $objXmlWriter->text($objPage->getStrName());
             $objXmlWriter->endElement();
             //try to load the parent page-name
             $strParentName = "";
             if (validateSystemid($objPage->getPrevId())) {
                 $objParentPage = new class_module_pages_page($objPage->getPrevId());
                 $strParentName = $objParentPage->getStrName();
             }
             $objXmlWriter->startElement("prevname");
             $objXmlWriter->text($strParentName);
             $objXmlWriter->endElement();
             $objXmlWriter->startElement("pageproperties");
             $this->createPageMetadata($objPage->getSystemid(), $objXmlWriter);
             $objXmlWriter->endElement();
             //metadata
             $objXmlWriter->endElement();
             $objXmlWriter->startElement("elements");
             $this->createElementData($objPage->getSystemid(), $objXmlWriter);
             $objXmlWriter->endElement();
             //page
             $objXmlWriter->endElement();
             //pages
             $objXmlWriter->endElement();
             $objXmlWriter->flush();
             //return $objXmlWriter->outputMemory(true);
             return $this->getLang("systemtask_pageexport_success") . $strExportFolder . "/" . $strExportPrefix . $objPage->getSystemid() . ".xml" . "";
         } else {
             throw new class_exception("writing XML: Folder " . $strExportFolder . " does not exist! ", class_exception::$level_ERROR);
         }
     }
     return $this->getLang("systemtask_pageexport_error");
 }
 /**
  * Sets the current SystemID
  *
  * @param string $strID
  *
  * @return bool
  * @final
  */
 public final function setSystemid($strID)
 {
     if (validateSystemid($strID)) {
         $this->strSystemid = $strID;
         return true;
     } else {
         return false;
     }
 }
 /**
  * Internal recursion helper, processes a single level of nodes in oder to
  * search a matching node.
  *
  * @param int $intLevel
  * @param string $strPage page to search
  * @param array $arrNodes
  * @param string $strCheckId systemid to check, only used to get active id stack
  * @param string $strCheckAction action to check, only used to get active id stack
  */
 private function searchPageInNavigationTreeHelper($intLevel, $strPage, $arrNodes, $strCheckId = "", $strCheckAction = "")
 {
     if (!isset($this->arrNodeTempHelper[$intLevel])) {
         $this->arrNodeTempHelper[$intLevel] = array();
     }
     if ($arrNodes["node"]->getStrPageI() == $strPage) {
         //systemid & ation given
         if (validateSystemid($arrNodes["node"]->getStrLinkSystemid()) && $arrNodes["node"]->getStrLinkAction() != "") {
             if ($arrNodes["node"]->getStrLinkSystemid() == $strCheckId && $arrNodes["node"]->getStrLinkAction() == $strCheckAction) {
                 $this->arrNodeTempHelper[$intLevel][] = $arrNodes["node"];
             }
         } else {
             if (validateSystemid($arrNodes["node"]->getStrLinkSystemid())) {
                 if ($arrNodes["node"]->getStrLinkSystemid() == $strCheckId) {
                     $this->arrNodeTempHelper[$intLevel][] = $arrNodes["node"];
                 }
             } else {
                 $this->arrNodeTempHelper[$intLevel][] = $arrNodes["node"];
             }
         }
     }
     foreach ($arrNodes["subnodes"] as $arrOneSubnode) {
         $this->searchPageInNavigationTreeHelper($intLevel + 1, $strPage, $arrOneSubnode, $strCheckId, $strCheckAction);
     }
 }
Example #28
0
 /**
  * Checks if a given user-id is granted the passed permission for the passed systemid.
  *
  * @param string $strUserid
  * @param string $strPermission
  * @param string $strSystemid
  *
  * @return bool
  */
 public function checkPermissionForUserId($strUserid, $strPermission, $strSystemid)
 {
     if ($strSystemid == "") {
         return false;
     }
     if ($this->bitTestMode) {
         return true;
     }
     $arrGroupIds = array();
     if (validateSystemid($strUserid)) {
         if ($strUserid == $this->objSession->getUserID()) {
             $arrGroupIds = $this->objSession->getGroupIdsAsArray();
         } else {
             $objUser = new class_module_user_user($strUserid);
             $arrGroupIds = $objUser->getArrGroupIds();
         }
     } else {
         if (validateSystemid($this->objSession->getUserID())) {
             $arrGroupIds = $this->objSession->getGroupIdsAsArray();
         } else {
             $arrGroupIds[] = class_module_system_setting::getConfigValue("_guests_group_id_");
         }
     }
     foreach ($arrGroupIds as $strOneGroupId) {
         if ($this->checkPermissionForGroup($strOneGroupId, $strPermission, $strSystemid)) {
             return true;
         }
     }
     return false;
 }
Example #29
0
 /**
  * Sends, finally, the mail
  *
  * @return bool
  */
 public function sendMail()
 {
     $bitReturn = false;
     //Do we have all neccessary arguments?
     if (count($this->arrayTo) > 0) {
         $bitReturn = true;
     }
     if ($bitReturn) {
         //Building the mail
         $strTo = implode(", ", $this->arrayTo);
         //Sender
         if ($this->strSender == "") {
             //try to load the current users' mail adress
             if (validateSystemid(class_carrier::getInstance()->getObjSession()->getUserID())) {
                 $objUser = new class_module_user_user(class_carrier::getInstance()->getObjSession()->getUserID());
                 if (checkEmailaddress($objUser->getStrEmail())) {
                     $this->strSender = $objUser->getStrEmail();
                 }
             }
         }
         if ($this->strSender == "" || class_module_system_setting::getConfigValue("_system_email_forcesender_") == "true") {
             $this->strSender = class_module_system_setting::getConfigValue("_system_email_defaultsender_");
         }
         if ($this->strSender != "") {
             //build the from-arguments
             if ($this->strSenderName != "") {
                 $strFrom = $this->encodeText($this->strSenderName) . " <" . $this->strSender . ">";
             } else {
                 $strFrom = $this->strSender;
             }
             $this->arrHeader[] = "From: " . $strFrom . $this->strEndOfLine;
             $this->arrHeader[] = "Reply-To: " . $this->strSender . $this->strEndOfLine;
         }
         //cc
         if (count($this->arrayCc) > 0) {
             $this->arrHeader[] = "Cc: " . implode(", ", $this->arrayCc) . $this->strEndOfLine;
         }
         //bcc
         if (count($this->arrayBcc) > 0) {
             $this->arrHeader[] = "Bcc: " . implode(", ", $this->arrayBcc) . $this->strEndOfLine;
         }
         //Kajona Headers to avoid being marked as spam
         $this->arrHeader[] = "X-Mailer: Kajona Mailer V4" . $this->strEndOfLine;
         $this->arrHeader[] = "Message-ID: <" . generateSystemid() . "_kajona@" . getServer("SERVER_NAME") . ">" . $this->strEndOfLine;
         //header for multipartmails?
         $strBoundary = generateSystemid();
         if ($this->bitMultipart || $this->bitFileAttached) {
             $this->arrHeader[] = 'MIME-Version: 1.0' . $this->strEndOfLine;
             //file attached?
             if ($this->bitFileAttached) {
                 $this->arrHeader[] = "Content-Type: multipart/related; boundary=\"" . $strBoundary . "\"" . $this->strEndOfLine;
             } else {
                 $this->arrHeader[] = "Content-Type: multipart/alternative; boundary=\"" . $strBoundary . "\"" . $this->strEndOfLine;
             }
         }
         //generate the mail-body
         $strBody = "";
         //multipart mail using html?
         if ($this->bitMultipart) {
             //multipart encoded mail
             $strBoundaryAlt = generateSystemid();
             //if a file should attached, a splitter is needed here
             if ($this->bitFileAttached) {
                 $strBody .= "--" . $strBoundary . $this->strEndOfLine;
                 $strBody .= "Content-Type: multipart/alternative; boundary=\"" . $strBoundaryAlt . "\"" . $this->strEndOfLine;
             } else {
                 //no new boundary-section, use old boundary instead
                 $strBoundaryAlt = $strBoundary;
             }
             //place a body for strange mail-clients
             $strBody .= "This is a multi-part message in MIME format." . $this->strEndOfLine . $this->strEndOfLine;
             //text-version
             $strBody .= "--" . $strBoundaryAlt . $this->strEndOfLine;
             $strBody .= "Content-Type: text/plain; charset=UTF-8" . $this->strEndOfLine;
             $strText = strip_tags($this->strText == "" ? str_replace(array("<br />", "<br />"), array("\n", "\n"), $this->strHtml) : $this->strText);
             if (function_exists("quoted_printable_encode")) {
                 $strBody .= "Content-Transfer-Encoding: quoted-printable" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= quoted_printable_encode($strText);
             } else {
                 $strBody .= "Content-Transfer-Encoding: 8bit" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= $strText;
             }
             $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             //html-version
             if ($this->strHtml != "") {
                 $strBody .= "--" . $strBoundaryAlt . $this->strEndOfLine;
                 $strBody .= "Content-Type: text/html; charset=UTF-8" . $this->strEndOfLine;
                 $strBody .= "Content-Transfer-Encoding: 8bit" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= $this->strHtml;
                 $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             }
             if ($this->bitFileAttached) {
                 $strBody .= "--" . $strBoundaryAlt . "--" . $this->strEndOfLine . $this->strEndOfLine;
             }
         } else {
             $this->arrHeader[] = "Content-Type: text/plain; charset=UTF-8" . $this->strEndOfLine;
             if (function_exists("quoted_printable_encode")) {
                 $this->arrHeader[] = "Content-Transfer-Encoding: quoted-printable" . $this->strEndOfLine;
                 $strBody .= quoted_printable_encode($this->strText);
             } else {
                 $strBody .= $this->strText;
             }
         }
         //any files to place in the mail body?
         if ($this->bitFileAttached) {
             foreach ($this->arrFiles as $arrOneFile) {
                 $strFileContents = chunk_split(base64_encode(file_get_contents($arrOneFile["filename"])));
                 //place file in mailbody
                 $strBody .= "--" . $strBoundary . $this->strEndOfLine;
                 $strBody .= "Content-Type: " . $arrOneFile["mimetype"] . "; name=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine;
                 $strBody .= "Content-Transfer-Encoding: base64" . $this->strEndOfLine;
                 if ($arrOneFile["inline"] === true) {
                     $strBody .= "Content-Disposition: inline; filename=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine;
                     $strBody .= "Content-ID: <" . basename($arrOneFile["filename"]) . ">" . $this->strEndOfLine . $this->strEndOfLine;
                 } else {
                     $strBody .= "Content-Disposition: attachment; filename=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine . $this->strEndOfLine;
                 }
                 $strBody .= $strFileContents;
                 $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             }
         }
         //finish mail
         if ($this->bitFileAttached || $this->bitMultipart) {
             $strBody .= "--" . $strBoundary . "--" . $this->strEndOfLine . $this->strEndOfLine;
         }
         //send mail
         // in some cases, the optional param "-f test@kajona.de" may be added as mail()s' 5th param
         class_logger::getInstance()->addLogRow("sent mail to " . $strTo, class_logger::$levelInfo);
         $bitReturn = mail($strTo, $this->encodeText($this->strSubject), $strBody, implode("", $this->arrHeader));
     }
     return $bitReturn;
 }
Example #30
0
 /**
  * Fetches the current user-id locking the record
  *
  * @return string
  */
 private function getLockedUntilTimestamp()
 {
     $objObject = class_objectfactory::getInstance()->getObject($this->strSystemid);
     if (validateSystemid($this->strSystemid) && $objObject != null && $objObject->getStrLockId() != "") {
         return $objObject->getIntLockTime() + (int) class_module_system_setting::getConfigValue("_system_lock_maxtime_");
     } else {
         return "0";
     }
 }