/** * Initiate an object and other parameters * * @param object Main Object * @param string $role Current role to work with * @param string $rser Current user to work with */ public function __construct($parent, $role = FALSE, $user = FALSE) { $templatePath = WPACCESS_TEMPLATE_DIR . 'admin_options.html'; $this->template = mvb_Model_Template::readTemplate($templatePath); $this->roles = mvb_Model_API::getRoleList(); $this->setCurrentRole($role); $this->setCurrentUser($user); $this->initConfig(); mvb_Model_Label::initAllLabels(); }
/* Copyright (C) <2011> Vasyl Martyniuk <*****@*****.**> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once '../../../../wp-admin/admin.php'; require_once 'Zend/Markup.php'; require_once 'bbcodes.php'; wp_enqueue_style('aam-treeview', WPACCESS_CSS_URL . 'treeview/jquery.treeview.css'); wp_enqueue_style('aam-reference', WPACCESS_CSS_URL . 'reference.css'); wp_enqueue_script('jquery-treeview', WPACCESS_JS_URL . 'treeview/jquery.treeview.js', array('jquery')); wp_enqueue_script('jquery-treeedit', WPACCESS_JS_URL . 'treeview/jquery.treeview.edit.js'); wp_enqueue_script('admin-reference', WPACCESS_JS_URL . 'admin-reference.js'); iframe_header('ConfigPress Reference'); $template = mvb_Model_Template::readTemplate(WPACCESS_TEMPLATE_DIR . 'reference.html'); mvb_Model_Label::initConfigPressGuideLabels(); $bbcode = Zend_Markup::factory('Bbcode'); foreach ($bbcode_list as $code => $config) { $bbcode->addMarkup($code, Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE, $config); } $template = mvb_Model_Label::clearLabels($template, $bbcode); echo mvb_Model_Template::clearTemplate($template); iframe_footer();
/** * Get Information about current post or page * * @global type $wp_post_statuses * @global type $wp_post_types * @return type */ protected function get_info() { global $wp_post_statuses, $wp_post_types; $id = intval($_POST['id']); $type = trim($_POST['type']); $role = $_POST['role']; $user = $_POST['user']; if ($user) { $config = mvb_Model_API::getUserAccessConfig($user); } else { $config = mvb_Model_API::getRoleAccessConfig($role); } //render html $tmpl = new mvb_Model_Template(); $templatePath = WPACCESS_TEMPLATE_DIR . 'admin_options.html'; $template = $tmpl->readTemplate($templatePath); $template = $tmpl->retrieveSub('POST_INFORMATION', $template); $result = array('status' => 'error'); switch ($type) { case 'post': //get information about page or post $post = get_post($id); if ($post->ID) { $template = $tmpl->retrieveSub('POST', $template); if ($config->hasRestriction('post', $id)) { $restiction = $config->getRestriction('post', $id); $checked = $restiction['restrict'] ? 'checked' : ''; $checked_front = $restiction['restrict_front'] ? 'checked' : ''; $exclude = $config->hasExclude($id) ? 'checked' : ''; $expire = $restiction['expire'] ? date('m/d/Y', $restiction['expire']) : ''; } $markerArray = array('###post_title###' => mvb_Model_Helper::editPostLink($post), '###disabled_apply_all###' => $user ? 'disabled="disabled"' : '', '###restrict_checked###' => isset($checked) ? $checked : '', '###restrict_front_checked###' => isset($checked_front) ? $checked_front : '', '###restrict_expire###' => isset($expire) ? $expire : '', '###exclude_page_checked###' => isset($exclude) ? $exclude : '', '###post_type###' => ucfirst($post->post_type), '###post_status###' => $wp_post_statuses[$post->post_status]->label, '###post_visibility###' => mvb_Model_Helper::checkVisibility($post), '###ID###' => $post->ID); //check what type of post is it and render exclude if page $render_exclude = FALSE; if (isset($wp_post_types[$post->post_type])) { switch ($wp_post_types[$post->post_type]->capability_type) { case 'page': $render_exclude = TRUE; break; default: break; } } if ($render_exclude) { $excld_tmlp = $tmpl->retrieveSub('EXCLUDE_PAGE', $template); } else { $excld_tmlp = ''; } $template = $tmpl->replaceSub('EXCLUDE_PAGE', $excld_tmlp, $template); $template = $tmpl->updateMarkers($markerArray, $template); $result = array('status' => 'success', 'html' => $tmpl->clearTemplate($template)); } break; case 'taxonomy': //get information about category $taxonomy = mvb_Model_Helper::getTaxonomyByTerm($id); $term = get_term($id, $taxonomy); if ($term->term_id) { $template = $tmpl->retrieveSub('CATEGORY', $template); if ($config->hasRestriction('taxonomy', $id)) { $tax = $config->getRestriction('taxonomy', $id); $checked = $tax['restrict'] ? 'checked' : ''; $checked_front = $tax['restrict_front'] ? 'checked' : ''; $expire = $tax['expire'] ? date('m/d/Y', $tax['expire']) : ''; } $markerArray = array('###name###' => mvb_Model_Helper::editTermLink($term), '###disabled_apply_all###' => $user ? 'disabled="disabled"' : '', '###restrict_checked###' => isset($checked) ? $checked : '', '###restrict_front_checked###' => isset($checked_front) ? $checked_front : '', '###restrict_expire###' => isset($expire) ? $expire : '', '###post_number###' => $term->count, '###ID###' => $term->term_id); $template = $tmpl->updateMarkers($markerArray, $template); $result = array('status' => 'success', 'html' => $tmpl->clearTemplate($template)); } break; default: break; } return $result; }