예제 #1
0
 /**
  * This function will give controllers related to particular role id.
  * @parameters
  * @param $role_id    =  id of role.
  * @returns  Array of controllers.
  */
 public function getControllersByRole($role_id)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $query = "select m.menuName menuName,substring(m.url,2) url,SUBSTR(m.url,LOCATE('/',m.url)+1,(CHAR_LENGTH(m.url) - LOCATE('/',REVERSE(m.url)) - LOCATE('/',m.url))) nurl,p.addpermission,p.editpermission,p.deletepermission,p.viewpermission,\n                  p.uploadattachments,p.viewattachments from main_menu m inner join main_privileges p on p.object = m.id  \n                  where m.url != '/#' and m.isactive = 1 and p.isactive = 1 and p.role = " . $role_id;
     $result = $db->query($query);
     $url_arr = array();
     while ($row = $result->fetch()) {
         $url = $row['nurl'] == '' ? $row['url'] : $row['nurl'];
         $url_arr[$url . "controller.php"]['url'] = $url;
         if ($url != 'servicerequests') {
             $url_arr[$url . "controller.php"]['actions'] = $this->getControllersByRole_helper($row);
         } else {
             $service_actions = sapp_Global::generateAccessControl_helper(array('servicerequestscontroller.php' => array('url' => 'servicerequests')), 'random');
             $url_arr[$url . "controller.php"]['actions'] = $service_actions['servicerequestscontroller.php'];
         }
     }
     $index_arr = array();
     $index_arr['indexcontroller.php']['url'] = "index";
     $index_actions = sapp_Global::generateAccessControl_helper(array('indexcontroller.php' => array('url' => 'index')), 'random');
     $index_arr['indexcontroller.php']['actions'] = $index_actions['indexcontroller.php'];
     $index_arr['dashboardcontroller.php']['url'] = "dashboard";
     $dash_actions = sapp_Global::generateAccessControl_helper(array('dashboardcontroller.php' => array('url' => 'dashboard')), 'random');
     $index_arr['dashboardcontroller.php']['actions'] = $dash_actions['dashboardcontroller.php'];
     if ($role_id == SUPERADMINROLE) {
         $index_arr['managemenuscontroller.php']['url'] = "managemenus";
         $index_actions = sapp_Global::generateAccessControl_helper(array('managemenuscontroller.php' => array('url' => 'managemenus')), 'random');
         $index_arr['managemenuscontroller.php']['actions'] = $index_actions['managemenuscontroller.php'];
     }
     return $url_arr + $index_arr;
 }