当前位置: 首页>>代码示例>>PHP>>正文


PHP K2HelperPermissions::canAddItem方法代码示例

本文整理汇总了PHP中K2HelperPermissions::canAddItem方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperPermissions::canAddItem方法的具体用法?PHP K2HelperPermissions::canAddItem怎么用?PHP K2HelperPermissions::canAddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在K2HelperPermissions的用法示例。


在下文中一共展示了K2HelperPermissions::canAddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProfile

    public static function getProfile(&$params)
    {

        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $query = "SELECT * FROM #__k2_users  WHERE userID=".(int)$user->id;
        $db->setQuery($query, 0, 1);
        $profile = $db->loadObject();

        if ($profile)
        {
            if ($profile->image != '')
                $profile->avatar = JURI::root().'media/k2/users/'.$profile->image;

            require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'permissions'.'.php');

            if (JRequest::getCmd('option') != 'com_k2')
                K2HelperPermissions::setPermissions();

            if (K2HelperPermissions::canAddItem())
                $profile->addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');

            return $profile;

        }

    }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:27,代码来源:helper.php

示例2: display

 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $params = K2HelperUtilities::getParams('com_k2');
     $model = $this->getModel('itemlist');
     $limitstart = JRequest::getInt('limitstart');
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     $db = JFactory::getDBO();
     // Add link
     if (K2HelperPermissions::canAddItem()) {
         $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
     }
     $this->assignRef('addLink', $addLink);
     // Get data depending on task
     switch ($task) {
         case 'category':
             // Get category
             $id = JRequest::getInt('id');
             JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
             $category = JTable::getInstance('K2Category', 'Table');
             $category->load($id);
             $category->event = new stdClass();
             // State check
             if (!$category->published || $category->trash) {
                 JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
             }
             // Access check
             $user = JFactory::getUser();
             if (K2_JVERSION != '15') {
                 if (!in_array($category->access, $user->getAuthorisedViewLevels())) {
                     if ($user->guest) {
                         $uri = JFactory::getURI();
                         $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
                         $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
                     } else {
                         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                         return;
                     }
                 }
                 $languageFilter = $mainframe->getLanguageFilter();
                 $languageTag = JFactory::getLanguage()->getTag();
                 if ($languageFilter && $category->language != $languageTag && $category->language != '*') {
                     return;
                 }
             } else {
                 if ($category->access > $user->get('aid', 0)) {
                     if ($user->guest) {
                         $uri = JFactory::getURI();
                         $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
                         $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
                     } else {
                         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                         return;
                     }
                 }
             }
             // Hide the add new item link if user cannot post in the specific category
             if (!K2HelperPermissions::canAddItem($id)) {
                 unset($this->addLink);
             }
             // Merge params
             $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
             // Get the meta information before merging params since we do not want them to be inherited
             $category->metaDescription = $cparams->get('catMetaDesc');
             $category->metaKeywords = $cparams->get('catMetaKey');
             $category->metaRobots = $cparams->get('catMetaRobots');
             $category->metaAuthor = $cparams->get('catMetaAuthor');
             if ($cparams->get('inheritFrom')) {
                 $masterCategory = JTable::getInstance('K2Category', 'Table');
                 $masterCategory->load($cparams->get('inheritFrom'));
                 $cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
             }
             $params->merge($cparams);
             // Category link
             $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
             // Category image
             $category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
             // Category plugins
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $category->text = $category->description;
             if (K2_JVERSION != '15') {
                 $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
             } else {
                 $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
             }
             $category->description = $category->text;
             // Category K2 plugins
             $category->event->K2CategoryDisplay = '';
             JPluginHelper::importPlugin('k2');
             $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
             $category->event->K2CategoryDisplay = trim(implode("\n", $results));
             $category->text = $category->description;
             $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
             $category->description = $category->text;
             $this->assignRef('category', $category);
             $this->assignRef('user', $user);
             // Category children
             $ordering = $params->get('subCatOrdering');
//.........这里部分代码省略.........
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:101,代码来源:view.html.php

示例3: display

 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $params = K2HelperUtilities::getParams('com_k2');
     $limitstart = JRequest::getInt('limitstart', 0);
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     $db = JFactory::getDBO();
     $jnow = JFactory::getDate();
     $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
     $nullDate = $db->getNullDate();
     $this->setLayout('item');
     // Add link
     if (K2HelperPermissions::canAddItem()) {
         $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
     }
     $this->assignRef('addLink', $addLink);
     // Get item
     $model = $this->getModel();
     $item = $model->getData();
     $item->event = new stdClass();
     // Does the item exists?
     if (!is_object($item) || !$item->id) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     // Prepare item
     $item = $model->prepareItem($item, $view, $task);
     // Plugins
     $item = $model->execPlugins($item, $view, $task);
     // User K2 plugins
     $item->event->K2UserDisplay = '';
     if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('k2');
         $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
         $item->event->K2UserDisplay = trim(implode("\n", $results));
         $item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8');
     }
     // Access check
     if ($this->getLayout() == 'form') {
         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
     }
     if (K2_JVERSION != '15') {
         if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) {
             if ($user->guest) {
                 $uri = JFactory::getURI();
                 $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
                 $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                 $mainframe->redirect(JRoute::_($url, false));
             } else {
                 JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 return;
             }
         }
     } else {
         if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
             if ($user->guest) {
                 $uri = JFactory::getURI();
                 $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
                 $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                 $mainframe->redirect(JRoute::_($url, false));
             } else {
                 JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 return;
             }
         }
     }
     // Published check
     if (!$item->published || $item->trash) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if ($item->publish_up != $nullDate && $item->publish_up > $now) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if ($item->publish_down != $nullDate && $item->publish_down < $now) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if (!$item->category->published || $item->category->trash) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     // Increase hits counter
     $model->hit($item->id);
     // Set default image
     K2HelperUtilities::setDefaultImage($item, $view);
     // Comments
     $item->event->K2CommentsCounter = '';
     $item->event->K2CommentsBlock = '';
     if ($item->params->get('itemComments')) {
         // Trigger comments events
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('k2');
         $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart));
         $item->event->K2CommentsCounter = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart));
         $item->event->K2CommentsBlock = trim(implode("\n", $results));
         // Load K2 native comments system only if there are no plugins overriding it
         if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) {
             $limit = $params->get('commentsLimit');
//.........这里部分代码省略.........
开发者ID:emavro,项目名称:k2,代码行数:101,代码来源:view.raw.php

示例4: display

 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $params =& K2HelperUtilities::getParams('com_k2');
     $model =& $this->getModel('itemlist');
     $limitstart = JRequest::getInt('limitstart');
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     //Add link
     if (K2HelperPermissions::canAddItem()) {
         $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
     }
     $this->assignRef('addLink', $addLink);
     //Get data depending on task
     switch ($task) {
         case 'category':
             //Get category
             $id = JRequest::getInt('id');
             JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
             $category =& JTable::getInstance('K2Category', 'Table');
             $category->load($id);
             // State Check
             if (!$category->published || $category->trash) {
                 JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
             }
             //Access check
             $user =& JFactory::getUser();
             if (K2_JVERSION == '16') {
                 if (!in_array($category->access, $user->authorisedLevels())) {
                     JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 }
                 $languageFilter = $mainframe->getLanguageFilter();
                 $languageTag = JFactory::getLanguage()->getTag();
                 if ($languageFilter && $category->language != $languageTag && $category->language != '*') {
                     return;
                 }
             } else {
                 if ($category->access > $user->get('aid', 0)) {
                     JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 }
             }
             // Hide the add new item link if user cannot post in the specific category
             if (!K2HelperPermissions::canAddItem($id)) {
                 unset($this->addLink);
             }
             //Merge params
             $cparams = new JParameter($category->params);
             if ($cparams->get('inheritFrom')) {
                 $masterCategory =& JTable::getInstance('K2Category', 'Table');
                 $masterCategory->load($cparams->get('inheritFrom'));
                 $cparams = new JParameter($masterCategory->params);
             }
             $params->merge($cparams);
             //Category link
             $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
             //Category image
             $category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
             //Category plugins
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $category->text = $category->description;
             if (K2_JVERSION == '16') {
                 $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
             } else {
                 $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
             }
             $category->description = $category->text;
             //Category K2 plugins
             $category->event->K2CategoryDisplay = '';
             JPluginHelper::importPlugin('k2');
             $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
             $category->event->K2CategoryDisplay = trim(implode("\n", $results));
             $category->text = $category->description;
             $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
             $category->description = $category->text;
             $this->assignRef('category', $category);
             $this->assignRef('user', $user);
             //Category children
             $ordering = $params->get('subCatOrdering');
             $children = $model->getCategoryFirstChildren($id, $ordering);
             if (count($children)) {
                 foreach ($children as $child) {
                     if ($params->get('subCatTitleItemCounter')) {
                         $child->numOfItems = $model->countCategoryItems($child->id);
                     }
                     $child->image = K2HelperUtilities::getCategoryImage($child->image, $params);
                     $child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id . ':' . urlencode($child->alias))));
                     $subCategories[] = $child;
                 }
                 $this->assignRef('subCategories', $subCategories);
             }
             //Set limit
             $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
             //Set featured flag
             JRequest::setVar('featured', $params->get('catFeaturedItems'));
             //Set layout
             $this->setLayout('category');
             //Set title
             $title = $category->name;
             // Set ordering
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:101,代码来源:view.raw.php

