private function checkSingleLevel($strParentId, &$arrReturn)
 {
     $objRights = class_carrier::getInstance()->getObjRights();
     $arrParentRights = $objRights->getArrayRights($strParentId);
     //load the sub-ordinate nodes
     $objCommon = new class_module_system_common();
     $arrChildNodes = $objCommon->getChildNodesAsIdArray($strParentId);
     foreach ($arrChildNodes as $strOneChildId) {
         if (!$objRights->isInherited($strOneChildId)) {
             $arrChildRights = $objRights->getArrayRights($strOneChildId);
             $bitIsDifferent = false;
             foreach ($arrChildRights as $strPermission => $arrOneChildPermission) {
                 if ($strPermission == class_rights::$STR_RIGHT_INHERIT) {
                     continue;
                 }
                 if (count(array_diff($arrChildRights[$strPermission], $arrParentRights[$strPermission])) != 0) {
                     $bitIsDifferent = true;
                     break;
                 }
             }
             if (!$bitIsDifferent) {
                 $arrReturn[] = class_objectfactory::getInstance()->getObject($strOneChildId);
                 $objRights->setInherited(true, $strOneChildId);
             }
         }
         $this->checkSingleLevel($strOneChildId, $arrReturn);
     }
 }
Пример #2
0
 /**
  * Returns an instance of the objectfactory.
  *
  * @static
  * @return class_objectfactory
  */
 public static function getInstance()
 {
     if (self::$objInstance == null) {
         self::$objInstance = new class_objectfactory();
     }
     return self::$objInstance;
 }
 /**
  * @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;
 }
 /**
  * Renders the form to edit an existing entry
  *
  * @return string
  * @permissions edit
  */
 protected function actionEdit()
 {
     $objInstance = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objInstance instanceof class_module_workflows_handler && $objInstance->rightRight1()) {
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "editHandler", "&systemid=" . $objInstance->getSystemid()));
     }
     return "";
 }
