Пример #1
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $contentmodel = $this->getModel("content");
     $catmodel = $this->getModel("category");
     $positionmodel = $this->getModel("position");
     $fieldmodel = $this->getModel("field");
     $configurationmodel = $this->getModel("configuration");
     // Get the parameters of the active menu item
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $conf = $configurationmodel->getConfiguration();
     $positions = $positionmodel->getPositions('details');
     $fDisplay = $fieldmodel->getFieldsbyPositions();
     $field_values = $fieldmodel->getFieldValues();
     $contentid = JRequest::getInt('id', 0);
     $content = $contentmodel->getPendingContent($contentid);
     $this->assignRef('positions', $positions);
     $this->assignRef('fDisplay', $fDisplay);
     $this->assignRef('conf', $conf);
     $this->assignRef('userid', $user->id);
     $fields = $fieldmodel->getFields();
     $this->assignRef('fields', $fields);
     $document->setTitle(JText::_('ADSMANAGER_PAGE_TITLE') . " " . $content->ad_headline);
     $plugins = $fieldmodel->getPlugins();
     $field = new JHTMLAdsmanagerField($conf, $field_values, '1', $plugins);
     $this->assignRef('field', $field);
     $catid = 0;
     $general = new JHTMLAdsmanagerGeneral($catid, $conf, $user);
     $this->assignRef('general', $general);
     //
     // Process the content plugins.
     //
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     $showContact = TPermissions::checkRightContact();
     $this->assignRef('showContact', $showContact);
     $results = $dispatcher->trigger('ADSonContentPrepare', array($content));
     $event = new stdClass();
     $results = $dispatcher->trigger('ADSonContentAfterTitle', array($content));
     $event->onContentAfterTitle = trim(implode("\n", $results));
     $results = $dispatcher->trigger('ADSonContentBeforeDisplay', array($content));
     $event->onContentBeforeDisplay = trim(implode("\n", $results));
     $results = $dispatcher->trigger('ADSonContentAfterDisplay', array($content));
     $event->onContentAfterDisplay = trim(implode("\n", $results));
     $content->event = $event;
     $this->assignRef('content', $content);
     if ($conf->image_display == 'jssor') {
         $tpl = 'jssor';
     }
     parent::display($tpl);
 }
Пример #2
0
 /**
  * Return in a array all the authorised categories
  * 
  * @param string $mode
  * @return Array
  */
 public static function getAuthorisedCategories($mode)
 {
     //If the static variable is already set, we directly return it
     if (self::$listcategories == null) {
         $user = JFactory::getUser();
         $userGroups = array();
         //If the user is a guest, we authorise the public group
         //else we return the authorised group of the user
         if ($user->guest) {
             $userGroups[] = 1;
         } else {
             $userGroups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id);
         }
         $authorisedCategories = array();
         $modelCategories = new AdsmanagerModelCategory();
         $categories = $modelCategories->getCategories(false);
         foreach ($categories as $category) {
             $labelUsergroups = 'usergroups' . $mode;
             $catUserGroups = $category->{$labelUsergroups};
             $catUserGroupsArray = explode(',', $catUserGroups);
             //We load the usergroups authorised by the category
             //If there is no usergroups saved, we authorised the category
             if ($catUserGroups != '') {
                 //We compare the authorised usergroups of the two array
                 //And save in a array the matching value.
                 foreach ($userGroups as $userGroup) {
                     if (array_search($userGroup, $catUserGroupsArray) !== false) {
                         if (array_search($category->id, $authorisedCategories) === false) {
                             $authorisedCategories[] = $category->id;
                         }
                     }
                 }
             } else {
                 if (array_search($category->id, $authorisedCategories) === false) {
                     $authorisedCategories[] = $category->id;
                 }
             }
         }
         self::$listcategories = $authorisedCategories;
     }
     return self::$listcategories;
 }
Пример #3
0
 function getCatTree($onlyPublished = true, $getnbads = false, &$nbcontents = null, $mode = 'admin', $rootid = 0)
 {
     if ($onlyPublished == true) {
         $published = " c.published = 1 ";
     } else {
         $published = " 1 ";
     }
     if (version_compare(JVERSION, '1.6', 'ge')) {
         //If $mode isn't read or write, we authorised all the categories
         if (!($mode == 'write' || $mode == 'read')) {
             $listCategories = "";
         } else {
             $listCategories = TPermissions::getAuthorisedCategories($mode);
             //If the variable is an array and if it's not empty, we add a filter to the request
             //If not we're not return any category
             if (is_array($listCategories) && !empty($listCategories)) {
                 $listCategories = " AND c.id IN (" . implode(',', $listCategories) . ") ";
             } else {
                 $listCategories = " AND 0 ";
             }
         }
     } else {
         $listCategories = "";
     }
     if ((int) $rootid != 0) {
         $list = $this->getAllSubCatids($rootid, false);
         $listCategories .= " AND c.id IN (" . implode(',', $list) . ")";
     }
     $query = " SELECT c.* FROM #__adsmanager_categories as c WHERE {$published} {$listCategories} " . " ORDER BY c.parent,c.ordering,c.id";
     $this->_db->setQuery($query);
     $list = $this->_db->loadObjectList();
     if ($getnbads != null) {
         $query = " SELECT ac.catid,ac.adid " . " FROM #__adsmanager_adcat as ac" . " INNER JOIN #__adsmanager_ads as a ON a.id = ac.adid " . " WHERE a.published = 1 ";
         $this->_db->setQuery($query);
         $listads = $this->_db->loadObjectList();
         $nbadsbycat = array();
         foreach ($listads as $ad) {
             if (!isset($nbadsbycat[$ad->catid])) {
                 $nbadsbycat[$ad->catid] = array();
             }
             $nbadsbycat[$ad->catid][]++;
         }
     }
     // establish the hierarchy of the menu
     $tree = array();
     // first pass - collect children
     if (isset($list)) {
         foreach ($list as $v) {
             $pt = $v->parent;
             $list_temp = @$tree[$pt] ? $tree[$pt] : array();
             if (isset($nbadsbycat[$v->id])) {
                 $v->num_ads = count($nbadsbycat[$v->id]);
             } else {
                 $v->num_ads = 0;
             }
             $v->name = JText::_($v->name);
             array_push($list_temp, $v);
             $tree[$pt] = $list_temp;
         }
     }
     if ($getnbads != null) {
         $nbcontents = $this->calc_nb_ads(0, $tree);
     }
     return $tree;
 }
