本文整理汇总了PHP中cmsFramework::noAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::noAccess方法的具体用法?PHP cmsFramework::noAccess怎么用?PHP cmsFramework::noAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::noAccess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$this->EverywhereAfterFind = true;
// Triggers the afterFind in the Observer Model
$module_id = Sanitize::getVar($this->params, 'module_id', Sanitize::getVar($this->data, 'module_id'));
if (!Sanitize::getVar($this->params['module'], 'community')) {
cmsFramework::noAccess();
return;
}
$conditions = array();
$joins = array();
$order = array();
// Initialize variables
$id = Sanitize::getInt($this->params, 'id');
$option = Sanitize::getString($this->params, 'option');
$view = Sanitize::getString($this->params, 'view');
$task = Sanitize::getString($this->params, 'task');
$menu_id = Sanitize::getString($this->params, 'Itemid');
# Read module parameters
$extension = Sanitize::getString($this->params['module'], 'extension');
$user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
$limit = Sanitize::getInt($this->params['module'], 'module_limit', 5);
$total = min(50, Sanitize::getInt($this->params['module'], 'module_total', 10));
if (!$user_id && !$this->_user->id) {
cmsFramework::noAccess();
return;
}
$cat_id = Sanitize::getString($this->params['module'], 'category');
$listing_id = Sanitize::getString($this->params['module'], 'listing');
if ($extension == 'com_content') {
$dir_id = Sanitize::getString($this->params['module'], 'dir');
$section_id = Sanitize::getString($this->params['module'], 'section');
$criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
} else {
$dir_id = null;
$section_id = null;
$criteria_ids = null;
}
// This parameter determines the module mode
$sort = Sanitize::getString($this->params['module'], 'reviews_order');
# Remove unnecessary fields from model query
// $this->Review->modelUnbind();
!empty($extension) and $conditions[] = "Review.mode = '{$extension}'";
$conditions[] = "Review.userid = " . (int) $user_id;
# Set conditionals based on configuration parameters
if ($extension == 'com_content') {
// Only works for core articles
$conditions = array_merge($conditions, array('( Listing.publish_up = "' . NULL_DATE . '" OR DATE(Listing.publish_up) <= DATE("' . _CURRENT_SERVER_TIME . '") )', '( Listing.publish_down = "' . NULL_DATE . '" OR DATE(Listing.publish_down) >= DATE("' . _CURRENT_SERVER_TIME . '") )', 'Listing.catid > 0'));
if ($this->cmsVersion == CMS_JOOMLA15) {
// $conditions[] = 'Section.access <= ' . $this->Access->getAccessId();
$conditions[] = 'Category.access <= ' . $this->Access->getAccessId();
$conditions[] = 'Listing.access <= ' . $this->Access->getAccessId();
} else {
$conditions[] = 'Category.access IN (' . $this->Access->getAccessLevels() . ')';
$conditions[] = 'Listing.access IN ( ' . $this->Access->getAccessLevels() . ')';
}
$conditions[] = $this->Access->canEditListing() ? 'Listing.state >= 0' : 'Listing.state = 1';
!empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
!empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
if (!empty($cat_id)) {
$conditions[] = $this->cmsVersion == CMS_JOOMLA15 ? 'Listing.catid IN (' . $cat_id . ')' : 'ParentCategory.id IN (' . $cat_id . ')';
} else {
unset($this->Listing->joins['ParentCategory']);
}
} else {
if (Sanitize::getInt($this->params['module'], 'cat_auto') && method_exists($this->Listing, 'catUrlParam')) {
if ($cat_id = Sanitize::getInt($this->passedArgs, $this->Listing->catUrlParam())) {
$conditions[] = 'JreviewsCategory.id IN (' . $cat_id . ')';
}
} elseif ($cat_id) {
$conditions[] = 'JreviewsCategory.id IN (' . $cat_id . ')';
}
}
!empty($listing_id) and $conditions[] = "Review.pid IN ({$listing_id})";
$conditions[] = 'Review.published > 0';
switch ($sort) {
case 'latest':
$order[] = $this->Review->processSorting('rdate');
break;
case 'helpful':
$order[] = $this->Review->processSorting('helpful');
break;
case 'random':
srand((double) microtime() * 1000000);
$this->params['rand'] = rand();
$order[] = 'RAND(' . $this->params['rand'] . ')';
break;
default:
$order[] = $this->Review->processSorting('rdate');
break;
}
$queryData = array('fields' => array(), 'joins' => $joins, 'conditions' => $conditions, 'order' => $order, 'limit' => $total);
# Don't run it here because it's run in the Everywhere Observer Component
$this->Review->runProcessRatings = false;
// Excludes listing owner info in Everywhere component
$this->Review->controller = 'module_reviews';
$reviews = $this->Review->findAll($queryData);
$count = count($reviews);
# Send variables to view template
$this->set(array('module_id' => $module_id, 'reviews' => $reviews, 'total' => $count, 'limit' => $limit));
//.........这里部分代码省略.........
示例2: edit
function edit()
{
$this->autoRender = false;
$listing_id = Sanitize::getInt($this->params, 'id');
$sections = array();
$categories = array();
Configure::write('ListingEdit', true);
// Read in Fields model for PaidListings integration
$listing = $this->Listing->findRow(array('fields' => array('Listing.metakey AS `Listing.metakey`', 'Listing.metadesc AS `Listing.metadesc`'), 'conditions' => 'Listing.id = ' . $listing_id));
# Override global configuration
isset($listing['ListingType']) and $this->Config->override($listing['ListingType']['config']);
if (!$this->Access->canEditListing($listing['Listing']['user_id'])) {
cmsFramework::noAccess();
$this->autoRender = false;
return;
}
# Get listing custom fields
$listing_fields = $this->Field->getFieldsArrayNew($listing['Criteria']['criteria_id'], 'listing', $listing);
// Editors and above have access to the category/section editing functionality
$specialAccess = in_array($this->Access->gid, array(20, 21, 23, 24, 25));
// Show section/category lists if user is editor or above.
if ($specialAccess) {
// Limit sections/categories based on criteriaid of item being edited
$query = "SELECT id FROM #__jreviews_categories" . "\n WHERE criteriaid = '{$listing['Criteria']['criteria_id']}' AND `option` = 'com_content'";
$this->_db->setQuery($query);
$catids = implode(",", $this->_db->loadResultArray());
$sections = $this->Section->getList($catids);
$categories = $this->Category->getList($listing['Listing']['section_id'], $catids);
}
// Needed to preserve line breaks when not using wysiwyg editor
if (!$this->Access->loadWysiwygEditor()) {
$listing['Listing']['summary'] = $listing['Listing']['summary'];
$listing['Listing']['description '] = $listing['Listing']['description'];
}
$image_manager = '';
$image_count = count($listing['Listing']['images']);
// Check if image limit is enforced and modify the number of image fields shown based on current image account.
if ($this->Config->content_images_total_limit) {
$this->Config->content_images = $this->Config->content_images - $image_count;
}
$this->set(array('submit_step' => array(1, 2), 'User' => $this->_user, 'Access' => $this->Access, 'listing' => $listing, 'sections' => $sections, 'categories' => $categories, 'listing_fields' => $listing_fields));
return $this->render('listings', 'create');
}
示例3: edit
function edit()
{
$this->autoRender = false;
$listing_id = Sanitize::getInt($this->params, 'id');
$sections = array();
$categories = array();
Configure::write('ListingEdit', true);
// Read in Fields model for PaidListings integration
$listing = $this->Listing->findRow(array('fields' => array('Listing.metakey AS `Listing.metakey`', 'Listing.metadesc AS `Listing.metadesc`'), 'conditions' => 'Listing.id = ' . $listing_id));
# Override global configuration
isset($listing['ListingType']) and $this->Config->override($listing['ListingType']['config']);
# Set the theme suffix
$this->Theming->setSuffix(array('cat_id' => $listing['Category']['cat_id']));
if (!$this->Access->canEditListing($listing['Listing']['user_id'])) {
cmsFramework::noAccess();
$this->autoRender = false;
return;
}
# Get listing custom fields
$listing_fields = $this->Field->getFieldsArrayNew($listing['Criteria']['criteria_id'], 'listing', $listing);
// Show section/category lists if user is editor or above.
if ($this->cmsVersion == CMS_JOOMLA15 && $this->Access->isEditor()) {
// Limit sections/categories based on criteriaid of item being edited
$query = "SELECT id FROM #__jreviews_categories" . "\n WHERE criteriaid = '{$listing['Criteria']['criteria_id']}' AND `option` = 'com_content'";
$this->_db->setQuery($query);
$catids = implode(",", $this->_db->loadResultArray());
$sections = $this->Section->getList($catids);
$categories = $this->Category->getList($listing['Listing']['section_id'], $catids);
} elseif ($this->Access->isEditor() && Sanitize::getInt($listing['Criteria'], 'criteria_id')) {
$categories = $this->Category->getCategoryList(array('disabled' => true, 'type_id' => array(0, $listing['Criteria']['criteria_id']), 'listing_type' => true));
if (!empty($categories)) {
// Remove categories without submit access
foreach ($categories as $key => $row) {
$overrides = json_decode($row->config, true);
if (!$this->Access->canAddListing($overrides['addnewaccess'])) {
unset($categories[$key]);
}
}
}
}
// Needed to preserve line breaks when not using wysiwyg editor
if (!$this->Access->loadWysiwygEditor()) {
$listing['Listing']['summary'] = $listing['Listing']['summary'];
$listing['Listing']['description '] = $listing['Listing']['description'];
}
$image_manager = '';
$image_count = count($listing['Listing']['images']);
// Check if image limit is enforced and modify the number of image fields shown based on current image account.
if ($this->Config->content_images_total_limit) {
$this->Config->content_images = $this->Config->content_images - $image_count;
}
$this->set(array('submit_step' => array(1, 2), 'User' => $this->_user, 'Access' => $this->Access, 'listing' => $listing, 'sections' => $sections, 'categories' => $categories, 'listing_fields' => $listing_fields, 'formTokenKeys' => $this->formTokenKeys));
return $this->render('listings', 'create');
}
示例4: myreviews
function myreviews($params)
{
if ($this->_user->id === 0) {
$this->cacheAction = Configure::read('Cache.expires');
}
$page = array();
// Set layout
$this->layout = 'reviews';
$this->autoRender = false;
// Triggers the afterFind in the Observer Model
$this->EverywhereAfterFind = true;
$user_id = Sanitize::getInt($this->params, 'user');
if (!$user_id && !$this->_user->id) {
echo cmsFramework::noAccess();
$this->autoRender = false;
return;
}
if (!$user_id) {
$user_id = $this->_user->id;
}
$queryData = array('conditions' => array('Review.userid= ' . $user_id, 'Review.published = 1'), 'fields' => array('Review.mode AS `Review.extension`'), 'offset' => $this->offset, 'limit' => $this->limit, 'order' => array('Review.created DESC'));
# Don't run it here because it's run in the Everywhere Observer Component
$this->Review->runProcessRatings = false;
$reviews = $this->Review->findAll($queryData);
if (empty($reviews)) {
return __t("No reviews were found.", true);
}
$count = $this->Review->findCount($queryData);
$review = current($reviews);
App::import('Helper', 'community', 'jreviews');
$Community = RegisterClass::getInstance('CommunityHelper');
$Community->Config =& $this->Config;
$page['title'] = $page['description'] = sprintf(__t("Reviews written by %s", true), $Community->screenName($review, false));
$this->set(array('Access' => $this->Access, 'User' => $this->_user, 'reviews' => $reviews, 'pagination' => array('total' => $count, 'offset' => ($this->page - 1) * $this->limit), 'page' => $page));
return $this->render('reviews', 'reviews');
}
示例5: index
function index()
{
$this->EverywhereAfterFind = true;
// Triggers the afterFind in the Observer Model
// Required for ajax pagination to remember module settings
$Session = RegisterClass::getInstance('MvcSession');
$module_id = Sanitize::getVar($this->params, 'module_id', Sanitize::getVar($this->data, 'module_id'));
$cache_file = $module_id . '_' . md5(serialize($this->params));
if ($this->ajaxRequest) {
$this->params = $Session->get($module_id, null, S2Paths::get('jreviews', 'S2_CMSCOMP'));
} else {
srand((double) microtime() * 1000000);
$this->params['rand'] = rand();
// $Session->set($module_id.'_rand',$this->params['rand'],S2Paths::get('jreviews','S2_CMSCOMP'));
$Session->set($module_id, $this->params, S2Paths::get('jreviews', 'S2_CMSCOMP'));
}
if (!Sanitize::getVar($this->params['module'], 'community')) {
cmsFramework::noAccess();
return;
}
$conditions = array();
$joins = array();
$order = array();
// Initialize variables
$id = Sanitize::getInt($this->params, 'id');
$option = Sanitize::getString($this->params, 'option');
$view = Sanitize::getString($this->params, 'view');
$task = Sanitize::getString($this->params, 'task');
$menu_id = Sanitize::getString($this->params, 'Itemid');
# Read module parameters
$extension = Sanitize::getString($this->params['module'], 'extension');
$user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
if (!$user_id && !$this->_user->id) {
cmsFramework::noAccess();
return;
}
# Cached version
/* if($this->_user->id ===0) {
$page = $this->cached($cache_file);
if($page && $this->xajaxRequest) {
$xajax->assign('jr_modContainer'.$module_id,'innerHTML',$page);
return $xajax;
} elseif ($page) {
return $page;
}
} */
$catids_url = Sanitize::getString($this->params['module'], 'category');
$listing_id = Sanitize::getString($this->params['module'], 'listing');
if ($extension == 'com_content') {
$dir_id = Sanitize::getString($this->params['module'], 'dir');
$section_id = Sanitize::getString($this->params['module'], 'section');
$criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
} else {
$dir_id = null;
$section_id = null;
$criteria_ids = null;
}
$cat_autodetect = Sanitize::getInt($this->params['module'], 'cat_auto');
// This parameter determines the module mode
$sort = Sanitize::getString($this->params['module'], 'reviews_order');
# Remove unnecessary fields from model query
// $this->Review->modelUnbind();
if ($extension != '') {
$conditions[] = "Review.mode = '{$extension}'";
}
$conditions[] = "Review.userid = " . (int) $user_id;
# Set conditionals based on configuration parameters
if ($extension == 'com_content') {
// Only works for core articles
$conditions = array_merge($conditions, array('( Listing.publish_up = "' . NULL_DATE . '" OR DATE(Listing.publish_up) <= DATE("' . _CURRENT_SERVER_TIME . '") )', '( Listing.publish_down = "' . NULL_DATE . '" OR DATE(Listing.publish_down) >= DATE("' . _CURRENT_SERVER_TIME . '") )', 'Listing.access <= ' . $this->_user->gid, 'Listing.catid > 0'));
$conditions[] = $this->Access->canEditListing() ? 'Listing.state >= 0' : 'Listing.state = 1';
if ($dir_id) {
$conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
}
if ($section_id) {
$conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
}
if ($catids_url) {
$conditions[] = 'Listing.catid IN (' . $catids_url . ')';
}
} else {
if (Sanitize::getInt($this->params['module'], 'cat_auto') && method_exists($this->Listing, 'catUrlParam')) {
if ($catids_url = Sanitize::getInt($this->passedArgs, $this->Listing->catUrlParam())) {
$conditions[] = 'JreviewsCategory.id IN (' . $catids_url . ')';
}
} elseif ($catids_url) {
$conditions[] = 'JreviewsCategory.id IN (' . $catids_url . ')';
}
}
if ($listing_id) {
$conditions[] = "Review.pid IN ({$listing_id})";
}
$conditions[] = 'Review.published > 0';
switch ($sort) {
case 'latest':
$order[] = $this->Review->processSorting('rdate');
break;
case 'helpful':
//.........这里部分代码省略.........
示例6: listings
function listings()
{
$this->name = 'categories';
// Required for assets helper
if ($this->_user->id === 0 && $this->action != 'search') {
$this->cacheAction = Configure::read('Cache.expires');
}
$this->autoRender = false;
$action = Sanitize::paranoid($this->action);
$dir_id = str_replace(array('_', ' '), array(',', ''), Sanitize::getString($this->params, 'dir'));
$section_id = Sanitize::getString($this->params, 'section');
$cat_id = Sanitize::getString($this->params, 'cat');
$criteria_id = Sanitize::getString($this->params, 'criteria');
$user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
$index = Sanitize::getString($this->params, 'index');
$sort = Sanitize::getString($this->params, 'order', Sanitize::getString($this->Config, 'list_order_field'));
$sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
$menu_id = Sanitize::getInt($this->params, 'menu', Sanitize::getString($this->params, 'Itemid'));
// Avoid running the listing query if in section page and listings disabled
$query_listings = $this->action != 'section' || $this->action == 'section' && $this->Config->list_show_sectionlist;
$listings = array();
$count = 0;
switch ($action) {
case 'section':
!$section_id and $adminmsg[] = "Admin: You need to specify a valid section id in the menu parameters.";
break;
case 'category':
if (!$cat_id) {
$adminmsg[] = "Admin: You need to specify a valid category id in the menu parameters.";
} else {
// Find directory and section id
$category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $cat_id)));
if ($category) {
$section_id = $this->params['section'] = $category['Category']['section_id'];
$dir_id = $this->params['dir'] = $category['Category']['dir_id'];
# Override global configuration
isset($category['ListingType']) and $this->Config->override($category['ListingType']['config']);
$sort = Sanitize::getString($this->params, 'order', Sanitize::getString($this->Config, 'list_order_field'));
$sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
}
}
break;
case 'favorites':
if (!$user_id && !$this->_user->id) {
cmsFramework::noAccess();
return;
}
break;
}
if (isset($adminmsg) && !empty($adminmsg)) {
echo implode("<br />", $adminmsg);
return;
}
# Get section and category database information
if (in_array($action, array('section', 'category'))) {
$fields = array();
# Get all categories for page
if ($this->Config->dir_cat_num_entries || $this->Config->dir_category_hide_empty) {
$fields = array('
(SELECT
count(*)
FROM #__content AS Listing
INNER JOIN #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = Listing.catid AND JreviewsCategory.`option` = "com_content"
WHERE
Listing.sectionid = ' . $section_id . '
AND Listing.catid = Category.id
AND Listing.state = 1
AND Listing.access <= ' . $this->_user->gid . '
AND ( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )
AND ( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )
) AS `Category.listing_count`
');
}
$categories = $this->Category->findAll(array('fields' => $fields, 'conditions' => array('Category.section = ' . (int) $section_id, 'Category.published = 1'), 'order' => $this->Config->dir_category_order ? 'Category.title ASC' : 'Category.ordering ASC'));
$category_tmp = current($categories);
$dir_id = $category_tmp['Category']['dir_id'];
$section = $this->Section->findRow(array('fields' => array((int) $dir_id . ' AS `Section.dir_id`'), 'conditions' => array('Section.id = ' . (int) $section_id)));
}
if (isset($section) && !empty($section) && ($section['Section']['access'] > $this->_user->gid || !$section['Section']['published']) || $this->action == 'category' && isset($category) && !empty($category) && (!$category['Category']['published'] || $category['Category']['access'] > $this->_user->gid)) {
cmsFramework::noAccess();
return;
}
# Remove unnecessary fields from model query
$this->Listing->modelUnbind('Listing.fulltext AS `Listing.description`');
$conditions = array();
$joins = array();
# Get listings
# Modify and perform database query based on lisPage type
if ($action == 'section' && $this->Config->list_show_sectionlist || $action != 'section') {
// Build where statement
switch ($action) {
case 'alphaindex':
// $index = isset($index{0}) ? $index{0} : '';
$conditions[] = $index == '0' ? 'Listing.title REGEXP "^[0-9]"' : 'Listing.title LIKE ' . $this->quote($index . '%');
break;
case 'category':
# Shows only links users can access
$conditions[] = $category['Category']['access'] . ' <= ' . $this->_user->gid;
break;
case 'mylistings':
//.........这里部分代码省略.........
示例7: mylistings
function mylistings()
{
// Required for ajax pagination to remember module settings
$module_id = Sanitize::getString($this->params, 'module_id', Sanitize::getString($this->data, 'module_id'));
$extension = 'com_content';
if (!Sanitize::getVar($this->params['module'], 'community')) {
cmsFramework::noAccess();
return;
}
// Automagically load and initialize Everywhere Model
App::import('Model', 'everywhere_' . $extension, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
$this->Listing = new $class_name();
$this->Listing->_user = $this->_user;
$dir_id = Sanitize::getString($this->params['module'], 'dir');
$section_id = Sanitize::getString($this->params['module'], 'section');
$cat_id = Sanitize::getString($this->params['module'], 'category');
$listing_id = Sanitize::getString($this->params['module'], 'listing');
$user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
$sort = Sanitize::getString($this->params['module'], 'listings_order');
$limit = Sanitize::getInt($this->params['module'], 'module_limit', 5);
$total = min(50, Sanitize::getInt($this->params['module'], 'module_total', 10));
if (!$user_id && !$this->_user->id) {
cmsFramework::noAccess();
return;
}
# Remove unnecessary fields from model query
$this->Listing->modelUnbind('Listing.fulltext AS `Listing.description`');
$conditions = array();
$joins = array();
# Get listings
$conditions[] = 'Listing.created_by = ' . (int) $user_id;
# Set conditionals based on configuration parameters
if ($extension == 'com_content') {
// Only works for core articles
!empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
!empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
if (!empty($cat_id)) {
$conditions[] = $this->cmsVersion == CMS_JOOMLA15 ? 'Listing.catid IN (' . $cat_id . ')' : 'ParentCategory.id IN (' . $cat_id . ')';
} else {
unset($this->Listing->joins['ParentCategory']);
}
}
!empty($listing_id) and $conditions[] = "Listing.id IN ({$listing_id})";
if ($extension == 'com_content') {
// Only works for core articles
if ($this->Access->canEditListing()) {
$conditions[] = 'Listing.state >= 0';
} else {
$conditions[] = 'Listing.state = 1';
$conditions[] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )';
$conditions[] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )';
}
//Shows only links users can access
if ($this->cmsVersion == CMS_JOOMLA15) {
// $conditions[] = 'Section.access <= ' . $this->Access->getAccessId();
$conditions[] = 'Category.access <= ' . $this->Access->getAccessId();
$conditions[] = 'Listing.access <= ' . $this->Access->getAccessId();
} else {
$conditions[] = 'Category.access IN (' . $this->Access->getAccessLevels() . ')';
$conditions[] = 'Listing.access IN (' . $this->Access->getAccessLevels() . ')';
}
}
switch ($sort) {
case 'random':
srand((double) microtime() * 1000000);
$this->params['rand'] = rand();
$this->Listing->order = array();
$order[] = "RAND({$this->params['rand']})";
break;
default:
$this->Listing->order = array();
$order[] = "Listing.{$this->Listing->dateKey} DESC";
break;
}
$queryData = array('joins' => $joins, 'conditions' => $conditions, 'order' => $order, 'limit' => $total);
// This is used in Listings model to know whether this is a list page to remove the plugin tags
$this->Listing->controller = 'categories';
// Add custom fields to listings
$this->Listing->addFields = true;
$listings = $this->Listing->findAll($queryData);
$count = count($listings);
# Send variables to view template
$this->set(array('module_id' => $module_id, 'listings' => $listings, 'total' => $count, 'limit' => $limit));
$this->_completeModuleParamsArray();
$page = $this->ajaxRequest && empty($listings) ? '' : $this->render('community_plugins', 'community_mylistings');
return $this->ajaxRequest ? $this->ajaxResponse($page, false) : $page;
}
示例8: mylistings
function mylistings()
{
// Required for ajax pagination to remember module settings
$Session = RegisterClass::getInstance('MvcSession');
$module_id = Sanitize::getString($this->params, 'module_id', Sanitize::getString($this->data, 'module_id'));
$extension = 'com_content';
$cache_file = $module_id . '_' . md5(serialize($this->params));
if ($this->ajaxRequest) {
$this->params = $Session->get($module_id, null, S2Paths::get('jreviews', 'S2_CMSCOMP'));
} else {
srand((double) microtime() * 1000000);
$this->params['rand'] = rand();
$Session->set($module_id, $this->params, S2Paths::get('jreviews', 'S2_CMSCOMP'));
}
if (!Sanitize::getVar($this->params['module'], 'community')) {
cmsFramework::noAccess();
return;
}
if ($this->_user->id === 0) {
$this->cacheAction = Configure::read('Cache.expires');
}
// Automagically load and initialize Everywhere Model
App::import('Model', 'everywhere_' . $extension, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
$this->Listing = new $class_name();
$this->Listing->_user = $this->_user;
$action = Sanitize::paranoid($this->action);
$dir_id = Sanitize::getString($this->params['module'], 'dir');
$section_id = Sanitize::getString($this->params['module'], 'section');
$cat_id = Sanitize::getString($this->params['module'], 'category');
$listing_id = Sanitize::getString($this->params['module'], 'listing');
$user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
$index = Sanitize::getString($this->params, 'index');
$sort = Sanitize::getString($this->params['module'], 'listings_order');
$menu_id = Sanitize::getInt($this->params, 'menu', Sanitize::getString($this->params, 'Itemid'));
$listings = array();
$count = 0;
if (!$user_id && !$this->_user->id) {
cmsFramework::noAccess();
return;
}
# Remove unnecessary fields from model query
$this->Listing->modelUnbind('Listing.fulltext AS `Listing.description`');
$conditions = array();
$joins = array();
# Get listings
$conditions[] = 'Listing.created_by = ' . (int) $user_id;
# Set conditionals based on configuration parameters
if ($extension == 'com_content') {
// Only works for core articles
if ($dir_id) {
$conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
}
if ($section_id) {
$conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
}
if ($cat_id) {
$conditions[] = 'Listing.catid IN (' . $cat_id . ')';
}
}
if ($listing_id) {
$conditions[] = "Listing.id IN ({$listing_id})";
}
if ($extension == 'com_content') {
// Only works for core articles
if ($this->Access->canEditListing()) {
$conditions[] = 'Listing.state >= 0';
} else {
$conditions[] = 'Listing.state = 1';
$conditions[] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )';
$conditions[] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )';
}
//Shows only links users can access
$conditions[] = 'Listing.access <= ' . $this->_user->gid;
$conditions[] = 'Listing.catid > 0';
}
switch ($sort) {
case 'random':
$this->Listing->order = array();
$order[] = "RAND({$this->params['rand']})";
break;
default:
$this->Listing->order = array();
$order[] = "Listing.{$this->Listing->dateKey} DESC";
break;
}
$queryData = array('joins' => $joins, 'conditions' => $conditions, 'order' => $order, 'limit' => $this->module_limit, 'offset' => $this->module_offset);
// This is used in Listings model to know whether this is a list page to remove the plugin tags
$this->Listing->controller = 'categories';
// Add custom fields to listings
$this->Listing->addFields = true;
$listings = $this->Listing->findAll($queryData);
$count = 0;
if (!empty($listings)) {
unset($queryData['order']);
$count = $this->Listing->findCount($queryData, 'DISTINCT Listing.id');
if (Sanitize::getInt($this->data, 'total_special') && Sanitize::getInt($this->data, 'total_special') < $count) {
$count = Sanitize::getInt($this->data, 'total_special');
}
}
//.........这里部分代码省略.........