Пример #5
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 "";
 }
 /**
  * Fetches a list of records currently marked as deleted
  *
  * @return class_model[]
  */
 public static function getDeletedRecords($intStart = null, $intEnd = null)
 {
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::INCLUDED());
     $strQuery = "SELECT system_id FROM " . _dbprefix_ . "system WHERE system_deleted = 1 ORDER BY system_id DESC";
     $arrRows = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array(), $intStart, $intEnd);
     $arrReturn = array();
     foreach ($arrRows as $arrOneRow) {
         $arrReturn[] = class_objectfactory::getInstance()->getObject($arrOneRow["system_id"]);
     }
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     return $arrReturn;
 }
 protected function tearDown()
 {
     //since the test cleared the index, we want a fresh index again :)
     $objSearchIndexWriter = new class_module_search_indexwriter();
     $objSearchIndexWriter->indexRebuild();
     foreach (self::$arrObjectIds as $intKey => $strId) {
         $objObject = class_objectfactory::getInstance()->getObject($strId);
         if ($objObject !== null) {
             $objObject->deleteObjectFromDatabase();
         }
         unset(self::$arrObjectIds[$intKey]);
     }
 }
 /**
  * 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);
 }
 /**
  * @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);
     }
 }
 /**
  * @see interface_admin_systemtast::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("search")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     $objWorker = new class_module_search_indexwriter();
     if (!class_carrier::getInstance()->getObjSession()->sessionIsset($this->STR_SESSION_KEY)) {
         //fetch all records to be indexed
         $strQuery = "SELECT system_id FROM " . _dbprefix_ . "system WHERE system_deleted = 0";
         $arrRows = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array());
         $arrIds = array();
         foreach ($arrRows as $arrOneRow) {
             $arrIds[] = $arrOneRow["system_id"];
         }
         $objWorker->clearIndex();
         class_carrier::getInstance()->getObjSession()->setSession($this->STR_SESSION_KEY, $arrIds);
         $this->setParam("totalCount", count($arrIds));
     }
     $arrIds = class_carrier::getInstance()->getObjSession()->getSession($this->STR_SESSION_KEY);
     if (count($arrIds) == 0) {
         class_carrier::getInstance()->getObjSession()->sessionUnset($this->STR_SESSION_KEY);
         return $this->objToolkit->getTextRow($this->getLang("worker_indexrebuild_end", array($objWorker->getNumberOfDocuments(), $objWorker->getNumberOfContentEntries())));
     }
     $intMax = 0;
     foreach ($arrIds as $intKey => $strOneValue) {
         $objObject = class_objectfactory::getInstance()->getObject($strOneValue);
         if ($objObject != null) {
             $objWorker->indexObject($objObject);
         }
         unset($arrIds[$intKey]);
         if ($intMax++ > 500) {
             break;
         }
     }
     class_carrier::getInstance()->getObjSession()->setSession($this->STR_SESSION_KEY, $arrIds);
     //and create a small progress-info
     $intTotal = $this->getParam("totalCount");
     $floatOnePercent = 100 / $intTotal;
     //and multiply it with the already processed records
     $intLookupsDone = ((int) $intTotal - count($arrIds)) * $floatOnePercent;
     $intLookupsDone = round($intLookupsDone, 2);
     if ($intLookupsDone < 0) {
         $intLookupsDone = 0;
     }
     $this->setStrProgressInformation($this->getLang("worker_indexrebuild", array($objWorker->getNumberOfDocuments(), $objWorker->getNumberOfContentEntries())));
     $this->setStrReloadParam("&totalCount=" . $this->getParam("totalCount"));
     return $intLookupsDone;
 }
 /**
  * @return bool
  */
 public function execute()
 {
     $objIndex = new class_module_search_indexwriter();
     //start with deletions
     $objQueue = new class_search_indexqueue();
     foreach ($objQueue->getRows(class_search_enum_indexaction::DELETE()) as $arrRow) {
         $objIndex->removeRecordFromIndex($arrRow["search_queue_systemid"]);
         $objQueue->deleteBySystemid($arrRow["search_queue_systemid"]);
     }
     //index objects
     foreach ($objQueue->getRows(class_search_enum_indexaction::INDEX(), 0, $this->intMaxObjectsPerRun) as $arrRow) {
         $objIndex->indexObject(class_objectfactory::getInstance()->getObject($arrRow["search_queue_systemid"]));
         $objQueue->deleteBySystemidAndAction($arrRow["search_queue_systemid"], class_search_enum_indexaction::INDEX());
     }
     //reschedule for the next run
     return false;
 }
 /**
  * Getter to return the records ordered by the last modified date.
  * Can be filtered via a given module-id or a class-based filter
  *
  * @param int $intMaxNrOfRecords
  * @param bool|int $intModuleFilter
  * @param bool $strClassFilter
  *
  * @return array class_model[]
  * @since 3.3.0
  * @deprecated will be removed in v5
  */
 public static function getLastModifiedRecords($intMaxNrOfRecords, $intModuleFilter = false, $strClassFilter = false)
 {
     $arrReturn = array();
     $strQuery = "SELECT system_id\n                       FROM " . _dbprefix_ . "system\n                   " . ($intModuleFilter !== false ? "WHERE system_module_nr = ? " : "") . "\n                   " . ($strClassFilter !== false ? "WHERE system_class = ? " : "") . "\n                   ORDER BY system_lm_time DESC";
     $arrParams = array();
     if ($intModuleFilter !== false) {
         $arrParams[] = (int) $intModuleFilter;
     }
     if ($strClassFilter !== false) {
         $arrParams[] = $strClassFilter;
     }
     $arrIds = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, $arrParams, 0, $intMaxNrOfRecords - 1);
     foreach ($arrIds as $arrSingleRow) {
         $arrReturn[] = class_objectfactory::getInstance()->getObject($arrSingleRow["system_id"]);
     }
     return $arrReturn;
 }
 /**
  * Triggers the internal loading of the mapped assignments.
  * Real work is only done on first access.
  */
 private function lazyLoadArray()
 {
     if ($this->bitInitialized) {
         return;
     }
     $this->bitInitialized = true;
     $objInit = new class_orm_objectinit($this->objTargetObject);
     $objInit->setObjHandleLogicalDeleted($this->objDeletedHandling);
     $objCfg = class_orm_assignment_config::getConfigForProperty($this->objTargetObject, $this->strProperty);
     foreach ($objInit->getAssignmentsFromDatabase($this->strProperty) as $strOneId) {
         $objObject = class_objectfactory::getInstance()->getObject($strOneId);
         if ($objObject !== null && ($objCfg->getArrTypeFilter() == null || count(array_filter($objCfg->getArrTypeFilter(), function ($strSingleClass) use($objObject) {
             return $objObject instanceof $strSingleClass;
         })) > 0)) {
             $this->append($objObject);
         }
     }
 }
 /**
  * Constructor
  *
  * @param array $arrElementData
  */
 public function __construct($arrElementData)
 {
     parent::__construct($arrElementData);
     //Determine the current site to load
     $this->strCurrentSite = $this->getPagename();
     //init with the current navigation, required in all cases
     if (isset($this->arrElementData["navigation_id"])) {
         if (!isset(self::$arrStaticNodes[$this->arrElementData["navigation_id"]])) {
             /** @var class_module_navigation_tree $objNavigation */
             $objNavigation = class_objectfactory::getInstance()->getObject($this->arrElementData["navigation_id"]);
             self::$arrStaticNodes[$this->arrElementData["navigation_id"]] = $objNavigation->getCompleteNaviStructure();
         }
         $this->arrTempNodes[$this->arrElementData["navigation_id"]] = self::$arrStaticNodes[$this->arrElementData["navigation_id"]];
     }
     //set the default navigation mode
     $this->setAction("navigationSitemap");
     //foreach($this->arrTempNodes[$this->arrElementData["navigation_id"]]["subnodes"] as $objOneNode)
     //    $this->printTreeLevel(1, $objOneNode);
 }
