function em_admin_location($message = "") { global $EM_Location; if (empty($EM_Location) || !is_object($EM_Location)) { $title = __('Add location', 'dbem'); $EM_Location = new EM_Location(); } else { $title = __('Edit location', 'dbem'); } ?> <div class='wrap'> <div id='icon-edit' class='icon32'> <br/> </div> <h2><?php echo $title; ?> </h2> <?php em_location_form(); ?> </div> <?php }
/** * Outputs table of locations belonging to user * @param array $args */ function em_locations_admin($args = array()) { global $EM_Location; if (is_user_logged_in() && current_user_can('edit_locations')) { if (!empty($_GET['action']) && $_GET['action'] == 'edit') { if (empty($_REQUEST['redirect_to'])) { $_REQUEST['redirect_to'] = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => null, 'location_id' => null)); } em_location_form(); } else { if (get_option('dbem_css_editors')) { echo '<div class="css-locations-admin">'; } $limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20; //Default limit $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1; $offset = $page > 1 ? ($page - 1) * $limit : 0; $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC'; if (array_key_exists('status', $_REQUEST)) { $status = $_REQUEST['status'] ? 1 : 0; } else { $status = false; } $blog = false; if (EM_MS_GLOBAL && !get_site_option('dbem_ms_mainblog_locations') && !is_main_site()) { //set current blog id if not on main site and using global mode whilst not forcing all locations to be on main blog $blog = get_current_blog_id(); } $args = array('limit' => $limit, 'offset' => $offset, 'status' => $status, 'blog' => $blog); //count locations $locations_mine_count = EM_Locations::count(array('owner' => get_current_user_id(), 'blog' => $blog, 'status' => false)); $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count(array('blog' => $blog, 'status' => false, 'owner' => false)) : 0; //get set of locations if (!empty($_REQUEST['view']) && $_REQUEST['view'] == 'others' && current_user_can('read_others_locations')) { $locations = EM_Locations::get($args); $locations_count = $locations_all_count; } else { $locations = EM_Locations::get(array_merge($args, array('owner' => get_current_user_id()))); $locations_count = $locations_mine_count; } em_locate_template('tables/locations.php', true, array('args' => $args, 'locations' => $locations, 'locations_count' => $locations_count, 'locations_mine_count' => $locations_mine_count, 'locations_all_count' => $locations_all_count, 'page' => $page, 'limit' => $limit, 'offset' => $offset, 'show_add_new' => true)); if (get_option('dbem_css_editors')) { echo '</div>'; } } } else { if (get_option('dbem_css_editors')) { echo '<div class="css-locations-admin">'; } echo '<div class="css-locations-admin-login">' . __("You must log in to view and manage your locations.", 'dbem') . '</div>'; if (get_option('dbem_css_editors')) { echo '</div>'; } } }
/** * Outputs table of locations belonging to user * @param array $args */ function em_locations_admin($args = array()) { global $EM_Location; if (is_user_logged_in() && current_user_can('edit_locations')) { if (!empty($_GET['action']) && $_GET['action'] == 'edit') { if (empty($_REQUEST['redirect_to'])) { $_REQUEST['redirect_to'] = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => null, 'location_id' => null)); } em_location_form(); } else { $url = empty($url) ? $_SERVER['REQUEST_URI'] : $url; //url to this page $limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20; //Default limit $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1; $offset = $page > 1 ? ($page - 1) * $limit : 0; $args = array('limit' => $limit, 'offset' => $offset, 'status' => false, 'blog' => false); if (!empty($_REQUEST['view']) && $_REQUEST['view'] == 'others' && current_user_can('read_others_locations')) { $locations = EM_Locations::get($args); $locations_count = EM_Locations::count(array('status' => false, 'blog' => false, 'owner' => false)); } else { $locations = EM_Locations::get(array_merge($args, array('owner' => get_current_user_id()))); $locations_count = EM_Locations::count(array('status' => false, 'blog' => false, 'owner' => get_current_user_id())); } $locations_mine_count = EM_Locations::count(array('owner' => get_current_user_id(), 'blog' => false, 'status' => false)); $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count(array('blog' => false, 'status' => false)) : 0; em_locate_template('tables/locations.php', true, array('args' => $args, 'locations' => $locations, 'locations_count' => $locations_count, 'locations_mine_count' => $locations_mine_count, 'locations_all_count' => $locations_all_count, 'url' => $url, 'page' => $page, 'limit' => $limit, 'offset' => $offset, 'show_add_new' => true)); } } else { echo __("You must log in to view and manage your locations.", 'dbem'); } }