コード例 #1
0
 /**
  *
  * @global type $wp_meta_boxes
  * @global type $post
  * @param type $area 
  */
 function manage($area = 'post')
 {
     global $wp_meta_boxes, $post;
     switch ($area) {
         case 'dashboard':
             if (is_array($wp_meta_boxes['dashboard'])) {
                 foreach ($wp_meta_boxes['dashboard'] as $position => $metaboxes) {
                     foreach ($metaboxes as $priority => $metaboxes1) {
                         foreach ($metaboxes1 as $metabox => $data) {
                             if (mvb_Model_AccessControl::getUserConf()->hasMetabox('dashboard-' . $metabox)) {
                                 unset($wp_meta_boxes['dashboard'][$position][$priority][$metabox]);
                             }
                         }
                     }
                 }
             }
             break;
         default:
             if ($wp_meta_boxes[$post->post_type]) {
                 foreach ($wp_meta_boxes[$post->post_type] as $position => $metaboxes) {
                     foreach ($metaboxes as $priority => $metaboxes1) {
                         foreach ($metaboxes1 as $metabox => $data) {
                             if (mvb_Model_AccessControl::getUserConf()->hasMetabox($post->post_type . '-' . $metabox)) {
                                 unset($wp_meta_boxes[$post->post_type][$position][$priority][$metabox]);
                             }
                         }
                     }
                 }
             }
             break;
     }
 }
コード例 #2
0
 /**
  *
  * @param type $menu
  * @param type $level
  * @return type 
  */
 private function filter_top_bar(&$menu, $level = 0)
 {
     if ($level > 999) {
         return;
         //save step
     }
     if (is_object($menu)) {
         foreach ($menu as $item => &$data) {
             if (isset($data['href']) && !isset($data['children']) && mvb_Model_AccessControl::getMenuConf()->checkAccess($data['href'])) {
                 unset($menu->{$item});
             } elseif (isset($data['children'])) {
                 $this->filter_top_bar($data['children'], $level + 1);
                 if (count($data['children'])) {
                     foreach ($data['children'] as $key => $value) {
                         $data['href'] = $value['href'];
                         break;
                     }
                 } else {
                     unset($menu[$item]);
                 }
             }
         }
     }
 }
コード例 #3
0
 function checkAccess($requestedMenu)
 {
     if (!mvb_Model_API::isSuperAdmin()) {
         //get base file
         $parts = $this->get_parts($requestedMenu);
         //aam_debug($this->cParams[$role]['menu']);
         foreach (mvb_Model_AccessControl::getUserConf()->getMenu() as $menu => $sub) {
             if ($this->compareMenus($parts, $menu) && isset($sub['whole'])) {
                 return FALSE;
             }
             if (isset($sub['sub']) && is_array($sub['sub'])) {
                 foreach ($sub['sub'] as $subMenu => $dummy) {
                     if ($this->compareMenus($parts, $subMenu)) {
                         return FALSE;
                     }
                 }
             }
         }
     }
     return TRUE;
 }