示例5: save

 function save($front = false)
 {
     $mainframe = JFactory::getApplication();
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'class.upload.php';
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $row = JTable::getInstance('K2Item', 'Table');
     $params = JComponentHelper::getParams('com_k2');
     $nullDate = $db->getNullDate();
     if (!$row->bind(JRequest::get('post'))) {
         $mainframe->enqueueMessage($row->getError(), 'error');
         $mainframe->redirect('index.php?option=com_k2&view=items');
     }
     if ($front && $row->id == NULL) {
         JLoader::register('K2HelperPermissions', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'permissions.php');
         if (!K2HelperPermissions::canAddItem($row->catid)) {
             $mainframe->enqueueMessage(JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY_SAVE_FAILED'), 'error');
             $mainframe->redirect('index.php?option=com_k2&view=item&task=add&tmpl=component');
         }
     }
     $isNew = $row->id ? false : true;
     // If we are in front-end and the item is not new we need to get it's current published state.
     if (!$isNew && $front) {
         $id = JRequest::getInt('id');
         $currentRow = JTable::getInstance('K2Item', 'Table');
         $currentRow->load($id);
         $isAlreadyPublished = $currentRow->published;
         $currentFeaturedState = $currentRow->featured;
     }
     if ($params->get('mergeEditors')) {
         $text = JRequest::getVar('text', '', 'post', 'string', 2);
         if ($params->get('xssFiltering')) {
             $filter = new JFilterInput(array(), array(), 1, 1, 0);
             $text = $filter->clean($text);
         }
         $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
         $tagPos = preg_match($pattern, $text);
         if ($tagPos == 0) {
             $row->introtext = $text;
             $row->fulltext = '';
         } else {
             list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2);
         }
     } else {
         $row->introtext = JRequest::getVar('introtext', '', 'post', 'string', 2);
         $row->fulltext = JRequest::getVar('fulltext', '', 'post', 'string', 2);
         if ($params->get('xssFiltering')) {
             $filter = new JFilterInput(array(), array(), 1, 1, 0);
             $row->introtext = $filter->clean($row->introtext);
             $row->fulltext = $filter->clean($row->fulltext);
         }
     }
     if ($row->id) {
         $datenow = JFactory::getDate();
         $row->modified = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
         $row->modified_by = $user->get('id');
     } else {
         $row->ordering = $row->getNextOrder("catid = {$row->catid} AND trash = 0");
         if ($row->featured) {
             $row->featured_ordering = $row->getNextOrder("featured = 1 AND trash = 0", 'featured_ordering');
         }
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($front) {
         $K2Permissions = K2Permissions::getInstance();
         if (!$K2Permissions->permissions->get('editAll')) {
             $row->created_by = $user->get('id');
         }
     }
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config = JFactory::getConfig();
     $tzoffset = K2_JVERSION == '30' ? $config->get('offset') : $config->getValue('config.offset');
     $date = JFactory::getDate($row->created, $tzoffset);
     $row->created = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql();
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date = JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql();
     if (trim($row->publish_down) == JText::_('K2_NEVER') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date = JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql();
     }
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
//.........这里部分代码省略.........
开发者ID:educakanchay,项目名称:educa,代码行数:101,代码来源:item.php

示例6: save

    public function save($item, $front = false)
    {

        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.archive');
        require_once (JPATH_ADMINISTRATOR.'/components/com_k2/lib/class.upload.php');
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        $row = JTable::getInstance('K2Item', 'Table');
        $params = JComponentHelper::getParams('com_k2');
        $nullDate = $db->getNullDate();

        if (!$row->bind($item))
        {
            $this->setError($row->getError());
            return false;
        }

        $row->catid = (int)$row->catid;

        if ($front && $row->id == NULL)
        {
            JLoader::register('K2HelperPermissions', JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'permissions.php');
            if (!K2HelperPermissions::canAddItem($row->catid))
            {
                $this->setError(JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY_SAVE_FAILED'));
                return false;
            }
        }

        ($row->id) ? $isNew = false : $isNew = true;

        if ($params->get('xssFiltering'))
        {
            $filter = new JFilterInput( array(), array(), 1, 1, 0);
            $item['articletext'] = $filter->clean($item['articletext']);
        }
        $pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
        $tagPos = preg_match($pattern, $item['articletext']);
        if ($tagPos == 0)
        {
            $row->introtext = $item['articletext'];
            $row->fulltext = '';
        }
        else
        {
            list($row->introtext, $row->fulltext) = preg_split($pattern, $item['articletext'], 2);
        }

        if ($row->id)
        {
            $datenow = JFactory::getDate();
            $row->modified = $datenow->toSql();
            $row->modified_by = $user->get('id');
        }
        else
        {
            $row->ordering = $row->getNextOrder("catid = {$row->catid} AND trash = 0");
            if ($row->featured)
                $row->featured_ordering = $row->getNextOrder("featured = 1 AND trash = 0", 'featured_ordering');
        }

        $row->created_by = $row->created_by ? $row->created_by : $user->get('id');

        if ($front)
        {
            $K2Permissions = K2Permissions::getInstance();
            if (!$K2Permissions->permissions->get('editAll'))
            {
                $row->created_by = $user->get('id');
            }
        }

        if ($row->created && strlen(trim($row->created)) <= 10)
        {
            $row->created .= ' 00:00:00';
        }

        $config = JFactory::getConfig();
        $tzoffset = $config->get('config.offset');
        $date = JFactory::getDate($row->created, $tzoffset);
        $row->created = $date->toSql();

        if (strlen(trim($row->publish_up)) <= 10)
        {
            $row->publish_up .= ' 00:00:00';
        }

        $date = JFactory::getDate($row->publish_up, $tzoffset);
        $row->publish_up = $date->toSql();

        if (trim($row->publish_down) == JText::_('K2_NEVER') || trim($row->publish_down) == '')
        {
            $row->publish_down = $nullDate;
        }
        else
        {
            if (strlen(trim($row->publish_down)) <= 10)
            {
//.........这里部分代码省略.........
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:101,代码来源:item.php

示例7: display

    function display($tpl = null)
    {
        $mainframe =& JFactory::getApplication();
        $user =& JFactory::getUser();
        $document =& JFactory::getDocument();
        $params =& K2HelperUtilities::getParams('com_k2');
        $limitstart = JRequest::getInt('limitstart', 0);
        $view = JRequest::getWord('view');
        $task = JRequest::getWord('task');
        $db =& JFactory::getDBO();
        $jnow =& JFactory::getDate();
        $now = $jnow->toMySQL();
        $nullDate = $db->getNullDate();
        $this->setLayout('item');
        // Add link
        if (K2HelperPermissions::canAddItem()) {
            $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
        }
        $this->assignRef('addLink', $addLink);
        // Get item
        $model =& $this->getModel();
        $item = $model->getData();
        // Does the item exists?
        if (!is_object($item) || !$item->id) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        // Prepare item
        $item = $model->prepareItem($item, $view, $task);
        // Plugins
        $item = $model->execPlugins($item, $view, $task);
        // User K2 plugins
        $item->event->K2UserDisplay = '';
        if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
            $dispatcher =& JDispatcher::getInstance();
            JPluginHelper::importPlugin('k2');
            $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
            $item->event->K2UserDisplay = trim(implode("\n", $results));
        }
        // Access check
        if ($this->getLayout() == 'form') {
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
        }
        if (K2_JVERSION == '16') {
            if (!in_array($item->access, $user->authorisedLevels()) || !in_array($item->category->access, $user->authorisedLevels())) {
                JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
            }
        } else {
            if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
                JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
            }
        }
        // Published check
        if (!$item->published || $item->trash) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if ($item->publish_up != $nullDate && $item->publish_up > $now) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if ($item->publish_down != $nullDate && $item->publish_down < $now) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if (!$item->category->published || $item->category->trash) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        // Increase hits counter
        $model->hit($item->id);
        // Set default image
        K2HelperUtilities::setDefaultImage($item, $view);
        // Comments
        $item->event->K2CommentsCounter = '';
        $item->event->K2CommentsBlock = '';
        if ($item->params->get('itemComments')) {
            // Trigger comments events
            $dispatcher =& JDispatcher::getInstance();
            JPluginHelper::importPlugin('k2');
            $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart));
            $item->event->K2CommentsCounter = trim(implode("\n", $results));
            $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart));
            $item->event->K2CommentsBlock = trim(implode("\n", $results));
            // Load K2 native comments system only if there are no plugins overriding it
            if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) {
                // Load reCAPTCHA script
                if (!JRequest::getInt('print') && ($item->params->get('comments') == '1' || $item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($item->catid))) {
                    if ($item->params->get('recaptcha') && $user->guest) {
                        $document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js');
                        $js = '
						function showRecaptcha(){
							Recaptcha.create("' . $item->params->get('recaptcha_public_key') . '", "recaptcha", {
								theme: "' . $item->params->get('recaptcha_theme', 'clean') . '"
							});
						}
						$K2(window).load(function() {
							showRecaptcha();
						});
						';
                        $document->addScriptDeclaration($js);
                    }
                }
                // Check for inline comment moderation
                if (!$user->guest && $user->id == $item->created_by && $params->get('inlineCommentsModeration')) {
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:101,代码来源:view.html.php

示例8: 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);
//.........这里部分代码省略.........
开发者ID:navinpai,项目名称:GEC-Tandav,代码行数:101,代码来源:view.html.php

示例9: display

 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $params =& JComponentHelper::getParams('com_k2');
     $model =& $this->getModel('itemlist');
     $limitstart = JRequest::getInt('limitstart');
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     //Add link
     if (K2HelperPermissions::canAddItem()) {
         $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
     }
     $this->assignRef('addLink', $addLink);
     //Get data depending on task
     switch ($task) {
         case 'category':
             //Get category
             $id = JRequest::getInt('id');
             JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
             $category =& JTable::getInstance('K2Category', 'Table');
             $category->load($id);
             //Access check
             $user =& JFactory::getUser();
             if ($category->access > $user->get('aid', 0)) {
                 JError::raiseError(403, JText::_("ALERTNOTAUTH"));
             }
             if (!$category->published || $category->trash) {
                 JError::raiseError(404, JText::_("Category not found"));
             }
             //Merge params
             $cparams = new JParameter($category->params);
             if ($cparams->get('inheritFrom')) {
                 $masterCategory =& JTable::getInstance('K2Category', 'Table');
                 $masterCategory->load($cparams->get('inheritFrom'));
                 $cparams = new JParameter($masterCategory->params);
             }
             $params->merge($cparams);
             //Category link
             $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
             //Category image
             if (!empty($category->image)) {
                 $category->image = JURI::root() . 'media/k2/categories/' . $category->image;
             } else {
                 if ($params->get('catImageDefault')) {
                     $category->image = JURI::root() . 'components/com_k2/images/placeholder/category.png';
                 }
             }
             //Category plugins
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $category->text = $category->description;
             $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
             $category->description = $category->text;
             //Category K2 plugins
             $category->event->K2CategoryDisplay = '';
             JPluginHelper::importPlugin('k2');
             $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
             $category->event->K2CategoryDisplay = trim(implode("\n", $results));
             $category->text = $category->description;
             $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
             $category->description = $category->text;
             $this->assignRef('category', $category);
             $this->assignRef('user', $user);
             //Category childs
             $ordering = $params->get('subCatOrdering');
             $childs = $model->getCategoryFirstChilds($id, $ordering);
             if (count($childs)) {
                 foreach ($childs as $child) {
                     if ($params->get('subCatTitleItemCounter')) {
                         $child->numOfItems = $model->countCategoryItems($child->id);
                     }
                     if (!empty($child->image)) {
                         $child->image = JURI::root() . 'media/k2/categories/' . $child->image;
                     } else {
                         if ($params->get('catImageDefault')) {
                             $child->image = JURI::root() . 'components/com_k2/images/placeholder/category.png';
                         }
                     }
                     $child->name = htmlspecialchars($child->name, ENT_QUOTES);
                     $child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id . ':' . urlencode($child->alias))));
                     $subCategories[] = $child;
                 }
                 $this->assignRef('subCategories', $subCategories);
             }
             //Set limit
             $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
             //Set featured flag
             JRequest::setVar('featured', $params->get('catFeaturedItems'));
             //Set layout
             $this->setLayout('category');
             //Set title
             $title = $category->name;
             $category->name = htmlspecialchars($category->name, ENT_QUOTES);
             break;
         case 'user':
             //Get user
             $id = JRequest::getInt('id');
             $user =& JFactory::getUser($id);
             //Check user status
             if ($user->block) {
//.........这里部分代码省略.........
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:101,代码来源:view.html.php

示例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'));
     }