Пример #16
0
 public function testModuleModels()
 {
     echo "preparing object saves...\n";
     class_carrier::getInstance()->getObjRights()->setBitTestMode(true);
     $arrFiles = class_resourceloader::getInstance()->getFolderContent("/system", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_module_") !== false) {
             $objClass = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
             if (!$objClass->isAbstract() && $objClass->isSubclassOf("class_model")) {
                 $objAnnotations = new class_reflection(uniSubstr($strOneFile, 0, -4));
                 //block from autotesting?
                 if ($objAnnotations->hasClassAnnotation("@blockFromAutosave")) {
                     echo "skipping class " . uniSubstr($strOneFile, 0, -4) . " due to @blockFromAutosave annotation" . "\n";
                     return false;
                 }
                 return true;
             }
         }
         return false;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile();
     });
     $arrSystemids = array();
     /** @var $objOneInstance class_model */
     foreach ($arrFiles as $objOneInstance) {
         echo "testing object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
         $this->assertTrue($objOneInstance->updateObjectToDb(), "saving object " . get_class($objOneInstance));
         $arrSystemids[$objOneInstance->getSystemid()] = get_class($objOneInstance);
         echo " ...saved object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
     }
     $objObjectfactory = class_objectfactory::getInstance();
     foreach ($arrSystemids as $strSystemid => $strClass) {
         echo "instantiating " . $strSystemid . "@" . $strClass . "\n";
         $objInstance = $objObjectfactory->getObject($strSystemid);
         $this->assertTrue($objInstance != null);
         $this->assertEquals(get_class($objInstance), $strClass);
         echo "deleting " . $strSystemid . "@" . $strClass . "\n";
         $objInstance->deleteObjectFromDatabase();
     }
     class_carrier::getInstance()->getObjRights()->setBitTestMode(false);
 }
 /**
  * Looks up the list of tags and renders the list.
  *
  * @return string the prepared html-output
  */
 public function loadData()
 {
     $strReturn = "";
     $arrTags = class_module_tags_tag::getTagsWithAssignments();
     //load the template
     $strTemplateWrapperID = $this->objTemplate->readTemplate("/element_tags/" . $this->arrElementData["char1"], "tags");
     $strTemplateTagID = $this->objTemplate->readTemplate("/element_tags/" . $this->arrElementData["char1"], "tagname");
     $strTemplateTaglinkID = $this->objTemplate->readTemplate("/element_tags/" . $this->arrElementData["char1"], "taglink");
     $strTags = "";
     foreach ($arrTags as $objTag) {
         if ($objTag->rightView()) {
             $arrAssignments = $objTag->getListOfAssignments();
             $strLinks = "";
             //render the links - if possible
             foreach ($arrAssignments as $arrOneAssignment) {
                 $objRecord = class_objectfactory::getInstance()->getObject($arrOneAssignment["tags_systemid"]);
                 if ($objRecord == null) {
                     continue;
                 }
                 if ($objRecord instanceof class_module_pages_page) {
                     $strLink = getLinkPortal($objRecord->getStrName(), "", "_self", $objRecord->getStrBrowsername(), "", "&highlight=" . urlencode($objTag->getStrName()), "", "", $arrOneAssignment["tags_attribute"]);
                     $strLinks .= $this->fillTemplate(array("taglink" => $strLink), $strTemplateTaglinkID);
                 }
                 if (class_module_system_module::getModuleByName("news") != null && $objRecord->getIntModuleNr() == _news_module_id_) {
                     //TODO: fix after news integration, move to search link target interface handler
                     $objNews = new class_module_news_news($objRecord->getSystemid());
                     $strLink = getLinkPortal("newsdetails", "", "_self", $objNews->getStrTitle(), "newsDetail", "&highlight=" . urlencode($objTag->getStrName()), $objRecord->getSystemid(), "", "", $objNews->getStrTitle());
                     $strLinks .= $this->fillTemplate(array("taglink" => $strLink), $strTemplateTaglinkID);
                 }
             }
             $arrTemplate = array();
             $arrTemplate["tagname"] = $objTag->getStrName();
             $arrTemplate["linkcount"] = count($arrAssignments);
             $arrTemplate["taglinks"] = $strLinks;
             $arrTemplate["tagid"] = $objTag->getSystemid();
             $strTags .= $this->fillTemplate($arrTemplate, $strTemplateTagID);
         }
     }
     $strReturn = $this->fillTemplate(array("tags" => $strTags), $strTemplateWrapperID);
     return $strReturn;
 }
