Exemple #1
0
	static function execute() {
		$conf = TConf::getConfig();
		require_once(JPATH_BASE.'/administrator/components/com_adsmanager/models/cron.php');
		$cronmodel = new AdsmanagerModelCron();	
		
		$last = $cronmodel->getLastCronTime();
		$current = time();
		$cronmodel->saveCronTime($current);

		//Daily Action
		if (date("d",$current) != date("d",$last))
		{
			if ($conf->crontype != "onrequest")
				echo "Daily Action<br/>\n";
			$contentmodel = new AdsmanagerModelContent();
			$fieldmodel = new AdsmanagerModelField();
			$contentmodel->manage_expiration($fieldmodel->getPlugins(),$conf);
		}

		//Hourly Action
		if (date("H",$current) != date("H",$last))
		{
			if ($conf->crontype != "onrequest")
				echo "Hourly Action<br/>\n";
			if (function_exists("managePaidOption")) {
				managePaidOption();
			}
			$db = JFactory::getDbo();
		
			$query = "SELECT id FROM #__adsmanager_ads";
			$db->setQuery($query);
		
			$ads = $db->loadObjectList();
		
			foreach($ads as $ad) {
				$query = "UPDATE #__adsmanager_ads
						  SET ordering = ".rand(0, 1000)."
						  WHERE id = ".(int)$ad->id;
				$db->setQuery($query);
				$db->query();
			}
		}
	}
 /**
  * Prepare Mail Content, parse tags,etc..
  * @param string $subject mail subject
  * @param string $body mail body
  * @param object $user Ad owner object
  * @param object $content Content Object
  * @param object $conf Adsmanager Configuration
  * @param string $usertype "admin" or "user"
  * @param string $type expiration|recall|new|update|validation|waiting_validation|option_expiration
  */
 function prepareMail(&$subject, &$body, $user, $content, $conf, $usertype, $type)
 {
     $config = JFactory::getConfig();
     $from = JOOMLA_J3 ? $config->get('mailfrom') : $config->getValue('config.mailfrom');
     $fromname = JOOMLA_J3 ? $config->get('fromname') : $config->getValue('config.fromname');
     $sitename = JOOMLA_J3 ? $config->get('sitename') : $config->getValue('config.sitename');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     $results = $dispatcher->trigger('ADSonMailPrepare', array(&$subject, &$body, $user, $content, $conf, $usertype, $type));
     $fieldmodel = new AdsmanagerModelField();
     $fields = $fieldmodel->getFields();
     $field_values = $fieldmodel->getFieldValues();
     $plugins = $fieldmodel->getPlugins();
     $baseurl = JURI::base();
     $field = new JHTMLAdsmanagerField($conf, $field_values, 1, $plugins, '', $baseurl, null);
     foreach ($fields as $f) {
         $fvalue = "";
         if (strpos($subject, "{" . $f->name . "}") !== false) {
             $fvalue = str_replace(array("<br/>", "<br />", "<br>"), "", $field->showFieldValue($content, $f));
             $subject = str_replace("{" . $f->name . "}", $fvalue, $subject);
         }
         if (strpos($body, "{" . $f->name . "}") !== false) {
             if ($fvalue == "") {
                 $fvalue = str_replace(array("<br/>", "<br />", "<br>"), "", $field->showFieldValue($content, $f));
             }
             $body = str_replace("{" . $f->name . "}", $fvalue, $body);
         }
     }
     $subject = str_replace("{id}", $content->id, $subject);
     $body = str_replace("{id}", $content->id, $body);
     $subject = str_replace("{username}", $user->username, $subject);
     $body = str_replace("{username}", $user->username, $body);
     $subject = str_replace("{name}", $user->name, $subject);
     $body = str_replace("{name}", $user->name, $body);
     $subject = str_replace("{sitename}", $sitename, $subject);
     $body = str_replace("{sitename}", $sitename, $body);
     $uri = JURI::getInstance();
     $root = $uri->toString(array('scheme', 'host', 'port'));
     if (!version_compare(JVERSION, '1.6.0', 'ge')) {
         $root = $root . '/';
     }
     $link = $root . TRoute::_("index.php?option=com_adsmanager&view=details&catid=" . $content->catid . "&id=" . $content->id, false);
     $link = str_replace("administrator/", "", $link);
     $body = str_replace('{link}', $link, $body);
     $subject = str_replace("{expiration_date}", strftime(JText::_('ADSMANAGER_DATE_FORMAT_LC'), strtotime($content->expiration_date)), $subject);
     $body = str_replace("{expiration_date}", strftime(JText::_('ADSMANAGER_DATE_FORMAT_LC'), strtotime($content->expiration_date)), $body);
 }
	function display($tpl = null)
	{
		jimport( 'joomla.session.session' );	
        $currentSession = JSession::getInstance('none',array());
        $defaultvalues = $currentSession->get("search_fields",array());

        $catid = $currentSession->get("searchfieldscatid",JRequest::getInt('catid', 0 ));
		$app = JFactory::getApplication();
        $text_search = $currentSession->get("tsearch",$app->getUserStateFromRequest('com_adsmanager.front_content.tsearch','tsearch',""));

        $type = "table";
		
        $fieldmodel  = new AdsmanagerModelField();
        $searchmodel  = new AdsmanagerModelSearchmodule();
        $field_values = array();
        $searchconfig = $searchmodel->getSearchModuleConfiguration();
        $simple_fields = $searchmodel->getSearchFields("simple");
        $advanced_fields = $searchmodel->getSearchFields("advanced");
        $field_values = $fieldmodel->getFieldValues();
		
        foreach($simple_fields as $field)
        {
            if ($field->cbfieldvalues != "-1")
            {
                /*get CB value fields */
                $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues);
                $field_values[$field->fieldid] = $cbfieldvalues;
            }
        }
        foreach($advanced_fields as $field)
        {
            if ($field->cbfieldvalues != "-1")
            {
                /*get CB value fields */
                $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues);
                $field_values[$field->fieldid] = $cbfieldvalues;
            }
        }

		
        $confmodel = new AdsmanagerModelConfiguration();
        $conf = $confmodel->getConfiguration();
		
        $categorymodel = new AdsmanagerModelCategory();
	
        $moduleclass_sfx = '';
		
        $search_by_cat = 1;
        $search_by_text = 0;
		
		
        $rootid = 0 ;
		
        switch($conf->single_category_selection_type) {
            default:
            case 'normal':
            case 'color':
            case 'combobox':
                $cats = $categorymodel->getFlatTree(true, false, $nbcontents, 'read',$rootid);
                break;
            case 'cascade':
                $cats = $categorymodel->getCategoriesPerLevel(true, false, $nbcontents, 'read',$rootid);
                break;
        }

        $baseurl = JURI::base();

        $field = new JHTMLAdsmanagerField($conf,$field_values,"2",$fieldmodel->getPlugins());//0 =>list

        $url = "index.php";
        $this->assignRef('search_by_cat',$search_by_cat);
        $this->assignRef('search_by_text',$search_by_text);
        $this->assignRef('text_search',$text_search);
        $this->assignRef('conf',$conf);
        $this->assignRef('cats',$cats);
        $this->assignRef('catid',$catid);
        $this->assignRef('simple_fields',$simple_fields);
        $this->assignRef('advanced_fields',$advanced_fields);
		$this->assignRef('field',$field);
        $this->assignRef('defaultvalues',$defaultvalues);
        $this->assignRef('rootid',$rootid);
		
		parent::display($tpl);
	}
