本文整理汇总了PHP中FlexicontentHelperPerm::getAllowedCats方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentHelperPerm::getAllowedCats方法的具体用法?PHP FlexicontentHelperPerm::getAllowedCats怎么用?PHP FlexicontentHelperPerm::getAllowedCats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentHelperPerm
的用法示例。
在下文中一共展示了FlexicontentHelperPerm::getAllowedCats方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
//initialise variables
global $globalcats;
$app = JFactory::getApplication();
$option = JRequest::getVar('option');
$view = JRequest::getVar('view');
$user = JFactory::getUser();
$db = JFactory::getDBO();
$document = JFactory::getDocument();
$cparams = JComponentHelper::getParams('com_flexicontent');
$print_logging_info = $cparams->get('print_logging_info');
if ($print_logging_info) {
global $fc_run_times;
}
JHTML::_('behavior.tooltip');
//get vars
$order_property = !FLEXI_J16GE ? 'c.ordering' : 'c.lft';
$filter_order = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order', 'filter_order', $order_property, 'cmd');
$filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_state = $app->getUserStateFromRequest($option . '.' . $view . '.filter_state', 'filter_state', '', 'string');
$filter_cats = $app->getUserStateFromRequest($option . '.' . $view . '.filter_cats', 'filter_cats', '', 'int');
$filter_level = $app->getUserStateFromRequest($option . '.' . $view . '.filter_level', 'filter_level', '', 'string');
$filter_access = $app->getUserStateFromRequest($option . '.' . $view . '.filter_access', 'filter_access', '', 'string');
if (FLEXI_J16GE) {
$filter_language = $app->getUserStateFromRequest($option . '.' . $view . '.filter_language', 'filter_language', '', 'string');
}
$search = $app->getUserStateFromRequest($option . '.' . $view . '.search', 'search', '', 'string');
$search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
// Prepare the document: add css files, etc
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
if (FLEXI_J30GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
} else {
if (FLEXI_J16GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
} else {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
}
}
// Get User's Global Permissions
$perms = FlexicontentHelperPerm::getPerm();
// Create Submenu (and also check access to current view)
FLEXISubmenu('CanCats');
// Create document/toolbar titles
$doc_title = JText::_('FLEXI_CATEGORIES');
$site_title = $document->getTitle();
JToolBarHelper::title($doc_title, 'fc_categories');
$document->setTitle($doc_title . ' - ' . $site_title);
// ******************
// Create the toolbar
// ******************
$js = "window.addEvent('domready', function(){";
$contrl = FLEXI_J16GE ? "categories." : "";
$contrl_singular = FLEXI_J16GE ? "category." : "";
$toolbar = JToolBar::getInstance('toolbar');
// Copy Parameters
$btn_task = '';
$popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component';
if (FLEXI_J30GE || !FLEXI_J16GE) {
// Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually
$js .= "\n\t\t\t\tjQuery('#toolbar-params a.toolbar, #toolbar-params button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 600, y: 440}, onClose: function() {}}');\n\t\t\t";
JToolBarHelper::custom($btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false);
JHtml::_('behavior.modal', '#toolbar-params a.toolbar, #toolbar-params button');
} else {
$toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), str_replace('&', '&', $popup_load_url), 600, 440);
}
//if (FLEXI_J16GE)
// $toolbar->appendButton('Popup', 'move', JText::_('FLEXI_COPY_MOVE'), JURI::base().'index.php?option=com_flexicontent&view=categories&layout=batch&tmpl=component', 800, 440);
JToolBarHelper::divider();
$add_divider = false;
if (!FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent')) {
$cancreate_cat = true;
} else {
$usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
$cancreate_cat = count($usercats) > 0;
}
if ($cancreate_cat) {
JToolBarHelper::addNew($contrl_singular . 'add');
$add_divider = true;
}
if (!FLEXI_J16GE || ($user->authorise('core.edit', 'com_flexicontent') || $user->authorise('core.edit.own', 'com_flexicontent'))) {
JToolBarHelper::editList($contrl_singular . 'edit');
$add_divider = true;
}
if (FLEXI_J16GE && $user->authorise('core.admin', 'checkin')) {
JToolBarHelper::checkin($contrl . 'checkin');
$add_divider = true;
}
if ($add_divider) {
JToolBarHelper::divider();
}
$add_divider = false;
if (!FLEXI_J16GE || ($user->authorise('core.edit.state', 'com_flexicontent') || $user->authorise('core.edit.state.own', 'com_flexicontent'))) {
JToolBarHelper::publishList($contrl . 'publish');
JToolBarHelper::unpublishList($contrl . 'unpublish');
JToolBarHelper::divider();
if (FLEXI_J16GE) {
JToolBarHelper::archiveList($contrl . 'archive');
}
//.........这里部分代码省略.........
示例2: buildcatselect
/**
* Build a html select form field that displays a Category Tree
*
* The output is filtered (via FLEXIaccess or via J1.6+ permission) and has disabled specific categories
* About Disabled categories:
* - currently edited category is disabled
* - if the user can view all categories then categories he has no permission are disabled !!!
*
* @param array $list
* @param string $name
* @param array $selected
* @param bool $top
* @param string $check_published
* @param string $check_perms
* @param string $require_all
* @param array $skip_subtrees
* @param array $disable_subtrees
* @param array $custom_options
*
* @return a category form field element
*/
public static function buildcatselect($list, $name, $selected, $top, $attribs = 'class="inputbox"', $check_published = false, $check_perms = true, $actions_allowed = array('core.create', 'core.edit', 'core.edit.own'), $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disable_specific_cats = array(), $empty_errmsg = false)
{
// ***************************
// Initialize needed variables
// ***************************
global $globalcats;
$cparams = JComponentHelper::getParams('com_flexicontent');
$user = JFactory::getUser();
$controller = JRequest::getVar('controller');
$task = JRequest::getVar('task');
$print_logging_info = $cparams->get('print_logging_info');
if ($print_logging_info) {
global $fc_run_times;
$start_microtime = microtime(true);
}
// Privilege of (a) viewing all categories (even if disabled) and (b) viewing as a tree
require_once JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
$viewallcats = FlexicontentHelperPerm::getPerm()->ViewAllCats;
$viewtree = FlexicontentHelperPerm::getPerm()->ViewTree;
// Global parameter to force always displaying of categories as tree
if ($cparams->get('cats_always_astree', 1)) {
$viewtree = 1;
}
// **************************************************************
// Find user allowed categories to be used during Filtering below
// **************************************************************
if ($check_perms) {
// Get user allowed categories, NOTE: if user (a) (J2.5) has 'core.admin' or (b) (J1.5) user is super admin (gid==25) then all cats are allowed
$usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed, $require_all, $check_published);
// NOTE: already selected categories will be allowed to the user, add them to the category list
$selectedcats = !is_array($selected) ? array($selected) : $selected;
$usercats_indexed = array_flip($usercats);
foreach ($selectedcats as $selectedcat) {
if ($selectedcat) {
$usercats_indexed[$selectedcat] = 1;
}
}
}
// *********************************************************************************
// Excluded subtrees e.g. featured categories subtree in item form
// Disabled subtrees e.g. existing children subtree when selecting category's parent
// *********************************************************************************
$skip_cats_arr = array();
if (!empty($skip_subtrees)) {
foreach ($skip_subtrees as $subtree_rootid) {
if ($subtree_rootid && isset($globalcats[$subtree_rootid]->descendantsarray)) {
foreach ($globalcats[$subtree_rootid]->descendantsarray as $_excluded) {
$skip_cats_arr[$_excluded] = 1;
}
}
}
}
$disable_cats_arr = array();
if (!empty($disable_subtrees)) {
foreach ($disable_subtrees as $subtree_rootid) {
if ($subtree_rootid && isset($globalcats[$subtree_rootid]->descendantsarray)) {
foreach ($globalcats[$subtree_rootid]->descendantsarray as $_excluded) {
$disable_cats_arr[$_excluded] = 1;
}
}
}
}
// Disable specific categories
if (!empty($disable_specific_cats)) {
foreach ($disable_specific_cats as $_excluded) {
$disable_cats_arr[$_excluded] = 1;
}
}
// **************************************************************************
// TOP parameter: defines the APPROPRIATE PROMPT option at top of select list
// **************************************************************************
$cats_count = 0;
$catlist = array();
// A tree to select: e.g. a parent category
if (!is_numeric($top) && strlen($top)) {
$catlist[] = JHTML::_('select.option', '', $top);
} else {
if ($top == 1) {
$catlist[] = JHTML::_('select.option', FLEXI_J16GE ? 1 : 0, JText::_('FLEXI_TOPLEVEL'));
//.........这里部分代码省略.........
示例3: allowAdd
/**
* Method to check if you can add a new record.
*
* Extended classes can override this if necessary.
*
* @param array An array of input data.
*
* @return boolean
* @since 1.6
*/
protected function allowAdd($data = array())
{
$user = JFactory::getUser();
if (!FLEXI_J16GE || $user->authorise('core.create', $this->extension)) {
$cancreate_cat = true;
} else {
$usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
$cancreate_cat = count($usercats) > 0;
}
return $cancreate_cat;
}
示例4: getUserPerms
static function getUserPerms($user_id = null)
{
// handle jcomments integration
if (JPluginHelper::isEnabled('system', 'jcomments')) {
$JComments_Installed = 1;
$destpath = JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'plugins';
$dest = $destpath . DS . 'com_flexicontent.plugin.php';
$source = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'jcomments' . DS . 'com_flexicontent.plugin.php';
jimport('joomla.filesystem.file');
if (!JFile::exists($dest)) {
if (!JFolder::exists($destpath)) {
if (!JFolder::create($destpath)) {
JError::raiseWarning(100, JText::_('FLEXIcontent: Unable to create jComments plugin folder'));
}
}
if (!JFile::copy($source, $dest)) {
JError::raiseWarning(100, JText::_('FLEXIcontent: Unable to copy jComments plugin'));
} else {
$mainframe->enqueueMessage(JText::_('Copied FLEXIcontent jComments plugin'));
}
}
} else {
$JComments_Installed = 0;
}
// Find permissions for given user id
$user = $user_id ? JFactory::getUser($user_id) : JFactory::getUser();
// no user id given, use current user)
$permission = new stdClass();
// !!! This is the Super User Privelege of GLOBAL Configuration (==> (for J2.5) core.admin ACTION allowed on ROOT ASSET: 'root.1')
$permission->SuperAdmin = JAccess::check($user->id, 'core.admin', 'root.1');
//!!! ALLOWs USERS to change component's CONFIGURATION (==> (for J2.5) core.admin ACTION allowed on COMPONENT ASSET: e.g. 'com_flexicontent')
$permission->CanConfig = $user->authorise('core.admin', 'com_flexicontent');
//!!! ALLOWs USERS in JOOMLA BACKEND : (not used in J1.5)
// (a) to view the FLEXIcontent menu item in Components Menu and
// (b) to access the FLEXIcontent component screens (whatever they are allowed to see by individual FLEXIcontent area permissions)
// NOTE: the initially installed permissions allows all areas to be managed for J2.5 and none (except for items) for J1.5
$permission->CanManage = $user->authorise('core.manage', 'com_flexicontent');
// ITEMS/CATEGORIES: category-inherited permissions, (NOTE: these are the global settings, so:)
// *** 1. the action permissions of individual items are checked seperately per item
// *** 2. the view permission is checked via the access level of each item
// --- *. We will check for SOFT DENY, and then try to find the FIRST ALLOWED CATEGORY FOR EACH ACTION
$permission->CanAdd = $user->authorise('core.create', 'com_flexicontent');
if ($permission->CanAdd === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanAdd = count($allowedcats) > 0;
}
$permission->CanEdit = $user->authorise('core.edit', 'com_flexicontent');
if ($permission->CanEdit === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanEdit = count($allowedcats) > 0;
}
$permission->CanEditOwn = $user->authorise('core.edit.own', 'com_flexicontent');
if ($permission->CanEditOwn === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit.own'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanEditOwn = count($allowedcats) > 0;
}
$permission->CanPublish = $user->authorise('core.edit.state', 'com_flexicontent');
if ($permission->CanPublish === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit.state'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanPublish = count($allowedcats) > 0;
}
$permission->CanPublishOwn = $user->authorise('core.edit.state.own', 'com_flexicontent');
if ($permission->CanPublishOwn === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit.state.own'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanPublishOwn = count($allowedcats) > 0;
}
$permission->CanDelete = $user->authorise('core.delete', 'com_flexicontent');
if ($permission->CanDelete === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.delete'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanDelete = count($allowedcats) > 0;
}
$permission->CanDeleteOwn = $user->authorise('core.delete.own', 'com_flexicontent');
if ($permission->CanDeleteOwn === NULL) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.delete.own'), $require_all = true, $check_published = true, false, $find_first = true);
$permission->CanDeleteOwn = count($allowedcats) > 0;
}
$permission->CanChangeCat = $user->authorise('flexicontent.change.cat', 'com_flexicontent');
$permission->CanChangeSecCat = $user->authorise('flexicontent.change.cat.sec', 'com_flexicontent');
$permission->CanChangeFeatCat = $user->authorise('flexicontent.change.cat.feat', 'com_flexicontent');
// Permission for changing the ACL rules of items and categories that user can edit
// Currently given to user that can edit component configuration
$permission->CanRights = $permission->CanConfig;
// Permission for changing the access level of items and categories that user can edit
// (a) In J1.5 with FLEXIaccess, this is given to those that can edit the FLEXIaccess configuration
// (b) In J1.5 without FLEXIaccess, this is given to users being at least an Editor
// (c) In J2.5, this is the FLEXIcontent component ACTION 'accesslevel'
$permission->CanAccLvl = $user->authorise('flexicontent.accesslevel', 'com_flexicontent');
// ITEMS: component controlled permissions
$permission->DisplayAllItems = $user->authorise('flexicontent.displayallitems', 'com_flexicontent');
// (backend) List all items (otherwise only items that can be edited)
$permission->CanCopy = $user->authorise('flexicontent.copyitems', 'com_flexicontent');
// (backend) Item Copy Task
$permission->CanOrder = $user->authorise('flexicontent.orderitems', 'com_flexicontent');
// (backend) Reorder items inside the category
$permission->CanParams = $user->authorise('flexicontent.paramsitem', 'com_flexicontent');
// (backend) Edit item parameters like meta data and template parameters
$permission->CanVersion = $user->authorise('flexicontent.versioning', 'com_flexicontent');
// (backend) Use item versioning
$permission->AssocAnyTrans = $user->authorise('flexicontent.assocanytrans', 'com_flexicontent');
// (item edit form) associate any translation
//.........这里部分代码省略.........
示例5: _buildContentWhere
/**
* Method to build the where clause of the query for the Items
*
* @access private
* @return string
* @since 1.0
*/
function _buildContentWhere(&$extra_joins = "")
{
$session = JFactory::getSession();
$user = JFactory::getUser();
$perms = FlexicontentHelperPerm::getPerm();
// ***********************************
// FLAGs to decide which items to list
// ***********************************
$allitems = $perms->DisplayAllItems;
$viewable_items = $this->cparams->get('iman_viewable_items', 1);
$editable_items = $this->cparams->get('iman_editable_items', 0);
// ************************************************************************
// SPECIAL item listing CASES, item ids are already calculated and provided,
// in such a case WHERE clause limits to the given item ids
// ************************************************************************
// CASE 1: listing items using a file
$filter_fileid = $this->getState('filter_fileid');
if ($filter_fileid) {
$fileid_to_itemids = $session->get('fileid_to_itemids', array(), 'flexicontent');
$itemids = $fileid_to_itemids[$filter_fileid];
if (empty($itemids)) {
return ' WHERE 0 ';
} else {
return ' WHERE i.id IN (' . implode(',', $itemids) . ') ';
}
}
// *********************
// Get item list filters
// *********************
// various filters (mostly multi-value)
$filter_tag = $this->getState('filter_tag');
$filter_lang = $this->getState('filter_lang');
$filter_type = $this->getState('filter_type');
$filter_author = $this->getState('filter_author');
$filter_state = $this->getState('filter_state');
$filter_access = $this->getState('filter_access');
// category related filters
$filter_cats = $this->getState('filter_cats');
$filter_subcats = $this->getState('filter_subcats');
$filter_catsinstate = $this->getState('filter_catsinstate');
// filter id
$filter_id = $this->getState('filter_id');
// text search and search scope
$scope = $this->getState('scope');
$search = $this->getState('search');
$search = trim(JString::strtolower($search));
// date filters
$date = $this->getState('date');
$startdate = $this->getState('startdate');
$enddate = $this->getState('enddate');
$startdate = trim(JString::strtolower($startdate));
$enddate = trim(JString::strtolower($enddate));
// ********************************************
// Start building the AND parts of where clause
// ********************************************
$where = array();
// Limit items to the children of the FLEXI_CATEGORY, currently FLEXI_CATEGORY is root category (id:1) ...
//$where[] = ' (cat.lft > ' . $this->_db->Quote(FLEXI_LFT_CATEGORY) . ' AND cat.rgt < ' . $this->_db->Quote(FLEXI_RGT_CATEGORY) . ')';
//$where[] = ' cat.extension = ' . $this->_db->Quote(FLEXI_CAT_EXTENSION);
// *************************************
// IF items viewable: default is enabled
// *************************************
$joinaccess = "";
if (!$allitems && $viewable_items) {
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$aid_list = implode(",", $aid_arr);
$where[] = ' t.access IN (0,' . $aid_list . ')';
$where[] = ' c.access IN (0,' . $aid_list . ')';
$where[] = ' i.access IN (0,' . $aid_list . ')';
}
$extra_joins .= $joinaccess;
// ************************************************************
// IF items in an editable (main) category: default is disabled
// ************************************************************
$allowedcats = false;
$allowedcats_own = false;
if (!$allitems && $editable_items) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit'), $require_all = true, $check_published = false, false, $find_first = false);
$allowedcats_own = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit.own'), $require_all = true, $check_published = false, false, $find_first = false);
if ($allowedcats || $allowedcats_own) {
$_edit_where = '( ';
if ($allowedcats) {
$_edit_where .= '( i.catid IN (' . implode(', ', $allowedcats) . ') )';
}
if ($allowedcats && $allowedcats_own) {
$_edit_where .= ' OR ';
}
if ($allowedcats_own) {
$_edit_where .= '( i.catid IN (' . implode(', ', $allowedcats_own) . ') AND i.created_by=' . $user->id . ')';
}
$where[] = $_edit_where . ' )';
}
}
//.........这里部分代码省略.........
示例6: addbutton
/**
* Creates the add button
*
* @param array $params
* @since 1.0
*/
static function addbutton(&$params, &$submit_cat = null, $menu_itemid = 0, $submit_text = '', $auto_relations = false, $ignore_unauthorized = false)
{
if (!$params->get('show_addbutton', 1) || JRequest::getCmd('print')) {
return;
}
// Currently add button will appear to logged users only
// ... unless unauthorized users are allowed
$user = JFactory::getUser();
if (!$user->id && $ignore_unauthorized < 2) {
return '';
}
// IF not auto-relation given ... then check if current view / layout can use ADD button
$view = JRequest::getVar('view');
$layout = JRequest::getVar('layout', 'default');
if (!$auto_relations) {
if ($view != 'category' || $layout == 'author') {
return '';
}
}
// *********************************************************************
// Check if user can ADD to (a) given category or to (b) at any category
// *********************************************************************
// (a) Given category
if ($submit_cat && $submit_cat->id) {
$canAdd = $user->authorise('core.create', 'com_content.category.' . $submit_cat->id);
} else {
// Given CATEGORY VIEW OBJECT may limit to specific category ids
$canAdd = $user->authorise('core.create', 'com_flexicontent');
if ($canAdd === NULL && $user->id) {
// Perfomance concern (NULL for $canAdd) means SOFT DENY, also check for logged user
// thus to avoid checking some/ALL categories for "create" privelege for unlogged users
$specific_catids = $submit_cat ? @$submit_cat->ids : false;
if ($specific_catids && count($specific_catids) > 3) {
$specific_catids = false;
}
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids, $find_first = true);
$canAdd = count($allowedcats);
}
}
if (!$canAdd && !$ignore_unauthorized) {
return '';
}
// ******************************
// Create submit button/icon text
// ******************************
if ($submit_text) {
$submit_lbl = JText::_($submit_text);
} else {
$submit_lbl = JText::_($submit_cat && $submit_cat->id ? 'FLEXI_ADD_NEW_CONTENT_TO_CURR_CAT' : 'FLEXI_ADD_NEW_CONTENT_TO_LIST');
}
// ***********
// Create link
// ***********
// Add Itemid (if given) and do SEF URL routing it --before-- appending more variables, so that
// ... menu item URL variables from given menu item ID will be appended if SEF URLs are OFF
$menu_itemid = $menu_itemid ? $menu_itemid : (int) $params->get('addbutton_menu_itemid', 0);
$link = 'index.php?option=com_flexicontent';
$link .= $menu_itemid ? '&Itemid=' . $menu_itemid : '&view=' . FLEXI_ITEMVIEW . '&task=add';
$link = JRoute::_($link);
// Add main category ID (if given)
if ($submit_cat && $submit_cat->id) {
$link .= (strstr($link, '?') ? '&' : '?') . 'maincat=' . $submit_cat->id;
}
// Append autorelate information to the URL (if given)
if ($auto_relations) {
foreach ($auto_relations as $auto_relation) {
$link .= (strstr($link, '?') ? '&' : '?') . 'autorelation_' . $auto_relation->fieldid . '=' . $auto_relation->itemid;
}
}
// ***************************************
// Finally create the submit icon / button
// ***************************************
$overlib = $submit_lbl;
$text = JText::_('FLEXI_ADD');
$show_icons = 2;
//$params->get('show_icons');
if ($show_icons && !$auto_relations) {
$attribs = '';
$image = JHTML::image('components/com_flexicontent/assets/images/' . 'plus-button.png', $submit_lbl, $attribs);
} else {
$image = '';
}
$button_classes = 'fc_addbutton';
if ($show_icons == 1 && !$auto_relations) {
$caption = '';
$button_classes .= '';
} else {
$caption = $text;
$button_classes .= (FLEXI_J30GE ? ' btn btn-small' : ' fc_button fcsimple fcsmall') . ($auto_relations ? ' btn-success' : '');
}
$button_classes .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
$tooltip_title = flexicontent_html::getToolTip($text, $overlib, 0);
$output = '<a href="' . $link . '" class="' . $button_classes . '" title="' . $tooltip_title . '">' . $image . $caption . '</a>';
if (!$auto_relations) {
//.........这里部分代码省略.........
示例7: onDisplayField
//.........这里部分代码省略.........
$onlypublished = $field->parameters->get('onlypublished', 1);
$ownedbyuser = $field->parameters->get('ownedbyuser', 0);
// ******************
// EDITING PARAMETERS
// ******************
// some parameters shortcuts
$size = $field->parameters->get('size', 12);
$size = $size ? ' size="' . $size . '"' : '';
$prepend_item_state = $field->parameters->get('prepend_item_state', 1);
$maxtitlechars = $field->parameters->get('maxtitlechars', 40);
$title_filter = $field->parameters->get('title_filter', 1);
$required = $field->parameters->get('required', 0);
$required = $required ? ' required' : '';
$select_items_prompt = $field->parameters->get('select_items_prompt', 'FLEXI_RIFLD_SELECT_ITEMS_PROMPT');
$selected_items_label = $field->parameters->get('selected_items_label', 'FLEXI_RIFLD_SELECTED_ITEMS_LABEL');
$display_cat_filter_label = $field->parameters->get('display_cat_filter_label', 1);
$display_title_filter_label = $field->parameters->get('display_title_filter_label', 1);
$default_value_title_filter = $field->parameters->get('default_value_title_filter', '');
// ***********************************************
// Get & check Global category related permissions
// ***********************************************
require_once JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
$viewallcats = FlexicontentHelperPerm::getPerm()->ViewAllCats;
$viewtree = FlexicontentHelperPerm::getPerm()->ViewTree;
if (!$viewtree) {
$field->html = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_NO_ACCESS_LEVEL_TO_VIEW_CATEGORY_TREE') . '</div><div class="clear"></div>';
return;
}
// ****************************************************
// Calculate categories to use for retrieving the items
// ****************************************************
$allowed_cats = $disallowed_cats = false;
// Get user allowed categories
$usercats = FLEXI_J16GE || FLEXI_ACCESS ? FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create', 'core.edit', 'core.edit.own'), $require_all = false, $check_published = true) : FlexicontentHelperPerm::returnAllCats($check_published = true, $specific_catids = null);
// Find (if configured) , descendants of the categories
if ($usesubcats) {
global $globalcats;
$_catids = array();
foreach ($catids as $catid) {
$subcats = $globalcats[$catid]->descendantsarray;
foreach ($subcats as $subcat) {
$_catids[(int) $subcat] = 1;
}
}
$catids = array_keys($_catids);
}
// ... TODO: retrieve items via AJAX
// *********************************************
// Item retrieving query ... CREATE WHERE CLAUSE
// *********************************************
$where = array();
// **************
// CATEGORY SCOPE
// **************
// Include method
if ($method_cat == 3) {
$allowed_cats = $viewallcats ? $catids : array_intersect($usercats, $catids);
if (!empty($allowed_cats)) {
$where[] = " rel.catid IN (" . implode(',', $allowed_cats) . ") ";
} else {
$field->html = JText::_('FLEXI_CANNOT_EDIT_FIELD') . ': <br/> ' . JText::_('FLEXI_NO_ACCESS_TO_USE_CONFIGURED_CATEGORIES');
return;
}
} else {
if ($method_cat == 2) {
$disallowed_cats = $viewallcats ? $catids : array_diff($usercats, $catids);
示例8: store
//.........这里部分代码省略.........
$publish_up_forced = $publish_up_date->toSql();
} else {
$publish_up_date = new DateTime(JHTML::_('date', JFactory::getDate()->toFormat(), '%Y-%m-%d %H:%M:%S'));
$publish_up_date->modify('+ ' . $submit_conf['autopublished_up_interval'] . ' minutes');
$publish_up_forced = $publish_up_date->format('Y-m-d H:i:s');
}
}
if (@$submit_conf['autopublished_down_interval']) {
if (FLEXI_J16GE) {
$publish_down_date = JFactory::getDate();
// Gives editor's timezone by default
$publish_down_date->modify('+ ' . $submit_conf['autopublished_down_interval'] . ' minutes');
$publish_down_forced = $publish_down_date->toSql();
} else {
$publish_down_date = new DateTime(JHTML::_('date', JFactory::getDate()->toFormat(), '%Y-%m-%d %H:%M:%S'));
$publish_down_date->modify('+ ' . $submit_conf['autopublished_down_interval'] . ' minutes');
$publish_down_forced = $publish_down_date->format('Y-m-d H:i:s');
}
}
}
} else {
$autopublished = 0;
$overridecatperms = 0;
}
// ***********************************************************
// SECURITY concern: Check form tampering of categories, of:
// (a) menu overridden categories for frontent item submit
// (b) or check user has 'create' privilege in item categories
// ***********************************************************
if ($overridecatperms) {
$allowed_cid = @$submit_conf['cids'];
} else {
if (FLEXI_J16GE || FLEXI_ACCESS) {
$allowed_cid = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true);
}
}
if (isset($allowed_cid)) {
// Add existing item's categories into the user allowed categories
$allowed_cid = array_merge($allowed_cid, $item->categories);
// Check main category tampering
if (!in_array($data['catid'], $allowed_cid) && $data['catid'] != $item->catid) {
$this->setError('main category is not in allowed list (form tampered ?)');
return false;
}
// Check multi category tampering
$postcats = @$submit_conf['postcats'];
if (!$isnew || !$overridecatperms || $postcats == 2) {
$data['categories'] = array_intersect($data['categories'], $allowed_cid);
} else {
if ($postcats == 0) {
$data['categories'] = $allowed_cid;
} else {
if ($postcats == 1) {
$data['categories'] = array($data['catid']);
}
}
}
}
// *****************************************************************
// SECURITY concern: Check form tampering of state related variables
// *****************************************************************
// Save old main category & creator (owner)
$old_created_by = $item->created_by;
$old_catid = $item->catid;
// New or Existing item must use the current user + new main category to calculate 'Edit State' privelege
$item->created_by = $user->get('id');
示例9: display
function display($tpl = null)
{
global $globalcats;
$app = JFactory::getApplication();
$user = JFactory::getUser();
$document = JFactory::getDocument();
JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, null, true);
// ***********************************************************
// Get category data, and check if item is already checked out
// ***********************************************************
// Get data from the model
$model = $this->getModel();
if (FLEXI_J16GE) {
$row = $this->get('Item');
$form = $this->get('Form');
} else {
$row = $this->get('Category');
}
$catparams = new JRegistry($row->params);
$cid = $row->id;
$isnew = !$cid;
// Check category is checked out by different editor / administrator
if (!$isnew && $model->isCheckedOut($user->get('id'))) {
JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
$app->redirect('index.php?option=com_flexicontent&view=categories');
}
// ***************************************************************************
// Currently access checking for category add/edit form , it is done here, for
// most other views we force going though the controller and checking it there
// ***************************************************************************
// *********************************************************************************************
// Global Permssions checking (needed because this view can be called without a controller task)
// *********************************************************************************************
// Get global permissions
$perms = FlexicontentHelperPerm::getPerm();
// handles super admins correctly
// Check no access to categories management (Global permission)
if (!$perms->CanCats) {
$app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS'));
}
// Check no privilege to create new categories (Global permission)
if ($isnew && !$perms->CanAddCats) {
JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE'));
$app->redirect('index.php?option=com_flexicontent');
}
// ************************************************************************************
// Record Permssions (needed because this view can be called without a controller task)
// ************************************************************************************
// Get edit privilege for current category
if (!$isnew) {
if (FLEXI_J16GE) {
$isOwner = $row->get('created_by') == $user->id;
$rights = FlexicontentHelperPerm::checkAllItemAccess($user->id, 'category', $cid);
$canedit_cat = in_array('edit', $rights) || in_array('edit.own', $rights) && $isOwner;
} else {
if (FLEXI_ACCESS) {
$rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, 0, $row->id);
$canedit_cat = $user->gid < 25 ? in_array('edit', $rights) || in_array('editown', $rights) : 1;
} else {
$canedit_cat = true;
}
}
}
// Get if we can create inside at least one (com_content) category
if ($user->authorise('core.create', 'com_flexicontent')) {
$cancreate_cat = true;
} else {
$usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
$cancreate_cat = count($usercats) > 0;
}
// Creating new category: Check if user can create inside any existing category
if ($isnew && !$cancreate_cat) {
$acc_msg = JText::_('FLEXI_NO_ACCESS_CREATE') . "<br/>" . (FLEXI_J16GE ? JText::_('FLEXI_CANNOT_ADD_CATEGORY_REASON') : "");
JError::raiseWarning(403, $acc_msg);
$app->redirect('index.php?option=com_flexicontent&view=categories');
}
// Editing existing category: Check if user can edit existing (current) category
if (!$isnew && !$canedit_cat) {
$acc_msg = JText::_('FLEXI_NO_ACCESS_EDIT') . "<br/>" . JText::_('FLEXI_CANNOT_EDIT_CATEGORY_REASON');
JError::raiseWarning(403, $acc_msg);
$app->redirect('index.php?option=com_flexicontent&view=categories');
}
// **************************************************
// Include needed files and add needed js / css files
// **************************************************
// Add css to document
$document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION);
$document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION);
// Add JS frameworks
flexicontent_html::loadFramework('select2');
// Add js function to overload the joomla submitform validation
JHTML::_('behavior.formvalidation');
// load default validation JS to make sure it is overriden
$document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION);
$document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION);
//Load pane behavior
jimport('joomla.html.pane');
// ********************
// Initialise variables
//.........这里部分代码省略.........
示例10: _buildContentWhere
//.........这里部分代码省略.........
// *************************************
$joinaccess = "";
if (!$allitems && $viewable_items) {
if (FLEXI_J16GE) {
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$aid_list = implode(",", $aid_arr);
$where[] = ' t.access IN (0,' . $aid_list . ')';
$where[] = ' c.access IN (0,' . $aid_list . ')';
$where[] = ' i.access IN (0,' . $aid_list . ')';
} else {
$aid = (int) $user->get('aid');
if (FLEXI_ACCESS) {
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gt ON t.id = gt.axo AND gt.aco = "read" AND gt.axosection = "type"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gc ON c.id = gc.axo AND gc.aco = "read" AND gc.axosection = "category"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gi ON i.id = gi.axo AND gi.aco = "read" AND gi.axosection = "item"';
$where[] = ' (gt.aro IN ( ' . $user->gmid . ' ) OR t.access <= ' . $aid . ')';
$where[] = ' (gc.aro IN ( ' . $user->gmid . ' ) OR c.access <= ' . $aid . ')';
$where[] = ' (gi.aro IN ( ' . $user->gmid . ' ) OR i.access <= ' . $aid . ')';
} else {
$where[] = ' t.access <= ' . $aid;
$where[] = ' c.access <= ' . $aid;
$where[] = ' i.access <= ' . $aid;
}
}
}
$extra_joins .= $joinaccess;
// ************************************************************
// IF items in an editable (main) category: default is disabled
// ************************************************************
$allowedcats = false;
$allowedcats_own = false;
if (!$allitems && $editable_items) {
if (FLEXI_J16GE || FLEXI_ACCESS) {
$allowedcats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit'), $require_all = true, $check_published = false, false, $find_first = false);
$allowedcats_own = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.edit.own'), $require_all = true, $check_published = false, false, $find_first = false);
} else {
// In J1.5 without FLEXIaccess, the backend users can edit all files by default,
// since they belong to at least the managers user-group
// and ... listing only editable items is too slow in large websites, disable it
//if (FLEXI_ACCESS) $this->faccess_items_editable_where($where);
}
if ($allowedcats || $allowedcats_own) {
$_edit_where = '( ';
if ($allowedcats) {
$_edit_where .= '( i.catid IN (' . implode(', ', $allowedcats) . ') )';
}
if ($allowedcats && $allowedcats_own) {
$_edit_where .= ' OR ';
}
if ($allowedcats_own) {
$_edit_where .= '( i.catid IN (' . implode(', ', $allowedcats_own) . ') AND i.created_by=' . $user->id . ')';
}
$where[] = $_edit_where . ' )';
}
}
// *******************************
// Limit using the category filter
// *******************************
if ($filter_cats) {
// CURRENTLY in main or secondary category. -TODO- maybe add limiting by main category, if ... needed
$cat_type = 'rel.catid';
// $filter_maincat ? 'i.catid' : 'rel.catid';
if ($filter_subcats) {
global $globalcats;
$_sub_cids = array();
if ($filter_catsinstate == 99) {
示例11: display
function display($tpl = null)
{
// ********************
// Initialise variables
// ********************
global $globalcats;
$app = JFactory::getApplication();
$cparams = JComponentHelper::getParams('com_flexicontent');
$user = JFactory::getUser();
$db = JFactory::getDBO();
$document = JFactory::getDocument();
$option = JRequest::getCmd('option');
$view = JRequest::getVar('view');
$order_property = 'c.lft';
// Get model
$model = $this->getModel();
$print_logging_info = $cparams->get('print_logging_info');
if ($print_logging_info) {
global $fc_run_times;
}
// ***********
// Get filters
// ***********
$count_filters = 0;
// various filters
$filter_state = $model->getState('filter_state');
$filter_cats = $model->getState('filter_cats');
$filter_level = $model->getState('filter_level');
$filter_access = $model->getState('filter_access');
$filter_language = $model->getState('filter_language');
if ($filter_state) {
$count_filters++;
}
if ($filter_cats) {
$count_filters++;
}
if ($filter_level) {
$count_filters++;
}
if ($filter_access) {
$count_filters++;
}
if ($filter_language) {
$count_filters++;
}
// Item ID filter
$filter_id = $model->getState('filter_id');
if ($filter_id) {
$count_filters++;
}
// text search
$search = $model->getState('search');
$search = $db->escape(trim(JString::strtolower($search)));
// ordering
$filter_order = $model->getState('filter_order');
$filter_order_Dir = $model->getState('filter_order_Dir');
// **************************
// Add css and js to document
// **************************
flexicontent_html::loadFramework('select2');
//JHTML::_('behavior.tooltip');
$document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
$document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
// *****************************
// Get user's global permissions
// *****************************
$perms = FlexicontentHelperPerm::getPerm();
// ************************
// Create Submenu & Toolbar
// ************************
// Create Submenu (and also check access to current view)
FLEXISubmenu('CanCats');
// Create document/toolbar titles
$doc_title = JText::_('FLEXI_CATEGORIES');
$site_title = $document->getTitle();
JToolBarHelper::title($doc_title, 'fc_categories');
$document->setTitle($doc_title . ' - ' . $site_title);
$js = "jQuery(document).ready(function(){";
$contrl = "categories.";
$contrl_singular = "category.";
$toolbar = JToolBar::getInstance('toolbar');
// Copy Parameters
$btn_task = '';
$popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component';
if (FLEXI_J30GE || !FLEXI_J16GE) {
// Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually
$js .= "\n\t\t\t\tjQuery('#toolbar-params a.toolbar, #toolbar-params button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 600, y: 440}, onClose: function() {}}');\n\t\t\t";
JToolBarHelper::custom($btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false);
JHtml::_('behavior.modal', '#toolbar-params a.toolbar, #toolbar-params button');
} else {
$toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), str_replace('&', '&', $popup_load_url), 600, 440);
}
//$toolbar->appendButton('Popup', 'move', JText::_('FLEXI_BATCH'), JURI::base().'index.php?option=com_flexicontent&view=categories&layout=batch&tmpl=component', 800, 440);
JToolBarHelper::divider();
$add_divider = false;
if ($user->authorise('core.create', 'com_flexicontent')) {
$cancreate_cat = true;
} else {
$usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
$cancreate_cat = count($usercats) > 0;
//.........这里部分代码省略.........