Пример #4
0
 function getLatestContents($nbcontents, $sort_type = 0, $catselect = "no", $rootid = null)
 {
     switch ($sort_type) {
         /* Popular */
         case 2:
             $order_sql = "ORDER BY a.views DESC,a.date_created DESC ,a.id DESC ";
             break;
             /* Random */
         /* Random */
         case 1:
             $order_sql = "ORDER BY RAND() ";
             break;
             /* Latest */
         /* Latest */
         case 0:
         default:
             $order_sql = "ORDER BY a.date_created DESC ,a.id DESC ";
             break;
     }
     if (version_compare(JVERSION, '1.6', 'ge')) {
         $listCategories = TPermissions::getAuthorisedCategories('read');
         //If the variable is an array and if it's not empty, we add a filter to the request
         //If not we're not return any category
         if (is_array($listCategories) && !empty($listCategories)) {
             $categories = implode(',', $listCategories);
             $listCategories = " AND c.id IN (" . $categories . ") ";
         } else {
             $listCategories = " AND 0 ";
         }
     } else {
         $listCategories = "";
     }
     $cat_query = "";
     switch ($catselect) {
         case "no":
             break;
         case "-1":
             $catid = JRequest::getInt('catid', 0);
             if ($catid != 0 && $catid != -1) {
                 $this->_db->setQuery("SELECT c.id, c.name,c.parent " . " FROM #__adsmanager_categories as c " . " WHERE c.published = 1 {$listCategories} ORDER BY c.parent,c.ordering");
                 $listcats = $this->_db->loadObjectList();
                 //List
                 $list = array();
                 $list[] = $catid;
                 $this->_recurseSearch($listcats, $list, $catid);
                 $listids = implode(',', $list);
                 $cat_query = "adcat.catid IN ({$listids}) AND ";
             }
             break;
         default:
             $this->_db->setQuery("SELECT c.id, c.name,c.parent " . " FROM #__adsmanager_categories as c " . " WHERE c.published = 1 {$listCategories} ORDER BY c.parent,c.ordering");
             $listcats = $this->_db->loadObjectList();
             $catsid = explode(',', $catselect);
             //List
             $list = array();
             foreach ($catsid as $catid) {
                 $list[] = $catid;
                 $this->_recurseSearch($listcats, $list, $catid);
             }
             $listids = implode(',', $list);
             $cat_query = " adcat.catid IN ({$listids}) AND ";
             break;
     }
     if (ADSMANAGER_SPECIAL == 'newspaper') {
         $cat_query .= " (a.ad_publishtype = 'both' OR a.ad_publishtype = 'online') AND ";
     }
     $currentSession = JSession::getInstance('none', array());
     $sql = $currentSession->get("sqlglobalfilter", "");
     $globalfilter = "";
     if ($sql != "") {
         $globalfilter = " AND {$sql} ";
     }
     $sql = " SELECT a.*,p.id as parentid,p.name as parent,c.id as catid, c.name as cat,u.username as user " . " FROM #__adsmanager_ads as a " . " INNER JOIN #__adsmanager_adcat as adcat ON adcat.adid = a.id " . " LEFT JOIN #__users as u ON a.userid = u.id " . " INNER JOIN #__adsmanager_categories as c ON adcat.catid = c.id " . " LEFT JOIN #__adsmanager_categories as p ON c.parent = p.id " . " WHERE 1 {$globalfilter} AND {$cat_query} c.published = 1 and a.published = 1 GROUP BY a.id {$order_sql} LIMIT 0, {$nbcontents}";
     if (function_exists("updateQuery")) {
         updateQuery($sql);
     }
     $this->_db->setQuery($sql);
     $contents = $this->_db->loadObjectList();
     if ($contents == null) {
         $contents = array();
     }
     foreach ($contents as &$content) {
         $content->images = @json_decode($content->images);
         $content->cat = JText::_($content->cat);
         if ($content->parent != "") {
             $content->parent = JText::_($content->parent);
         }
         if (!is_array($content->images)) {
             $content->images = array();
         }
     }
     return $contents;
 }
Пример #5
0
	function display($tpl = null)
	{
		$app = JFactory::getApplication();

		$user		= JFactory::getUser();
		$pathway	= $app->getPathway();
		$document	= JFactory::getDocument();
		
		$contentmodel	=$this->getModel( "content" );
		$catmodel		=$this->getModel( "category" );
		$positionmodel	=$this->getModel( "position" );
		$fieldmodel	    =$this->getModel( "field" );
		$configurationmodel	=$this->getModel( "configuration" );

		// Get the parameters of the active menu item
		$menus	= $app->getMenu();
		$menu    = $menus->getActive();
		
		$conf = $configurationmodel->getConfiguration();
		
		$catid = JRequest::getInt( 'catid',	0 );
		if ($catid != "0") {
			$category = $catmodel->getCategory($catid);
			$category->img = TTools::getCatImageUrl($catid,true);
		}
		else
		{
			$category = new stdClass();
			$category->name = JText::_("ADSMANAGER_ALL_ADS");
			$category->description = "";
			$category->img = "";
		}
		
		$rootid = JRequest::getInt('rootid',0);
		
		$pathlist = $catmodel->getPathList($catid,'read',$rootid);
		$this->assignRef('pathlist',$pathlist);
		
		$positions = $positionmodel->getPositions();
		$fDisplay = $fieldmodel->getFieldsbyPositions();
		
		$field_values = $fieldmodel->getFieldValues();
		
		$contentid = JRequest::getInt( 'id',	0 );
		$content = $contentmodel->getContent($contentid,false);
		if (($content->published == false)&&($content->userid != $user->id)) {
			if (ADSMANAGER_SPECIAL == 'sale') {
				require_once(JPATH_ROOT.'/administrator/components/com_sale/models/configuration.php');
				$model = new SaleModelConfiguration();
				$saleconf = $model->getConfiguration();
				if ($content->userid != $saleconf->userid) {
					$app->redirect( TRoute::_('index.php?option=com_adsmanager&view=list&catid='.$catid));
				}
				//Display Ad
			} else if (ADSMANAGER_SPECIAL == 'barter') {
			} else {
				//JError::raiseError(404, JText::_("Page Not Found"));
				$app->redirect( TRoute::_('index.php?option=com_adsmanager&view=list&catid='.$catid));
			}
		}
		
		if ($content == null)
			$app->redirect( JRoute::_('index.php?option=com_adsmanager&view=front&status=error'), JText::_('ADSMANAGER_ADS_NO_RIGHT'),'message' );
		
        if($user->guest == false){
            $favorites = $contentmodel->getFavorites($user->id);
        } else {
            $favorites = array();
        }
        $this->assignRef('favorites',$favorites);
        
        $showContact = TPermissions::checkRightContact();
		
        $this->assignRef('showContact',$showContact);
		$this->assignRef('list_name',$category->name);
		$this->assignRef('list_img',$category->img);
		$this->assignRef('list_description',$category->description);
		$this->assignRef('positions',$positions);	
		$this->assignRef('fDisplay',$fDisplay);	
		$this->assignRef('conf',$conf);
		$this->assignRef('userid',$user->id);
		
		$fields = $fieldmodel->getFields();
		$this->assignRef('fields',$fields);
		
		$document->setTitle( JText::_('ADSMANAGER_PAGE_TITLE')." ".JText::_($category->name)." - ".$content->ad_headline);

		//set breadcrumbs 
		$pathlist = $catmodel->getPathList($catid,'read',$rootid);
		$nb = count($pathlist);
		for ($i = $nb - 1 ; $i >=0;$i--)
		{
			$pathway->addItem($pathlist[$i]->text, $pathlist[$i]->link);
		}
		
		// need to be before getMultiLangText
		$plugins = $fieldmodel->getPlugins();
		
		if (ADSMANAGER_SPECIAL == "abrivac") {
			$pathway->addItem(getMultiLangText($content->ad_headline), "#");
		} else {
			$pathway->addItem($content->ad_headline, "#");
		}
		
		
		$field = new JHTMLAdsmanagerField($conf,$field_values,'1',$plugins);
		
		$this->assignRef('field',$field);
		
		$general = new JHTMLAdsmanagerGeneral($catid,$conf,$user);
		$this->assignRef('general',$general);
		
		//
		// Process the content plugins.
		//
		$dispatcher = JDispatcher::getInstance();
		JPluginHelper::importPlugin('adsmanagercontent');
		
		
		$results = $dispatcher->trigger('ADSonContentPrepare', array ($content));

		$event = new stdClass();
		$results = $dispatcher->trigger('ADSonContentAfterTitle', array ($content));
		$event->onContentAfterTitle = trim(implode("\n", $results));

		$results = $dispatcher->trigger('ADSonContentBeforeDisplay', array ($content));
		$event->onContentBeforeDisplay = trim(implode("\n", $results));

		$results = $dispatcher->trigger('ADSonContentAfterDisplay', array ($content));
		$event->onContentAfterDisplay = trim(implode("\n", $results));
		
		$content->event = $event;
		$this->assignRef('content',$content);
		
		if ($conf->metadata_mode == 'automatic') {
			if (ADSMANAGER_SPECIAL == "abrivac") {
				$content->metadata_description = getMultiLangText($content->ad_description);
				$content->metadata_keywords = str_replace(" ",",",getMultiLangText($content->ad_headline));
			} else {
				$content->metadata_description = $content->ad_text;
				$content->metadata_keywords = str_replace(" ",",",$content->ad_headline);
			}
		}
		
        if($conf->image_display == 'jssor') {
            $tpl = 'jssor';
        }
        
		parent::display($tpl);
	}