Exemple #4
0
 function getPlugins()
 {
     if (self::$_plugins) {
         return self::$_plugins;
     } else {
         $plugins = array();
         if (file_exists(JPATH_ROOT . "/images/com_adsmanager/plugins/")) {
             $path = JPATH_ROOT . "/images/com_adsmanager/plugins/";
             $handle = opendir($path);
             while ($file = readdir($handle)) {
                 $dir = $path . '/' . $file;
                 if (is_dir($dir)) {
                     if ($file != "." && $file != "..") {
                         if (file_exists($path . '/' . $file . '/plug.php')) {
                             include_once $path . '/' . $file . '/plug.php';
                             if ($file == "zipcode") {
                                 $plugins["zipcode"] = new AdsManagerZipCodePlugin();
                             }
                             if ($file == "region") {
                                 $plugins["region"] = new AdsManagerRegionPlugin();
                             }
                         } else {
                             if (is_file($path . '/' . $file)) {
                                 JFolder::delete($path . '/' . $file);
                             }
                         }
                     }
                 }
             }
             closedir($handle);
         }
         self::$_plugins = $plugins;
         return self::$_plugins;
     }
 }
Exemple #5
0
 public static function fieldtypes($name = 'type', $selected = '', $attribs = array())
 {
     require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/field.php';
     $model = new AdsmanagerModelField();
     $plugins = $model->getPlugins();
     $types = array();
     $types[] = JHTML::_('select.option', '', '- ' . sprintf(JText::_('ADSMANAGER_COMMON_SELECT'), JText::_('ADSMANAGER_FIELDTYPE')) . ' -');
     $types[] = JHTML::_('select.option', 'checkbox', 'Check Box (Single)');
     $types[] = JHTML::_('select.option', 'multicheckbox', 'Check Box (Multiple)');
     $types[] = JHTML::_('select.option', 'multicheckboximage', 'Check Box (Multiple Images)');
     $types[] = JHTML::_('select.option', 'date', 'Date');
     $types[] = JHTML::_('select.option', 'select', 'Drop Down (Single Select)');
     $types[] = JHTML::_('select.option', 'multiselect', 'Drop Down (Multi-Select)');
     $types[] = JHTML::_('select.option', 'emailaddress', 'Email Address');
     $types[] = JHTML::_('select.option', 'number', 'Number Text');
     $types[] = JHTML::_('select.option', 'price', 'Price');
     $types[] = JHTML::_('select.option', 'editor', 'Editor Text Area');
     $types[] = JHTML::_('select.option', 'textarea', 'Text Area');
     $types[] = JHTML::_('select.option', 'text', 'Text Field');
     $types[] = JHTML::_('select.option', 'url', 'URL');
     $types[] = JHTML::_('select.option', 'radio', 'Radio Button');
     $types[] = JHTMLSelect::option('radioimage', 'Radio Button (Image)');
     $types[] = JHTML::_('select.option', 'file', 'File');
     if (isset($plugins)) {
         foreach ($plugins as $key => $plug) {
             $types[] = JHTML::_('select.option', $key, $plug->getFieldName());
         }
     }
     $html = self::genericlist($types, $name, $attribs, $selected, $name);
     return $html;
 }
 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;
 }
