function write($duplicate = false) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); // Set the default view name from the Request $type = "html"; $uri = JFactory::getURI(); $baseurl = JURI::base(); // Push a model into the view $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models'); $configurationmodel = $this->getModel("configuration"); $catmodel = $this->getModel("category"); $contentmodel = $this->getModel("content"); $positionmodel = $this->getModel("position"); $fieldmodel = $this->getModel("field"); $usermodel = $this->getModel("user"); $user = JFactory::getUser(); $conf = $configurationmodel->getConfiguration(); loadAdsManagerCss(); JuloaLib::loadJqueryUI(); /* submission_type = 1 -> Account needed */ if ($conf->submission_type == 1 && $user->id == "0") { TTools::redirectToLogin("index.php?option=com_adsmanager&task=write"); return; } else { $contentid = JRequest::getInt('id', 0); $nbcontents = $contentmodel->getNbContentsOfUser($user->id); if ($contentid == 0 && $user->id != "0" && $conf->nb_ads_by_user != -1 && $nbcontents >= $conf->nb_ads_by_user) { //REDIRECT $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'); } else { $view = $this->getView("edit", 'html'); $view->setModel($contentmodel, true); $view->setModel($catmodel); $view->setModel($configurationmodel); $view->setModel($fieldmodel); $view->setModel($usermodel); $view->setModel($positionmodel); $uri = JFactory::getURI(); $baseurl = JURI::base(); $view->assign("baseurl", $baseurl); if ($duplicate == true) { $isDuplicated = 1; $view->assign("isDuplicated", 1); } $view->display(); } } $path = JPATH_ADMINISTRATOR . '/../libraries/joomla/database/table'; JTable::addIncludePath($path); }
<?php /** * @package AdsManager * @copyright Copyright (C) 2010-2014 Juloa.com. All rights reserved. * @license GNU/GPL */ // no direct access defined('_JEXEC') or die('Restricted access'); require_once JPATH_ROOT . "/components/com_adsmanager/lib/core.php"; require_once JPATH_BASE . '/administrator/components/com_adsmanager/models/configuration.php'; require_once JPATH_BASE . '/administrator/components/com_adsmanager/models/field.php'; require_once JPATH_BASE . '/administrator/components/com_adsmanager/models/category.php'; require_once JPATH_BASE . "/components/com_adsmanager/helpers/field.php"; loadAdsManagerCss(); /****************************************************/ 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', "")); $advanced_search = intval($params->get('advanced_search', 1)); $search_by_cat = intval($params->get('search_by_cat', 1)); $display_cat_label = intval($params->get('display_cat_label', 0)); $search_by_text = intval($params->get('search_by_text', 1)); $fields[] = $params->get('field1', ""); $fields[] = $params->get('field2', ""); $fields[] = $params->get('field3', ""); $fields[] = $params->get('field4', ""); $fields[] = $params->get('field5', "");
function _editcontent() { $this->setEditToolbar(JText::_("COM_ADSMANAGER") . " - " . JText::_("ADSMANAGER_EDIT_CONTENT")); $app = JFactory::getApplication(); $document = JFactory::getDocument(); $user = JFactory::getUser(); $confmodel = $this->getModel("Configuration"); $usermodel = $this->getModel("User"); $contentmodel = $this->getModel("Content"); $catmodel = $this->getModel("Category"); $fieldmodel = $this->getModel("Field"); $conf = $confmodel->getConfiguration(); if (!isset($conf->single_category_selection_type)) { $conf->single_category_selection_type = 'normal'; } $baseurl = JURI::root(); loadAdsManagerCss(); $this->assignRef('conf', $conf); $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::_(""); $category->description = ""; $category->img = ""; } $this->assignRef('category', $category); $this->assignRef('catid', $catid); $fields = $fieldmodel->getFields(); $this->assignRef('fields', $fields); $field_values = $fieldmodel->getFieldValues(); foreach ($fields as $field) { if ($field->cbfieldvalues != "-1") { /*get CB value fields */ $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues); $field_values[$field->fieldid] = $cbfieldvalues; } } $this->assignRef('field_values', $field_values); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf, $field_values, "1", $plugins, "", $this->get('baseurl')); $this->assignRef('field', $field); $errorMsg = JRequest::getString('errorMsg', ""); $this->assignRef('errorMsg', $errorMsg); $users = $usermodel->getUsers(); $this->assignRef('users', $users); /* No need to user query, if errorMsg */ if ($errorMsg == "") { if (COMMUNITY_BUILDER == 0) { $profile = $usermodel->getProfile($user->id); } else { $profile = $usermodel->getCBProfile($user->id); } } $contentid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($contentid, array(0)); $contentid = JRequest::getVar('id', $contentid[0], '', 'int'); // Update Ad ? if ($contentid > 0) { // edit ad $content = $contentmodel->getContent($contentid, false, 1); if ($content == null) { echo "Error Ad not found"; exit; } $content->ad_text = str_replace('<br/>', "\r\n", $content->ad_text); $isUpdateMode = 1; } else { // insert $content = new stdClass(); $content->published = 1; $isUpdateMode = 0; } $this->assignRef('content', $content); $this->assignRef('isUpdateMode', $isUpdateMode); $nbcats = $conf->nbcats; if (function_exists("getMaxCats")) { $nbcats = getMaxCats($conf->nbcats); } $this->assignRef('nbcats', $nbcats); if ($nbcats > 1) { $cats = $catmodel->getFlatTree(); } else { switch ($conf->single_category_selection_type) { default: case 'normal': case 'color': case 'combobox': $cats = $catmodel->getFlatTree(); break; case 'cascade': $cats = $catmodel->getCategoriesPerLevel(); break; } } $this->assignRef('cats', $cats); $nullobj = null; if ($errorMsg != "") { $this->assignRef('default', (object) JRequest::get('post')); } else { $this->assignRef('default', $nullobj); } if ($conf->submission_type == 2 && $user->id == "0") { $this->assignRef('warning_text', ADSMANAGER_WARNING_NEW_AD_NO_ACCOUNT . "<br/>"); } switch ($errorMsg) { case "bad_password": $this->assignRef('error_text', JText::_('ADSMANAGER_BAD_PASSWORD') . "<br />"); break; case "email_already_used": $this->assignRef('error_text', JText::_('ADSMANAGER_EMAIL_ALREADY_USED') . "<br />"); break; case "file_too_big": $this->assignRef('error_text', JText::_('ADSMANAGER_FILE_TOO_BIG') . "<br />"); } if (PAIDSYSTEM) { if (isset($content->id)) { $db = JFactory::getDbo(); $db->setQuery("SELECT * FROM #__paidsystem_ads WHERE id=" . (int) $content->id); $adext = $db->loadObject(); } else { $adext = new stdClass(); $adext->images = 0; } } else { $adext = new stdClass(); $adext->images = 0; } $this->assignRef('adext', $adext); if ($conf->submission_type == 0 && $user->id == 0) { $this->assignRef('account_creation', 1); } }