Пример #18
0
function validateSingleLevelSort($strParentId)
{
    $objCommon = new class_module_system_common($strParentId);
    if ($objCommon->getIntModuleNr() == _pages_modul_id_ || $objCommon->getIntModuleNr() == _pages_folder_id_) {
        $strQuery = "SELECT system_id\n                         FROM " . _dbprefix_ . "system\n                         WHERE system_prev_id=? AND system_id != '0'\n                           AND system_module_nr IN (?, ?)\n                         ORDER BY system_sort ASC, system_comment ASC";
        $arrNodesRaw = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array($strParentId, _pages_modul_id_, _pages_folder_id_));
        $arrNodes = array();
        foreach ($arrNodesRaw as $arrOneRow) {
            $arrNodes[] = $arrOneRow["system_id"];
        }
    } else {
        $arrNodes = $objCommon->getChildNodesAsIdArray($strParentId);
    }
    echo "<div style='padding-left: 25px;'>";
    for ($intI = 1; $intI <= count($arrNodes); $intI++) {
        $objCurNode = class_objectfactory::getInstance()->getObject($arrNodes[$intI - 1]);
        if ($objCurNode == null) {
            $objCommon = new class_module_system_common($arrNodes[$intI - 1]);
            $strCurLevel = "<span style='color: red'>error loading node for: " . $intI . " @ " . $arrNodes[$intI - 1] . " - " . $objCommon->getStrRecordClass() . "</span>";
            echo "<div>" . $strCurLevel . "</div>";
        }
        $strCurLevel = $objCurNode->getSystemid() . " - " . $objCurNode->getIntSort() . " - " . $objCurNode->getStrRecordClass() . " - " . $objCurNode->getStrRecordComment();
        if ($intI != $objCurNode->getIntSort()) {
            $strCurLevel = "<span style='color: red'>expected: " . $intI . ", got " . $objCurNode->getIntSort() . " @ " . $strCurLevel . "</span>";
            if (getGet("doFix") != "") {
                $strCurLevel .= "\nSetting new sort-id to " . $intI . "\n";
                $strQuery = "UPDATE " . _dbprefix_ . "system SET system_sort = ? WHERE system_id = ? ";
                class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array($intI, $objCurNode->getSystemid()));
            }
        } else {
            $strCurLevel = "<span style='color: green'>" . $strCurLevel . "</span>";
        }
        echo "<div>" . $strCurLevel . "</div>";
        if ($objCurNode instanceof class_module_pages_page) {
            validateSinglePage($objCurNode);
        }
        validateSingleLevelSort($objCurNode->getSystemid());
    }
    echo "</div>";
}
 /**
  * @return string
  * @throws class_exception
  * @permissions right1
  */
 protected function actionAddFavorite()
 {
     $objTags = class_objectfactory::getInstance()->getObject($this->getSystemid());
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_XML);
     $strError = "<message>" . $this->getLang("favorite_save_error") . "</message>";
     $strSuccess = "<message>" . $this->getLang("favorite_save_success") . ": " . $objTags->getStrDisplayName() . "</message>";
     $strExisting = "<message>" . $this->getLang("favorite_save_remove") . ": " . $objTags->getStrDisplayName() . "</message>";
     //already added before?
     if (count(class_module_tags_favorite::getAllFavoritesForUserAndTag($this->objSession->getUserID(), $this->getSystemid())) > 0) {
         $arrFavorites = class_module_tags_favorite::getAllFavoritesForUserAndTag($this->objSession->getUserID(), $this->getSystemid());
         foreach ($arrFavorites as $objOneFavorite) {
             $objOneFavorite->deleteObjectFromDatabase();
         }
         return $strExisting;
     }
     $objFavorite = new class_module_tags_favorite();
     $objFavorite->setStrUserId($this->objSession->getUserID());
     $objFavorite->setStrTagId($objTags->getSystemid());
     if (!$objFavorite->updateObjectToDb()) {
         return $strError;
     } else {
         return $strSuccess;
     }
 }
 /**
  * @param interface_model $objOneElement
  * @param string $intAllowedLevel
  * @return string
  */
 public static function getPathName(interface_model $objOneElement)
 {
     //fetch the process-path, at least two levels
     $arrParents = $objOneElement->getPathArray();
     // remove first two nodes
     if (count($arrParents) >= 2) {
         array_shift($arrParents);
         array_shift($arrParents);
     }
     //remove current element
     array_pop($arrParents);
     //Only return three levels
     $arrPath = array();
     for ($intI = 0; $intI < 3; $intI++) {
         $strPathId = array_pop($arrParents);
         if (!validateSystemid($strPathId)) {
             break;
         }
         $objObject = class_objectfactory::getInstance()->getObject($strPathId);
         $arrPath[] = $objObject->getStrDisplayName();
     }
     if (count($arrPath) == 0) {
         return "";
     }
     $strPath = implode(" &gt; ", array_reverse($arrPath));
     return $strPath;
 }
