/**
  * Returns the default aspect, defined in the admin.
  * This takes permissions into account!
  *
  * @param bool $bitIgnorePermissions
  *
  * @return class_module_system_aspect null if no aspect is set up
  */
 public static function getDefaultAspect($bitIgnorePermissions = false)
 {
     $objORM = new class_orm_objectlist();
     $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND system_status = 1", array()));
     $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND aspect_default = 1", array()));
     /** @var class_module_system_aspect $objAspect */
     $objAspect = $objORM->getSingleObject(get_called_class());
     if ($objAspect != null && ($bitIgnorePermissions || $objAspect->rightView())) {
         return $objAspect;
     } else {
         $arrAspects = class_module_system_aspect::getActiveObjectList();
         if (count($arrAspects) > 0) {
             foreach ($arrAspects as $objOneAspect) {
                 if ($objOneAspect->rightView()) {
                     return $objOneAspect;
                 }
             }
         }
         return null;
     }
 }
Пример #2
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);
 }