public function removeCompare() { $config = JFactory::getConfig(); $cookie_domain = $config->get('cookie_domain', ''); $cookie_path = $config->get('cookie_path', '/'); $app = JFactory::getApplication(); $jInput = $app->input; $JInputCookie = $jInput->cookie; $user = JFactory::getUser(); $removeAll = $jInput->getInt('all', 0); if ($removeAll == 1) { $JInputCookie->set('judir-compare-listing-' . $user->id, '', time() - 3600, $cookie_path, $cookie_domain); $this->setRedirect(JRoute::_('index.php?option=com_judirectory&view=compare', false), JText::_('COM_JUDIRECTORY_YOU_HAVE_REMOVED_ALL_LISTING_COMPARISON')); return true; } $listingId = $jInput->getInt('listing_id', 0); if ($listingId > 0) { $listingObject = JUDirectoryFrontHelperListing::getListing($listingId); if (is_object($listingObject)) { $listingIdString = $JInputCookie->get('judir-compare-listing-' . $user->id, '', 'string'); $listingIdArray = explode(",", $listingIdString); if (in_array($listingId, $listingIdArray)) { $keyListing = array_search($listingId, $listingIdArray); unset($listingIdArray[$keyListing]); } else { $this->setRedirect(JRoute::_('index.php?option=com_judirectory&view=compare', false), JText::_('COM_JUDIRECTORY_LISTING_IS_NOT_IN_COMPARISON_LIST')); return false; } if (count($listingIdArray)) { $listingIdArray = array_unique($listingIdArray); } if (count($listingIdArray) > 0) { $listingIdString = implode(",", $listingIdArray); $JInputCookie->set('judir-compare-listing-' . $user->id, $listingIdString, time() + 3600 * 24, $cookie_path, $cookie_domain); } else { $JInputCookie->set('judir-compare-listing-' . $user->id, null, time() - 3600 * 24, $cookie_path, $cookie_domain); } $this->setRedirect(JRoute::_('index.php?option=com_judirectory&view=compare', false), JText::_('COM_JUDIRECTORY_YOU_HAVE_MODIFIED_YOUR_LISTING_COMPARISON')); return true; } } }
* @license GNU General Public License version 2 or later; see LICENSE.txt * @author JoomUltra Co., Ltd * @website http://www.joomultra.com * @----------------------------------------------------------------------@ */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); //@todo properties has called in view $user = JFactory::getUser(); $isOwnDashboard = JUDirectoryFrontHelperPermission::isOwnDashboard(); JLoader::register('JUDirectoryAvatarHelper', JPATH_SITE . '/components/com_judirectory/helpers/avatar.php'); $avatar = JUDirectoryAvatarHelper::getJUAvatar($user->id); $userId = JUDirectoryFrontHelper::getDashboardUserId(); $linkDashboard = JRoute::_(JUDirectoryHelperRoute::getDashboardRoute($userId)); $linkUserProfile = JRoute::_(JUDirectoryHelperRoute::getUserProfileRoute()); $linkCreateListing = JRoute::_(JUDirectoryFrontHelperListing::getAddListingLink()); $linkUserComments = JRoute::_(JUDirectoryHelperRoute::getUserCommentsRoute($userId)); $linkUserCollection = JRoute::_(JUDirectoryHelperRoute::getCollectionsRoute($userId)); $linkUserListings = JRoute::_(JUDirectoryHelperRoute::getUserListingsRoute($userId)); $linkUserSubscriptions = JRoute::_(JUDirectoryHelperRoute::getUserSubscriptionsRoute($userId)); $linkLogOutReturn = JRoute::_('index.php', false); ?> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <ul class="nav navbar-nav"> <li class="go-home"> <a class="hasTooltip" title="<?php echo JText::_('COM_JUDIRECTORY_DASHBOARD_HOME'); ?> " href="<?php
public function loadTemplate($tpl = null) { $this->_output = null; $app = JFactory::getApplication(); $template = JFactory::getApplication()->getTemplate(); if ($this->getName() == 'category' || $this->getName() == 'tree') { $layoutUrl = $app->input->getString('layout', ''); if (isset($layoutUrl) && $layoutUrl != '') { $layout = $layoutUrl; } else { $layout = null; } $catId = $app->input->getInt('id', 1); $layout = JUDirectoryFrontHelperCategory::getCategoryViewLayout($layout, $catId); $this->setLayout($layout); } elseif ($this->getName() == 'listing') { $layoutUrl = $app->input->getString('layout', ''); if (isset($layoutUrl) && $layoutUrl != '') { $layout = $layoutUrl; } else { $layout = null; } $listingId = $app->input->getInt('id', 0); if ($listingId > 0) { $layout = JUDirectoryFrontHelperListing::getListingViewLayout($layout, $listingId); $this->setLayout($layout); } } $layout = $this->getLayout(); $layoutTemplate = $this->getLayoutTemplate(); $file = isset($tpl) ? $layout . '_' . $tpl : $layout; $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; $lang = JFactory::getLanguage(); $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, false); $component = JApplicationHelper::getComponentName(); $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); $app = JFactory::getApplication(); $id = $app->input->getInt('id', 0); $user = JFactory::getUser(); if ($previewStyle = (int) $app->input->getInt('tplStyle', 0)) { if ($user->id == 0) { $uri = JUri::getInstance(); $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false); $app->enqueueMessage(JText::_("COM_JUDIRECTORY_YOU_MUST_LOGIN_AS_SUPER_ADMIN_TO_PREVIEW_TEMPLATE_STYLE"), 'Notice'); $app->redirect($loginUrl); return false; } else { if (!$user->authorise('core.admin', 'com_judirectory')) { $app->enqueueMessage(JText::_("COM_JUDIRECTORY_YOU_MUST_LOGIN_AS_SUPER_ADMIN_TO_PREVIEW_TEMPLATE_STYLE"), 'Notice'); } } } if ($user->authorise('core.admin', 'com_judirectory') && ($previewStyle = (int) $app->input->getInt('tplStyle', 0))) { $currentTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleObject($previewStyle); } else { $currentTemplateStyleObject = JUDirectoryFrontHelperTemplate::getCurrentTemplateStyle($this->getName(), $id); } $JUTemplate = trim($currentTemplateStyleObject->folder); $JUTemplate = strtolower($JUTemplate); $this->template_params = $currentTemplateStyleObject->params; if (!$JUTemplate) { $JUTemplate = 'default'; } $this->template = $JUTemplate; $JUTemplatePath = JUDirectoryFrontHelperTemplate::getTemplatePathWithoutRoot($currentTemplateStyleObject->template_id); $topLevelTemplate = $JUTemplatePath[0]->folder ? $JUTemplatePath[0]->folder : 'default'; $asset_file = JPATH_SITE . '/components/com_judirectory/templates/' . $topLevelTemplate . '/load_assets.php'; if (JFile::exists($asset_file)) { include_once $asset_file; } $JUTemplatePathFull = array(); $JUTemplatePathFull[] = $this->_basePath . '/templates/default/' . $this->getName(); $JUTemplatePathFull[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'default' . '/' . $this->getName(); $JUTemplatePath = array_reverse($JUTemplatePath); foreach ($JUTemplatePath as $JUTemplatePathItem) { $JUTemplatePathFull[] = $this->_basePath . '/templates/' . $JUTemplatePathItem->folder . '/' . $this->getName(); $JUTemplatePathFull[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $JUTemplatePathItem->folder . '/' . $this->getName(); } foreach ($JUTemplatePathFull as $item) { $this->_addPath('template', $item); } if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) { $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']); } $jversion_arr = explode(".", JVERSION); $priVersion = $jversion_arr[0]; $subVersion = $jversion_arr[1]; $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . $subVersion)); $this->_template = JPath::find($this->_path['template'], $fileToFind); if ($this->_template == false) { $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . 'x')); $this->_template = JPath::find($this->_path['template'], $fileToFind); } if ($this->_template == false) { $fileToFind = $this->_createFileName('template', array('name' => $file)); $this->_template = JPath::find($this->_path['template'], $fileToFind); } if ($this->_template == false) { $fallbackPaths = array(); $fallbackPaths[] = $this->_basePath . '/templates/default/' . $this->getName(); $fallbackPaths[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'default' . '/' . $this->getName(); foreach ($fallbackPaths as $fallbackPath) { $fallbackPath = trim($fallbackPath); if (substr($fallbackPath, -1) != DIRECTORY_SEPARATOR) { $fallbackPath .= DIRECTORY_SEPARATOR; } array_unshift($fallbackPaths, $fallbackPath); } $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . $subVersion . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($fallbackPaths, $fileToFind); if ($this->_template == false) { $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . 'x' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($fallbackPaths, $fileToFind); } if ($this->_template == false) { $fileToFind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($fallbackPaths, $fileToFind); } } if ($this->_template != false) { unset($tpl); unset($file); if (isset($this->this)) { unset($this->this); } ob_start(); include $this->_template; $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; } else { return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file)); } }
public static function appendDataToListingObjList(&$listingObjectList, $params, $usingForMod = false) { if (is_array($listingObjectList) && count($listingObjectList)) { $user = JFactory::getUser(); foreach ($listingObjectList as $listingObject) { JUDirectoryHelper::getListingById($listingObject->id, false, $listingObject); $listingObject->params = JUDirectoryFrontHelperListing::getListingDisplayParams($listingObject->id); if (!$user->get('guest')) { $canEditListing = JUDirectoryFrontHelperPermission::canEditListing($listingObject->id); $canEditStateListing = JUDirectoryFrontHelperPermission::canEditStateListing($listingObject); $canDeleteListing = JUDirectoryFrontHelperPermission::canDeleteListing($listingObject->id); $listingObject->params->set('access-edit', $canEditListing); $listingObject->params->set('access-edit-state', $canEditStateListing); $listingObject->params->set('access-delete', $canDeleteListing); } if ($listingObject->published != 1) { $listingObject->label_unpublished = true; } else { $listingObject->label_unpublished = false; } $listingObject->label_pending = false; $nowDate = JFactory::getDate()->toSql(); if (intval($listingObject->publish_up) > 0) { if (strtotime($listingObject->publish_up) > strtotime($nowDate)) { $listingObject->label_pending = true; } } $listingObject->label_expired = false; if (intval($listingObject->publish_down) > 0) { if (intval($listingObject->publish_up) > 0) { if (strtotime($listingObject->publish_up) <= strtotime($nowDate)) { if (strtotime($listingObject->publish_down) < strtotime($nowDate)) { $listingObject->label_expired = true; } } } else { if (strtotime($listingObject->publish_down) < strtotime($nowDate)) { $listingObject->label_expired = true; } } } if ($params->get('show_new_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->publish_up, $params->get('num_day_to_show_as_new', 10))) { $listingObject->label_new = true; } else { $listingObject->label_new = false; } if ($params->get('show_updated_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->updated, $params->get('num_day_to_show_as_updated', 10))) { $listingObject->label_updated = true; } else { $listingObject->label_updated = false; } if ($params->get('show_hot_label', 1) && JUDirectoryFrontHelperListing::checkHotListing($listingObject->publish_up, $params->get('num_hit_per_day_to_be_hot', 100), $listingObject->hits)) { $listingObject->label_hot = true; } else { $listingObject->label_hot = false; } if ($params->get('show_featured_label', 1) && $listingObject->featured) { $listingObject->label_featured = true; } else { $listingObject->label_featured = false; } } } }
public static function getListingLayout($listingId) { $storeId = md5(__METHOD__ . "::" . $listingId); if (!isset(self::$cache[$storeId])) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('layout'); $query->from('#__judirectory_listings'); $query->where('id =' . $listingId); $db->setQuery($query); $layout = $db->loadResult(); if ($layout == -2) { $params = JUDirectoryHelper::getParams(null, $listingId); $layout = $params->get('layout_listing', '_:default'); } elseif ($layout == -1) { $parentId = (int) JUDirectoryFrontHelperCategory::getMainCategoryId($listingId); if ($parentId == 0) { $params = JUDirectoryHelper::getParams(null, $listingId); $layout = $params->get('layout_listing', '_:default'); } else { $layout = JUDirectoryFrontHelperListing::getListingLayoutFromCategory($parentId); } } else { $layout = trim($layout); } self::$cache[$storeId] = $layout; } return self::$cache[$storeId]; }
public function canView($options = array()) { $storeId = md5(__METHOD__ . "::" . $this->listing_id . "::" . $this->id . "::" . serialize($options)); if (!isset(self::$cache[$storeId])) { if (!$this->isPublished()) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } $app = JFactory::getApplication(); $languageFilter = $app->getLanguageFilter(); if ($languageFilter) { $languageTag = JFactory::getLanguage()->getTag(); if ($this->language != $languageTag && $this->language != '*' && $this->language != '') { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } if ($this->listing_id) { $listing_display_params = JUDirectoryFrontHelperListing::getListingDisplayParams($this->listing_id); $listing_display_fields = $listing_display_params->get('fields'); } $options = (array) $options; $field_name = $this->field_name ? $this->field_name : $this->id; if ($this->isDetailsView($options)) { if (isset($listing_display_fields->{$field_name}) && isset($listing_display_fields->{$field_name}->details_view)) { if (!$listing_display_fields->{$field_name}->details_view) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } elseif (!$this->details_view) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } else { if (isset($listing_display_fields->{$field_name}) && isset($listing_display_fields->{$field_name}->list_view)) { if (!$listing_display_fields->{$field_name}->list_view) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } elseif (!$this->list_view) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } if (isset($this->listing) && $this->listing->cat_id) { $params = JUDirectoryHelper::getParams($this->listing->cat_id); } else { $params = JUDirectoryHelper::getParams(null, $this->listing_id); } $show_empty_field = $params->get('show_empty_field', 0); if ($this->listing_id && !$show_empty_field) { $field_value = $this->value; if (is_null($field_value)) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } if (is_string($field_value) && trim($field_value) === '') { self::$cache[$storeId] = false; return self::$cache[$storeId]; } if (is_array($field_value) && count($field_value) == 0) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } $user = JFactory::getUser(); if ($user) { $viewLevels = JAccess::getAuthorisedViewLevels($user->id); $fieldGroupObj = JUDirectoryFrontHelperField::getFieldGroupById($this->group_id); if (!in_array($fieldGroupObj->access, $viewLevels)) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } else { if (in_array($this->access, $viewLevels)) { self::$cache[$storeId] = true; return self::$cache[$storeId]; } } } self::$cache[$storeId] = false; return self::$cache[$storeId]; } return self::$cache[$storeId]; }
public function display($tpl = null) { $model = $this->getModel(); $this->model = $model; $this->state = $this->get('State'); $params = $this->state->params; $this->params = $params; $this->token = JSession::getFormToken(); $this->root_category = JUDirectoryFrontHelperCategory::getRootCategory(); $categoryId = $this->state->get('category.id', $this->root_category->id); if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $error = array(); if (!JUDirectoryFrontHelperPermission::canDoCategory($categoryId, true, $error)) { $user = JFactory::getUser(); if ($user->id) { return JError::raiseError($error['code'], $error['message']); } else { $uri = JUri::getInstance(); $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false); $app = JFactory::getApplication(); $app->redirect($loginUrl, JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning'); return false; } } $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $categoryId); if (is_array($topLevelCats) && count($topLevelCats) > 0) { $this->tl_catid = $topLevelCats[0]->id; } $this->category = JUDirectoryFrontHelperCategory::getCategory($categoryId); $this->show_feed = JUDIRPROVERSION ? $this->params->get('rss_display_icon', 1) : 0; $this->rss_link = JRoute::_(JUDirectoryHelperRoute::getCategoryRoute($this->category->id, null, true)); if (isset($this->category->images) && !empty($this->category->images) && !empty($this->category->images->detail_image)) { $this->category->images->detail_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judirectory/images/category/detail/', true) . $this->category->images->detail_image; } $this->category->images->detail_image_width = (int) $this->params->get('category_image_width', 200); $this->category->images->detail_image_height = (int) $this->params->get('category_image_height', 200); if ($this->params->get('category_show_description', 1)) { $this->category->description = $this->category->introtext . $this->category->fulltext; } else { $this->category->description = $this->category->fulltext; } $categoryDescLimit = (int) $this->params->get('category_desc_limit', 0); if ($categoryDescLimit > 0) { $this->category->description = JUDirectoryFrontHelperString::truncateHtml($this->category->description, $categoryDescLimit); } if ($this->params->get('plugin_support', 0)) { $this->category->description = JHtml::_('content.prepare', $this->category->description, '', 'com_judirectory.category'); } $this->category->class_sfx = htmlspecialchars($this->category->class_sfx); $relatedCatOrdering = $this->params->get('related_category_ordering', 'crel.ordering'); $relatedCatDirection = $this->params->get('related_category_direction', 'ASC'); $this->related_cats = $model->getRelatedCategories($this->category->id, $relatedCatOrdering, $relatedCatDirection); if (is_array($this->related_cats) && count($this->related_cats) > 0) { foreach ($this->related_cats as $relatedCategory) { if (isset($relatedCategory->images->intro_image) && !empty($relatedCategory->images->intro_image)) { $relatedCategory->images->intro_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/images/category/intro/', true) . $relatedCategory->images->intro_image; } $relatedCategory->images->intro_image_width = (int) $this->params->get('related_category_intro_image_width', 200); $relatedCategory->images->intro_image_height = (int) $this->params->get('related_category_intro_image_height', 200); if ($this->params->get('related_category_show_introtext', 1)) { $relatedCategoryDescLimit = (int) $this->params->get('related_category_introtext_character_limit', 500); if ($relatedCategoryDescLimit > 0) { $relatedCategory->introtext = JUDirectoryFrontHelperString::truncateHtml($relatedCategory->introtext, $relatedCategoryDescLimit); } if ($params->get('plugin_support', 0)) { $relatedCategory->introtext = JHtml::_('content.prepare', $relatedCategory->introtext, '', 'com_judirectory.category'); } } else { $relatedCategory->introtext = ''; } } } $subCatOrdering = $this->params->get('subcategory_ordering', 'title'); $subCatDirection = $this->params->get('subcategory_direction', 'ASC'); $this->subcategories = $model->getSubCategories($this->category->id, $subCatOrdering, $subCatDirection); if (is_array($this->subcategories) && count($this->subcategories) > 0) { foreach ($this->subcategories as $subCategory) { if (isset($subCategory->images->intro_image) && !empty($subCategory->images->intro_image)) { $subCategory->images->intro_image_src = JUri::root(true) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/images/category/intro/', true) . $subCategory->images->intro_image; } $subCategory->images->intro_image_width = (int) $this->params->get('subcategory_intro_image_width', 200); $subCategory->images->intro_image_height = (int) $this->params->get('subcategory_intro_image_height', 200); if ($this->params->get('subcategory_show_introtext', 1)) { $subCategoryDescLimit = (int) $this->params->get('subcategory_introtext_character_limit', 500); if ($subCategoryDescLimit > 0) { $subCategory->introtext = JUDirectoryFrontHelperString::truncateHtml($subCategory->introtext, $subCategoryDescLimit); } if ($this->params->get('plugin_support', 0)) { $subCategory->introtext = JHtml::_('content.prepare', $subCategory->introtext, '', 'com_judirectory.category'); } } else { $subCategory->introtext = ''; } } } $this->category->can_submit_listing = JUDirectoryFrontHelperPermission::canSubmitListing($this->category->id); if ($this->category->can_submit_listing && $this->params->get('show_submit_listing_btn_in_category', 1)) { $this->category->submit_listing_link = JUDirectoryFrontHelperListing::getAddListingLink($this->category->id); } $this->items = array(); if ($this->category->show_item) { $user = JFactory::getUser(); $uri = JUri::getInstance(); $this->items = $this->get('Items'); foreach ($this->items as $item) { $item->report_link = JRoute::_(JUDirectoryHelperRoute::getReportListingRoute($item->id)); $item->claim_link = JRoute::_(JUDirectoryHelperRoute::getClaimListingRoute($item->id)); if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) { if (JUDirectoryFrontHelperPermission::canCheckInListing($item->id)) { $item->checkin_link = JRoute::_('index.php?option=com_judirectory&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri))); } } else { $item->edit_link = JRoute::_('index.php?option=com_judirectory&task=form.edit&id=' . $item->id . '&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id)); if ($item->published == 1) { $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id)); } else { $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id)); } } $item->delete_link = JRoute::_('index.php?option=com_judirectory&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id)); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $item->event = new stdClass(); $context = 'com_judirectory.listing_list'; $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } $this->pagination = $this->get('Pagination'); //print_r($this->pagination); } $this->locations = JUDirectoryFrontHelper::getLocations($this->items); //print_r($this->locations); $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->_prepareData(); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public static function canAutoApprovalListingWhenEdit($listingId, $newMainCategoryId) { $listingObject = JUDirectoryHelper::getListingById($listingId); if ($listingObject->approved == 1) { $originalListingId = $listingObject->id; $originalListingObject = $listingObject; $mainCategoryId = JUDirectoryFrontHelperCategory::getMainCategoryId($originalListingObject->id); $params = JUDirectoryHelper::getParams($newMainCategoryId); } elseif ($listingObject->approved < 0) { $tempListingObject = $listingObject; $originalListingId = abs($listingObject->approved); $originalListingObject = JUDirectoryHelper::getListingById($originalListingId); $mainCategoryId = JUDirectoryFrontHelperCategory::getMainCategoryId($originalListingObject->id); $params = JUDirectoryHelper::getParams($newMainCategoryId); } else { return false; } $isListingOwner = JUDirectoryFrontHelperPermission::isListingOwner($originalListingObject->id); $autoApprovalForListingOwner = $params->get('listing_owner_can_edit_listing_auto_approval', 1); if ($isListingOwner && $autoApprovalForListingOwner) { return true; } $user = JFactory::getUser(); if ($mainCategoryId == $newMainCategoryId) { if ($user->authorise('judir.listing.edit.auto_approval', 'com_judirectory.category.' . $mainCategoryId)) { return true; } } else { if ($user->authorise('judir.listing.create.auto_approval', 'com_judirectory.category.' . $newMainCategoryId)) { return true; } } if (!$user->get('guest')) { $autoApprovalListingThreshold = (int) $params->get('auto_approval_listing_threshold', 0); if ($autoApprovalListingThreshold > 0) { $totalApprovedListingsOfUser = JUDirectoryFrontHelperListing::getTotalListingsOfUserApprovedByMod($user->id); if ($totalApprovedListingsOfUser >= $autoApprovalListingThreshold) { return true; } } } return false; }
public function getItem() { $params = $this->getState('params'); $listingId = (int) $this->getState('listing.id'); if (!$listingId) { JError::raiseError(404, JText::_('COM_JUDIRECTORY_LISTING_NOT_FOUND')); return false; } $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('listing.*, c.id AS cat_id'); $query->from('#__judirectory_listings AS listing'); $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main=1'); $query->join('', '#__judirectory_categories AS c ON c.id = listingxref.cat_id'); $query->select('(SELECT COUNT(*) FROM #__judirectory_comments AS cm WHERE cm.listing_id = listing.id AND cm.approved = 1 AND cm.published = 1) AS total_comments'); $query->select('(SELECT COUNT(*) FROM #__judirectory_subscriptions AS sub WHERE sub.item_id = listing.id AND sub.type = "listing" AND sub.published = 1) AS total_subscriptions'); $query->select('(SELECT COUNT(*) FROM #__judirectory_reports AS r WHERE r.item_id = listing.id AND r.type = "listing") AS total_reports'); $query->select('(SELECT GROUP_CONCAT(catids.id ORDER BY listingx_catids.main DESC, listingx_catids.ordering ASC SEPARATOR ",") FROM (#__judirectory_categories AS catids JOIN #__judirectory_listings_xref AS listingx_catids ON catids.id = listingx_catids.cat_id) WHERE listing.id = listingx_catids.listing_id GROUP BY listing.id) AS cat_ids'); $query->select('(SELECT GROUP_CONCAT(cattitles.title ORDER BY listingx_cattitles.main DESC, listingx_cattitles.ordering ASC SEPARATOR "|||") FROM (#__judirectory_categories AS cattitles JOIN #__judirectory_listings_xref AS listingx_cattitles ON cattitles.id = listingx_cattitles.cat_id) WHERE listing.id = listingx_cattitles.listing_id GROUP BY listing.id) AS cat_titles'); $accessLevel = implode(',', $user->getAuthorisedViewLevels()); $db = JFactory::getDbo(); $date = JFactory::getDate(); $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote($date->toSql()); $fieldQuery = $db->getQuery(true); $fieldQuery->select('field.id'); $fieldQuery->from('#__judirectory_fields AS field'); $fieldQuery->where('field.group_id != 1'); $fieldQuery->where('field.details_view = 1'); $fieldQuery->where('field.published = 1'); $fieldQuery->where('field.publish_up <= ' . $nowDate); $fieldQuery->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')'); $fieldQuery->where('field.access IN (' . $accessLevel . ')'); $category = JUDirectoryFrontHelperCategory::getMainCategory($listingId); if (is_object($category)) { $fieldQuery->where('field.group_id = ' . $category->fieldgroup_id); } $fieldQuery->join('', '#__judirectory_fields_groups AS field_group ON field.group_id = field_group.id'); $fieldQuery->where('field_group.published = 1'); $fieldQuery->where('field_group.access IN (' . $accessLevel . ')'); $fieldQuery->group('field.id'); $db->setQuery($fieldQuery); $fields = $db->loadObjectList(); foreach ($fields as $field) { $query->select('IFNULL (fields_values_' . $field->id . '.value, "") AS field_values_' . $field->id); $query->join('LEFT', '#__judirectory_fields_values AS fields_values_' . $field->id . ' ON fields_values_' . $field->id . '.listing_id = listing.id AND fields_values_' . $field->id . '.field_id = ' . $field->id); } $query->where('listing.id = ' . $listingId); $db->setQuery($query); $listingObject = $db->loadObject(); if (!is_object($listingObject)) { JError::raiseError(404, JText::_('COM_JUDIRECTORY_LISTING_NOT_FOUND')); return false; } $listingObject->params = JUDirectoryFrontHelperListing::getListingDisplayParams($listingObject->id); if (!$user->get('guest')) { $canEditListing = JUDirectoryFrontHelperPermission::canEditListing($listingObject->id); $canDeleteListing = JUDirectoryFrontHelperPermission::canDeleteListing($listingObject->id); $canEditStateListing = JUDirectoryFrontHelperPermission::canEditStateListing($listingObject); $listingObject->params->set('access-edit', $canEditListing); $listingObject->params->set('access-edit-state', $canEditStateListing); $listingObject->params->set('access-delete', $canDeleteListing); } $canReportListing = JUDirectoryFrontHelperPermission::canReportListing($listingObject->id); $canContactListing = JUDirectoryFrontHelperPermission::canContactListing($listingObject->id); $canClaimListing = JUDirectoryFrontHelperPermission::canClaimListing($listingObject->id); $canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingObject->id); $canCommentListing = JUDirectoryFrontHelperPermission::canComment($listingObject->id); $listingObject->params->set('access-report', $canReportListing); $listingObject->params->set('access-contact', $canContactListing); $listingObject->params->set('access-claim', $canClaimListing); $listingObject->params->set('access-rate', $canRateListing); $listingObject->params->set('access-comment', $canCommentListing); $listingObject->template_params = new JRegistry($listingObject->template_params); if ($params->get('show_new_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->publish_up, $params->get('num_day_to_show_as_new', 10))) { $listingObject->label_new = true; } else { $listingObject->label_new = false; } if ($params->get('show_updated_label', 1) && JUDirectoryFrontHelper::isWithinXDays($listingObject->updated, $params->get('num_day_to_show_as_updated', 10))) { $listingObject->label_updated = true; } else { $listingObject->label_updated = false; } if ($params->get('show_hot_label', 1) && JUDirectoryFrontHelperListing::checkHotListing($listingObject->publish_up, $params->get('num_hit_per_day_to_be_hot', 100), $listingObject->hits)) { $listingObject->label_hot = true; } else { $listingObject->label_hot = false; } if ($params->get('show_featured_label', 1) && $listingObject->featured) { $listingObject->label_featured = true; } else { $listingObject->label_featured = false; } $listingObject->next_item = $this->getNextPrevItem($listingObject, 'next'); $listingObject->prev_item = $this->getNextPrevItem($listingObject, 'prev'); return $listingObject; }
public function delete() { JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); $cid = JFactory::getApplication()->input->get('id', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_NO_ITEM_SELECTED')); $this->setRedirect($this->getReturnPage()); } else { $model = $this->getModel(); jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } $isListingPublished = JUDirectoryFrontHelperListing::isListingPublished($cid[0]); if ($isListingPublished) { $mainCategoryId = JUDirectoryFrontHelperCategory::getMainCategoryId($cid[0]); $this->setRedirect(JRoute::_(JUDirectoryHelperRoute::getCategoryRoute($mainCategoryId), false)); } else { $this->setRedirect($this->getReturnPage()); } } }