Пример #21
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 "";
 }
 /**
  * Saves the rights passed by form
  *
  * @throws class_exception
  * @return string "" in case of success
  * @permissions right
  * @xml
  */
 protected function actionSaveRights()
 {
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
     $arrRequest = json_decode($this->getParam("json"));
     //Collecting & sorting the passed values
     $strSystemid = $this->getSystemid();
     $objRights = class_carrier::getInstance()->getObjRights();
     if ($this->getParam("systemid") == "0") {
         $objTarget = new class_module_system_common("0");
         $objTarget->setStrSystemid("0");
         $strSystemid = "0";
     } else {
         $objTarget = class_objectfactory::getInstance()->getObject($this->getSystemid());
     }
     //Special case: The root-record.
     if (!$objTarget->rightRight()) {
         return $this->objToolkit->warningBox($this->getLang("commons_error_permissions"), "alert-danger");
     }
     //Inheritance?
     if ($arrRequest->bitInherited) {
         $intInherit = 1;
     } else {
         $intInherit = 0;
     }
     //Modified RootRecord? Here Inheritance is NOT allowed!
     if ($strSystemid == "0") {
         $intInherit = 0;
     }
     $strAdminsGroupId = class_module_system_setting::getConfigValue("_admins_group_id_");
     $strView = $strAdminsGroupId;
     $strEdit = $strAdminsGroupId;
     $strDelete = $strAdminsGroupId;
     $strRight = $strAdminsGroupId;
     $strRight1 = $strAdminsGroupId;
     $strRight2 = $strAdminsGroupId;
     $strRight3 = $strAdminsGroupId;
     $strRight4 = $strAdminsGroupId;
     $strRight5 = $strAdminsGroupId;
     $strChangelog = $strAdminsGroupId;
     foreach ($arrRequest->arrConfigs as $strOneCfg) {
         $arrRow = explode(",", $strOneCfg);
         if ($arrRow[1] == $strAdminsGroupId) {
             continue;
         }
         switch ($arrRow[0]) {
             case "1":
                 $strView .= "," . $arrRow[1];
                 break;
             case "2":
                 $strEdit .= "," . $arrRow[1];
                 break;
             case "3":
                 $strDelete .= "," . $arrRow[1];
                 break;
             case "4":
                 $strRight .= "," . $arrRow[1];
                 break;
             case "5":
                 $strRight1 .= "," . $arrRow[1];
                 break;
             case "6":
                 $strRight2 .= "," . $arrRow[1];
                 break;
             case "7":
                 $strRight3 .= "," . $arrRow[1];
                 break;
             case "8":
                 $strRight4 .= "," . $arrRow[1];
                 break;
             case "9":
                 $strRight5 .= "," . $arrRow[1];
                 break;
             case "10":
                 $strChangelog .= "," . $arrRow[1];
                 break;
         }
     }
     $arrReturn = array("inherit" => $intInherit, "view" => $strView, "edit" => $strEdit, "delete" => $strDelete, "right" => $strRight, "right1" => $strRight1, "right2" => $strRight2, "right3" => $strRight3, "right4" => $strRight4, "right5" => $strRight5, "changelog" => $strChangelog);
     //Pass to right-class
     if ($objRights->setRights($arrReturn, $strSystemid)) {
         $strReturn = $this->objToolkit->warningBox($this->getLang("permissions_success"), "alert-success");
     } else {
         $strReturn = $this->objToolkit->warningBox($this->getLang("fehler_setzen"), "alert-danger");
     }
     return json_encode(array("message" => $strReturn));
 }