Пример #6
0
 /**
  * Saves the content item an edit form submit
  *
  * @todo
  */
 function save()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $user = JFactory::getUser();
     $content = JTable::getInstance('contents', 'AdsmanagerTable');
     $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models');
     $configurationmodel = $this->getModel("configuration");
     $contentmodel = $this->getModel("content");
     $usermodel = $this->getModel("user");
     $fieldmodel = $this->getModel("field");
     $conf = $configurationmodel->getConfiguration();
     $plugins = $fieldmodel->getPlugins();
     $id = JRequest::getInt('id', 0);
     // New or Update
     if ($id != 0) {
         $content->load($id);
         if ($content == null || $content->userid != $user->id) {
             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'));
         }
         $isUpdateMode = 1;
         if ($conf->update_validation == 1) {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_CONFIRM');
         } else {
             $redirect_text = JText::_('ADSMANAGER_AD_UPDATED');
         }
     } else {
         $isUpdateMode = 0;
         if ($conf->auto_publish == 0) {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_CONFIRM');
         } else {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_PUBLISH');
         }
     }
     //Check Max Ads by User
     $nbcats = $conf->nbcats;
     if (function_exists("getMaxCats")) {
         $nbcats = getMaxCats($conf->nbcats);
     }
     if ($nbcats <= 1) {
         if (function_exists("checkAuthorisedNumberAds")) {
             $limitAds = checkAuthorisedNumberAds($contentmodel, JRequest::getInt('category', 0));
             if ($limitAds !== true) {
                 $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_PER_CATEGORY_REACHED'), $limitAds);
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
             }
         } else {
             if (JRequest::getInt('category', 0) != 0) {
                 $category = JRequest::getInt('category', 0);
                 // Need to check limit only for new ad and if category of ad is changed
                 if ($isUpdateMode == 0 || !in_array($category, $contentmodel->getContentCategories($id))) {
                     $nb = $contentmodel->getNbContentsOfUser($user->id, $category);
                     //TODO : check authorised number for multi-categories
                     $categoriesModel = $this->getModel("category");
                     $category = $categoriesModel->getCategory($category);
                     if ($category->limitads !== "" && $category->limitads !== null) {
                         if ($nb >= $category->limitads && $category->limitads != -1) {
                             $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_PER_CATEGORY_REACHED'), $category->limitads);
                             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
                         }
                     }
                 }
             }
         }
     }
     if ($id == 0 && $user->id != "0" && $conf->nb_ads_by_user != -1) {
         $nb = $contentmodel->getNbContentsOfUser($user->id);
         if ($nb >= $conf->nb_ads_by_user) {
             $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_REACHED'), $conf->nb_ads_by_user);
             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
         }
     }
     //check if user can post an ad in the category selected
     //TODO : If multiple category
     if (version_compare(JVERSION, '1.6', 'ge')) {
         if ($nbcats <= 1) {
             $authorisedCategory = TPermissions::getAuthorisedCategories('write');
             if (array_search(JRequest::getInt('category', 0), $authorisedCategory) === false) {
                 $redirect_text = sprintf(JText::_('ADSMANAGER_FORBIDDEN_CATEGORY'), $conf->nb_ads_by_user);
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
             }
         }
     }
     $current = clone $content;
     $content->bindContent(JRequest::get('post'), JRequest::get('files'), $conf, $this->getModel("adsmanager"), $plugins);
     if (function_exists('bindPaidSystemContent')) {
         bindPaidSystemContent($content, JRequest::get('post'), JRequest::get('files'), $conf, $this->getModel("adsmanager"));
     }
     $content->current = $current;
     $errors = $content->getErrors();
     if (count($errors) > 0) {
         $this->reloadForm($content);
     }
     if ($conf->metadata_mode == 'backendonly') {
         $content->metadata_description = JRequest::getVar('ad_text', '');
         $content->metadata_keywords = str_replace(" ", ",", JRequest::getVar('ad_headline', ''));
     }
     $errorMsg = null;
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     try {
         $results = $dispatcher->trigger('ADSonContentBeforeSave', array());
     } catch (Exception $e) {
         $errorMsg = $e->getMessage();
         $this->reloadForm($content, $errorMsg);
     }
     //Creation of account if needed
     if ($conf->submission_type == 0 && $user->id == 0) {
         $username = JRequest::getVar('username', "");
         $password = JRequest::getVar('password', "");
         $email = JRequest::getVar('email', "");
         $errorMsg = $usermodel->checkAccount($username, $password, $email, $userid, $conf);
         if (isset($errorMsg)) {
             $this->reloadForm($content, $errorMsg);
         }
         $user->id = $userid;
     }
     //Valid account or visitor are allowed to post
     if ($user->id != 0 || $conf->submission_type == 2) {
         $content->userid = $user->id;
     } else {
         //trying to save ad, without being registered
         return;
     }
     if (function_exists("getPaidSystemMode")) {
         $mode = getPaidSystemMode();
     } else {
         $mode = "nopaidsystem";
     }
     $total = 0;
     switch ($mode) {
         case "credits":
             computeCost($total, $items, $content, $conf, $isUpdateMode);
             if ($total == 0) {
                 $content->save();
             } else {
                 if (checkCredits($total, $user->id) == true) {
                     //TODO ?
                     //generateBill($content,$total,$items,$mode,"ok");
                     removeCredits($user->id, $total, $items, 'Adsmanager');
                     $content->save();
                 } else {
                     $errorMsg = sprintf(JText::_('PAIDSYSTEM_NOT_ENOUGH_CREDITS'), strtolower(getCurrencySymbol()));
                     $this->reloadForm($content, $errorMsg);
                 }
             }
             break;
         case "payperad":
             $adid = $content->savePending();
             $content->isPending = true;
             computeCost($total, $items, $content, $conf, $isUpdateMode);
             if ($total == 0) {
                 $content->save();
             } else {
                 $invoice_id = generateBill($content, $items, $adid);
             }
             break;
         case "nopaidsystem":
             $content->save();
             break;
     }
     // We need to put "pending or new values" in the $content obj instead of $content->data
     $content->map();
     if ($mode == "payperad" && $total > 0 && $isUpdateMode == 0) {
         if (@$conf->preview == 1) {
             $app->redirect('index.php?option=com_adsmanager&view=preview&id=' . $adid);
         } else {
             Invoicing::redirectToPayment($invoice_id);
             //$app->redirect( 'index.php?option=com_paidsystem&view=payment');
         }
     } else {
         if (@$conf->preview == 1 && JRequest::getInt('pending', 0) == 1) {
             $app->redirect('index.php?option=com_adsmanager&view=preview&id=' . $adid);
         } else {
             if ($mode == "payperad" && $total > 0 && $isUpdateMode == 1) {
                 Invoicing::redirectToPayment($invoice_id);
             } else {
                 $cache =& JFactory::getCache('com_adsmanager');
                 $cache->clean();
                 if ($isUpdateMode == 0) {
                     if ($conf->send_email_on_new_to_user == 1 && $conf->auto_publish == 1) {
                         $contentmodel->sendMailToUser($conf->new_subject, $conf->new_text, $user, $content, $conf, "new");
                     } else {
                         if ($conf->send_email_waiting_validation_to_user == 1 && $conf->auto_publish == 0) {
                             $contentmodel->sendMailToUser($conf->waiting_validation_subject, $conf->waiting_validation_text, $user, $content, $conf, "waiting_validation");
                         }
                     }
                     if ($conf->email_on_waiting_validation == 1 && $conf->auto_publish == 0) {
                         if (isset($conf->admin_waiting_validation_subject) && $conf->admin_waiting_validation_text) {
                             $contentmodel->sendMailToAdmin($conf->admin_waiting_validation_subject, $conf->admin_waiting_validation_text, $user, $content, $conf, "admin_waiting_validation");
                         }
                     }
                     if ($conf->send_email_on_new == 1) {
                         $contentmodel->sendMailToAdmin($conf->admin_new_subject, $conf->admin_new_text, $user, $content, $conf, "new");
                     }
                 } else {
                     if ($conf->update_validation == 1) {
                         $contentmodel->sendMailToUser($conf->waiting_validation_subject, $conf->waiting_validation_text, $user, $content, $conf, "waiting_validation");
                     } else {
                         if ($conf->send_email_on_update_to_user == 1) {
                             $contentmodel->sendMailToUser($conf->update_subject, $conf->update_text, $user, $content, $conf, "update");
                         }
                     }
                     if ($conf->email_on_waiting_validation == 1 && $conf->update_validation == 1) {
                         if (isset($conf->admin_waiting_validation_subject) && $conf->admin_waiting_validation_text) {
                             $contentmodel->sendMailToAdmin($conf->admin_waiting_validation_subject, $conf->admin_waiting_validation_text, $user, $content, $conf, "admin_waiting_validation");
                         }
                     }
                     if ($conf->send_email_on_update == 1) {
                         $contentmodel->sendMailToAdmin($conf->admin_update_subject, $conf->admin_update_text, $user, $content, $conf, "update");
                     }
                 }
                 JPluginHelper::importPlugin('adsmanagercontent');
                 try {
                     $results = $dispatcher->trigger('ADSonContentAfterSave', array($content, $isUpdateMode, $conf));
                 } catch (Exception $e) {
                     $errorMsg = $e->getMessage();
                 }
                 //Redirect
                 if ($conf->submission_type == 2) {
                     $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
                 } else {
                     $app->redirect(TLink::getMyAdsLink(), $redirect_text, 'message');
                 }
             }
         }
     }
 }
