/** * Returns all modules available in the module-table. * Limited to those with a proper title, so * a subset of getModuleIds() / all module-entries * @return array */ public function getPossibleModulesForFilter() { $arrFilterModules = array(); $arrModules = class_module_system_module::getAllModules(); $arrNrs = $this->getModuleNumbers(); foreach ($arrModules as $objOneModule) { if (in_array($objOneModule->getIntNr(), $arrNrs) && $objOneModule->rightView()) { $strName = $this->getLang("modul_titel", $objOneModule->getStrName()); if ($strName != "!modul_titel!") { $arrFilterModules[$objOneModule->getIntNr()] = $strName; } } } return $arrFilterModules; }
/** * Generates the list of modules installed. * Returned structure: * <modules> * <module> * <name></name> * <version></version> * <module> * </modules> * * @return string * @permissions view */ protected function actionModuleList() { $strReturn = ""; $strReturn .= "<modules>"; //Loading the modules $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { $strReturn .= "<module>"; $strReturn .= "<name>" . xmlSafeString($objSingleModule->getStrName()) . "</name>"; $strReturn .= "<version>" . xmlSafeString($objSingleModule->getStrVersion()) . "</version>"; $strReturn .= "</module>"; } $strReturn .= "</modules>"; return $strReturn; }
public function testInheritanceForObjects() { if (class_module_system_module::getModuleByName("pages") === null) { return; } echo "\tRIGHTS INHERITANCE...\n"; $objRights = class_carrier::getInstance()->getObjRights(); $this->objRights = class_carrier::getInstance()->getObjRights(); //create a new user & group to be used during testing echo "\tcreating a test user\n"; $objUser = new class_module_user_user(); $strUsername = "******" . generateSystemid(); $objUser->setStrUsername($strUsername); $objUser->updateObjectToDb(); echo "\tid of user: "******"\n"; $this->strUserId = $objUser->getSystemid(); echo "\tcreating a test group\n"; $objGroup = new class_module_user_group(); $strName = "name_" . generateSystemid(); $objGroup->setStrName($strName); $objGroup->updateObjectToDb(); echo "\tid of group: " . $objGroup->getSystemid() . "\n"; echo "\tadding user to group\n"; $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser()); $strModuleId = $this->createObject("class_module_system_module", "0")->getSystemid(); class_carrier::getInstance()->flushCache(class_carrier::INT_CACHE_TYPE_MODULES); class_module_system_module::getAllModules(); echo "\tcreating node-tree\n"; $strRootId = $this->createObject("class_module_pages_page", $strModuleId)->getSystemid(); echo "\tid of root-node: " . $strRootId . "\n"; echo "\tcreating child nodes...\n"; $strSecOne = $this->createObject("class_module_pages_page", $strRootId)->getSystemid(); $strSecTwo = $this->createObject("class_module_pages_page", $strRootId)->getSystemid(); $strThirdOne1 = $this->createObject("class_module_pages_page", $strSecOne)->getSystemid(); $strThirdOne2 = $this->createObject("class_module_pages_page", $strSecOne)->getSystemid(); $strThirdTwo1 = $this->createObject("class_module_pages_page", $strSecTwo)->getSystemid(); $strThirdTwo2 = $this->createObject("class_module_pages_page", $strSecTwo)->getSystemid(); $strThird111 = $this->createObject("class_module_pages_page", $strThirdOne1)->getSystemid(); $strThird112 = $this->createObject("class_module_pages_page", $strThirdOne1)->getSystemid(); $strThird121 = $this->createObject("class_module_pages_page", $strThirdOne2)->getSystemid(); $strThird122 = $this->createObject("class_module_pages_page", $strThirdOne2)->getSystemid(); $strThird211 = $this->createObject("class_module_pages_page", $strThirdTwo1)->getSystemid(); $strThird212 = $this->createObject("class_module_pages_page", $strThirdTwo1)->getSystemid(); $strThird221 = $this->createObject("class_module_pages_page", $strThirdTwo2)->getSystemid(); $strThird222 = $this->createObject("class_module_pages_page", $strThirdTwo2)->getSystemid(); $arrThirdLevelNodes = array($strThird111, $strThird112, $strThird121, $strThird122, $strThird211, $strThird212, $strThird221, $strThird222); echo "\tchecking leaf nodes for initial rights\n"; foreach ($arrThirdLevelNodes as $strOneRootNode) { $this->checkNodeRights($strOneRootNode, false, false); } echo "\tadding group with right view & edit\n"; $objRights->addGroupToRight($objGroup->getSystemid(), $strModuleId, "view"); $objRights->addGroupToRight($objGroup->getSystemid(), $strModuleId, "edit"); echo "\tchecking leaf nodes for inherited rights\n"; foreach ($arrThirdLevelNodes as $strOneRootNode) { $this->checkNodeRights($strOneRootNode, true, true); } echo "\tremoving right view from node secTwo\n"; $objRights->removeGroupFromRight($objGroup->getSystemid(), $strSecTwo, "view"); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, true, true); $this->checkNodeRights($strSecTwo, false, true); $this->checkNodeRights($strThirdOne1, true, true); $this->checkNodeRights($strThirdOne2, true, true); $this->checkNodeRights($strThirdTwo1, false, true); $this->checkNodeRights($strThirdTwo2, false, true); $this->checkNodeRights($strThird111, true, true); $this->checkNodeRights($strThird112, true, true); $this->checkNodeRights($strThird121, true, true); $this->checkNodeRights($strThird122, true, true); $this->checkNodeRights($strThird211, false, true); $this->checkNodeRights($strThird212, false, true); $this->checkNodeRights($strThird221, false, true); $this->checkNodeRights($strThird222, false, true); echo "\tmove SecOne as child to 221\n"; $objTempCommons = class_objectfactory::getInstance()->getObject($strSecOne); $objTempCommons->setStrPrevId($strThird221); $objTempCommons->updateObjectToDb(); //$objSystemCommon->setPrevId($strThird221, $strSecOne); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, false, true); $this->checkNodeRights($strSecTwo, false, true); $this->checkNodeRights($strThirdOne1, false, true); $this->checkNodeRights($strThirdOne2, false, true); $this->checkNodeRights($strThirdTwo1, false, true); $this->checkNodeRights($strThirdTwo2, false, true); $this->checkNodeRights($strThird111, false, true); $this->checkNodeRights($strThird112, false, true); $this->checkNodeRights($strThird121, false, true); $this->checkNodeRights($strThird122, false, true); $this->checkNodeRights($strThird211, false, true); $this->checkNodeRights($strThird212, false, true); $this->checkNodeRights($strThird221, false, true); $this->checkNodeRights($strThird222, false, true); echo "\tsetting rights of third21 to only view\n"; $objRights->removeGroupFromRight($objGroup->getSystemid(), $strThirdTwo1, "edit"); $objRights->addGroupToRight($objGroup->getSystemid(), $strThirdTwo1, "view"); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, false, true); $this->checkNodeRights($strSecTwo, false, true); $this->checkNodeRights($strThirdOne1, false, true); $this->checkNodeRights($strThirdOne2, false, true); $this->checkNodeRights($strThirdTwo1, true); $this->checkNodeRights($strThirdTwo2, false, true); $this->checkNodeRights($strThird111, false, true); $this->checkNodeRights($strThird112, false, true); $this->checkNodeRights($strThird121, false, true); $this->checkNodeRights($strThird122, false, true); $this->checkNodeRights($strThird211, true); $this->checkNodeRights($strThird212, true); $this->checkNodeRights($strThird221, false, true); $this->checkNodeRights($strThird222, false, true); echo "\tsetting 211 as parent node for third11\n"; $objTempCommons = class_objectfactory::getInstance()->getObject($strThirdOne1); $objTempCommons->setStrPrevId($strThird211); $objTempCommons->updateObjectToDb(); //$objSystemCommon->setPrevId($strThird211, $strThirdOne1); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, false, true); $this->checkNodeRights($strSecTwo, false, true); $this->checkNodeRights($strThirdOne1, true); $this->checkNodeRights($strThirdOne2, false, true); $this->checkNodeRights($strThirdTwo1, true); $this->checkNodeRights($strThirdTwo2, false, true); $this->checkNodeRights($strThird111, true); $this->checkNodeRights($strThird112, true); $this->checkNodeRights($strThird121, false, true); $this->checkNodeRights($strThird122, false, true); $this->checkNodeRights($strThird211, true); $this->checkNodeRights($strThird212, true); $this->checkNodeRights($strThird221, false, true); $this->checkNodeRights($strThird222, false, true); echo "\trebuilding initial tree structure\n"; $objTempCommons = class_objectfactory::getInstance()->getObject($strSecOne); $objTempCommons->setStrPrevId($strRootId); $objTempCommons->updateObjectToDb(); //$objSystemCommon->setPrevId($strRootId, $strSecOne); //SecOne still inheriting $objTempCommons = class_objectfactory::getInstance()->getObject($strThirdOne1); $objTempCommons->setStrPrevId($strSecOne); $objTempCommons->updateObjectToDb(); //$objSystemCommon->setPrevId($strSecOne, $strThirdOne1); $objRights->setInherited(true, $strThirdOne1); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, true, true); $this->checkNodeRights($strSecTwo, false, true); $this->checkNodeRights($strThirdOne1, true, true); $this->checkNodeRights($strThirdOne2, true, true); $this->checkNodeRights($strThirdTwo1, true); $this->checkNodeRights($strThirdTwo2, false, true); $this->checkNodeRights($strThird111, true, true); $this->checkNodeRights($strThird112, true, true); $this->checkNodeRights($strThird121, true, true); $this->checkNodeRights($strThird122, true, true); $this->checkNodeRights($strThird211, true); $this->checkNodeRights($strThird212, true); $this->checkNodeRights($strThird221, false, true); $this->checkNodeRights($strThird222, false, true); echo "\trebuilding initial inheritance structure\n"; $objRights->setInherited(true, $strSecTwo); $objRights->setInherited(true, $strThirdTwo1); echo "\tchecking node rights\n"; $this->checkNodeRights($strRootId, true, true); $this->checkNodeRights($strSecOne, true, true); $this->checkNodeRights($strSecTwo, true, true); $this->checkNodeRights($strThirdOne1, true, true); $this->checkNodeRights($strThirdOne2, true, true); $this->checkNodeRights($strThirdTwo1, true, true); $this->checkNodeRights($strThirdTwo2, true, true); $this->checkNodeRights($strThird111, true, true); $this->checkNodeRights($strThird112, true, true); $this->checkNodeRights($strThird121, true, true); $this->checkNodeRights($strThird122, true, true); $this->checkNodeRights($strThird211, true, true); $this->checkNodeRights($strThird212, true, true); $this->checkNodeRights($strThird221, true, true); $this->checkNodeRights($strThird222, true, true); echo "\tdeleting systemnodes\n"; class_objectfactory::getInstance()->getObject($strThird111)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird112)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird121)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird122)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird211)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird212)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird221)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThird222)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThirdOne1)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThirdOne2)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThirdTwo1)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strThirdTwo2)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strSecOne)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strSecTwo)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strRootId)->deleteObjectFromDatabase(); class_objectfactory::getInstance()->getObject($strModuleId)->deleteObjectFromDatabase(); echo "\tdeleting the test user\n"; $objUser->deleteObjectFromDatabase(); echo "\tdeleting the test group\n"; $objGroup->deleteObjectFromDatabase(); }
/** * Loads the data for one module * * @param int $intModuleID * @param bool $bitZeroIsSystem * * @return class_module_system_module */ private function getModuleDataID($intModuleID, $bitZeroIsSystem = false) { $arrModules = class_module_system_module::getAllModules(); if ($intModuleID != 0 || !$bitZeroIsSystem) { foreach ($arrModules as $objOneModule) { if ($objOneModule->getIntNr() == $intModuleID) { return $objOneModule; } } } elseif ($intModuleID == 0 && $bitZeroIsSystem) { foreach ($arrModules as $objOneModule) { if ($objOneModule->getStrName() == "system") { return $objOneModule; } } } return null; }
/** * @return string * @permissions view */ protected function actionRenderCalendar() { $strReturn = ""; $strContent = ""; $arrJsHighlights = array(); $strReturn .= "<content><![CDATA["; /** @var interface_calendarsource_admin[] $arrRelevantModules */ $arrRelevantModules = array(); //fetch modules relevant for processing $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) { $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule(); } } //the header row $arrWeekdays = explode(",", $this->getLang("calendar_weekday")); foreach ($arrWeekdays as $intKey => $strValue) { $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue)); } $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays); //render the single rows. calculate the first day of the row $objDate = new class_date(); $objDate->setIntDay(1); //set to interval stored in session if ($this->objSession->getSession($this->strStartMonthKey) != "") { $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey)); } if ($this->objSession->getSession($this->strStartYearKey) != "") { $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey)); } $intCurMonth = $objDate->getIntMonth(); $intCurYear = $objDate->getIntYear(); $objToday = new class_date(); //start by monday while ($objDate->getIntDayOfWeek() != 1) { $objDate->setPreviousDay(); } $strEntries = ""; $intRowEntryCount = 0; while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) { $intRowEntryCount++; $strDate = $objDate->getIntDay(); $arrEvents = array(); if ($objDate->getIntMonth() == $intCurMonth) { //Query modules for dates $objStartDate = clone $objDate; $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0); $objEndDate = clone $objDate; $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59); foreach ($arrRelevantModules as $objOneModule) { $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents); } } while (count($arrEvents) <= 3) { $objDummy = new class_calendarentry(); $objDummy->setStrClass("spacer"); $objDummy->setStrName(" "); $arrEvents[] = $objDummy; } $strEvents = ""; /** @var class_calendarentry $objOneEvent */ foreach ($arrEvents as $objOneEvent) { $strName = $objOneEvent->getStrName(); $strSecondLine = $objOneEvent->getStrSecondLine(); if ($strSecondLine != "") { $strSecondLine = "<br />" . $strSecondLine; } //register mouse-over highlight relations if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") { if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) { $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array(); } $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid(); } $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass()); } $bitBlocked = false; if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) { $bitBlocked = true; } $strToday = ""; if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) { $strToday = " calendarDateToday"; } if ($objDate->getIntMonth() != $intCurMonth) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday); } else { if ($bitBlocked) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday); } else { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday); } } if ($intRowEntryCount % 7 == 0) { $strContent .= $this->objToolkit->getCalendarRow($strEntries); $strEntries = ""; } $objDate->setNextDay(); } if ($strEntries != "") { $strContent .= $this->objToolkit->getCalendarRow($strEntries); } $strReturn .= $this->objToolkit->getCalendarWrapper($strContent); //build js-arrays $strJs = "<script type=\"text/javascript\">"; foreach ($arrJsHighlights as $strCommonId => $arrEntries) { $strJs .= " var kj_cal_" . $strCommonId . " = new Array();"; foreach ($arrEntries as $strOneIdentifier) { $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');"; } } $strJs .= "</script>"; $strReturn .= $strJs; $strReturn .= "]]></content>"; return $strReturn; }
/** * Creates a calendar-based view of the current month. * Single objects may register themselves to be rendered within the calendar. * The calendar-view consists of a view single elements: * +---------------------------+ * | control-elements (pager) | * +---------------------------+ * | wrapper | * +---------------------------+ * | the column headers | * +---------------------------+ * | a row for each week (4x) | * +---------------------------+ * | wrapper | * +---------------------------+ * | legend | * +---------------------------+ * * The calendar internally is loaded via ajax since fetching all events * may take some time. * * @return string * @since 3.4 * @autoTestable * @permissions view */ protected function actionCalendar() { $strReturn = ""; //save dates to session if ($this->getParam("month") != "") { $this->objSession->setSession($this->strStartMonthKey, $this->getParam("month")); } if ($this->getParam("year") != "") { $this->objSession->setSession($this->strStartYearKey, $this->getParam("year")); } $strContainerId = generateSystemid(); $strContent = "<script type=\"text/javascript\">"; $strContent .= <<<JS \$(document).ready(function() { KAJONA.admin.ajax.genericAjaxCall("dashboard", "renderCalendar", "{$strContainerId}", function(data, status, jqXHR) { if(status == 'success') { var intStart = data.indexOf("[CDATA[")+7; \$("#{$strContainerId}").html(data.substr( intStart, data.indexOf("]]")-intStart )); if(data.indexOf("[CDATA[") < 0) { var intStart = data.indexOf("<error>")+7; \$("#{$strContainerId}").html(o.responseText.substr( intStart, data.indexOf("</error>")-intStart )); } KAJONA.util.evalScript(data); KAJONA.admin.tooltip.initTooltip(); } else { KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b><br />" + data); } }) }); JS; $strContent .= "</script>"; //fetch modules relevant for processing $arrLegendEntries = array(); $arrFilterEntries = array(); $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { /** @var $objAdminInstance interface_calendarsource_admin|class_module_system_module */ $objAdminInstance = $objSingleModule->getAdminInstanceOfConcreteModule(); if ($objSingleModule->getIntRecordStatus() == 1 && $objAdminInstance instanceof interface_calendarsource_admin) { //TODO: switch to plugin manager $arrLegendEntries = array_merge($arrLegendEntries, $objAdminInstance->getArrLegendEntries()); $arrFilterEntries = array_merge($arrFilterEntries, $objAdminInstance->getArrFilterEntries()); } } if ($this->getParam("doCalendarFilter") != "") { //update filter-criteria foreach (array_keys($arrFilterEntries) as $strOneId) { if ($this->getParam($strOneId) != "") { $this->objSession->sessionUnset($strOneId); } else { $this->objSession->setSession($strOneId, "disabled"); } } } //render the single rows. calculate the first day of the row $objDate = new class_date(); $objDate->setIntDay(1); if ($this->objSession->getSession($this->strStartMonthKey) != "") { $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey)); } if ($this->objSession->getSession($this->strStartYearKey) != "") { $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey)); } //pager-setup $objEndDate = clone $objDate; $objEndDate->setNextMonth(); $objEndDate->setPreviousDay(); $strCenter = dateToString($objDate, false) . " - " . dateToString($objEndDate, false); $objEndDate->setNextDay(); $objPrevDate = clone $objDate; $objPrevDate->setPreviousDay(); $strPrev = class_link::getLinkAdmin($this->getArrModule("modul"), "calendar", "&month=" . $objPrevDate->getIntMonth() . "&year=" . $objPrevDate->getIntYear(), $this->getLang("calendar_prev")); $strNext = class_link::getLinkAdmin($this->getArrModule("modul"), "calendar", "&month=" . $objEndDate->getIntMonth() . "&year=" . $objEndDate->getIntYear(), $this->getLang("calendar_next")); $strReturn .= $this->objToolkit->getCalendarPager($strPrev, $strCenter, $strNext); $strReturn .= $strContent; $strReturn .= $this->objToolkit->getCalendarContainer($strContainerId); $strReturn .= $this->objToolkit->getCalendarLegend($arrLegendEntries); $strReturn .= $this->objToolkit->getCalendarFilter($arrFilterEntries); return $strReturn; }