Example #1
0
 /**
  * Get all the launchers for the user that is registered in the ACL
  *
  * The launchers will be stored in the returning array with fixed configured
  * indexes. Can move the indexes to constants (constants through the whole
  * application). But this class seems to much overhead and should be merged
  * with the webdesktop model.
  *
  * @return array
  */
 public function getUserLaunchers()
 {
     $return = array('autorun' => array(), 'contextmenu' => array(), 'quickstart' => array(), 'shortcut' => array());
     foreach ($this->dbLaunchers->findByUserId($this->acl->getUser()->getId()) as $row) {
         switch ($row['l_type']) {
             case Webdesktop_Model_DbTable_Launchers::LAUNCHER_AUTORUN:
                 $return['autorun'][] = $row['m_moduleId'];
                 break;
             case Webdesktop_Model_DbTable_Launchers::LAUNCHER_CONTEXT:
                 $return['contextmenu'][] = $row['m_moduleId'];
                 break;
             case Webdesktop_Model_DbTable_Launchers::LAUNCHER_QUICKSTART:
                 $return['quickstart'][] = $row['m_moduleId'];
                 break;
             case Webdesktop_Model_DbTable_Launchers::LAUNCHER_SHORTCUT:
                 $return['shortcut'][] = $row['m_moduleId'];
                 break;
         }
     }
     return $return;
 }
 /**
  * Main request method
  *
  * Every call to a module/action should be routed through  this method, as
  * it is responsible for loading and ACL validating the call.
  *
  * It dynamicly load the right module class on the backend and passes the
  * request.
  *
  * @return array
  * @todo refactor: I think it can be removed -> self::detectCallParameters()
  * @todo refactor: remove the pass in of the config object
  * @todo refactor: use method chaining on $obj
  * @todo introduce Admin_Model_DbRow_Module to remove Db Column names
  */
 public function requestAction()
 {
     if ($this->detectCallParameters(TRUE, TRUE) === FALSE) {
         return $this->defaultResponses('Invalid call, need Module and Action defined', self::REQUEST_ERROR_PRECONDITION);
     }
     $dbModules = new Webdesktop_Model_DbTable_Modules();
     $module = $dbModules->findModuleById($this->module);
     if ($module->count() === 1) {
         try {
             $class = $module->current()->m_classname;
             $obj = new $class();
             if ($obj->has($this->action) === FALSE) {
                 throw new Exception('Action is not defined');
             }
             if ($this->acl->isAllowed($module->current()->m_moduleId, $this->action) === FALSE) {
                 return $this->defaultResponses('No userrights to perform this action', self::REQUEST_ERROR_BADREQUEST);
             }
         } catch (Exception $e) {
             return $this->defaultResponses($e->getMessage(), self::REQUEST_ERROR_PRECONDITION);
         }
         $obj->setWebDesktopConfig($this->config);
         $obj->setRequest($this->getRequest());
         $obj->setResponse($this->getResponse());
         $obj->init();
         try {
             $return = $obj->{$this->action . 'Action'}();
         } catch (Webdesktop_Model_Exception $e) {
             return $this->defaultResponses($e->getMessage(), self::REQUEST_ERROR_PRECONDITION);
         }
         $this->_helper->json->sendJson($return);
     } else {
         return $this->defaultResponses('Cannot request Module, module not found', self::REQUEST_ERROR_PRECONDITION);
     }
 }