Пример #7
0
 function display($tpl = null)
 {
     //TODO	JFactory::getApplication()->allowCache(true);
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $contentmodel = $this->getModel("content");
     $catmodel = $this->getModel("category");
     $columnmodel = $this->getModel("column");
     $positionmodel = $this->getModel("position");
     $fieldmodel = $this->getModel("field");
     $usermodel = $this->getModel("user");
     $configurationmodel = $this->getModel("configuration");
     $uri = JFactory::getURI();
     $this->requestURL = $uri->toString();
     // Get the parameters of the active menu item
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $conf = $configurationmodel->getConfiguration();
     $this->assignRef('conf', $conf);
     $this->assignRef('userid', $user->id);
     $filters = array();
     if (isset($conf->publication_date) && $conf->publication_date == 1) {
         $filters['publication_date'] = 1;
     }
     jimport('joomla.session.session');
     $global_filter = JRequest::getInt('global_filter', 0);
     if ($global_filter == 1) {
         $searchfields = $fieldmodel->getFields();
         $globalfiltersql = $fieldmodel->getSearchFieldsSql($searchfields);
         $currentSession = JSession::getInstance('none', array());
         $currentSession->set("sqlglobalfilter", $globalfiltersql);
         $currentSession->set("globalfilter_values", JRequest::get('request'));
     }
     $new_search = JRequest::getInt('new_search', 0);
     if ($new_search == 1) {
         if (!JRequest::getInt('search_catid', 0)) {
             $catid = JRequest::getInt('catid', 0);
         } else {
             $catid = JRequest::getInt('search_catid', 0);
         }
         if ($catid == -1) {
             $catid = 0;
         }
         $searchfields = $fieldmodel->getFields();
         $filters['fields'] = $fieldmodel->getSearchFieldsSql($searchfields);
         $currentSession = JSession::getInstance('none', array());
         $currentSession->set("searchfieldssql", $filters['fields']);
         $currentSession->set("search_fields", JRequest::get('request'));
         $currentSession->set("searchfieldscatid", $catid);
         if (@$conf->globalfilter_fieldname != "") {
             $globalfilter = JRequest::getVar($conf->globalfilter_fieldname, null);
             if ($globalfilter !== null) {
                 $searchfields = $fieldmodel->getFieldsByName("'" . $conf->globalfilter_fieldname . "'");
                 $globalfiltersql = $fieldmodel->getSearchFieldsSql($searchfields);
                 $currentSession = JSession::getInstance('none', array());
                 $currentSession->set("sqlglobalfilter", $globalfiltersql);
                 $currentSession->set("globalfilter_values", array($conf->globalfilter_fieldname => $globalfilter));
             }
         }
         $tsearch = JRequest::getVar('tsearch', "");
         $currentSession->set('tsearch', $tsearch, 'adsmanager');
     } else {
         $currentSession = JSession::getInstance('none', array());
         $filters['fields'] = $currentSession->get("searchfieldssql", " 1 ");
         $tsearch = $currentSession->get("tsearch", "", 'adsmanager');
     }
     $defaultvalues = $currentSession->get("search_fields", "1");
     $this->assignRef('searchfieldvalues', $defaultvalues);
     $catid = $currentSession->get("searchfieldscatid", JRequest::getInt('catid', 0));
     $this->assignRef('catid', $catid);
     $mode = $app->getUserStateFromRequest('com_adsmanager.front_content.mode', 'mode', $conf->display_expand);
     if ($mode == 2) {
         $mode = 0;
     }
     $this->assignRef('mode', $mode);
     $columns = array();
     $fcolumns = array();
     $positions = array();
     $fDisplay = array();
     if ($mode == 0) {
         $columns = $columnmodel->getColumns($catid);
         $fcolumns = $fieldmodel->getFieldsbyColumns();
         $this->assignRef('columns', $columns);
         $this->assignRef('fColumns', $fcolumns);
     } else {
         $positions = $positionmodel->getPositions('details');
         $fDisplay = $fieldmodel->getFieldsbyPositions();
         $this->assignRef('positions', $positions);
         $this->assignRef('fDisplay', $fDisplay);
     }
     $filters['publish'] = 1;
     if ($catid != 0) {
         $filters['category'] = $catid;
     }
     if ($tsearch != "") {
         $filters['search'] = $tsearch;
     }
     $this->assignRef('text_search', $tsearch);
     $orderfields = $fieldmodel->getOrderFields($catid);
     $this->assignRef('orders', $orderfields);
     $limitstart = JRequest::getInt("limitstart", 0);
     $customlimit = $app->getUserStateFromRequest('com_adsmanager.front_content.limit_per_page', 'limit', 0, 'String');
     $this->assignRef('adsperpage', $customlimit);
     if ($customlimit == 0) {
         $limit = $conf->ads_per_page;
     } else {
         if ($customlimit == 'all') {
             $limit = $conf->ads_per_page;
         } else {
             $limit = (int) $customlimit;
         }
     }
     $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order', 'order', 0, 'int');
     $orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderid', 'orderdir', 'DESC');
     $orderdir = strtoupper($orderdir);
     if ($orderdir != "DESC" && $orderdir != "ASC") {
         $orderdir = "DESC";
     }
     $filter_order = $contentmodel->getFilterOrder($order);
     $filter_order_dir = $orderdir;
     $this->assignRef('order', $order);
     $this->assignRef('orderdir', $orderdir);
     $listuser = JRequest::getInt("user", -1);
     if ($listuser != -1) {
         $filters['user'] = $listuser;
     }
     $rootid = JRequest::getInt('rootid', 0);
     $filters['rootid'] = $rootid;
     $total = $contentmodel->getNbContents($filters);
     $contents = $contentmodel->getContents($filters, $limitstart, $limit, $filter_order, $filter_order_dir);
     if ($user->guest == false) {
         $favorites = $contentmodel->getFavorites($user->id);
     } else {
         $favorites = array();
     }
     $this->assignRef('favorites', $favorites);
     $showContact = TPermissions::checkRightContact();
     $this->assignRef('showContact', $showContact);
     $this->assignRef('contents', $contents);
     jimport('joomla.html.pagination');
     $pagination = new JPagination($total, $limitstart, $limit);
     $this->assignRef('pagination', $pagination);
     $name = JText::_('ADSMANAGER_PAGE_RESULT');
     $img = "";
     $this->assignRef('list_name', $name);
     $this->assignRef('list_img', $img);
     $this->assignRef('requestURL', $requestURL);
     $document->setTitle(JText::_('ADSMANAGER_PAGE_TITLE') . JText::_('ADSMANAGER_PAGE_RESULT'));
     $field_values = $fieldmodel->getFieldValues();
     $fields = $fieldmodel->getFields();
     $this->assignRef('fields', $fields);
     $plugins = $fieldmodel->getPlugins();
     $field = new JHTMLAdsmanagerField($conf, $field_values, $mode, $plugins);
     $this->assignRef('field', $field);
     $general = new JHTMLAdsmanagerGeneral($catid, $conf, $user);
     $this->assignRef('general', $general);
     $searchfields = $fieldmodel->getSearchFields();
     $cats = $catmodel->getCatTree(true, false, $nbcontents, 'read', $rootid);
     $this->assignRef('searchfields', $searchfields);
     $this->assignRef('cats', $cats);
     parent::display($tpl);
 }
