當前位置: 首頁>>代碼示例>>PHP>>正文


PHP K2HelperPermissions::canEditPublished方法代碼示例

本文整理匯總了PHP中K2HelperPermissions::canEditPublished方法的典型用法代碼示例。如果您正苦於以下問題:PHP K2HelperPermissions::canEditPublished方法的具體用法?PHP K2HelperPermissions::canEditPublished怎麽用?PHP K2HelperPermissions::canEditPublished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在K2HelperPermissions的用法示例。


在下文中一共展示了K2HelperPermissions::canEditPublished方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save


//.........這裏部分代碼省略.........
                             $tagID = $K2Tag->id;
                         }
                     } else {
                         if ($K2Tag->name) {
                             $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($K2Tag->name);
                             $db->setQuery($query);
                             $tagID = $db->loadResult();
                         }
                     }
                     if ($tagID) {
                         $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
     } else {
         $tags = JRequest::getVar('selectedTags', NULL, 'POST', 'array');
         if (count($tags)) {
             foreach ($tags as $tagID) {
                 $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {intval({$tagID})}, {intval({$row->id})})";
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     // If we are in front-end check publishing permissions properly.
     if ($front) {
         // New items require the "Publish items" permission.
         if ($isNew && $row->published && !K2HelperPermissions::canPublishItem($row->catid)) {
             $row->published = 0;
             $mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
         }
         // Existing items require either the "Publish items" or the "Allow editing of already published items" permission.
         if (!$isNew && $row->published) {
             $canEditPublished = $isAlreadyPublished && K2HelperPermissions::canEditPublished($row->catid);
             if (!K2HelperPermissions::canPublishItem($row->catid) && !$canEditPublished) {
                 $row->published = 0;
                 $mainframe->enqueueMessage(JText::_('K2_YOU_DONT_HAVE_THE_PERMISSION_TO_PUBLISH_ITEMS'), 'notice');
             }
         }
         // If user has cannot publish the item then also cannot make it featured
         if (!K2HelperPermissions::canPublishItem($row->catid)) {
             if ($isNew) {
                 $row->featured = 0;
             } else {
                 $row->featured = $currentFeaturedState;
             }
         }
     }
     $query = "UPDATE #__k2_items SET \n        video_caption = " . $db->Quote($row->video_caption) . ", \n        video_credits = " . $db->Quote($row->video_credits) . ", ";
     if (!is_null($row->video)) {
         $query .= " video = " . $db->Quote($row->video) . ", ";
     }
     if (!is_null($row->gallery)) {
         $query .= " gallery = " . $db->Quote($row->gallery) . ", ";
     }
     $query .= " extra_fields = " . $db->Quote($row->extra_fields) . ", \n        extra_fields_search = " . $db->Quote($row->extra_fields_search) . " ,\n        published = " . $db->Quote($row->published) . " \n        WHERE id = " . $row->id;
     $db->setQuery($query);
     if (!$db->query()) {
         $mainframe->enqueueMessage($db->getErrorMsg(), 'error');
         $mainframe->redirect('index.php?option=com_k2&view=items');
     }
     $row->checkin();
     $cache = JFactory::getCache('com_k2');
     $cache->clean();
     $dispatcher->trigger('onAfterK2Save', array(&$row, $isNew));
     JPluginHelper::importPlugin('content');
     if (K2_JVERSION != '15') {
         $dispatcher->trigger('onContentAfterSave', array('com_k2.item', &$row, $isNew));
     } else {
         $dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));
     }
     //Trigger the finder after save event
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     $results = $dispatcher->trigger('onFinderAfterSave', array('com_k2.item', $row, $isNew));
     switch (JRequest::getCmd('task')) {
         case 'apply':
             $msg = JText::_('K2_CHANGES_TO_ITEM_SAVED');
             $link = 'index.php?option=com_k2&view=item&cid=' . $row->id;
             break;
         case 'saveAndNew':
             $msg = JText::_('K2_ITEM_SAVED');
             $link = 'index.php?option=com_k2&view=item';
             break;
         case 'save':
         default:
             $msg = JText::_('K2_ITEM_SAVED');
             if ($front) {
                 $link = 'index.php?option=com_k2&view=item&task=edit&cid=' . $row->id . '&tmpl=component&Itemid=' . JRequest::getInt('Itemid');
             } else {
                 $link = 'index.php?option=com_k2&view=items';
             }
             break;
     }
     $mainframe->enqueueMessage($msg);
     $mainframe->redirect($link);
 }
開發者ID:educakanchay,項目名稱:educa,代碼行數:101,代碼來源:item.php


注:本文中的K2HelperPermissions::canEditPublished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。