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);
     }
 }
 /**
  * @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"));
 }
 /**
  * @param $strSystemid
  * @param $strGroupId
  * @param $arrPermissions
  * @param bool $bitForce
  */
 private function updateRecord($strSystemid, $strGroupId, $arrPermissions, $bitForce = false)
 {
     $objRights = class_carrier::getInstance()->getObjRights();
     $objCommon = new class_module_system_common();
     foreach ($arrPermissions as $strPermission => $bitIsGiven) {
         if (!$objRights->isInherited($strSystemid) || $bitForce) {
             if ($bitIsGiven) {
                 $objRights->addGroupToRight($strGroupId, $strSystemid, $strPermission);
             } else {
                 $objRights->removeGroupFromRight($strGroupId, $strSystemid, $strPermission);
             }
         }
     }
     foreach ($objCommon->getChildNodesAsIdArray($strSystemid) as $strOneId) {
         $this->updateRecord($strOneId, $strGroupId, $arrPermissions);
     }
 }
function printSingleLevel($strStartId, &$arrGlobalNodes)
{
    foreach ($arrGlobalNodes as $intI => $strId) {
        if ($strId["system_id"] == $strStartId) {
            unset($arrGlobalNodes[$intI]);
            break;
        }
    }
    $objCommon = new class_module_system_common($strStartId);
    $arrRecord = $objCommon->getSystemRecord();
    $arrChilds = $objCommon->getChildNodesAsIdArray();
    echo "<div style=\"padding-bottom: 5px; " . (count($arrChilds) > 0 ? " cursor: pointer; " : "") . "  \"\n             onmouseover=\"this.style.backgroundColor='#cccccc';\" onmouseout=\"this.style.backgroundColor='#ffffff';\"\n            " . (count($arrChilds) > 0 ? " onclick=\"javascript:fold('" . $strStartId . "')\"  " : " ") . "\n            >";
    $strStatus = "<span style=\"color: green; \">active</span>";
    if ($objCommon->getIntRecordStatus() == 0) {
        $strStatus = "<span style=\"color: red;\">inactive</span>";
    }
    if (count($arrChilds) > 0) {
        echo " + ";
    } else {
        echo "  ";
    }
    echo $objCommon->getStrRecordClass() . " / " . $objCommon->getRecordComment() . " / " . $objCommon->getSystemid() . "\n";
    echo "   state: " . $strStatus . " module nr: " . $arrRecord["system_module_nr"] . " sort: " . $arrRecord["system_sort"] . "\n";
    echo "</div>";
    if (count($arrChilds) > 0) {
        echo "<div id=\"" . $strStartId . "\" style=\"border: 1px solid #cccccc; margin: 0 0 0px 20px; display: none;\" >";
        for ($intI = 0; $intI < count($arrChilds); $intI++) {
            $strSingleId = $arrChilds[$intI];
            printSingleLevel($strSingleId, $arrGlobalNodes);
        }
        echo "</div>";
    }
}
示例#5
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>";
}
 /**
  * This method is called, when the widget should generate it's content.
  * Return the complete content using the methods provided by the base class.
  * Do NOT use the toolkit right here!
  *
  * @return string
  */
 public function getWidgetOutput()
 {
     $strReturn = "";
     if (!class_module_system_module::getModuleByName("pages")->rightView()) {
         return $this->getLang("commons_error_permissions");
     }
     $intMax = $this->getFieldValue("nrofrows");
     if ($intMax < 0) {
         $intMax = 1;
     }
     /** @var class_module_pages_page[] $arrRecords */
     $arrRecords = class_module_system_common::getLastModifiedRecords($intMax, false, "class_module_pages_page");
     foreach ($arrRecords as $objPage) {
         if ($objPage->rightEdit()) {
             $strReturn .= $this->widgetText(class_link::getLinkAdmin("pages_content", "list", "&systemid=" . $objPage->getSystemid(), $objPage->getStrDisplayName()));
         } else {
             $strReturn .= $this->widgetText($objPage->getStrDisplayName());
         }
         $strReturn .= $this->widgetText("&nbsp; &nbsp; " . timeToString($objPage->getIntLmTime()) . "");
     }
     return $strReturn;
 }
 /**
  * Delegate to system-kernel, used to write to params
  *
  * @param string $strKey
  * @param mixed $strValue
  *
  * @return void
  */
 public function setParam($strKey, $strValue)
 {
     $this->objSystemCommon->setParam($strKey, $strValue);
 }
 /**
  * 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));
 }
 /**
  * Generates a sorted array of systemids, reaching from the passed systemid up
  * until the assigned module-id
  *
  * @param string $strSystemid
  * @param string $strStopSystemid
  *
  * @return mixed
  * @deprecated should be handled by the model-classes instead
  */
 public function getPathArray($strSystemid = "", $strStopSystemid = "")
 {
     if ($strSystemid == "") {
         $strSystemid = $this->getSystemid();
     }
     if ($strStopSystemid == "") {
         $strStopSystemid = $this->getObjModule()->getSystemid();
     }
     $objSystemCommon = new class_module_system_common();
     return $objSystemCommon->getPathArray($strSystemid, $strStopSystemid);
 }
    /**
     * Saves the passed Element to the database (edit or new modes)
     *
     * @throws class_exception
     * @return string "" in case of success
     */
    protected function actionSaveElement()
    {
        $strReturn = "";
        //There are two modes - edit and new
        //The element itself just knows the edit mode, so in case of new, we have to create a dummy element - before
        //passing control to the element
        if ($this->getParam("mode") == "new") {
            //Using the passed placeholder-param to load the element and get the table
            $strPlaceholder = $this->getParam("placeholder");
            //Split up the placeholder
            $arrPlaceholder = explode("_", $strPlaceholder);
            $strPlaceholderName = $arrPlaceholder[0];
            $strPlaceholderElement = $this->getParam("element");
            //Now, load all infos about the requested element
            $objElement = class_module_pages_element::getElement($strPlaceholderElement);
            //Load the class to create an object
            $strElementClass = str_replace(".php", "", $objElement->getStrClassAdmin());
            //and finally create the object
            /** @var class_element_admin $objElement */
            $objElement = new $strElementClass();
            //really continue? try to validate the passed data.
            if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) {
                class_carrier::getInstance()->setParam("peClose", "");
                $strReturn .= $this->actionNew(true);
                return $strReturn;
            } else {
                if (!$objElement->validateForm()) {
                    class_carrier::getInstance()->setParam("peClose", "");
                    $strReturn .= $this->actionNew(true);
                    return $strReturn;
                }
            }
            //So, lets do the magic - create the records
            $objPageElement = new class_module_pages_pageelement();
            $objPageElement->setStrName($strPlaceholderName);
            $objPageElement->setStrPlaceholder($strPlaceholder);
            $objPageElement->setStrElement($strPlaceholderElement);
            $objPageElement->setStrLanguage($this->getParam("page_element_ph_language"));
            if (!$objPageElement->updateObjectToDb($this->getSystemid())) {
                throw new class_exception("Error saving new element-object to db", class_exception::$level_ERROR);
            }
            $strElementSystemId = $objPageElement->getSystemid();
            $objLockmanager = new class_lockmanager($strElementSystemId);
            $objLockmanager->lockRecord();
            //To have the element working as expected, set the systemid
            $this->setSystemid($strElementSystemId);
        }
        // ************************************* Edit the current Element *******************************
        //check, if the element isn't locked
        $objCommons = new class_module_system_common($this->getSystemid());
        $strPageSystemid = $objCommons->getPrevId();
        $objLockmanager = new class_lockmanager($this->getSystemid());
        if ($objLockmanager->isLockedByCurrentUser()) {
            //Load the data of the current element
            $objElementData = new class_module_pages_pageelement($this->getSystemid());
            /** @var $objElement class_element_admin */
            $objElement = $objElementData->getConcreteAdminInstance();
            //really continue? try to validate the passed data.
            if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) {
                class_carrier::getInstance()->setParam("peClose", "");
                $strReturn .= $this->actionEdit(true);
                return $strReturn;
            } else {
                if (!$objElement->validateForm()) {
                    class_carrier::getInstance()->setParam("peClose", "");
                    $strReturn .= $this->actionEdit(true);
                    return $strReturn;
                }
            }
            //pass the data to the element, maybe the element wants to update some data
            $objElement->setArrParamData($this->getAllParams());
            if ($objElement->getAdminForm() !== null) {
                $objElement->getAdminForm()->updateSourceObject();
            }
            $objElement->doBeforeSaveToDb();
            //check, if we could save the data, so the element needn't to
            //woah, we are soooo great
            $objElement->updateForeignElement();
            //Edit Date of page & unlock
            $objPage = class_objectfactory::getInstance()->getObject($strPageSystemid);
            $objPage->updateObjectToDb();
            $objLockmanager->unlockRecord();
            //And update the internal comment and language
            $objElementData->setStrTitle($this->getParam("page_element_ph_title"));
            $objElementData->setStrLanguage($this->getParam("page_element_ph_language"));
            //placeholder to update?
            if ($this->getParam("placeholder") != "") {
                $objElementData->setStrPlaceholder($this->getParam("placeholder"));
            }
            $objStartDate = new class_date("0");
            $objEndDate = new class_date("0");
            $objStartDate->generateDateFromParams("start", $this->getAllParams());
            $objEndDate->generateDateFromParams("end", $this->getAllParams());
            if ($objStartDate->getIntYear() == "0000") {
                $objElementData->setObjStartDate(null);
            } else {
                $objElementData->setObjStartDate($objStartDate);
            }
            if ($objEndDate->getIntYear() == "0000") {
                $objElementData->setObjEndDate(null);
            } else {
                $objElementData->setObjEndDate($objEndDate);
            }
            if (!$objElementData->updateObjectToDb()) {
                throw new class_exception("Error updating object to db", class_exception::$level_ERROR);
            }
            //allow the element to run actions after saving
            $objElement->doAfterSaveToDb();
            //Loading the data of the corresponding site
            $objPage = new class_module_pages_page($strPageSystemid);
            $this->flushCompletePagesCache();
            if ($this->getParam("peClose") == "1") {
                //generate the elements' output
                $objPortalElement = $objElementData->getConcretePortalInstance();
                $strElementContent = $objPortalElement->getElementOutput();
                $strContent = json_encode($strElementContent, JSON_FORCE_OBJECT);
                //JSON_HEX_QUOT|JSON_HEX_APOS
                $strReturn = <<<JS
                    parent.KAJONA.admin.portaleditor.changeElementData('{$objElementData->getStrPlaceholder()}', '{$objElementData->getSystemid()}', {$strContent});
                    parent.KAJONA.admin.portaleditor.closeDialog(true);

JS;
                class_carrier::getInstance()->setParam("peClose", null);
                return "<script type='text/javascript'>{$strReturn}</script>";
            }
            $this->adminReload(class_link::getLinkAdminHref("pages_content", "list", "systemid=" . $objPage->getSystemid()));
        } else {
            $strReturn = $this->objToolkit->warningBox($this->getLang("ds_gesperrt"));
        }
        return $strReturn;
    }
示例#11
0
 /**
  * Internal helper, checks if a child-node is the descendant of a given base-node
  *
  * @param string $strBaseId
  * @param string $strChildId
  *
  * @return bool
  */
 private function isSystemidChildNode($strBaseId, $strChildId)
 {
     while (validateSystemid($strChildId)) {
         $objCommon = new class_module_system_common($strChildId);
         if ($objCommon->getSystemid() == $strBaseId) {
             return true;
         } else {
             return $this->isSystemidChildNode($strBaseId, $objCommon->getPrevId());
         }
     }
     return false;
 }
 /**
  * Loads the language to edit content
  *
  * @return string
  */
 public function getLanguageToWorkOn()
 {
     $objSystemCommon = new class_module_system_common();
     return $objSystemCommon->getStrAdminLanguageToWorkOn();
 }
 /**
  * Gets the Prev-ID of a record
  *
  * @param string $strSystemid
  *
  * @return string
  * @deprecated
  */
 public function getPrevId($strSystemid = "")
 {
     if ($strSystemid == "") {
         $strSystemid = $this->getSystemid();
     }
     $objCommon = new class_module_system_common($strSystemid);
     return $objCommon->getPrevId();
 }