Пример #1
0
 /**
  * Fetches the list of actions for a single module, saved to the session for performance reasons
  *
  * @param class_module_system_module $objModule
  * @static
  *
  * @return array
  */
 public static function getModuleActionNaviHelper(class_module_system_module $objModule)
 {
     if (class_carrier::getInstance()->getObjSession()->isLoggedin()) {
         $strKey = __CLASS__ . "adminNaviEntries" . $objModule->getSystemid() . class_module_system_aspect::getCurrentAspectId();
         $arrFinalItems = class_carrier::getInstance()->getObjSession()->getSession($strKey);
         if ($arrFinalItems !== false) {
             return $arrFinalItems;
         }
         $objAdminInstance = $objModule->getAdminInstanceOfConcreteModule();
         $arrItems = $objAdminInstance->getOutputModuleNavi();
         $arrItems = array_merge($arrItems, $objAdminInstance->getModuleRightNaviEntry());
         $arrFinalItems = array();
         //build array of final items
         $intI = 0;
         foreach ($arrItems as $arrOneItem) {
             if ($arrOneItem[0] == "") {
                 $bitAdd = true;
             } else {
                 $bitAdd = class_carrier::getInstance()->getObjRights()->validatePermissionString($arrOneItem[0], $objModule);
             }
             if ($bitAdd || $arrOneItem[1] == "") {
                 if ($arrOneItem[1] != "" || (!isset($arrFinalItems[$intI - 1]) || $arrFinalItems[$intI - 1] != "")) {
                     $arrFinalItems[] = $arrOneItem[1];
                     $intI++;
                 }
             }
         }
         //if the last one is a divider, remove it
         if ($arrFinalItems[count($arrFinalItems) - 1] == "") {
             unset($arrFinalItems[count($arrFinalItems) - 1]);
         }
         class_carrier::getInstance()->getObjSession()->setSession($strKey, $arrFinalItems);
         return $arrFinalItems;
     }
     return array();
 }
Пример #2
0
 /**
  * Validates if the requested module is valid for the current aspect.
  * If necessary, the current aspect is updated.
  *
  * @return void
  */
 private function validateAndUpdateCurrentAspect()
 {
     if (_xmlLoader_ === true || $this->getArrModule("template") == "/folderview.tpl") {
         return;
     }
     $objModule = $this->getObjModule();
     $strCurrentAspect = class_module_system_aspect::getCurrentAspectId();
     if ($objModule != null && $objModule->getStrAspect() != "") {
         $arrAspects = explode(",", $objModule->getStrAspect());
         if (count($arrAspects) == 1 && $arrAspects[0] != $strCurrentAspect) {
             $objAspect = new class_module_system_aspect($arrAspects[0]);
             if ($objAspect->rightView()) {
                 class_module_system_aspect::setCurrentAspectId($arrAspects[0]);
             }
         }
     }
 }
