本文整理汇总了PHP中K2HelperPermissions::canEditPublished方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperPermissions::canEditPublished方法的具体用法?PHP K2HelperPermissions::canEditPublished怎么用?PHP K2HelperPermissions::canEditPublished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperPermissions
的用法示例。
在下文中一共展示了K2HelperPermissions::canEditPublished方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
//.........这里部分代码省略.........
$tagID = $K2Tag->id;
}
} else {
if ($K2Tag->name) {
$query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($K2Tag->name);
$db->setQuery($query);
$tagID = $db->loadResult();
}
}
if ($tagID) {
$query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
$db->setQuery($query);
$db->query();
}
}
}
}
} else {
$tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
if (count($tags)) {
foreach ($tags as $tagID) {
$query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
$db->setQuery($query);
$db->query();
}
}
}
// If we are in front-end check publishing permissions properly.
if ($front) {
// New items require the "Publish items" permission.
if ($isNew && $row->published && !K2HelperPermissions::canPublishItem($row->catid)) {
$row->published = 0;
$mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
}
// Existing items require either the "Publish items" or the "Allow editing of already published items" permission.
if (!$isNew && $row->published) {
$canEditPublished = $isAlreadyPublished && K2HelperPermissions::canEditPublished($row->catid);
if (!K2HelperPermissions::canPublishItem($row->catid) && !$canEditPublished) {
$row->published = 0;
$mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
}
}
// If user has cannot publish the item then also cannot make it featured
if (!K2HelperPermissions::canPublishItem($row->catid)) {
if ($isNew) {
$row->featured = 0;
} else {
$row->featured = $currentFeaturedState;
}
}
}
$query = "UPDATE #__k2_items SET \n video_caption = " . $db->Quote($row->video_caption) . ", \n video_credits = " . $db->Quote($row->video_credits) . ", ";
if (!is_null($row->video)) {
$query .= " video = " . $db->Quote($row->video) . ", ";
}
if (!is_null($row->gallery)) {
$query .= " gallery = " . $db->Quote($row->gallery) . ", ";
}
$query .= " extra_fields = " . $db->Quote($row->extra_fields) . ", \n extra_fields_search = " . $db->Quote($row->extra_fields_search) . " ,\n published = " . $db->Quote($row->published) . " \n WHERE id = " . $row->id;
$db->setQuery($query);
if (!$db->query()) {
$mainframe->enqueueMessage($db->getErrorMsg(), 'error');
$mainframe->redirect('index.php?option=com_k2&view=items');
}
$row->checkin();
$cache = JFactory::getCache('com_k2');
$cache->clean();
$dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
JPluginHelper::importPlugin('content');
if (K2_JVERSION != '15') {
$dispatcher->trigger('onContentAfterSave', array('com_k2.item', &$row, $isNew));
} else {
$dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));
}
//Trigger the finder after save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderAfterSave', array('com_k2.item', $row, $isNew));
switch (JRequest::getCmd('task')) {
case 'apply':
$msg = JText::_('K2_CHANGES_TO_ITEM_SAVED');
$link = 'index.php?option=com_k2&view=item&cid=' . $row->id;
break;
case 'saveAndNew':
$msg = JText::_('K2_ITEM_SAVED');
$link = 'index.php?option=com_k2&view=item';
break;
case 'save':
default:
$msg = JText::_('K2_ITEM_SAVED');
if ($front) {
$link = 'index.php?option=com_k2&view=item&task=edit&cid=' . $row->id . '&tmpl=component&Itemid=' . JRequest::getInt('Itemid');
} else {
$link = 'index.php?option=com_k2&view=items';
}
break;
}
$mainframe->enqueueMessage($msg);
$mainframe->redirect($link);
}