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


PHP K2HelperPermissions::canPublishItem方法代码示例

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


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

示例1: save


//.........这里部分代码省略.........
                     if ($K2Tag->check()) {
                         $K2Tag->published = 1;
                         if ($K2Tag->store()) {
                             $tagID = $K2Tag->id;
                         }
                     } else {
                         if ($K2Tag->name) {
                             $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($K2Tag->name);
                             $db->setQuery($query);
                             $tagID = $db->loadResult();
                         }
                     }
                     if ($tagID) {
                         $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
     } else {
         $tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
         if (count($tags)) {
             foreach ($tags as $tagID) {
                 $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     // If we are in front-end check publishing permissions properly.
     if ($front) {
         // New items require the "Publish items" permission.
         if ($isNew && $row->published && !K2HelperPermissions::canPublishItem($row->catid)) {
             $row->published = 0;
             $mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
         }
         // Existing items require either the "Publish items" or the "Allow editing of already published items" permission.
         if (!$isNew && $row->published) {
             $canEditPublished = $isAlreadyPublished && K2HelperPermissions::canEditPublished($row->catid);
             if (!K2HelperPermissions::canPublishItem($row->catid) && !$canEditPublished) {
                 $row->published = 0;
                 $mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
             }
         }
         // If user has cannot publish the item then also cannot make it featured
         if (!K2HelperPermissions::canPublishItem($row->catid)) {
             if ($isNew) {
                 $row->featured = 0;
             } else {
                 $row->featured = $currentFeaturedState;
             }
         }
     }
     $query = "UPDATE #__k2_items SET \n        video_caption = " . $db->Quote($row->video_caption) . ", \n        video_credits = " . $db->Quote($row->video_credits) . ", ";
     if (!is_null($row->video)) {
         $query .= " video = " . $db->Quote($row->video) . ", ";
     }
     if (!is_null($row->gallery)) {
         $query .= " gallery = " . $db->Quote($row->gallery) . ", ";
     }
     $query .= " extra_fields = " . $db->Quote($row->extra_fields) . ", \n        extra_fields_search = " . $db->Quote($row->extra_fields_search) . " ,\n        published = " . $db->Quote($row->published) . " \n        WHERE id = " . $row->id;
     $db->setQuery($query);
     if (!$db->query()) {
         $mainframe->enqueueMessage($db->getErrorMsg(), 'error');
         $mainframe->redirect('index.php?option=com_k2&view=items');
开发者ID:educakanchay,项目名称:educa,代码行数:67,代码来源:item.php

示例2: save


//.........这里部分代码省略.........
                 $json = new Services_JSON();
                 $object->set('value', $json->decode(JRequest::getVar('K2CSV_' . $object->id)));
                 if (JRequest::getBool('K2ResetCSV_' . $object->id)) {
                     $object->set('value', null);
                 }
             }
             unset($object->_errors);
             $objects[] = $object;
         }
     }
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'JSON.php';
     $json = new Services_JSON();
     $row->extra_fields = $json->encode($objects);
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'extrafield.php';
     $extraFieldModel = new K2ModelExtraField();
     $row->extra_fields_search = '';
     foreach ($objects as $object) {
         $row->extra_fields_search .= $extraFieldModel->getSearchValue($object->id, $object->value);
         $row->extra_fields_search .= ' ';
     }
     //Tags
     if ($user->gid < 24 && $params->get('lockTags')) {
         $params->set('taggingSystem', 0);
     }
     $db =& JFactory::getDBO();
     $query = "DELETE FROM #__k2_tags_xref WHERE itemID={intval({$row->id})}";
     $db->setQuery($query);
     $db->query();
     if ($params->get('taggingSystem')) {
         if ($user->gid < 24 && $params->get('lockTags')) {
             JError::raiseError(403, JText::_("ALERTNOTAUTH"));
         }
         $tags = JRequest::getVar('tags', NULL, 'POST', 'array');
         if (count($tags)) {
             $tags = array_unique($tags);
             foreach ($tags as $tag) {
                 $tag = str_replace('-', '', $tag);
                 $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($tag);
                 $db->setQuery($query);
                 $tagID = $db->loadResult();
                 if ($tagID) {
                     $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                     $db->setQuery($query);
                     $db->query();
                 } else {
                     $K2Tag =& JTable::getInstance('K2Tag', 'Table');
                     $K2Tag->name = $tag;
                     $K2Tag->published = 1;
                     $K2Tag->check();
                     $K2Tag->store();
                     $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$K2Tag->id})}, {intval({$row->id})})";
                     $db->setQuery($query);
                     $db->query();
                 }
             }
         }
     } else {
         $tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
         if (count($tags)) {
             foreach ($tags as $tagID) {
                 $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     if ($front) {
         if (!K2HelperPermissions::canPublishItem($row->catid) && $row->published == 1) {
             $row->published = 0;
             $mainframe->enqueueMessage(JText::_("You don't have the permission to publish items."), 'notice');
         }
     }
     if (!$row->store()) {
         $mainframe->redirect('index.php?option=com_k2&view=items', $row->getError(), 'error');
     }
     $row->checkin();
     $cache =& JFactory::getCache('com_k2');
     $cache->clean();
     $dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
     switch (JRequest::getCmd('task')) {
         case 'apply':
             $msg = JText::_('Changes to Item saved');
             $link = 'index.php?option=com_k2&view=item&cid=' . $row->id;
             break;
         case 'saveAndNew':
             $msg = JText::_('Item saved');
             $link = 'index.php?option=com_k2&view=item';
             break;
         case 'save':
         default:
             $msg = JText::_('Item Saved');
             if ($front) {
                 $link = 'index.php?option=com_k2&view=item&task=edit&cid=' . $row->id . '&tmpl=component';
             } else {
                 $link = 'index.php?option=com_k2&view=items';
             }
             break;
     }
     $mainframe->redirect($link, $msg);
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:101,代码来源:item.php

示例3: save


//.........这里部分代码省略.........
            }
        }

        require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
        $json = new Services_JSON;
        $row->extra_fields = $json->encode($objects);

        $row->extra_fields_search = '';

        foreach ($objects as $object)
        {
            $row->extra_fields_search .= $this->getSearchValue($object->id, $object->value);
            $row->extra_fields_search .= ' ';
        }

        $query = "DELETE FROM #__k2_tags_xref WHERE itemID={intval($row->id)}";
        $db->setQuery($query);
        $db->query();

        $tags = JRequest::getVar('tags', NULL, 'POST', 'array');
        if (count($tags))
        {
            $tags = array_unique($tags);
            foreach ($tags as $tag)
            {
                $tag = JString::str_ireplace('-', '', $tag);
                $query = "SELECT id FROM #__k2_tags WHERE name=".$db->Quote($tag);
                $db->setQuery($query);
                $tagID = $db->loadResult();
                if ($tagID)
                {
                    $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval($tagID)}, {intval($row->id)})";
                    $db->setQuery($query);
                    $db->query();
                }
                else
                {
                    $K2Tag = JTable::getInstance('K2Tag', 'Table');
                    $K2Tag->name = $tag;
                    $K2Tag->published = 1;
                    $K2Tag->check();
                    $K2Tag->store();
                    $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval($K2Tag->id)}, {intval($row->id)})";
                    $db->setQuery($query);
                    $db->query();
                }
            }
        }

        $files = JRequest::get('files');

        //Image
        if ((int)$params->get('imageMemoryLimit'))
        {
            ini_set('memory_limit', (int)$params->get('imageMemoryLimit').'M');
        }

        if ($front)
        {
            if (!K2HelperPermissions::canPublishItem($row->catid) && $row->published)
            {
                $row->published = 0;
                $this->setError(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'));
            }
        }

        $query = "UPDATE #__k2_items SET video_caption = ".$db->Quote($row->video_caption).", video_credits = ".$db->Quote($row->video_credits).", ";

        if (!is_null($row->video))
        {
            $query .= " video = ".$db->Quote($row->video).", ";
        }
        if (!is_null($row->gallery))
        {
            $query .= " gallery = ".$db->Quote($row->gallery).", ";
        }
        $query .= " extra_fields = ".$db->Quote($row->extra_fields).", extra_fields_search = ".$db->Quote($row->extra_fields_search)." , published = ".$db->Quote($row->published)." WHERE id = ".$row->id;
        $db->setQuery($query);

        if (!$db->query())
        {
            $this->setError($db->getErrorMsg());
            return false;
        }

        $row->checkin();

        $cache = JFactory::getCache('com_k2');
        $cache->clean();

        //$dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
        $dispatcher->trigger('onContentAfterSave', array(&$row, $isNew));

        //Trigger the finder after save event
        $dispatcher = JDispatcher::getInstance();
        JPluginHelper::importPlugin('finder');
        $results = $dispatcher->trigger('onFinderAfterSave', array('com_k2.item', $row, $isNew));

        return $row->id;
    }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:101,代码来源:item.php