//.........这里部分代码省略.........
开发者ID:Tommar,项目名称:remate,代码行数:101,代码来源:view.html.php

示例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;
     }
 }
开发者ID:navinpai,项目名称:GEC-Tandav,代码行数:54,代码来源:permissions.php

示例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();
 }
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:43,代码来源:item.php

示例13: display

    function display($tpl = null)
    {
        $mainframe = JFactory::getApplication();
        $user = JFactory::getUser();
        $document = JFactory::getDocument();
        $params = K2HelperUtilities::getParams('com_k2');
        $limitstart = JRequest::getInt('limitstart', 0);
        $view = JRequest::getWord('view');
        $task = JRequest::getWord('task');
        $db = JFactory::getDBO();
        $jnow = JFactory::getDate();
        $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
        $nullDate = $db->getNullDate();
        $this->setLayout('item');
        // Add link
        if (K2HelperPermissions::canAddItem()) {
            $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
        }
        $this->assignRef('addLink', $addLink);
        // Get item
        $model = $this->getModel();
        $item = $model->getData();
        // Does the item exists?
        if (!is_object($item) || !$item->id) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        // Prepare item
        $item = $model->prepareItem($item, $view, $task);
        // Plugins
        $item = $model->execPlugins($item, $view, $task);
        // User K2 plugins
        $item->event->K2UserDisplay = '';
        if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
            $dispatcher = JDispatcher::getInstance();
            JPluginHelper::importPlugin('k2');
            $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
            $item->event->K2UserDisplay = trim(implode("\n", $results));
            $item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8');
        }
        // Access check
        if ($this->getLayout() == 'form') {
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
        }
        if (K2_JVERSION != '15') {
            if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) {
                if ($user->guest) {
                    $uri = JFactory::getURI();
                    $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
                    $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                    $mainframe->redirect(JRoute::_($url, false));
                } else {
                    JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                    return;
                }
            }
        } else {
            if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
                if ($user->guest) {
                    $uri = JFactory::getURI();
                    $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
                    $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                    $mainframe->redirect(JRoute::_($url, false));
                } else {
                    JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                    return;
                }
            }
        }
        // Published check
        if (!$item->published || $item->trash) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if ($item->publish_up != $nullDate && $item->publish_up > $now) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if ($item->publish_down != $nullDate && $item->publish_down < $now) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        if (!$item->category->published || $item->category->trash) {
            JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
        }
        // Increase hits counter
        $model->hit($item->id);
        // Set default image
        K2HelperUtilities::setDefaultImage($item, $view);
        // Pass the old parameter to the view in order to avoid layout changes
        if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') {
            $params->set('recaptcha', true);
            $item->params->set('recaptcha', true);
        } else {
            $params->set('recaptcha', false);
            $item->params->set('recaptcha', false);
        }
        // Comments
        $item->event->K2CommentsCounter = '';
        $item->event->K2CommentsBlock = '';
        if ($item->params->get('itemComments')) {
            // Trigger comments events
            $dispatcher = JDispatcher::getInstance();
            JPluginHelper::importPlugin('k2');
//.........这里部分代码省略.........
开发者ID:emavro,项目名称:k2,代码行数:101,代码来源:view.html.php

示例14: save

 /**
  * This method is copied from admin/com_k2/models/item.php 
  * Modifications have been made
  * Changed all $mainframe redirects
  * Removed the check for extra fields, we don't want to override them
  */
 function save($front = false)
 {
     $mainframe =& JFactory::getApplication();
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     require_once JPATH_ADMINISTRATOR . '/components/com_k2' . DS . 'lib' . DS . 'class.upload.php';
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $row =& JTable::getInstance('K2Item', 'Table');
     $params =& JComponentHelper::getParams('com_k2');
     $nullDate = $db->getNullDate();
     if (!$row->bind(JRequest::get('post'))) {
         $this->setError($row->getError());
         return false;
     }
     if ($front && $row->id == NULL) {
         JLoader::register('K2HelperPermissions', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'permissions.php');
         if (!K2HelperPermissions::canAddItem($row->catid)) {
             $this->setError(JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY_SAVE_FAILED'));
             return false;
         }
     }
     $row->id ? $isNew = false : ($isNew = true);
     if ($params->get('mergeEditors')) {
         $text = JRequest::getVar('text', '', 'post', 'string', 2);
         if ($params->get('xssFiltering')) {
             $filter = new JFilterInput(array(), array(), 1, 1, 0);
             $text = $filter->clean($text);
         }
         $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
         $tagPos = preg_match($pattern, $text);
         if ($tagPos == 0) {
             $row->introtext = $text;
             $row->fulltext = '';
         } else {
             list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2);
         }
     } else {
         $row->introtext = JRequest::getVar('introtext', '', 'post', 'string', 2);
         $row->fulltext = JRequest::getVar('fulltext', '', 'post', 'string', 2);
         if ($params->get('xssFiltering')) {
             $filter = new JFilterInput(array(), array(), 1, 1, 0);
             $row->introtext = $filter->clean($row->introtext);
             $row->fulltext = $filter->clean($row->fulltext);
         }
     }
     if ($row->id) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     } else {
         $row->ordering = $row->getNextOrder("catid = {$row->catid} AND trash = 0");
         if ($row->featured) {
             $row->featured_ordering = $row->getNextOrder("featured = 1 AND trash = 0", 'featured_ordering');
         }
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($front) {
         $K2Permissions =& K2Permissions::getInstance();
         if (!$K2Permissions->permissions->get('editAll')) {
             $row->created_by = $user->get('id');
         }
     }
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date =& JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = $date->toMySQL();
     if (trim($row->publish_down) == JText::_('K2_NEVER') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
//.........这里部分代码省略.........
开发者ID:rcorral,项目名称:com_jm-plugins,代码行数:101,代码来源:item.php

示例15: is_null

    $row->load($folder);
    $isNew = is_null($row->id);
    if ($view == 'galleries') {
        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);
开发者ID:SeventF,项目名称:ikea.com,代码行数:31,代码来源:sigpro.php


注:本文中的K2HelperPermissions::canAddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。