Пример #23
0
 /**
  * Writes rights to the database.
  * Wrapper to the recursive function class_rights::setRightsRecursive($arrRights, $strSystemid)
  *
  * @param mixed $arrRights
  * @param string $strSystemid
  *
  * @see setRightsRecursive($arrRights, $strSystemid)
  * @throws class_exception
  * @return bool
  */
 public function setRights($arrRights, $strSystemid)
 {
     //start a new tx
     $this->flushRightsCache();
     $this->objDb->transactionBegin();
     $objInstance = class_objectfactory::getInstance()->getObject($strSystemid);
     if ($objInstance !== null && $objInstance instanceof interface_versionable) {
         $arrCurrPermissions = $this->getPlainRightRow($strSystemid);
         //create a changehistory entry
         $objLog = new class_module_system_changelog();
         $arrChanges = array(array("property" => "rightInherit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_INHERIT], "newvalue" => $arrRights[self::$STR_RIGHT_INHERIT]), array("property" => "rightView", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_VIEW], "newvalue" => $arrRights[self::$STR_RIGHT_VIEW]), array("property" => "rightEdit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_EDIT], "newvalue" => $arrRights[self::$STR_RIGHT_EDIT]), array("property" => "rightDelete", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_DELETE], "newvalue" => $arrRights[self::$STR_RIGHT_DELETE]), array("property" => "rightRight", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT]), array("property" => "rightRight1", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT1], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT1]), array("property" => "rightRight2", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT2], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT2]), array("property" => "rightRight3", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT3], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT3]), array("property" => "rightRight4", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT4], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT4]), array("property" => "rightRight5", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT5], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT5]), array("property" => "rightChangelog", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_CHANGELOG], "newvalue" => $arrRights[self::$STR_RIGHT_CHANGELOG]));
         $objLog->processChanges($objInstance, "editPermissions", $arrChanges);
     }
     $bitSave = $this->setRightsRecursive($arrRights, $strSystemid);
     if ($bitSave) {
         $this->objDb->transactionCommit();
         class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " succeeded", class_logger::$levelInfo);
     } else {
         $this->objDb->transactionRollback();
         class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " failed", class_logger::$levelError);
         throw new class_exception("saving rights of record " . $strSystemid . " failed", class_exception::$level_ERROR);
     }
     return $bitSave;
 }