Пример #8
0
    /**
     * Return if a user can see the ads contact
     * 
     * @return boolean
     */
	static public function checkRightContact(){
        
        //If the static variable is already set, we directly return it
        if (self::$showContact == null) {
            $user = JFactory::getUser();
            
            $conf = TConf::getConfig();
            
            $userGroups = array();

            if(version_compare(JVERSION, '1.6', 'ge')) {
                //If the user is a guest, we authorise the public group
                //else we return the authorised group of the user
                if($user->guest)
                    $userGroups[] = 1;
                else
                    $userGroups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id);

                $authorisedContact = false;
                $allowedContacts = explode(',', $conf->show_contact);

                foreach ($userGroups as $userGroup) {
                    if(array_search($userGroup, $allowedContacts) !== false){
                        $authorisedContact = true;
                    }
                }

                self::$showContact = $authorisedContact;
            } else {
                self::$showContact = true;
            }
        }
        return self::$showContact;
    }
Пример #9
0
 function getFieldsbyPositions($published = true, $usergroups = true, $mode = 'read')
 {
     if ($published) {
         $sqlpublished = "AND f.published = 1 ";
     } else {
         $sqlpublished = "";
     }
     $this->_db->setQuery("SELECT f.* FROM #__adsmanager_fields AS f " . "WHERE f.pos != -1 {$sqlpublished} ORDER by f.posorder");
     $fields = $this->_db->loadObjectList();
     if ($this->_db->getErrorNum()) {
         echo $this->_db->stderr();
         return;
     }
     foreach ($fields as $key => $field) {
         $fields[$key]->options = json_decode($field->options);
     }
     if ($usergroups) {
         require_once JPATH_ROOT . '/components/com_adsmanager/lib/tpermissions.php';
         $fields = TPermissions::getAuthorisedFields($fields, $mode);
     }
     // establish the hierarchy of the menu
     $fDisplay = array();
     // first pass - collect children
     if (isset($fields)) {
         foreach ($fields as $f) {
             $pt = $f->pos;
             $list = @$fDisplay[$pt] ? $fDisplay[$pt] : array();
             array_push($list, $f);
             $fDisplay[$pt] = $list;
         }
     }
     return $fDisplay;
 }
