本文整理汇总了PHP中K2HelperPermissions类的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperPermissions类的具体用法?PHP K2HelperPermissions怎么用?PHP K2HelperPermissions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了K2HelperPermissions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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);
}
开发者ID:naka211,项目名称:malerfirmaet,代码行数:8,代码来源:tagsk2.php
示例3: 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
示例4: 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
示例5: comment
function comment()
{
$mainframe =& JFactory::getApplication();
jimport('joomla.mail.helper');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$params =& JComponentHelper::getParams('com_k2');
$user = JFactory::getUser();
$config =& JFactory::getConfig();
//Get item
$item =& JTable::getInstance('K2Item', 'Table');
$item->load(JRequest::getInt('itemID'));
//Get category
$category =& JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
//Access check
if ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
//Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_("Item not found"));
}
if (!$category->published || $category->trash) {
JError::raiseError(404, JText::_("Item not found"));
}
//Check permissions
if ($params->get('comments') == '2' && $user->id > 0 && K2HelperPermissions::canAddComment($item->catid) || $params->get('comments') == '1') {
$row =& JTable::getInstance('K2Comment', 'Table');
if (!$row->bind(JRequest::get('post'))) {
echo $row->getError();
$mainframe->close();
}
$row->commentText = JRequest::getString('commentText');
$datenow =& JFactory::getDate();
$row->commentDate = $datenow->toMySQL();
if (!$user->guest) {
$row->userID = $user->id;
$row->commentEmail = $user->email;
$row->userName = $user->name;
}
$userName = trim($row->userName);
$commentEmail = trim($row->commentEmail);
$commentText = trim($row->commentText);
$commentURL = trim($row->commentURL);
if (empty($userName) || $userName == JText::_('enter your name...') || empty($commentText) || $commentText == JText::_('enter your comment here...') || empty($commentEmail) || $commentEmail == JText::_('enter your e-mail address...')) {
echo JText::_('You need to fill in all required fields!');
$mainframe->close();
}
if (!JMailHelper::isEmailAddress($commentEmail)) {
echo JText::_('Invalid e-mail address!');
$mainframe->close();
}
if ($user->guest) {
$db =& JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__users WHERE name=" . $db->Quote($userName) . " OR email=" . $db->Quote($commentEmail);
$db->setQuery($query);
$result = $db->loadresult();
if ($result > 0) {
echo JText::_('The name or email address you typed is already in use!');
$mainframe->close();
}
}
if ($params->get('recaptcha')) {
require_once JPATH_COMPONENT . DS . 'lib' . DS . 'recaptchalib.php';
$privatekey = $params->get('recaptcha_private_key');
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
echo JText::_("The words you typed did not match the ones displayed. Please try again.");
$mainframe->close();
}
}
if ($commentURL == JText::_('enter your site URL...') || $commentURL == "") {
$row->commentURL = NULL;
} else {
if (substr($commentURL, 0, 7) != 'http://') {
$row->commentURL = 'http://' . $commentURL;
}
}
if ($params->get('commentsPublishing')) {
$row->published = 1;
} else {
$row->published = 0;
}
if (!$row->store()) {
echo $row->getError();
$mainframe->close();
}
if ($params->get('commentsPublishing')) {
if ($config->getValue('config.caching')) {
echo JText::_('Thank you. Your comment will be published shortly.');
} else {
echo '<span class="success">' . JText::_('Comment added! Refreshing page...') . '</span>';
}
} else {
echo JText::_('Comment added and waiting for approval.');
}
}
$mainframe->close();
}
开发者ID:navinpai,项目名称:GEC-Tandav,代码行数:99,代码来源:item.php
示例6: 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::_('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;
}
}
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:54,代码来源:permissions.php
示例7: 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
示例8: 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;
}
}
开发者ID:jamielaff,项目名称:als_resourcing,代码行数:101,代码来源:view.json.php
示例9: display
function display($tpl = null)
{
$mainframe =& JFactory::getApplication();
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
$params =& JComponentHelper::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();
//Prepare item
if ($user->guest) {
$cache =& JFactory::getCache('com_k2_extended');
$hits = $item->hits;
$item->hits = 0;
$item = $cache->call(array('K2ModelItem', 'prepareItem'), $item, $view, $task);
$item->hits = $hits;
} else {
$item = $model->prepareItem($item, $view, $task);
}
//Plugins
$item = $model->execPlugins($item, $view, $task);
//Access check
if ($this->getLayout() == 'form') {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
//Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_("Item not found"));
}
if ($item->publish_up != $nullDate && $item->publish_up > $now) {
JError::raiseError(404, JText::_("Item not found"));
}
if ($item->publish_down != $nullDate && $item->publish_down < $now) {
JError::raiseError(404, JText::_("Item not found"));
}
if (!$item->category->published || $item->category->trash) {
JError::raiseError(404, JText::_("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') . '"
});
}
window.addEvent(\'load\', function(){
showRecaptcha();
})';
$document->addScriptDeclaration($js);
}
//Auto complete some fields for registered users
if (!$user->guest) {
$js = "window.addEvent('domready', function(){\n\t\t\t\t\t\t\t\t\t\$('userName').setProperty('value','" . $user->name . "');\n\t\t\t\t\t\t\t\t\t\$('userName').setProperty('disabled','disabled');\n\t\t\t\t\t\t\t\t\t\$('commentEmail').setProperty('value','" . $user->email . "');\n\t\t\t\t\t\t\t\t\t\$('commentEmail').setProperty('disabled','disabled');\n\n\t\t\t\t\t\t\t\t})";
$document->addScriptDeclaration($js);
}
}
$limit = $params->get('commentsLimit');
$comments = $model->getItemComments($item->id, $limitstart, $limit);
$pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
for ($i = 0; $i < sizeof($comments); $i++) {
$comments[$i]->commentText = nl2br($comments[$i]->commentText);
$comments[$i]->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $comments[$i]->commentText);
$comments[$i]->userImage = K2HelperUtilities::getAvatar($comments[$i]->userID, $comments[$i]->commentEmail, $params->get('commenterImgWidth'));
if ($comments[$i]->userID > 0) {
$comments[$i]->userLink = K2HelperRoute::getUserRoute($comments[$i]->userID);
//.........这里部分代码省略.........
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:101,代码来源:view.raw.php
示例10: 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
示例11:
}
?>
</ul>
<div class="itemCommentsPagination">
<?php
echo $this->pagination->getPagesLinks();
?>
<div class="clr"></div>
</div>
<?php
}
?>
<?php
if ($this->item->params->get('commentsFormPosition') == 'below' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || $this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid))) {
?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php
echo $this->loadTemplate('comments_form');
?>
</div>
<?php
}
?>
<?php
$user = JFactory::getUser();
if ($this->item->params->get('comments') == '2' && $user->guest) {
?>
开发者ID:proyectoseb,项目名称:University,代码行数:31,代码来源:item.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: getCategoryChilds
function getCategoryChilds($catid)
{
static $array = array();
$user =& JFactory::getUser();
$aid = $user->get('aid');
$db =& JFactory::getDBO();
if ($catid == "all") {
$query = "SELECT * FROM #__k2_categories WHERE published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
} else {
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
}
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2HelperPermissions::hasChilds($row->id)) {
K2HelperPermissions::getCategoryChilds($row->id);
}
}
return $array;
}
开发者ID:navinpai,项目名称:GEC-Tandav,代码行数:21,代码来源:permissions.php
示例14: 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(&$it
|
请发表评论