Пример #24
0
 /**
  * Fetches a list of records currently locked in the database
  *
  * @param string $strUserId
  *
  * @return class_model[]
  */
 public static function getLockedRecordsForUser($strUserId)
 {
     $strQuery = "SELECT system_id FROM " . _dbprefix_ . "system WHERE system_lock_id = ? AND system_lock_time > ? ORDER BY system_id DESC";
     $arrRows = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array($strUserId, time() - (int) class_module_system_setting::getConfigValue("_system_lock_maxtime_")));
     $arrReturn = array();
     foreach ($arrRows as $arrOneRow) {
         $arrReturn[] = class_objectfactory::getInstance()->getObject($arrOneRow["system_id"]);
     }
     return $arrReturn;
 }
Пример #25
0
 /**
  * Deletes an assignment of the current tag from the database.
  *
  * @param string $strTargetSystemid
  * @param string $strAttribute
  * @return bool
  */
 public function removeFromSystemrecord($strTargetSystemid, $strAttribute = null)
 {
     $arrParams = array();
     $arrParams[] = $strTargetSystemid;
     if ($strAttribute != null) {
         $arrParams[] = $strAttribute;
     }
     $arrParams[] = $this->getSystemid();
     $strPrivate = "";
     if ($this->getIntPrivate() == 1) {
         $strPrivate = "AND (tags_owner IS NULL OR tags_owner = '' OR tags_owner = ?)";
         $arrParams[] = $this->objSession->getUserID();
     }
     $strQuery = "DELETE FROM " . _dbprefix_ . "tags_member\n                           WHERE tags_systemid = ?\n                             " . ($strAttribute != null ? "AND tags_attribute = ?" : "") . "\n                             AND tags_tagid = ?\n                             " . $strPrivate;
     $bitReturn = $this->objDB->_pQuery($strQuery, $arrParams);
     //trigger an object update
     class_objectfactory::getInstance()->getObject($strTargetSystemid)->updateObjectToDb();
     return $bitReturn;
 }
 /**
  * Fetches all change-sets within the specified period for the given property.
  *
  * @param string $strSystemid
  * @param string $strProperty
  * @param class_date $objDateFrom
  * @param class_date $objDateTo
  *
  * @static
  * @return array
  */
 public static function getValuesForDateRange($strSystemid, $strProperty, class_date $objDateFrom, class_date $objDateTo)
 {
     $strQuery = "SELECT change_oldvalue, change_newvalue\n                       FROM " . _dbprefix_ . self::getTableForClass(class_objectfactory::getInstance()->getClassNameForId($strSystemid)) . "\n                      WHERE change_systemid = ?\n                        AND change_property = ?\n                        AND change_date >= ?\n                        AND change_date <= ?\n                   ORDER BY change_date DESC ";
     $arrRow = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array($strSystemid, $strProperty, $objDateFrom->getLongTimestamp(), $objDateTo->getLongTimestamp()), 0, 1);
     return $arrRow;
 }
 /**
  * Returns the list of pages and folders, so containing both object types, being located
  * under a given systemid.
  *
  * @param string $strFolderid
  * @param bool $bitOnlyActive
  * @param null $intStart
  * @param null $intEnd
  *
  * @return class_module_pages_page[] | class_module_pages_folder[]
  */
 public static function getPagesAndFolderList($strFolderid = "", $bitOnlyActive = false, $intStart = null, $intEnd = null)
 {
     if (!validateSystemid($strFolderid)) {
         $strFolderid = class_module_system_module::getModuleByName("pages")->getSystemid();
     }
     $objORM = new class_orm_objectlist();
     $strQuery = "SELECT system_id, system_module_nr\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\t                      " . ($bitOnlyActive ? " AND system_status = 1 " : "") . "\n\t                      " . $objORM->getDeletedWhereRestriction() . "\n                    ORDER BY system_sort ASC";
     $arrIds = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array($strFolderid, _pages_modul_id_, _pages_folder_id_), $intStart, $intEnd);
     $arrReturn = array();
     foreach ($arrIds as $arrOneRecord) {
         $objRecord = class_objectfactory::getInstance()->getObject($arrOneRecord["system_id"]);
         if ($objRecord instanceof class_module_pages_folder || $objRecord instanceof class_module_pages_page) {
             $arrReturn[] = $objRecord;
         }
     }
     return $arrReturn;
 }
 /**
  * Sets the prev-id of a record.
  * expects the param prevId
  *
  * @return string
  * @permissions edit
  */
 protected function actionSetPrevid()
 {
     $strReturn = "";
     $objRecord = class_objectfactory::getInstance()->getObject($this->getSystemid());
     $strNewPrevId = $this->getParam("prevId");
     //check permissions
     if ($objRecord != null && $objRecord->rightEdit() && validateSystemid($strNewPrevId)) {
         if ($objRecord->getStrPrevId() != $strNewPrevId) {
             $objRecord->updateObjectToDb($strNewPrevId);
         }
         $strReturn .= "<message>" . $objRecord->getStrDisplayName() . " - " . $this->getLang("setPrevIdOk") . "</message>";
         $this->flushCompletePagesCache();
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED);
         $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>";
     }
     return $strReturn;
 }
 /**
  * Fetches all child-nodes of the passed node.
  * Used by the tree-view in module-navigation admin view.
  *
  * @return string
  * @since 3.3.0
  * @xml
  * @permissions view
  */
 protected function actionGetChildNodes()
 {
     $arrNavigations = class_module_navigation_point::getNaviLayer($this->getSystemid());
     $arrReturn = array();
     if (count($arrNavigations) > 0) {
         /** @var class_module_navigation_point $objSinglePoint */
         foreach ($arrNavigations as $objSinglePoint) {
             if ($objSinglePoint->rightView()) {
                 $arrReturn[] = array("data" => array("title" => class_adminskin_helper::getAdminImage($objSinglePoint->getStrIcon()) . "&nbsp;" . $objSinglePoint->getStrDisplayName()), "state" => count(class_module_navigation_point::getNaviLayer($objSinglePoint->getSystemid())) == 0 ? "" : "closed", "attr" => array("id" => $objSinglePoint->getSystemid(), "systemid" => $objSinglePoint->getSystemid(), "link" => class_link::getLinkAdminHref("navigation", "list", "&systemid=" . $objSinglePoint->getSystemid(), false)));
             }
         }
     }
     $objCurNode = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objCurNode instanceof class_module_navigation_tree) {
         $arrReturn = array("data" => array("title" => class_adminskin_helper::getAdminImage($objCurNode->getStrIcon()) . "&nbsp;" . $objCurNode->getStrDisplayName()), "state" => "", "attr" => array("id" => $objCurNode->getSystemid(), "systemid" => $objCurNode->getSystemid(), "link" => ""), "children" => $arrReturn);
     }
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
     return json_encode($arrReturn);
 }
 /**
  * Syncs the repo partially
  *
  * @return string
  * @permissions edit
  */
 protected function actionSyncRepo()
 {
     $strReturn = "";
     $strResult = "";
     /** @var class_module_mediamanager_repo|class_module_mediamanager_file $objInstance */
     $objInstance = class_objectfactory::getInstance()->getObject($this->getSystemid());
     //close the session to avoid a blocking behaviour
     $this->objSession->sessionClose();
     if ($objInstance instanceof class_module_mediamanager_repo) {
         $arrSyncs = $objInstance->syncRepo();
     } else {
         return "<error>mediamanager repo could not be loaded</error>";
     }
     $strResult = 0;
     $strResult += $arrSyncs["insert"] + $arrSyncs["delete"];
     $strReturn .= "<repo>" . xmlSafeString(strip_tags($strResult)) . "</repo>";
     class_logger::getInstance()->addLogRow("synced gallery partially >" . $this->getSystemid() . ": " . $strResult, class_logger::$levelInfo);
     return $strReturn;
 }