本文整理汇总了PHP中K2HelperPermissions::canEditItem方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperPermissions::canEditItem方法的具体用法?PHP K2HelperPermissions::canEditItem怎么用?PHP K2HelperPermissions::canEditItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperPermissions
的用法示例。
在下文中一共展示了K2HelperPermissions::canEditItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canEdit
public function canEdit()
{
JLoader::register('K2HelperPermissions', JPATH_SITE . '/components/com_k2/helpers/permissions.php');
if ($this->params->option != 'com_k2') {
K2HelperPermissions::setPermissions();
}
return K2HelperPermissions::canEditItem($this->article->created_by, $this->article->catid);
}
示例2: users
function users()
{
$itemID = JRequest::getInt('itemID');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item = JTable::getInstance('K2Item', 'Table');
$item->load($itemID);
if (!K2HelperPermissions::canAddItem() && !K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$K2Permissions = K2Permissions::getInstance();
if (!$K2Permissions->permissions->get('editAll')) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
JRequest::setVar('tmpl', 'component');
$mainframe = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$language = JFactory::getLanguage();
$language->load('com_k2', JPATH_ADMINISTRATOR);
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
JHtml::_('behavior.framework');
} else {
JHTML::_('behavior.mootools');
}
// CSS
$document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.6.8');
// JS
K2HelperHTML::loadjQuery(true);
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.6.8&sitepath=' . JURI::root(true) . '/');
$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views');
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$view = $this->getView('users', 'html');
$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'users' . DS . 'tmpl');
$view->setLayout('element');
$view->display();
}
示例3: display
//.........这里部分代码省略.........
$items = $model->getData();
} else {
$items = $model->getData($ordering);
}
}
//Prepare items
$user = JFactory::getUser();
$cache = JFactory::getCache('com_k2_extended');
$model = JModelLegacy::getInstance('item', 'K2Model');
$rows = array();
for ($i = 0; $i < sizeof($items); $i++) {
//Item group
if ($task == "category" || $task == "") {
$items[$i]->itemGroup = 'links';
if ($i < $params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')) {
$items[$i]->itemGroup = 'links';
}
if ($i < $params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')) {
$items[$i]->itemGroup = 'secondary';
}
if ($i < $params->get('num_primary_items') + $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'primary';
}
if ($i < $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'leading';
}
} else {
$items[$i]->itemGroup = '';
}
$itemParams = class_exists('JParameter') ? new JParameter($items[$i]->params) : new JRegistry($items[$i]->params);
$itemParams->set($prefix . 'ItemIntroText', true);
$itemParams->set($prefix . 'ItemFullText', true);
$itemParams->set($prefix . 'ItemTags', true);
$itemParams->set($prefix . 'ItemExtraFields', true);
$itemParams->set($prefix . 'ItemAttachments', true);
$itemParams->set($prefix . 'ItemRating', true);
$itemParams->set($prefix . 'ItemAuthor', true);
$itemParams->set($prefix . 'ItemImageGallery', true);
$itemParams->set($prefix . 'ItemVideo', true);
$itemParams->set($prefix . 'ItemImage', true);
$items[$i]->params = $itemParams->toString();
//Check if model should use cache for preparing item even if user is logged in
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') {
$cacheFlag = true;
} else {
$cacheFlag = true;
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) {
$cacheFlag = false;
}
}
//Prepare item
if ($cacheFlag) {
$hits = $items[$i]->hits;
$items[$i]->hits = 0;
JTable::getInstance('K2Category', 'Table');
$items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task);
$items[$i]->hits = $hits;
} else {
$items[$i] = $model->prepareItem($items[$i], $view, $task);
}
//Plugins
$items[$i]->params->set('genericItemIntroText', $params->get('catItemIntroText'));
$items[$i] = $model->execPlugins($items[$i], $view, $task);
//Trigger comments counter event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
// Set default image
if ($task == 'user' || $task == 'tag' || $task == 'search' || $task == 'date') {
$items[$i]->image = isset($items[$i]->imageGeneric) ? $items[$i]->imageGeneric : '';
} else {
if (!$moduleID) {
K2HelperUtilities::setDefaultImage($items[$i], $view, $params);
}
}
$rows[] = $model->prepareJSONItem($items[$i]);
}
$response->items = $rows;
// Prevent spammers from using the tag view
if ($task == 'tag' && !count($response->items)) {
$tag = JRequest::getString('tag');
$db = JFactory::getDBO();
$db->setQuery('SELECT id FROM #__k2_tags WHERE name = ' . $db->quote($tag));
$tagID = $db->loadResult();
if (!$tagID) {
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
return false;
}
}
// Output
$json = json_encode($response);
$callback = JRequest::getCmd('callback');
if ($callback) {
$document->setMimeEncoding('application/javascript');
echo $callback . '(' . $json . ')';
} else {
echo $json;
}
}
示例4: display
//.........这里部分代码省略.........
$items = $model->getData();
} else {
$items = $model->getData($ordering);
}
// Pagination
jimport('joomla.html.pagination');
$total = count($items) ? $model->getTotal() : 0;
$pagination = new JPagination($total, $limitstart, $limit);
//Prepare items
$user = JFactory::getUser();
$cache = JFactory::getCache('com_k2_extended');
$model = $this->getModel('item');
for ($i = 0; $i < sizeof($items); $i++) {
//Item group
if ($task == "category" || $task == "") {
if ($i < $params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')) {
$items[$i]->itemGroup = 'links';
}
if ($i < $params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')) {
$items[$i]->itemGroup = 'secondary';
}
if ($i < $params->get('num_primary_items') + $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'primary';
}
if ($i < $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'leading';
}
}
// Check if the model should use the cache for preparing the item even if the user is logged in
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') {
$cacheFlag = true;
} else {
$cacheFlag = true;
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) {
$cacheFlag = false;
}
}
// Prepare item
if ($cacheFlag) {
$hits = $items[$i]->hits;
$items[$i]->hits = 0;
JTable::getInstance('K2Category', 'Table');
$items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task);
$items[$i]->hits = $hits;
} else {
$items[$i] = $model->prepareItem($items[$i], $view, $task);
}
// Plugins
$items[$i] = $model->execPlugins($items[$i], $view, $task);
// Trigger comments counter event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
}
// Set title
$document = JFactory::getDocument();
$application = JFactory::getApplication();
$menus = $application->getMenu();
$menu = $menus->getActive();
if (is_object($menu)) {
if (is_string($menu->params)) {
$menu_params = K2_JVERSION == '15' ? new JParameter($menu->params) : new JRegistry($menu->params);
} else {
$menu_params = $menu->params;
}
示例5: display
//.........这里部分代码省略.........
$items = $model->getData();
} else {
$items = $model->getData($ordering);
}
//Pagination
jimport('joomla.html.pagination');
$total = $model->getTotal();
$pagination = new JPagination($total, $limitstart, $limit);
//Prepare items
$user =& JFactory::getUser();
$cache =& JFactory::getCache('com_k2_extended');
$model =& $this->getModel('item');
for ($i = 0; $i < sizeof($items); $i++) {
//Item group
if ($task == "category" || $task == "") {
if ($i < $params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')) {
$items[$i]->itemGroup = 'links';
}
if ($i < $params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')) {
$items[$i]->itemGroup = 'secondary';
}
if ($i < $params->get('num_primary_items') + $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'primary';
}
if ($i < $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'leading';
}
}
//Check if model should use cache for preparing item even if user is logged in
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') {
$cacheFlag = true;
} else {
$cacheFlag = true;
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) {
$cacheFlag = false;
}
}
//Prepare item
if ($cacheFlag) {
$hits = $items[$i]->hits;
$items[$i]->hits = 0;
JTable::getInstance('K2Category', 'Table');
$items[$i] = $cache->call(array('K2ModelItem', 'prepareItem'), $items[$i], $view, $task);
$items[$i]->hits = $hits;
} else {
$items[$i] = $model->prepareItem($items[$i], $view, $task);
}
//Plugins
$items[$i] = $model->execPlugins($items[$i], $view, $task);
//Trigger comments counter event
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
}
//Pathway
$pathway =& $mainframe->getPathWay();
$pathway->addItem($title);
//Feed link
$config =& JFactory::getConfig();
$menu =& JSite::getMenu();
$default = $menu->getDefault();
$active = $menu->getActive();
if ($task == 'tag') {
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
} else {
示例6: prepareItem
function prepareItem($item, $view, $task){
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$limitstart=JRequest::getInt('limitstart');
//Initialize params
if ($view!='item'){
$component = JComponentHelper::getComponent( 'com_k2' );
$params = new JParameter( $component->params );
$itemid = JRequest::getInt( 'Itemid' );
if ($itemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams( $itemid );
$params->merge( $menuparams );
}
}
else {
$params = & JComponentHelper::getParams('com_k2');
}
//Category
$db = & JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$item->catid;
$db->setQuery($query, 0, 1);
$category = $db->loadObject();
$item->category=$category;
$item->category->link=urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias),$item->catid.':'.urlencode($item->category->alias));
$item->link=urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link.'&tmpl=component&print=1'));
//Params
$cparams = new JParameter( $category->params );
$iparams = new JParameter( $item->params );
$item->params= $params;
if ($cparams->get('inheritFrom')){
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$masterCategoryID;
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter( $masterCategory->params );
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by,$item->catid))
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid='.$item->id.'&tmpl=component');
//Tags
if(
($view=='item' && ($item->params->get('itemTags') || $item->params->get('itemRelated'))) ||
($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemTags')) ||
($view=='itemlist' && $task=='user' && $item->params->get('userItemTags')) ||
($view=='latest' && $params->get('latestItemTags'))
)
{
$tags = K2ModelItem::getItemTags($item->id);
for ($i=0; $i<sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags=$tags;
}
//Image
$item->imageXSmall='';
$item->imageSmall='';
$item->imageMedium='';
$item->imageLarge='';
$item->imageXLarge='';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
//Extra fields
//.........这里部分代码省略.........
示例7: prepareItem
function prepareItem($item, $view, $task)
{
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$limitstart = JRequest::getInt('limitstart');
//Initialize params
if ($view != 'item') {
$component = JComponentHelper::getComponent('com_k2');
$params = new JParameter($component->params);
$itemid = JRequest::getInt('Itemid');
if ($itemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams($itemid);
$params->merge($menuparams);
}
} else {
$params =& JComponentHelper::getParams('com_k2');
}
//Category
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id={$item->catid}";
$db->setQuery($query, 0, 1);
$category = $db->loadObject();
$item->category = $category;
$item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
$item->link = urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
//Params
$cparams = new JParameter($category->params);
$iparams = new JParameter($item->params);
$item->params = $params;
if ($cparams->get('inheritFrom')) {
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id={$masterCategoryID}";
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter($masterCategory->params);
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
}
//Tags
if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
$tags = K2ModelItem::getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name)));
}
$item->tags = $tags;
}
//Image
$item->imageXSmall = '';
$item->imageSmall = '';
$item->imageMedium = '';
$item->imageLarge = '';
$item->imageXLarge = '';
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
}
//Extra fields
if ($view == 'item' && $item->params->get('itemExtraFields') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields') || $view == 'itemlist' && ($task == 'search' || $task == 'tag' || $task == 'date') && $item->params->get('genericItemExtraFields')) {
$item->extra_fields = K2ModelItem::getItemExtraFields($item->extra_fields);
}
//Attachments
if ($view == 'item' && $item->params->get('itemAttachments') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) {
$item->attachments = K2ModelItem::getItemAttachments($item->id);
}
//Import plugins
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
//Gallery
if ($view == 'item' && $item->params->get('itemImageGallery') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemImageGallery')) {
$params->set('galleries_rootfolder', 'media/k2/galleries');
$params->set('popup_engine', 'mootools_slimbox');
$params->set('enabledownload', '0');
$item->text = $item->gallery;
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
$item->gallery = $item->text;
}
//Video
//.........这里部分代码省略.........
示例8: checkPermissions
public static function checkPermissions()
{
$view = JRequest::getCmd('view');
if ($view != 'item') {
return;
}
$task = JRequest::getCmd('task');
$user = JFactory::getUser();
if ($user->guest && ($task == 'add' || $task == 'edit')) {
$mainframe = JFactory::getApplication();
$uri = JURI::getInstance();
$return = base64_encode($uri->toString());
$mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
if (K2_JVERSION == '15') {
$mainframe->redirect('index.php?option=com_user&view=login&return=' . $return . '&tmpl=component');
} else {
$mainframe->redirect('index.php?option=com_users&view=login&return=' . $return . '&tmpl=component');
}
}
switch ($task) {
case 'add':
if (!K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
break;
case 'edit':
case 'deleteAttachment':
case 'checkin':
$cid = JRequest::getInt('cid');
if (!$cid) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item = JTable::getInstance('K2Item', 'Table');
$item->load($cid);
if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
break;
case 'save':
$cid = JRequest::getInt('id');
if ($cid) {
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item = JTable::getInstance('K2Item', 'Table');
$item->load($cid);
if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
} else {
if (!K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
break;
case 'tag':
if (!K2HelperPermissions::canAddTag()) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
break;
case 'extraFields':
if (!K2HelperPermissions::canRenderExtraFields()) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
break;
}
}
示例9: prepareItem
function prepareItem($item, $view, $task)
{
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$limitstart = JRequest::getInt('limitstart');
$application = JFactory::getApplication();
//Initialize params
if ($view != 'item') {
if (K2_JVERSION == '30') {
$params = $application->getParams('com_k2');
} else {
$component = JComponentHelper::getComponent('com_k2');
$params = class_exists('JParameter') ? new JParameter($component->params) : new JRegistry($component->params);
$itemid = JRequest::getInt('Itemid');
if ($itemid) {
$menu = $application->getMenu();
$menuparams = $menu->getParams($itemid);
$params->merge($menuparams);
}
}
} else {
$params = K2HelperUtilities::getParams('com_k2');
}
//Category
$db = JFactory::getDBO();
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
$item->category = $category;
$item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
$item->link = urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
//Params
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
$iparams = class_exists('JParameter') ? new JParameter($item->params) : new JRegistry($item->params);
$item->params = version_compare(PHP_VERSION, '5.0.0', '>=') ? clone $params : $params;
if ($cparams->get('inheritFrom')) {
$masterCategoryID = $cparams->get('inheritFrom');
$masterCategory = JTable::getInstance('K2Category', 'Table');
$masterCategory->load((int) $masterCategoryID);
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
}
//Tags
if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
$tags = $this->getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags = $tags;
}
//Image
$item->imageXSmall = '';
$item->imageSmall = '';
$item->imageMedium = '';
$item->imageLarge = '';
$item->imageXLarge = '';
$date = JFactory::getDate($item->modified);
$timestamp = '?t=' . $date->toUnix();
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
if ($params->get('imageTimestamp')) {
$item->imageXSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
if ($params->get('imageTimestamp')) {
$item->imageSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
if ($params->get('imageTimestamp')) {
$item->imageMedium .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
if ($params->get('imageTimestamp')) {
$item->imageLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
if ($params->get('imageTimestamp')) {
$item->imageXLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
if ($params->get('imageTimestamp')) {
$item->imageGeneric .= $timestamp;
//.........这里部分代码省略.........
示例10: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$view = JRequest::getCmd('view');
jimport('joomla.filesystem.file');
jimport('joomla.html.pane');
JHTML::_('behavior.keepalive');
JHTML::_('behavior.modal');
JRequest::setVar('hidemainmenu', 1);
$document = JFactory::getDocument();
$document->addScript(JURI::root(true) . '/media/k2/assets/js/nicEdit.js?v=2.6.8');
//var K2SitePath = '".JURI::root(true)."/';
$js = "\n\t\t\t\t\tvar K2BasePath = '" . JURI::base(true) . "/';\n\t\t\t\t\tvar K2Language = [\n\t\t\t\t\t\t'" . JText::_('K2_REMOVE', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_LINK_TITLE_OPTIONAL', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_LINK_TITLE_ATTRIBUTE_OPTIONAL', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_ARE_YOU_SURE', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_OR_SELECT_A_FILE_ON_THE_SERVER', true) . "'\n\t\t\t\t\t]\n\t\t\t\t";
$document->addScriptDeclaration($js);
K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$model = K2Model::getInstance('Item', 'K2Model', array('table_path' => JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'));
$item = $model->getData();
JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, array('video', 'params', 'plugins'));
$user = JFactory::getUser();
// Permissions check on frontend
if ($mainframe->isSite()) {
JLoader::register('K2HelperPermissions', JPATH_COMPONENT . DS . 'helpers' . DS . 'permissions.php');
$task = JRequest::getCmd('task');
if ($task == 'edit' && !K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
if ($task == 'add' && !K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
// Get permissions
$K2Permissions = K2Permissions::getInstance();
$this->assignRef('permissions', $K2Permissions->permissions);
// Build permissions message
$permissionsLabels = array();
if ($this->permissions->get('add')) {
$permissionsLabels[] = JText::_('K2_ADD_ITEMS');
}
if ($this->permissions->get('editOwn')) {
$permissionsLabels[] = JText::_('K2_EDIT_OWN_ITEMS');
}
if ($this->permissions->get('editAll')) {
$permissionsLabels[] = JText::_('K2_EDIT_ANY_ITEM');
}
if ($this->permissions->get('publish')) {
$permissionsLabels[] = JText::_('K2_PUBLISH_ITEMS');
}
if ($this->permissions->get('editPublished')) {
$permissionsLabels[] = JText::_('K2_ALLOW_EDITING_OF_ALREADY_PUBLISHED_ITEMS');
}
$permissionsMessage = JText::_('K2_YOU_ARE_ALLOWED_TO') . ' ' . implode(', ', $permissionsLabels);
$this->assignRef('permissionsMessage', $permissionsMessage);
}
if ($item->isCheckedOut($user->get('id'), $item->checked_out)) {
$message = JText::_('K2_THE_ITEM') . ': ' . $item->title . ' ' . JText::_('K2_IS_CURRENTLY_BEING_EDITED_BY_ANOTHER_ADMINISTRATOR');
$url = $mainframe->isSite() ? 'index.php?option=com_k2&view=item&id=' . $item->id . '&tmpl=component' : 'index.php?option=com_k2';
$mainframe->enqueueMessage($message);
$mainframe->redirect($url);
}
if ($item->id) {
$item->checkout($user->get('id'));
} else {
$item->published = 1;
$item->publish_down = $db->getNullDate();
$item->modified = $db->getNullDate();
$date = JFactory::getDate();
$now = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql();
$item->created = $now;
$item->publish_up = $item->created;
}
$lists = array();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$dateFormat = 'Y-m-d H:i:s';
} else {
$dateFormat = '%Y-%m-%d %H:%M:%S';
}
$created = $item->created;
$publishUp = $item->publish_up;
$publishDown = $item->publish_down;
$created = JHTML::_('date', $item->created, $dateFormat);
$publishUp = JHTML::_('date', $item->publish_up, $dateFormat);
if ((int) $item->publish_down) {
$publishDown = JHTML::_('date', $item->publish_down, $dateFormat);
} else {
$publishDown = '';
}
// Set up calendars
$lists['createdCalendar'] = JHTML::_('calendar', $created, 'created', 'created');
$lists['publish_up'] = JHTML::_('calendar', $publishUp, 'publish_up', 'publish_up');
$lists['publish_down'] = JHTML::_('calendar', $publishDown, 'publish_down', 'publish_down');
if ($item->id) {
$lists['created'] = JHTML::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
} else {
$lists['created'] = JText::_('K2_NEW_DOCUMENT');
}
if ($item->modified == $db->getNullDate() || !$item->id) {
$lists['modified'] = JText::_('K2_NEVER');
} else {
$lists['modified'] = JHTML::_('date', $item->modified, JText::_('DATE_FORMAT_LC2'));
}
//.........这里部分代码省略.........
示例11: checkPermissions
function checkPermissions()
{
$view = JRequest::getCmd('view');
if ($view != 'item') {
return;
}
$task = JRequest::getCmd('task');
switch ($task) {
case 'add':
if (!K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
break;
case 'edit':
case 'deleteAttachment':
case 'checkin':
$cid = JRequest::getInt('cid');
if (!$cid) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item =& JTable::getInstance('K2Item', 'Table');
$item->load($cid);
if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
break;
case 'save':
$cid = JRequest::getInt('id');
if ($cid) {
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item =& JTable::getInstance('K2Item', 'Table');
$item->load($cid);
if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
} else {
if (!K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
}
break;
case 'tag':
if (!K2HelperPermissions::canAddTag()) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
break;
case 'extraFields':
if (!K2HelperPermissions::canRenderExtraFields()) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
break;
}
}
示例12: users
function users()
{
$itemID = JRequest::getInt('itemID');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$item =& JTable::getInstance('K2Item', 'Table');
$item->load($itemID);
if (!K2HelperPermissions::canAddItem() && !K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$K2Permissions =& K2Permissions::getInstance();
if (!$K2Permissions->permissions->get('editAll')) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
JRequest::setVar('tmpl', 'component');
$mainframe =& JFactory::getApplication();
$params =& JComponentHelper::getParams('com_k2');
$language =& JFactory::getLanguage();
$language->load('com_k2', JPATH_ADMINISTRATOR);
$document =& JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
JHtml::_('behavior.framework');
} else {
JHTML::_('behavior.mootools');
}
// CSS
$document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.5.7');
// JS
$jQueryHandling = $params->get('jQueryHandling', '1.7remote');
if ($jQueryHandling && strpos($jQueryHandling, 'remote') == true) {
$document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/' . str_replace('remote', '', $jQueryHandling) . '/jquery.min.js');
$document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
} elseif ($jQueryHandling && strpos($jQueryHandling, 'remote') == false) {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-' . $jQueryHandling . '.min.js');
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-ui-1.8.16.custom.min.js');
}
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.5.7');
$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views');
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$view =& $this->getView('users', 'html');
$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'users' . DS . 'tmpl');
$view->setLayout('element');
$view->display();
}
示例13: ucfirst
if ($task == 'create') {
if ($isNew && !K2HelperPermissions::canAddItem()) {
$canAccess = false;
}
if (!$isNew && !K2HelperPermissions::canEditItem($row->created_by, $row->catid)) {
$canAccess = false;
}
} else {
$canAccess = false;
}
} else {
if ($view == 'gallery') {
if ($isNew && !K2HelperPermissions::canAddItem()) {
$canAccess = false;
}
if (!$isNew && !K2HelperPermissions::canEditItem($row->created_by, $row->catid)) {
$canAccess = false;
}
}
}
if (!$canAccess) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
$application->redirect('index.php');
}
}
// Bootstrap
if (JFile::exists(JPATH_COMPONENT_ADMINISTRATOR . '/controllers/' . $view . '.php')) {
JRequest::setVar('view', $view);
require_once JPATH_COMPONENT_ADMINISTRATOR . '/controllers/' . $view . '.php';
$class = 'SigProController' . ucfirst($view);
$controller = new $class();
示例14: edit
function edit()
{
$mainframe =& JFactory::getApplication();
jimport('joomla.filesystem.file');
jimport('joomla.html.pane');
$db =& JFactory::getDBO();
JHTML::_('behavior.mootools');
$document =& JFactory::getDocument();
$document->addScript(JURI::root() . 'administrator/components/com_k2/lib/Autocompleter.js');
$document->addScript(JURI::root() . 'administrator/components/com_k2/lib/observer.js');
$document->addScript(JURI::root() . 'administrator/components/com_k2/lib/simpletabs_1.3.js');
//$document->addScript(JURI::root().'administrator/components/com_k2/js/k2.js'); // Core JS
$document->addScript(JURI::root() . 'administrator/components/com_k2/js/k2.mootools.js');
// Mootools based JS
$document->addCustomTag('
<!-- K2 by JoomlaWorks (start) -->
<!-- Load Khepri styling -->
<link rel="stylesheet" href="' . JURI::root() . 'administrator/templates/system/css/system.css" type="text/css" />
<link href="' . JURI::root() . 'administrator/templates/khepri/css/template.css" rel="stylesheet" type="text/css" />
<!--[if IE 7]>
<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if lte IE 6]>
<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="' . JURI::root() . 'administrator/templates/khepri/css/rounded.css" />
<!-- Load K2 styling -->
<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2.css" rel="stylesheet" type="text/css" />
<!--[if IE 7]>
<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if lte IE 6]>
<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!-- K2 by JoomlaWorks (end) -->
');
JRequest::setVar('tmpl', 'component');
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.php';
$model = new K2ModelItem();
$task = JRequest::getCmd('task');
$user =& JFactory::getUser();
if ($task == 'edit') {
$item = $model->getData();
JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, 'video');
if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
if (JTable::isCheckedOut($user->get('id'), $item->checked_out)) {
$msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->title);
$mainframe->redirect('index.php?option=com_k2&view=item&id=' . $item->id . '&tmpl=component', $msg);
}
} elseif ($task == 'add') {
if (!K2HelperPermissions::canAddItem()) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
$item =& JTable::getInstance('K2Item', 'Table');
$createdate =& JFactory::getDate();
$item->published = 1;
$item->publish_up = $createdate->toUnix();
$item->publish_down = JText::_('Never');
$item->created = $createdate->toUnix();
$item->modified = $db->getNullDate();
}
if ($item->id) {
$item->checkout($user->get('id'));
}
$item->created = JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S');
$item->publish_up = JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S');
if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate()) {
$item->publish_down = JText::_('Never');
} else {
$item->publish_down = JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S');
}
$params =& JComponentHelper::getParams('com_k2');
$wysiwyg =& JFactory::getEditor();
if ($params->get("mergeEditors")) {
if (JString::strlen($item->fulltext) > 1) {
$textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext;
} else {
$textValue = $item->introtext;
}
$text = $wysiwyg->display('text', $textValue, '100%', '400', '40', '5', array('pagebreak'));
$this->assignRef('text', $text);
} else {
$introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
$this->assignRef('introtext', $introtext);
$fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
$this->assignRef('fulltext', $fulltext);
}
$lists = array();
$lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
$lists['access'] = JHTML::_('list.accesslevel', $item);
$query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}";
$lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query);
//.........这里部分代码省略.........