Пример #10
0
 function getDisplayTab($tab, $user, $ui)
 {
     require_once JPATH_ROOT . "/components/com_adsmanager/lib/core.php";
     $app = JFactory::getApplication();
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/adsmanager.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/column.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/category.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/configuration.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/content.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/field.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/position.php';
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/user.php';
     $juser = JFactory::getUser();
     if ($user->id == $juser->id) {
         $myads = true;
     } else {
         $myads = false;
     }
     if ($myads == true) {
         require_once JPATH_ROOT . '/components/com_adsmanager/views/myads/view.html.php';
     } else {
         require_once JPATH_ROOT . '/components/com_adsmanager/views/list/view.html.php';
     }
     if (file_exists(JPATH_ROOT . "/components/com_paidsystem/api.paidsystem.php")) {
         require_once JPATH_ROOT . "/components/com_paidsystem/api.paidsystem.php";
     }
     $uri = JFactory::getURI();
     $baseurl = JURI::base();
     $document = JFactory::getDocument();
     $templateDir = JPATH_ROOT . '/templates/' . $app->getTemplate();
     if (is_file($templateDir . '/html/com_adsmanager/css/adsmanager.css')) {
         $templateDir = JURI::base() . 'templates/' . $app->getTemplate();
         $document->addStyleSheet($templateDir . '/html/com_adsmanager/css/adsmanager.css');
     } else {
         $document->addStyleSheet($baseurl . 'components/com_adsmanager/css/adsmanager.css');
     }
     $contentmodel = new AdsmanagerModelContent();
     $catmodel = new AdsmanagerModelCategory();
     $positionmodel = new AdsmanagerModelPosition();
     $columnmodel = new AdsmanagerModelColumn();
     $fieldmodel = new AdsmanagerModelField();
     $usermodel = new AdsmanagerModelUser();
     $adsmanagermodel = new AdsmanagerModelAdsmanager();
     $configurationmodel = new AdsmanagerModelConfiguration();
     $catid = 0;
     $config = array();
     $config = array();
     $templateDir = JPATH_ROOT . '/templates/' . $app->getTemplate();
     if ($myads == true) {
         if (is_file($templateDir . '/html/com_adsmanager/myads/default.php')) {
             $config['template_path'] = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/com_adsmanager/myads';
         } else {
             $config['template_path'] = JPATH_BASE . '/components/com_adsmanager/views/myads/tmpl';
         }
         $view = new AdsmanagerViewMyads($config);
     } else {
         if (is_file($templateDir . '/html/com_adsmanager/list/default.php')) {
             $config['template_path'] = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/com_adsmanager/list';
         } else {
             $config['template_path'] = JPATH_BASE . '/components/com_adsmanager/views/list/tmpl';
         }
         $view = new AdsmanagerViewList($config);
     }
     $uri = JFactory::getURI();
     $requestURL = $uri->toString();
     $conf = $configurationmodel->getConfiguration();
     $filters = array();
     if ($myads == false) {
         $filters['publish'] = 1;
     }
     $filters['user'] = $user->id;
     $tsearch = JRequest::getVar('tsearch', '');
     if ($tsearch != "") {
         $filters['search'] = $tsearch;
     }
     $view->assignRef('tsearch', $tsearch);
     $showContact = TPermissions::checkRightContact();
     $view->assignRef('showContact', $showContact);
     $category = new stdClass();
     if ($conf->display_fullname) {
         $category->name = JText::_('ADSMANAGER_LIST_USER_TEXT') . " " . $user->name;
     } else {
         $category->name = JText::_('ADSMANAGER_LIST_USER_TEXT') . " " . $user->username;
     }
     $subcats = array();
     $pathlist = array();
     $orderfields = $fieldmodel->getOrderFields(0);
     $uri = JFactory::getURI();
     $baseurl = JURI::base();
     $view->assign("baseurl", $baseurl);
     $view->assignRef("baseurl", $baseurl);
     $view->assignRef('catid', $catid);
     $view->assignRef('listuser', $user->id);
     $modeuser = 1;
     $view->assignRef('modeuser', $modeuser);
     $tsearch = "";
     $view->assignRef('tsearch', $tsearch);
     $view->assignRef('orders', $orderfields);
     $view->assignRef('subcats', $subcats);
     $view->assignRef('pathlist', $pathlist);
     if (file_exists(JPATH_ROOT . '/components/com_sh404sef')) {
         $limit = $conf->ads_per_page;
     } else {
         $limit = $app->getUserStateFromRequest('com_adsmanager.front_ads_per_page', 'limit', $conf->ads_per_page, 'int');
     }
     $limitstart = JRequest::getInt("limitstart", 0);
     $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order', 'order', 0, 'int');
     $orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderdir', 'orderdir', 'DESC');
     $orderdir = strtoupper($orderdir);
     if ($orderdir != "DESC" && $orderdir != "ASC") {
         $orderdir = "DESC";
     }
     $filter_order = $contentmodel->getFilterOrder($order);
     $filter_order_dir = $orderdir;
     $view->assignRef('order', $order);
     $view->assignRef('orderdir', $orderdir);
     $view->assignRef('lists', $lists);
     $total = $contentmodel->getNbContents($filters);
     $contents = $contentmodel->getContents($filters, $limitstart, $limit, $filter_order, $filter_order_dir, 1);
     if ($juser->guest == false) {
         $favorites = $contentmodel->getFavorites($juser->id);
     } else {
         $favorites = array();
     }
     $view->assignRef('favorites', $favorites);
     $userId = JRequest::getInt("user", 0);
     if ($userId != 0) {
         $userId = '&user='******'';
     }
     $pagination = new JPagination2($total, $limitstart, $limit, "index.php?option=com_comprofiler&tab=AdsmanagerTab&limit={$limit}" . $userId);
     $view->assignRef('pagination', $pagination);
     $view->assignRef('list_name', $category->name);
     $view->assignRef('list_img', $category->img);
     $view->assignRef('list_description', $category->description);
     $view->assignRef('contents', $contents);
     $mode = $app->getUserStateFromRequest('com_adsmanager.front_content.mode', 'mode', $conf->display_expand);
     if ($mode == 2) {
         $mode = 0;
     }
     $view->assignRef('mode', $mode);
     if ($mode == 0) {
         $columns = $columnmodel->getColumns($catid);
         $fcolumns = $fieldmodel->getFieldsbyColumns();
         $view->assignRef('columns', $columns);
         $view->assignRef('fColumns', $fcolumns);
     } else {
         $positions = $positionmodel->getPositions('details');
         $fDisplay = $fieldmodel->getFieldsbyPositions();
         $view->assignRef('positions', $positions);
         $view->assignRef('fDisplay', $fDisplay);
     }
     $fields = $fieldmodel->getFields();
     $view->assignRef('fields', $fields);
     //Unactive Map Display on User List because the loadModule function is not working on CB page (I don't know why)
     $conf->display_map_list = 0;
     $view->assignRef('conf', $conf);
     $my = JFactory::getUser();
     $view->assignRef('userid', $my->id);
     $view->assignRef('requestURL', $requestURL);
     $field_values = $fieldmodel->getFieldValues();
     $plugins = $fieldmodel->getPlugins();
     $field = new JHTMLAdsmanagerField($conf, $field_values, $mode, $plugins, null);
     $view->assignRef('field', $field);
     $general = new JHTMLAdsmanagerGeneral($catid, $conf, $user);
     $view->assignRef('general', $general);
     $return = $view->loadTemplate(null);
     $path = JPATH_ADMINISTRATOR . '/../libraries/joomla/database/table';
     JTable::addIncludePath($path);
     return $return;
 }