$fields[] = $params->get('field1', "");
$fields[] = $params->get('field2', "");
$fields[] = $params->get('field3', "");
$fields[] = $params->get('field4', "");
$fields[] = $params->get('field5', "");
$type = $params->get('type', "table");
$listfields = "";
foreach ($fields as $field) {
    if ($listfields == "" && $field != "") {
        $listfields .= "'{$field}'";
    }
    if ($field != "") {
        $listfields .= ",'{$field}'";
    }
}
$fieldmodel = new AdsmanagerModelField();
$field_values = array();
if ($listfields != "") {
    $searchfields = $fieldmodel->getFieldsByName($listfields);
    $field_values = $fieldmodel->getFieldValues();
    foreach ($searchfields as $field) {
        if ($field->cbfieldvalues != "-1") {
            /*get CB value fields */
            $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues);
            $field_values[$field->fieldid] = $cbfieldvalues;
        }
    }
}
$confmodel = new AdsmanagerModelConfiguration();
$conf = $confmodel->getConfiguration();
$categorymodel = new AdsmanagerModelCategory();
$nb_ads = intval($params->get('nb_ads', 3));
$rootid = $params->get('rootid', null);
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
$contentmodel = new AdsmanagerModelContent();
$contents = $contentmodel->getLatestContents($nb_ads, $sort_sql, $catselect, $rootid);
if (function_exists("getMaxPaidSystemImages")) {
    $nb_images += getMaxPaidSystemImages();
}
if ($rootid != 0) {
    $urlparamroot = "&rootid={$rootid}";
} else {
    $urlparamroot = "";
}
$uri = JFactory::getURI();
$baseurl = JURI::base();
$catmodel = new AdsmanagerModelCategory();
$columnmodel = new AdsmanagerModelColumn();
$fieldmodel = new AdsmanagerModelField();
$usermodel = new AdsmanagerModelUser();
$adsmanagermodel = new AdsmanagerModelAdsmanager();
$user = JFactory::getUser();
$userid = $user->id;
$columns = $columnmodel->getColumns($catid);
$fColumns = $fieldmodel->getFieldsbyColumns();
$field_values = $fieldmodel->getFieldValues();
$plugins = $fieldmodel->getPlugins();
$field = new JHTMLAdsmanagerField($conf, $field_values, "1", $plugins, null);
require JModuleHelper::getLayoutPath('mod_adsmanager_table', $params->get('layout', 'table'));
$content = "";
$path = JPATH_ADMINISTRATOR . '/../libraries/joomla/database/table';
JTable::addIncludePath($path);