示例4: save


//.........这里部分代码省略.........
             $filename = JFile::stripExt($files['video']['name']);
             JFile::upload($files['video']['tmp_name'], $savepath . DS . $row->id . '.' . $filetype);
             $filetype = JFile::getExt($files['video']['name']);
             $row->video = '{' . $filetype . '}' . $row->id . '{/' . $filetype . '}';
         } else {
             if (JRequest::getVar('remoteVideo')) {
                 $fileurl = JRequest::getVar('remoteVideo');
                 $filetype = JFile::getExt($fileurl);
                 $row->video = '{' . $filetype . 'remote}' . $fileurl . '{/' . $filetype . 'remote}';
             }
             if (JRequest::getVar('videoID')) {
                 $provider = JRequest::getWord('videoProvider');
                 $videoID = JRequest::getVar('videoID');
                 $row->video = '{' . $provider . '}' . $videoID . '{/' . $provider . '}';
             }
             if (JRequest::getVar('embedVideo', '', 'post', 'string', JREQUEST_ALLOWRAW)) {
                 $row->video = JRequest::getVar('embedVideo', '', 'post', 'string', JREQUEST_ALLOWRAW);
             }
         }
     } else {
         $current =& JTable::getInstance('K2Item', 'Table');
         $current->load($row->id);
         preg_match_all("#^{(.*?)}(.*?){#", $current->video, $matches, PREG_PATTERN_ORDER);
         $videotype = $matches[1][0];
         $videofile = $matches[2][0];
         if (in_array($videotype, $videoExtensions)) {
             if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'videos' . DS . $videofile . '.' . $videotype)) {
                 JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'videos' . DS . $videofile . '.' . $videotype);
             }
         }
         if (in_array($videotype, $audioExtensions)) {
             if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'audio' . DS . $videofile . '.' . $videotype)) {
                 JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'audio' . DS . $videofile . '.' . $videotype);
             }
         }
         $row->video = '';
         $row->video_caption = '';
         $row->video_credits = '';
     }
     //Tags
     if (@$user->gid < 24 && $params->get('lockTags')) {
         $params->set('taggingSystem', 0);
     }
     $db =& JFactory::getDBO();
     $query = "DELETE FROM #__k2_tags_xref WHERE itemID={intval({$row->id})}";
     $db->setQuery($query);
     $db->query();
     if ($params->get('taggingSystem')) {
         if (@$user->gid < 24 && $params->get('lockTags')) {
             JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
         }
         $tags = JRequest::getVar('tags', NULL, 'POST', 'array');
         if (count($tags)) {
             $tags = array_unique($tags);
             foreach ($tags as $tag) {
                 $tag = str_replace('-', '', $tag);
                 $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($tag);
                 $db->setQuery($query);
                 $tagID = $db->loadResult();
                 if ($tagID) {
                     $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                     $db->setQuery($query);
                     $db->query();
                 } else {
                     $K2Tag =& JTable::getInstance('K2Tag', 'Table');
                     $K2Tag->name = $tag;
                     $K2Tag->published = 1;
                     $K2Tag->check();
                     $K2Tag->store();
                     $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$K2Tag->id})}, {intval({$row->id})})";
                     $db->setQuery($query);
                     $db->query();
                 }
             }
         }
     } else {
         $tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
         if (count($tags)) {
             foreach ($tags as $tagID) {
                 $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     if ($front) {
         if (!K2HelperPermissions::canPublishItem($row->catid) && $row->published) {
             $row->published = 0;
             $mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
         }
     }
     if (!$row->store()) {
         $this->setError($row->getError());
         return false;
     }
     $cache =& JFactory::getCache('com_k2');
     $cache->clean();
     $dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
     return $row;
 }
开发者ID:rcorral,项目名称:com_jm-plugins,代码行数:101,代码来源:item.php


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