Ejemplo n.º 1
0
 public function indexAction()
 {
     $aMenus = Model_Menu::getMenus();
     $this->assign('aData', $aMenus);
     $this->_frame = 'frame.phtml';
     //return $this->redirect($sUrl);
 }
Ejemplo n.º 2
0
Archivo: Role.php Proyecto: pancke/yyaf
 /**
  * 增加角色
  * @return NULL|boolean
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $aRole = $this->_checkData();
         if (empty($aRole)) {
             return null;
         }
         if (Model_Role::addData($aRole) > 0) {
             return $this->showMsg('角色增加成功!', true);
         } else {
             return $this->showMsg('角色增加失败!', false);
         }
     } else {
         $this->assign('aPermissionList', Model_Permission::getAllPermissions());
         $this->assign('aMenuList', Model_Menu::getMenus());
     }
 }
Ejemplo n.º 3
0
 public function permissionAction()
 {
     $aMenuList = Model_Menu::getMenus();
     $aCtrClass = array();
     $aMenuAction = array();
     foreach ($aMenuList as $aMenu) {
         if ($aMenu['bIsLeaf']) {
             $aRoute = Yaf_G::getRoute($aMenu['sUrl']);
             $aMenuAction[$aRoute['module'] . '_' . $aRoute['controller'] . '_' . $aRoute['action']] = $aMenu['sMenuName'];
             $aCtrClass[$aRoute['module'] . '_' . $aRoute['controller']] = array('iMenuID' => $aMenu['iMenuID'], 'sMenuName' => $aMenu['sMenuName'], 'sUrl' => $aMenu['sUrl']);
         }
     }
     $aPermission = array();
     foreach ($aCtrClass as $sCtrClass => $aMenu) {
         try {
             $sCtrClass = 'Controller_' . $sCtrClass;
             if (class_exists($sCtrClass)) {
                 $oCtr = new ReflectionClass($sCtrClass);
                 $aMethod = $oCtr->getMethods();
                 foreach ($aMethod as $oMethod) {
                     $sAction = $oMethod->getName();
                     if (substr($sAction, -6) === 'Action') {
                         $sAction = substr($sAction, 0, -6);
                         $aRow = array($aMenu['iMenuID']);
                         $aRow[] = Yaf_G::routeToUrl($sCtrClass . '_' . $sAction);
                         $sDoc = $oMethod->getDocComment();
                         $matches = null;
                         if (preg_match('/\\s+\\*\\s+(.+)/i', $sDoc, $matches)) {
                             $aRow[] = $matches[1];
                         } elseif (isset($aMenuAction[$sCtrClass . '_' . $sAction])) {
                             $aRow[] = $aMenuAction[$sCtrClass . '_' . $sAction];
                         } else {
                             $aRow[] = $aMenu['sMenuName'] . '::' . $sAction;
                         }
                         $aPermission[] = $aRow;
                     }
                 }
             }
         } catch (Exception $e) {
             $aPermission[] = array($aMenu['iMenuID'], Yaf_G::getUrl($aMenu['sUrl']), $aMenu['sMenuName']);
         }
     }
     $this->showMsg($aPermission, true);
 }
Ejemplo n.º 4
0
 public function indexAction()
 {
     $mdlMenu = new Model_Menu();
     $this->view->menus = $mdlMenu->getMenus();
 }
Ejemplo n.º 5
0
 /**
  * 生成权限点
  */
 public function makeAction()
 {
     $aMenuList = Model_Menu::getMenus();
     $aCtrClass = array();
     $aMenuAction = array();
     foreach ($aMenuList as $aMenu) {
         if ($aMenu['bIsLeaf']) {
             $aRoute = Yaf_G::getRoute($aMenu['sUrl']);
             $aMenuAction[$aRoute['module'] . '_' . $aRoute['controller'] . '_' . $aRoute['action']] = $aMenu['sMenuName'];
             $aCtrClass[$aRoute['module'] . '_' . $aRoute['controller']] = array('iMenuID' => $aMenu['iMenuID'], 'sMenuName' => $aMenu['sMenuName'], 'sUrl' => $aMenu['sUrl']);
         }
     }
     $aPermission = array();
     foreach ($aCtrClass as $sCtrClass => $aMenu) {
         try {
             $sCtrClass = 'Controller_' . $sCtrClass;
             if (class_exists($sCtrClass)) {
                 $oCtr = new ReflectionClass($sCtrClass);
                 $aMethod = $oCtr->getMethods();
                 foreach ($aMethod as $oMethod) {
                     $sAction = $oMethod->getName();
                     if (substr($sAction, -6) === 'Action') {
                         $sAction = substr($sAction, 0, -6);
                         $aRow = array($aMenu['iMenuID']);
                         $aRow[] = Yaf_G::routeToUrl($sCtrClass . '_' . $sAction);
                         $sDoc = $oMethod->getDocComment();
                         $matches = null;
                         if (preg_match('/\\s+\\*\\s+(.+)/i', $sDoc, $matches)) {
                             $aRow[] = $matches[1];
                         } elseif (isset($aMenuAction[$sCtrClass . '_' . $sAction])) {
                             $aRow[] = $aMenuAction[$sCtrClass . '_' . $sAction];
                         } else {
                             $aRow[] = $aMenu['sMenuName'] . '::' . $sAction;
                         }
                         $aPermission[] = $aRow;
                     }
                 }
             }
         } catch (Exception $e) {
             $aPermission[] = array($aMenu['iMenuID'], Yaf_G::getUrl($aMenu['sUrl']), $aMenu['sMenuName']);
         }
     }
     $iCnt = 0;
     foreach ($aPermission as $v) {
         $aRow = Model_Permission::getRow(array('where' => array('sPath' => $v[1])));
         if (empty($aRow)) {
             $aRow = array('iMenuID' => $v[0], 'sPermissionName' => $v[2], 'sPath' => $v[1]);
             Model_Permission::addData($aRow);
             $iCnt++;
         } else {
             $aRow['iMenuID'] = $v[0];
             $aRow['sPermissionName'] = $v[2];
             Model_Permission::updData($aRow);
             $iCnt++;
         }
     }
     return $this->showMsg('本次生成权限点【' . $iCnt . '】个', true);
 }
Ejemplo n.º 6
0
Archivo: Menu.php Proyecto: pancke/yyaf
 /**
  * 增加菜单
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $aMenu = $this->_checkData();
         if (empty($aMenu)) {
             return null;
         }
         $aMenu['iOrder'] = Model_Menu::getNextOrder($aMenu['iParentID']);
         if (Model_Menu::addData($aMenu) > 0) {
             return $this->showMsg('菜单增加成功!', true);
         } else {
             return $this->showMsg('菜单增加失败!', false);
         }
     } else {
         $aTree = Model_Menu::getMenus();
         $this->assign('aTree', $aTree);
     }
 }