本文整理汇总了PHP中FLEXIUtilities::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP FLEXIUtilities::getCache方法的具体用法?PHP FLEXIUtilities::getCache怎么用?PHP FLEXIUtilities::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLEXIUtilities
的用法示例。
在下文中一共展示了FLEXIUtilities::getCache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: access
/**
* Logic to set the access level of the Items
*
* @access public
* @return void
* @since 1.5
*/
function access()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$user = JFactory::getUser();
$cid = JRequest::getVar('cid', array(0), 'post', 'array');
$id = (int) $cid[0];
$task = JRequest::getVar('task');
// Decide / Retrieve new access level
$accesses = JRequest::getVar('access', array(0), 'post', 'array');
$access = $accesses[$id];
$model = $this->getModel('item');
$canEdit = $model->getItemAccess()->get('access-edit');
// Check if user can edit the item
if (!$canEdit) {
$msg_noauth = JText::_('FLEXI_CANNOT_CHANGE_ACCLEVEL_ASSETS');
$msg_noauth .= ": " . implode(',', $non_auth_cid) . " - " . JText::_('FLEXI_REASON_NO_PUBLISH_PERMISSION');
}
if ($msg_noauth) {
JError::raiseNotice(500, $msg_noauth);
$this->setRedirect('index.php?option=com_flexicontent&view=items', '');
return;
}
$model = $this->getModel('items');
if (!$model->saveaccess($id, $access)) {
$msg = JText::_('FLEXI_ERROR_SETTING_ITEM_ACCESS_LEVEL');
JError::raiseWarning(500, $msg . " " . $model->getError());
$msg = '';
} else {
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
}
$this->setRedirect('index.php?option=com_flexicontent&view=items');
}
示例2: initialPermission
//.........这里部分代码省略.........
$name = "com_flexicontent.field.{$field->id}";
// Test if an asset for the current FIELD ID already exists and load it instead of creating a new asset
if (!$asset->loadByName($name)) {
if ($field->asset_id) {
// asset name not found but field has an asset id set ?, we could delete it here
// but it maybe dangerous to do so ... it might be a legitimate asset_id for something else
}
// Initialize field asset
$asset->id = null;
$asset->name = $name;
$asset->title = $field->name;
$asset->setLocation($component_asset->id, 'last-child');
// Permissions of fields are directly inheritted by component
// Set asset rules to empty, (DO NOT set any ACTIONS, just let them inherit ... from parent)
$asset->rules = new JAccessRules();
/*
$actions = JAccess::getActions($component_name, 'field');
$rules = json_decode($component_asset->rules);
foreach ($actions as $action) {
$fieldrules[$action->name] = $rules->{$action->name};
}
$rules = new JAccessRules(json_encode($fieldrules));
$asset->rules = $rules->__toString();
*/
// Save the asset
if (!$asset->check() || !$asset->store(false)) {
echo $asset->getError();
$this->setError($asset->getError());
return false;
}
}
// Assign the asset to the field
$query = $db->getQuery(true)->update('#__flexicontent_fields')->set('asset_id = ' . (int) $asset->id)->where('id = ' . (int) $field->id);
$db->setQuery($query);
if (!$db->query()) {
echo JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $db->getErrorMsg());
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $db->getErrorMsg()));
return false;
}
}
}
/*** FLEXIcontent TYPES assets ***/
// Get a list flexicontent types that do not have assets
$query = $db->getQuery(true)->select('ff.id, ff.name, ff.asset_id')->from('#__assets AS se')->join('RIGHT', '#__flexicontent_types AS ff ON se.id=ff.asset_id AND se.name=concat("com_flexicontent.type.",ff.id)')->where('se.id is NULL');
$db->setQuery($query);
$results = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->getErrorMsg();
}
// Add an asset to every type that doesnot have one
if (count($results) > 0) {
foreach ($results as $type) {
$name = "com_flexicontent.type.{$type->id}";
// Test if an asset for the current TYPE ID already exists and load it instead of creating a new asset
if (!$asset->loadByName($name)) {
if ($type->asset_id) {
// asset name not found but type has an asset id set ?, we could delete it here
// but it maybe dangerous to do so ... it might be a legitimate asset_id for something else
}
// Initialize type asset
$asset->id = null;
$asset->name = $name;
$asset->title = $type->name;
$asset->setLocation($component_asset->id, 'last-child');
// Permissions of types are directly inheritted by component
// Set asset rules to empty, (DO NOT set any ACTIONS, just let them inherit ... from parent)
$asset->rules = new JAccessRules();
/*
$actions = JAccess::getActions($component_name, 'type');
$rules = json_decode($component_asset->rules);
foreach ($actions as $action) {
$typerules[$action->name] = $rules->{$action->name};
}
$rules = new JAccessRules(json_encode($typerules));
$asset->rules = $rules->__toString();
*/
// Save the asset
if (!$asset->check() || !$asset->store(false)) {
echo $asset->getError();
$this->setError($asset->getError());
return false;
}
}
// Assign the asset to the type
$query = $db->getQuery(true)->update('#__flexicontent_types')->set('asset_id = ' . (int) $asset->id)->where('id = ' . (int) $type->id);
$db->setQuery($query);
if (!$db->query()) {
echo JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $db->getErrorMsg());
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $db->getErrorMsg()));
return false;
}
}
}
// Clear cache so that per user permissions objects are recalculated
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_cats');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_cats');
return true;
}
示例3: setitemstate
/**
* Logic to change the state of an item
*
* @access public
* @return void
* @since 1.0
*/
static function setitemstate($controller_obj)
{
$id = JRequest::getInt('id', 0);
JRequest::setVar('cid', $id);
$app = JFactory::getApplication();
$modelname = $app->isAdmin() ? 'item' : FLEXI_ITEMVIEW;
$model = $controller_obj->getModel($modelname);
$user = JFactory::getUser();
$state = JRequest::getVar('state', 0);
// Get owner and other item data
$db = JFactory::getDBO();
$q = "SELECT id, created_by, catid FROM #__content WHERE id =" . $id;
$db->setQuery($q);
$item = $db->loadObject();
// Determine priveleges of the current user on the given item
$asset = 'com_content.article.' . $item->id;
$has_edit_state = $user->authorise('core.edit.state', $asset) || $user->authorise('core.edit.state.own', $asset) && $item->created_by == $user->get('id');
$has_delete = $user->authorise('core.delete', $asset) || $user->authorise('core.delete.own', $asset) && $item->created_by == $user->get('id');
// ...
$permission = FlexicontentHelperPerm::getPerm();
$has_archive = $permission->CanArchives;
$has_edit_state = $has_edit_state && in_array($state, array(0, 1, -3, -4, -5));
$has_delete = $has_delete && $state == -2;
$has_archive = $has_archive && $state == 2;
// check if user can edit.state of the item
$access_msg = '';
if (!$has_edit_state && !$has_delete && !$has_archive) {
//echo JText::_( 'FLEXI_NO_ACCESS_CHANGE_STATE' );
echo JText::_('FLEXI_DENIED');
// must a few words
return;
} else {
if (!$model->setitemstate($id, $state)) {
$msg = JText::_('FLEXI_ERROR_SETTING_THE_ITEM_STATE');
echo $msg . ": " . $model->getError();
return;
}
}
// Clean cache
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
// Output new state icon and terminate
$tmpparams = new JRegistry();
$tmpparams->set('stateicon_popup', 'basic');
$stateicon = flexicontent_html::stateicon($state, $tmpparams);
echo $stateicon;
exit;
}
示例4: importcsv
//.........这里部分代码省略.........
// Set/Force id to zero to indicate creation of new item, in case item 'id' column is being used
$c_item_id = @$data['id'];
$data['id'] = 0;
$session->set('csvimport_lineno', $lineno, 'flexicontent');
// If testing format then output some information
if ($task == 'testcsv') {
if ($lineno == 1) {
$parse_log .= '
<span class="fc-mssg fc-info">
Testing file format <br/>
COLUMNS: ' . implode(', ', $conf['columns']) . '<br/>
</span><hr/>
';
}
foreach ($_d as $i => $flddata) {
if (is_string($_d[$i])) {
if (mb_strlen($_d[$i], 'UTF-8') > 80) {
$_d[$i] = mb_substr(strip_tags($_d[$i]), 0, 80, 'UTF-8') . ' ... ';
}
}
}
if ($lineno <= $conf['debug_records']) {
$parse_log .= "<pre><b>Item no {$lineno}:</b>\n" . print_r($_d, true) . "</pre><hr/>";
} else {
$parse_log .= "<b>Item no {$lineno}:</b> <br/>" . "<u>TITLE</u>: " . $_d['title'] . "<br/>" . "<u>TEXT</u>: " . $_d['text'] . "<hr/>";
}
} else {
if (!$itemmodel->store($data)) {
$conf['failure_count']++;
$msg = 'Failed item no: ' . $lineno . ". titled as: '" . $data['title'] . "' : " . $itemmodel->getError();
JLog::add($msg);
echo $msg . "<br/>";
} else {
$conf['success_count']++;
$msg = 'Imported item no: ' . $lineno . ". titled as: '" . $data['title'] . "'";
JLog::add($msg);
echo $msg . "<br/>";
// Try to rename entry if id column is being used
if ($conf['id_col'] && $c_item_id) {
$item_id = $itemmodel->getId();
$q = "UPDATE #__content SET id='" . $c_item_id . "' WHERE id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_items_ext SET item_id='" . $c_item_id . "' WHERE item_id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_items_tmp SET id='" . $c_item_id . "' WHERE id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_tags_item_relations SET itemid='" . $c_item_id . "' WHERE itemid='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_cats_item_relations SET itemid='" . $c_item_id . "' WHERE itemid='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_fields_item_relations SET item_id='" . $c_item_id . "' WHERE item_id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_items_versions SET item_id='" . $c_item_id . "' WHERE item_id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_versions SET item_id='" . $c_item_id . "' WHERE item_id='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
$q = "UPDATE #__flexicontent_favourites SET itemid='" . $c_item_id . "' WHERE itemid='" . $item_id . "'";
$db->setQuery($q);
$db->execute();
if (FLEXI_J16GE) {
$q = "UPDATE #__assets SET id='" . $c_item_id . "' WHERE id='" . $item_id . "'";
} else {
$q = "UPDATE #__flexiaccess_acl SET axo='" . $c_item_id . "'" . " WHERE acosection = " . $db->Quote('com_content') . " AND axosection = " . $db->Quote('item') . " AND axo='" . $item_id . "'";
}
$db->setQuery($q);
$db->execute();
}
}
}
}
//fclose($fp);
// Done nothing more to do
if ($task == 'testcsv') {
echo $parse_log;
echo "\n\n\n" . '<b>please click</b> <a href="' . $link . '">here</a> to return previous page' . "\n\n\n";
jexit();
}
if ($lineno == $itemcount) {
// Clean item's cache
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
// Set a total results message and redirect
$msg = 'Imported items: ' . $conf['success_count'] . ' , failed items: ' . $conf['failure_count'] . ', please review (in the logs folder) the import log file: ' . $log_filename;
//$app->enqueueMessage($msg, ($conf['failure_count']==0 && $conf['success_count']>0) ? 'message' : 'warning');
//$this->setRedirect($link); // commented out this via AJAX call now
}
jexit();
}
示例5: approval
/**
* Logic to submit item to approval
*
* @access public
* @return void
* @since 1.5
*/
function approval($cid)
{
$db = $this->_db;
$user = JFactory::getUser();
$approvables = $this->isUserDraft($cid);
$requestApproval = FLEXI_J16GE ? $user->authorise('flexicontent.requestapproval', 'com_flexicontent') : $user->gid >= 20;
// or at least a J1.5 Editor
$submitted = 0;
$noprivilege = array();
$checked_out = array();
$publishable = array();
foreach ($approvables as $approvable) {
// Check if not owned (while not have global request approval privilege)
if (!$requestApproval && $approvable->created_by != (int) $user->get('id')) {
$noprivilege[] = $item->title;
continue;
}
// Check if checked out (edited) by different user
if ($approvable->checked_out != 0 && $approvable->checked_out != (int) $user->get('id')) {
$checked_out[] = $item->title;
continue;
}
// Get item setting it into the model, and get publish privilege
$item = $this->getItem($approvable->id, $check_view_access = false, $no_cache = true);
$canEditState = $this->canEditState($item, $check_cat_perm = true);
if ($canEditState) {
$publishable[] = $item->title;
continue;
}
// Set to pending approval
$this->setitemstate($approvable->id, -3);
$validators = $this->getApprovalRequestReceivers($approvable->id, $approvable->catid);
if (!count($validators->notify_emails)) {
$validators->notify_emails[] = JFactory::getApplication()->getCfg('mailfrom');
}
// Get component parameters and them merge into them the type parameters
$params = FLEXI_J16GE ? new JRegistry() : new JParameter("");
$cparams = JComponentHelper::getParams('com_flexicontent');
$params->merge($cparams);
$tparams = $this->getTypeparams();
$tparams = FLEXI_J16GE ? new JRegistry($tparams) : new JParameter($tparams);
$params->merge($tparams);
$query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' LEFT JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $approvable->id;
$db->setQuery($query);
$after_cats = $db->loadObjectList('id');
$notify_vars = new stdClass();
$notify_vars->needs_version_reviewal = 0;
$notify_vars->needs_publication_approval = 1;
$notify_vars->isnew = 1;
$notify_vars->notify_emails = $validators->notify_emails;
$notify_vars->notify_text = $validators->notify_text;
$notify_vars->before_cats = array();
$notify_vars->after_cats = $after_cats;
$this->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 1);
$submitted++;
}
// Number of submitted items
if ($submitted) {
$approve_str = $submitted > 1 ? 'FLEXI_APPROVAL_ITEMS_SUBMITTED' : 'FLEXI_APPROVAL_ITEM_SUBMITTED';
$msg = ($submitted > 1 ? $submitted : '') . JText::_($approve_str);
} else {
$msg = JText::_('FLEXI_APPROVAL_NO_ITEMS_SUBMITTED');
}
// Number of excluded items, and message that items must be owned and in draft state
$excluded = count($cid) - $submitted;
$msg .= $excluded ? ' ' . $excluded . ' ' . JText::_('FLEXI_APPROVAL_ITEMS_EXCLUDED') : '';
// Message about excluded non-owned items, that are being owned be a different user (this means current user does not have global request approval privilege)
if (count($noprivilege)) {
$noprivilege_str = '"' . implode('" , "', $noprivilege) . '"';
$msg .= '<div>' . JText::sprintf('FLEXI_APPROVAL_NO_REQUEST_PRIV_EXCLUDED', $noprivilege_str) . '</div>';
}
// Message about excluded checked_out items, that are being edited be a different user
if (count($checked_out)) {
$checked_out_str = '"' . implode('" , "', $checked_out) . '"';
$msg .= '<div>' . JText::sprintf('FLEXI_APPROVAL_CHECKED_OUT_EXCLUDED', $checked_out_str) . '</div>';
}
// Message about excluded publishable items, that can be published by the owner
if (count($publishable)) {
$publishable_str = '"' . implode('" , "', $publishable) . '"';
$msg .= '<div>' . JText::sprintf('FLEXI_APPROVAL_PUBLISHABLE_EXCLUDED', $publishable_str) . '</div>';
}
// This may not be needed since the item was already in unpublished stated ??
if (FLEXI_J16GE) {
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
} else {
$itemcache = JFactory::getCache('com_flexicontent_items');
$itemcache->clean();
$filtercache = JFactory::getCache('com_flexicontent_filters');
//.........这里部分代码省略.........
示例6: save
//.........这里部分代码省略.........
if ($isnew) {
$notify_text = $params->get('text_notify_new');
} else {
if ($needs_version_reviewal) {
$notify_text = $params->get('text_notify_existing_reviewal');
} else {
if (!$isnew) {
$notify_text = $params->get('text_notify_existing');
}
}
}
}
//print_r($notify_emails); jexit();
}
}
// *********************************************************************************************************************
// If there are emails to notify for current saving case, then send the notifications emails, but
// *********************************************************************************************************************
if (!empty($notify_emails) && count($notify_emails)) {
$notify_vars = new stdClass();
$notify_vars->needs_version_reviewal = $needs_version_reviewal;
$notify_vars->needs_publication_approval = $needs_publication_approval;
$notify_vars->isnew = $isnew;
$notify_vars->notify_emails = $notify_emails;
$notify_vars->notify_text = $notify_text;
$notify_vars->before_cats = $before_cats;
$notify_vars->after_cats = $after_cats;
$notify_vars->original_item = @$original_item;
$model->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 0);
}
// ***************************************************
// CLEAN THE CACHE so that our changes appear realtime
// ***************************************************
$cache = FLEXIUtilities::getCache($group = '', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group = '', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
// ****************************************************************************************************************************
// Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category
// and thus being able to set this category as item's main category, but then have no edit/editown permission for this category
// ****************************************************************************************************************************
$asset = 'com_content.article.' . $model->get('id');
$canEdit = $user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset) && $isOwner;
// ALTERNATIVE 1
//$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own
// ALTERNATIVE 2
//$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id'));
//$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $isOwner) ;
// *******************************************************************************************************
// Check if user can not edit item further (due to changed main category, without edit/editown permission)
// *******************************************************************************************************
if (!$canEdit) {
if ($task == 'apply' || $task == 'apply_type') {
// APPLY TASK: Temporarily set item to be editable till closing it and not through all session
// (we will/should clear this flag when item is closed, since we have another flag to indicate new items
$rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
$rendered_uneditable[$model->get('id')] = -1;
$session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
$canEdit = 1;
} else {
if ($newly_submitted_item) {
// NEW ITEM: Do not use editable till logoff behaviour
// ALSO: Clear editable FLAG set in the case that 'apply' button was used during new item creation
if (!$params->get('items_session_editable', 0)) {
示例7: resetvotes
/**
* Method to reset votes
*
* @since 1.0
*/
function resetvotes()
{
$id = JRequest::getInt('id', 0);
$model = $this->getModel('item');
$model->resetVotes($id);
if (FLEXI_J16GE) {
$cache = FLEXIUtilities::getCache();
$cache->clean('com_flexicontent_items');
} else {
$itemcache = JFactory::getCache('com_flexicontent_items');
$itemcache->clean();
}
echo JText::_('FLEXI_NOT_RATED_YET');
}
示例8: save
//.........这里部分代码省略.........
else if (!$isnew) $notify_emails = array();
if ($needs_publication_approval) $notify_text = $params->get('text_notify_new_pending');
else if ($isnew) $notify_text = $params->get('text_notify_new');
else if ($needs_version_reviewal) $notify_text = $params->get('text_notify_existing_reviewal');
else if (!$isnew) $notify_text = $params->get('text_notify_existing');
//print_r($notify_emails); jexit();
}
}
// *********************************************************************************************************************
// If there are emails to notify for current saving case, then send the notifications emails, but
// *********************************************************************************************************************
if ( !empty($notify_emails) && count($notify_emails) ) {
$notify_vars = new stdClass();
$notify_vars->needs_version_reviewal = $needs_version_reviewal;
$notify_vars->needs_publication_approval = $needs_publication_approval;
$notify_vars->isnew = $isnew;
$notify_vars->notify_emails = $notify_emails;
$notify_vars->notify_text = $notify_text;
$notify_vars->before_cats = $before_cats;
$notify_vars->after_cats = $after_cats;
$notify_vars->original_item = @ $original_item;
$model->sendNotificationEmails($notify_vars, $params, $manual_approval_request=0);
}
// ***************************************************
// CLEAN THE CACHE so that our changes appear realtime
// ***************************************************
if (FLEXI_J16GE) {
$cache = FLEXIUtilities::getCache($group='', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group='', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
} else {
$itemcache = JFactory::getCache('com_flexicontent_items');
$itemcache->clean();
$filtercache = JFactory::getCache('com_flexicontent_filters');
$filtercache->clean();
}
// ****************************************************************************************************************************
// Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category
// and thus being able to set this category as item's main category, but then have no edit/editown permission for this category
// ****************************************************************************************************************************
if (FLEXI_J16GE) {
$asset = 'com_content.article.' . $model->get('id');
$canEdit = $user->authorise('core.edit', $asset) || ($user->authorise('core.edit.own', $asset) && $model->get('created_by') == $user->get('id'));
// ALTERNATIVE 1
//$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own
// ALTERNATIVE 2
//$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id'));
//$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $model->get('created_by') == $user->get('id')) ;
} else if (FLEXI_ACCESS && $user->gid < 25) {
$rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, $model->get('id'), $model->get('catid'));
$canEdit = in_array('edit', $rights) || (in_array('editown', $rights) && $model->get('created_by') == $user->get('id')) ;
} else {
// This is meaningful when executed in frontend, since all backend users (managers and above) can edit items
$canEdit = $user->authorize('com_content', 'edit', 'content', 'all') || ($user->authorize('com_content', 'edit', 'content', 'own') && $model->get('created_by') == $user->get('id'));
}
示例9: save_import
//.........这里部分代码省略.........
else if (!$isnew) $notify_emails = array();
if ($needs_publication_approval) $notify_text = $params->get('text_notify_new_pending');
else if ($isnew) $notify_text = $params->get('text_notify_new');
else if ($needs_version_reviewal) $notify_text = $params->get('text_notify_existing_reviewal');
else if (!$isnew) $notify_text = $params->get('text_notify_existing');
//print_r($notify_emails); jexit();
}
}
// *********************************************************************************************************************
// If there are emails to notify for current saving case, then send the notifications emails, but
// *********************************************************************************************************************
if ( !empty($notify_emails) && count($notify_emails) ) {
$notify_vars = new stdClass();
$notify_vars->needs_version_reviewal = $needs_version_reviewal;
$notify_vars->needs_publication_approval = $needs_publication_approval;
$notify_vars->isnew = $isnew;
$notify_vars->notify_emails = $notify_emails;
$notify_vars->notify_text = $notify_text;
$notify_vars->before_cats = $before_cats;
$notify_vars->after_cats = $after_cats;
$notify_vars->original_item = @ $original_item;
$model->sendNotificationEmails($notify_vars, $params, $manual_approval_request=0);
}
// ***************************************************
// CLEAN THE CACHE so that our changes appear realtime
// ***************************************************
if (FLEXI_J16GE) {
$cache = FLEXIUtilities::getCache($group='', 0);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
$cache = FLEXIUtilities::getCache($group='', 1);
$cache->clean('com_flexicontent_items');
$cache->clean('com_flexicontent_filters');
} else {
$itemcache = JFactory::getCache('com_flexicontent_items');
$itemcache->clean();
$filtercache = JFactory::getCache('com_flexicontent_filters');
$filtercache->clean();
}
// ****************************************************************************************************************************
// Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category
// and thus being able to set this category as item's main category, but then have no edit/editown permission for this category
// ****************************************************************************************************************************
if (FLEXI_J16GE) {
$asset = 'com_content.article.' . $model->get('id');
$canEdit = $user->authorise('core.edit', $asset) || ($user->authorise('core.edit.own', $asset) && $model->get('created_by') == $user->get('id'));
// ALTERNATIVE 1
//$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own
// ALTERNATIVE 2
//$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id'));
//$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $model->get('created_by') == $user->get('id')) ;
} else if (FLEXI_ACCESS && $user->gid < 25) {
$rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, $model->get('id'), $model->get('catid'));
$canEdit = in_array('edit', $rights) || (in_array('editown', $rights) && $model->get('created_by') == $user->get('id')) ;
} else {
// This is meaningful when executed in frontend, since all backend users (managers and above) can edit items
$canEdit = $user->authorize('com_content', 'edit', 'content', 'all') || ($user->authorize('com_content', 'edit', 'content', 'own') && $model->get('created_by') == $user->get('id'));
}