Пример #3
0
 /**
  * Renders the list of aspects available
  *
  * @param string $strLastModule
  * @param string $strLastAction
  * @param string $strLastSystemid
  *
  * @return string
  * @todo param handling? remove params?
  */
 public function getAspectChooser($strLastModule, $strLastAction, $strLastSystemid)
 {
     $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "aspect_chooser");
     $strTemplateRowID = $this->objTemplate->readTemplate("/elements.tpl", "aspect_chooser_entry");
     $arrTemplate = array();
     $arrTemplate["options"] = "";
     //process rows
     $strCurrentId = class_module_system_aspect::getCurrentAspectId();
     $arrAspects = class_module_system_aspect::getActiveObjectList();
     $intNrOfAspects = 0;
     foreach ($arrAspects as $objSingleAspect) {
         if ($objSingleAspect->rightView()) {
             $arrSubtemplate = array();
             //start on dashboard since the current module may not be visible in another aspect
             $arrSubtemplate["value"] = getLinkAdminHref("dashboard", "", "&aspect=" . $objSingleAspect->getSystemid());
             $arrSubtemplate["name"] = $objSingleAspect->getStrDisplayName();
             $arrSubtemplate["selected"] = $strCurrentId == $objSingleAspect->getSystemid() ? "selected=\"selected\"" : "";
             $arrTemplate["options"] .= $this->objTemplate->fillTemplate($arrSubtemplate, $strTemplateRowID);
             $intNrOfAspects++;
         }
     }
     if ($arrTemplate["options"] == "" || $intNrOfAspects < 2) {
         return "";
     }
     return $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID);
 }
 /**
  * Searches the root-node for a users' widgets.
  * If not given, the node is created on the fly.
  * Those nodes are required to ensure a proper sort-handling on the system-table
  *
  * @param string $strUserid
  * @param string $strAspectId
  * @return string
  * @static
  */
 public static function getWidgetsRootNodeForUser($strUserid, $strAspectId = "")
 {
     if ($strAspectId == "") {
         $strAspectId = class_module_system_aspect::getCurrentAspectId();
     }
     $strQuery = "SELECT system_id\n        \t\t\t  FROM " . _dbprefix_ . "dashboard,\n        \t\t\t  \t   " . _dbprefix_ . "system\n        \t\t\t WHERE dashboard_id = system_id\n        \t\t\t   AND system_prev_id = ?\n        \t\t\t   AND dashboard_user = ?\n        \t\t\t   AND dashboard_aspect = ?\n        \t\t\t   AND dashboard_class = ?\n        \t     ORDER BY system_sort ASC ";
     $arrRow = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array(class_module_system_module::getModuleByName("dashboard")->getSystemid(), $strUserid, $strAspectId, "root_node"));
     if (!isset($arrRow["system_id"]) || !validateSystemid($arrRow["system_id"])) {
         //Create a new root-node on the fly
         $objWidget = new class_module_dashboard_widget();
         $objWidget->setStrAspect($strAspectId);
         $objWidget->setStrUser($strUserid);
         $objWidget->setStrClass("root_node");
         $objWidget->updateObjectToDb(class_module_system_module::getModuleByName("dashboard")->getSystemid());
         $strReturnId = $objWidget->getSystemid();
     } else {
         $strReturnId = $arrRow["system_id"];
     }
     return $strReturnId;
 }
 /**
  * Generates the forms to add a widget to the dashboard
  *
  * @return string, "" in case of success
  * @autoTestable
  * @permissions edit
  */
 protected function actionAddWidgetToDashboard()
 {
     $strReturn = "";
     //step 1: select a widget, plz
     if ($this->getParam("step") == "") {
         $arrWidgetsAvailable = class_module_dashboard_widget::getListOfWidgetsAvailable();
         $arrDD = array();
         foreach ($arrWidgetsAvailable as $strOneWidget) {
             /** @var $objWidget interface_adminwidget|class_adminwidget */
             $objWidget = new $strOneWidget();
             $arrDD[$strOneWidget] = $objWidget->getWidgetName();
         }
         $arrColumnsAvailable = array();
         foreach ($this->arrColumnsOnDashboard as $strOneColumn) {
             $arrColumnsAvailable[$strOneColumn] = $this->getLang($strOneColumn);
         }
         $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref("dashboard", "addWidgetToDashboard"));
         $strReturn .= $this->objToolkit->formInputDropdown("widget", $arrDD, $this->getLang("widget"));
         $strReturn .= $this->objToolkit->formInputDropdown("column", $arrColumnsAvailable, $this->getLang("column"));
         $strReturn .= $this->objToolkit->formInputHidden("step", "2");
         $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("addWidgetNextStep"));
         $strReturn .= $this->objToolkit->formClose();
         $strReturn .= $this->objToolkit->setBrowserFocus("widget");
     } else {
         if ($this->getParam("step") == "2") {
             $strWidgetClass = $this->getParam("widget");
             /** @var class_adminwidget|interface_adminwidget $objWidget */
             $objWidget = new $strWidgetClass();
             if ($objWidget->getEditForm() == "") {
                 $this->adminReload(class_link::getLinkAdminHref("dashboard", "addWidgetToDashboard", "&step=3&widget=" . $strWidgetClass . "&column=" . $this->getParam("column")));
             } else {
                 //ask the widget to generate its form-parts and wrap our elements around
                 $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref("dashboard", "addWidgetToDashboard"));
                 $strReturn .= $objWidget->getEditForm();
                 $strReturn .= $this->objToolkit->formInputHidden("step", "3");
                 $strReturn .= $this->objToolkit->formInputHidden("widget", $strWidgetClass);
                 $strReturn .= $this->objToolkit->formInputHidden("column", $this->getParam("column"));
                 $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
                 $strReturn .= $this->objToolkit->formClose();
             }
         } else {
             if ($this->getParam("step") == "3") {
                 //instantiate the concrete widget
                 $strWidgetClass = $this->getParam("widget");
                 /** @var class_adminwidget|interface_adminwidget $objWidget */
                 $objWidget = new $strWidgetClass();
                 //let it process its fields
                 $objWidget->loadFieldsFromArray($this->getAllParams());
                 //and save the dashboard-entry
                 $objDashboard = new class_module_dashboard_widget();
                 $objDashboard->setStrClass($strWidgetClass);
                 $objDashboard->setStrContent($objWidget->getFieldsAsString());
                 $objDashboard->setStrColumn($this->getParam("column"));
                 $objDashboard->setStrUser($this->objSession->getUserID());
                 $objDashboard->setStrAspect(class_module_system_aspect::getCurrentAspectId());
                 if ($objDashboard->updateObjectToDb(class_module_dashboard_widget::getWidgetsRootNodeForUser($this->objSession->getUserID(), class_module_system_aspect::getCurrentAspectId()))) {
                     $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul")));
                 } else {
                     return $this->getLang("errorSavingWidget");
                 }
             }
         }
     }
     return $strReturn;
 }