Пример #11
0
	function display($tpl = null)
	{
		$app = JFactory::getApplication();

		$user		= JFactory::getUser();
		$pathway	= $app->getPathway();
		$document	= JFactory::getDocument();
		
		$contentmodel	=$this->getModel( "content" );
		$catmodel		=$this->getModel( "category" );
		$positionmodel	=$this->getModel( "position" );
		$columnmodel	=$this->getModel( "column" );
		$fieldmodel	    =$this->getModel( "field" );
		$usermodel	    =$this->getModel( "user" );
		$configurationmodel	=$this->getModel( "configuration" );
		
		$uri = JFactory::getURI();
		$this->requestURL = $uri->toString();

		// Get the parameters of the active menu item
		$menus	= $app->getMenu();
		$menu    = $menus->getActive();
		
		$conf = $configurationmodel->getConfiguration();
		
		$catid = JRequest::getInt( 'catid',	0 );
		$this->assignRef('catid',$catid);
		if ($catid != "0") {
			$category = $catmodel->getCategory($catid);
			$category->img = TTools::getCatImageUrl($catid,true);
            $category->imgdefault = false;
		}
		else
		{
			$category = new stdClass();
			$category->name = JText::_("ADSMANAGER_ALL_ADS");
			$category->description = "";
			$category->img = $this->get('baseurl').'components/com_adsmanager/images/default.gif';
            $category->imgdefault = true;
		}
		
		jimport( 'joomla.session.session' );	
		$currentSession = JSession::getInstance('none',array());
		$currentSession->set("search_fields","");
        $currentSession->set("searchfieldssql"," 1 ");
		$currentSession->set("searchfieldscatid",0);
		$currentSession->set("tsearch","",'adsmanager');
		
		$global_filter = JRequest::getInt( 'global_filter',	0 );
		if ($global_filter == 1){
			$searchfields = $fieldmodel->getFields(0);
			$globalfiltersql = $fieldmodel->getSearchFieldsSql($searchfields);
			$currentSession->set("sqlglobalfilter",$globalfiltersql);
			$currentSession->set("globalfilter_values",JRequest::get( 'request' ));
		}
		
		$filters = array();
		$filters['publish'] =  1;
		if ($catid != 0)
			$filters['category'] = $catid;
			
        if(isset($conf->publication_date) && $conf->publication_date == 1) {
            $filters['publication_date'] = 1;
        }
        
		$modeuser = 0;
        
		$listuser = JRequest::getInt( 'user',	-1 );
		if (($listuser == 0)&&($user->id != 0))
			$listuser = $user->id;
			
		if ($listuser != -1) {			
			$filters['user'] = $listuser;
			$user = $usermodel->getUser($listuser);
			if ($conf->display_fullname) {
				$category->name = JText::_('ADSMANAGER_LIST_USER_TEXT')." ".$user->name;
			} else {
				$category->name = JText::_('ADSMANAGER_LIST_USER_TEXT')." ".$user->username;
			}
			$this->assignRef('listuser',$listuser);
			$modeuser = 1;		
		}
		
		$this->assignRef('modeuser',$modeuser);
		
		$session = JFactory::getSession();
		$list_type = $session->get('list_type','','adsmanager');
		$list_value = $session->get('list_value','','adsmanager');

		if ($listuser != -1) {	
			if (($list_type == 'user')&&($list_value == $listuser)) {
				$tsearch = JRequest::getVar( 'tsearch',	$session->get('tsearch','','adsmanager'));
				$session->set('tsearch',$tsearch,'adsmanager');
			} else {
				$session->set('list_type','user','adsmanager');
				$session->set('list_value',$listuser,'adsmanager');
				$session->set('tsearch','','adsmanager');
				$tsearch = '';
			}
		} else {
			if (($list_type == 'category')&&($list_value == $catid)) {
				$tsearch = JRequest::getVar( 'tsearch',	$session->get('tsearch','','adsmanager'));
				$session->set('tsearch',$tsearch,'adsmanager');
			} else {
				$session->set('list_type','category','adsmanager');
				$session->set('list_value',$catid,'adsmanager');
				$session->set('tsearch','','adsmanager');
				$tsearch = '';
			}
		}
		
		if ($tsearch != "")
		{
			$filters['search'] = $tsearch;
		}
		$this->assignRef('tsearch',$tsearch);
		
		$rootid = JRequest::getInt('rootid',0);

		if ($listuser == -1) {
			$subcats = $catmodel->getSubCats($catid,'read',$rootid);
			$pathlist = $catmodel->getPathList($catid,'read',$rootid);
		}
		else
		{
			$subcats = array();
			$pathlist = array();
		}
		
		$orderfields = $fieldmodel->getOrderFields($catid);
		
		$this->assignRef('orders',$orderfields);
		
		$this->assignRef('subcats',$subcats);
		$this->assignRef('pathlist',$pathlist);
			
		$limitstart = JRequest::getInt("limitstart",0);
			
        $customlimit = $app->getUserStateFromRequest('com_adsmanager.front_content.limit_per_page','limit',0,'String');
		$this->assignRef('adsperpage',$customlimit);
		if($customlimit == 0){
			$limit = $conf->ads_per_page;
        }else{
            if($customlimit == 'all'){
                $limit = $conf->ads_per_page;
            }else{
                $limit = (int)$customlimit;
            }
        }
		
		$fields = $fieldmodel->getFields();
		$this->assignRef('fields',$fields);
		
		$order = $app->getUserStateFromRequest('com_adsmanager.front_content.order','order',0,'int');
		$orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderdir','orderdir','DESC');
		$orderdir = strtoupper($orderdir);
		if (($orderdir != "DESC") && ($orderdir != "ASC")) {
			$orderdir = "DESC";
		}
		$filter_order = $contentmodel->getFilterOrder($order);
		$filter_order_dir = $orderdir;
		$this->assignRef('order',$order);
		$this->assignRef('orderdir',$orderdir);

		$this->assignRef('lists',$lists);
		
		$filters['rootid'] = $rootid;
		
        $total = $contentmodel->getNbContents($filters);
		$contents = $contentmodel->getContents($filters,$limitstart, $limit,$filter_order,$filter_order_dir);
		
        if($user->guest == false){
            $favorites = $contentmodel->getFavorites($user->id);
        } else {
            $favorites = array();
        }
        $this->assignRef('favorites',$favorites);
        
        $showContact = TPermissions::checkRightContact();
		
        $this->assignRef('showContact',$showContact);
		jimport('joomla.html.pagination');
		$pagination = new JPagination($total, $limitstart, $limit);
		$this->assignRef('pagination',$pagination);
		
		$this->assignRef('list_name',$category->name);
        $this->assignRef('list_img_default',$category->imgdefault);
		$this->assignRef('list_img',$category->img);
		$this->assignRef('list_description',$category->description);
		$this->assignRef('contents',$contents);
		
		$mode = $app->getUserStateFromRequest('com_adsmanager.front_content.mode','mode',$conf->display_expand);
		if ($mode == 2)
			$mode = 0;
		$this->assignRef('mode',$mode);
		
		$columns = array();
		$fcolumns = array();
		$positions = array();
		$fDisplay = array();
		
		if ($mode == 0) {
			$columns = $columnmodel->getColumns($catid);
			$fcolumns = $fieldmodel->getFieldsbyColumns();
			$this->assignRef('columns',$columns);	
			$this->assignRef('fColumns',$fcolumns);	
		}
		else {
			$positions = $positionmodel->getPositions();
			$fDisplay = $fieldmodel->getFieldsbyPositions();
			$this->assignRef('positions',$positions);	
			$this->assignRef('fDisplay',$fDisplay);	
		}
		
		
		
		$this->assignRef('conf',$conf);
		$this->assignRef('userid',$user->id);
		
		$this->assignRef('requestURL',$requestURL);
		
		$document->setTitle( JText::_('ADSMANAGER_PAGE_TITLE'). JText::_($category->name) );
		if (($catid != 0)&&($conf->metadata_mode != 'nometadata')) {
			$document->setMetaData("description", $category->metadata_description);
			$document->setMetaData("keywords", $category->metadata_keywords);
		}
		
		$field_values = $fieldmodel->getFieldValues();
		
		$plugins = $fieldmodel->getPlugins();
		$field = new JHTMLAdsmanagerField($conf,$field_values,$mode,$plugins);
		$this->assignRef('field',$field);
		
		//set breadcrumbs 
		$nb = count($pathlist);
		for ($i = $nb - 1 ; $i >=0;$i--)
		{
			$pathway->addItem($pathlist[$i]->text, $pathlist[$i]->link);
		}
		
		$general = new JHTMLAdsmanagerGeneral($catid,$conf,$user);
		$this->assignRef('general',$general);
		
		$searchfields = $fieldmodel->getSearchFields();
		$cats = $catmodel->getCatTree(true, false, $nbcontents, 'read',$rootid);
		$this->assignRef('searchfields',$searchfields);
		$this->assignRef('cats',$cats);
		
		$defaultvalues = array();
		$this->assignRef('defaultvalues',$defaultvalues);
		$this->assignRef('catid',$catid);
		$text_search = "";
		$this->assignRef('text_search',$text_search);

		parent::display($tpl);
	}
