/** * Get all Modules from the database, which are enabled * * @param bool $onlyEnabled (default to TRUE) * @return Webdesktop_Model_ModuleSet */ public function getAllModules($onlyEnabled = TRUE) { $modules = new Webdesktop_Model_ModuleSet(); $where = $onlyEnabled === TRUE ? 'm_enabled = 1' : NULL; foreach ($this->dbModules->fetchAll($where) as $module) { $name = $module->m_moduleId; $modules->add(new $module->m_classname()); } return $modules; }
/** * 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); } }
/** * Save the autorun modules that should startup * after the user logins or refreshes the page * * @return array */ public function changeQuickstartAction() { $launcher = new Webdesktop_Model_DbTable_Launchers(); $modulesMod = new Webdesktop_Model_DbTable_Modules(); $user = Zend_Auth::getInstance()->getIdentity(); $modules = Zend_Json::decode($this->request->getParam('modules', array())); $launcher->deleteByUserType($user->getId(), Webdesktop_Model_DbTable_Launchers::LAUNCHER_QUICKSTART); if (count($modules)) { // find the module id foreach ($modules as $module) { $module = $modulesMod->findModuleById($module); if ($module->count() == 0) { continue; } $launcher->insertLauncher($module->current()->m_id, $user->getId(), Webdesktop_Model_DbTable_Launchers::LAUNCHER_QUICKSTART); } } return $this->responseSuccess(); }