/** * * @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; } }
/** * * @param type $query */ public function pre_get_posts($query) { $r_posts = array(); $r_cats = array(); $rests = mvb_Model_AccessControl::getUserConf()->getRestrictions(); $t_posts = array(); if (isset($rests['categories']) && is_array($rests['categories'])) { foreach ($rests['categories'] as $id => $data) { $exclude = FALSE; if (is_admin() && $data['restrict']) { $exclude = TRUE; } elseif (!is_admin() && $data['restrict_front']) { $exclude = TRUE; } if ($exclude) { if (isset($r_cats[$data['taxonomy']])) { $r_cats[$data['taxonomy']]['terms'][] = $id; } else { $r_cats[$data['taxonomy']] = array('taxonomy' => $data['taxonomy'], 'terms' => array($id), 'field' => 'term_id', 'operator' => 'NOT IN'); } } } } if (isset($rests['posts']) && is_array($rests['posts'])) { //get list of all posts foreach ($rests['posts'] as $id => $data) { if (is_admin() && $data['restrict']) { $t_posts[] = $id; } elseif (!is_admin() && $data['restrict_front']) { $t_posts[] = $id; } } $t_posts = is_array($t_posts) ? $t_posts : array(); $r_posts = array_merge($r_posts, $t_posts); } $query->query_vars['tax_query'] = $r_cats; $query->query_vars['post__not_in'] = $r_posts; }
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; }