Пример #12
0
 function getFieldsbyPositions($published = true, $usergroups = true, $mode = 'read', $type = 'details')
 {
     if ($type == "details") {
         $where = "f.pos != -1";
         if ($published) {
             $where .= " AND f.published = 1 ";
         }
         $this->_db->setQuery("SELECT f.*,f.pos as positionid FROM #__adsmanager_fields AS f " . "WHERE {$where} ORDER by f.posorder ASC");
         $fields = $this->_db->loadObjectList();
         if ($this->_db->getErrorNum()) {
             echo $this->_db->stderr();
             return;
         }
     } else {
         $where = "1";
         if ($published) {
             $where .= " AND f.published = 1 ";
         }
         $query = "SELECT f.*,fp.positionid FROM #__adsmanager_fields AS f \n    \t\t\t\t  INNER JOIN #__adsmanager_field2position as fp ON fp.fieldid = f.fieldid\n    \t\t\t\t  WHERE {$where} ORDER by fp.ordering ASC";
         $this->_db->setQuery($query);
         $fields = $this->_db->loadObjectList();
         if ($this->_db->getErrorNum()) {
             echo $this->_db->stderr();
             return;
         }
     }
     foreach ($fields as $key => $field) {
         $fields[$key]->options = json_decode($field->options);
     }
     if ($usergroups) {
         require_once JPATH_ROOT . '/components/com_adsmanager/lib/tpermissions.php';
         $fields = TPermissions::getAuthorisedFields($fields, $mode);
     }
     // establish the hierarchy of the menu
     $fDisplay = array();
     // first pass - collect children
     if (isset($fields)) {
         foreach ($fields as $f) {
             $pt = $f->positionid;
             $list = @$fDisplay[$pt] ? $fDisplay[$pt] : array();
             array_push($list, $f);
             $fDisplay[$pt] = $list;
         }
     }
     return $fDisplay;
 }