Beispiel #1
0
 function save()
 {
     $app = JFactory::getApplication();
     $conf = JTable::getInstance('adsconfiguration', 'AdsmanagerTable');
     $post = JRequest::get('post', JREQUEST_ALLOWHTML);
     $post['show_contact'] = implode(',', $post['show_contact']);
     $bannedWords = explode("\n", $post['bannedwords']);
     $bannedWordFormat = array();
     foreach ($bannedWords as $word) {
         if (trim($word) != '') {
             $bannedWordFormat[] = trim($word);
         }
     }
     $post['bannedwords'] = implode("\n", $bannedWordFormat);
     // bind it to the table
     if (!$conf->bind($post)) {
         return JError::raiseWarning(500, $conf->getError());
     }
     // store it in the db
     if (!$conf->store()) {
         return JError::raiseWarning(500, $conf->getError());
     }
     if (version_compare(JVERSION, '2.5', '>=')) {
         $model = $this->getModel("configuration");
         $model->updateUpdateSiteXML(JRequest::getCmd('params_dlid', ''));
     }
     cleanAdsManagerCache();
     $app->redirect('index.php?option=com_adsmanager&c=configuration', JText::_('ADSMANAGER_CONFIGURATION_SAVED'), 'message');
 }
Beispiel #2
0
 function save()
 {
     $app = JFactory::getApplication();
     $conf = JTable::getInstance('searchmodule', 'AdsmanagerTable');
     // bind it to the table
     if (!$conf->bind(JRequest::get('post', JREQUEST_ALLOWHTML))) {
         return JError::raiseWarning(500, $conf->getError());
     }
     // store it in the db
     if (!$conf->store()) {
         return JError::raiseWarning(500, $conf->getError());
     }
     cleanAdsManagerCache();
     $app->redirect('index.php?option=com_adsmanager&c=searchmodule', JText::_('ADSMANAGER_SEARCH_MODULE_SAVED'), 'message');
 }
Beispiel #3
0
 function remove()
 {
     jimport('joomla.filesystem.folder');
     $app = JFactory::getApplication();
     $cid = JRequest::getVar('cid');
     if (!is_array($cid) || count($cid) < 1) {
         $app->redirect("index.php?option=com_adsmanager&c=plugins");
     }
     foreach ($cid as $pluginname) {
         $plugins = array();
         $path = JPATH_ROOT . "/images/com_adsmanager/plugins/{$pluginname}";
         require_once $path . "/plug.php";
         foreach ($plugins as $plug) {
             $plug->uninstall();
         }
         if ($pluginname != "") {
             if (is_dir($path)) {
                 JFolder::delete($path);
             }
         }
     }
     cleanAdsManagerCache();
     $app->redirect("index.php?option=com_adsmanager&c=plugins");
 }
Beispiel #4
0
 /**
  * No args just to be compliant with joomla API
  * @param unknown_type $src
  * @param unknown_type $orderingFilter
  * @param unknown_type $ignore
  */
 function saveContent($src, $orderingFilter = '', $ignore = '')
 {
     $row = new JObject();
     if ($this->id != 0) {
         $row->id = $this->id;
     }
     //new_ad
     $app = JFactory::getApplication();
     if ($app->isAdmin() == true || $app->isAdmin() == false && @$this->new_ad == true) {
         $row->date_created = $this->date_created;
         $row->expiration_date = $this->expiration_date;
         $row->publication_date = $this->publication_date;
     }
     //In case of bindContent / update Ad, $this->published is not set
     if ($this->published !== null) {
         $row->published = $this->published;
     }
     $row->date_modified = date('Y-m-d H:i:s');
     $row->userid = $this->userid;
     foreach ($this->data['fields'] as $name => $value) {
         if (is_array($value)) {
             $v = ',' . implode(',', $value) . ',';
         } else {
             $v = $value;
         }
         $row->{$name} = $v;
     }
     $row->metadata_description = $this->metadata_description;
     $row->metadata_keywords = $this->metadata_keywords;
     //Insert new record.
     if ($this->id == 0) {
         $ret = $this->_db->insertObject('#__adsmanager_ads', $row);
         $contentid = (int) $this->_db->insertid();
     } else {
         $ret = $this->_db->updateObject('#__adsmanager_ads', $row, 'id');
         $contentid = $this->id;
     }
     // Category
     $query = "DELETE FROM #__adsmanager_adcat WHERE adid = {$contentid}";
     $this->_db->setQuery($query);
     $this->_db->query();
     foreach ($this->data['categories'] as $cat) {
         $query = "INSERT INTO #__adsmanager_adcat(adid,catid) VALUES ({$contentid},{$cat})";
         $this->_db->setQuery($query);
         $this->_db->query();
         $this->catid = $cat;
     }
     //Images
     $dir = JPATH_IMAGES_FOLDER . "/waiting/";
     $dirfinal = JPATH_IMAGES_FOLDER . "/";
     $current_images = json_decode($this->images);
     if ($current_images == null) {
         $current_images = array();
     }
     if (!is_array($current_images)) {
         $current_images = get_object_vars($current_images);
     }
     foreach ($this->data['delimages'] as $image) {
         if (is_file(JPATH_IMAGES_FOLDER . "/" . $image->image)) {
             JFile::delete(JPATH_IMAGES_FOLDER . "/" . $image->image);
         }
         if (is_file(JPATH_IMAGES_FOLDER . "/" . $image->thumbnail)) {
             JFile::delete(JPATH_IMAGES_FOLDER . "/" . $image->thumbnail);
         }
         if (is_file(JPATH_IMAGES_FOLDER . "/" . $image->medium)) {
             @JFile::delete(JPATH_IMAGES_FOLDER . "/" . $image->medium);
         }
         foreach ($current_images as $key => $img) {
             if ($img->index == $image->index) {
                 unset($current_images[$key]);
                 break;
             }
         }
     }
     if (!is_array($current_images)) {
         $current_images = get_object_vars($current_images);
     }
     sort($current_images);
     jimport('joomla.filter.output');
     //True to force transliterate
     $imgtitle = TTools::stringURLSafe($row->ad_headline, true);
     if ($imgtitle == "") {
         $imgtitle = "image";
     }
     foreach ($this->data['images'] as &$image) {
         $src = $dir . $image->image;
         $dest = $dirfinal . $imgtitle . "_" . $contentid . "_" . $image->index . ".jpg";
         JFile::move($src, $dest);
         $image->image = $imgtitle . "_" . $contentid . "_" . $image->index . ".jpg";
         $src = $dir . $image->thumbnail;
         $dest = $dirfinal . $imgtitle . "_" . $contentid . "_" . $image->index . "_t.jpg";
         JFile::move($src, $dest);
         $image->thumbnail = $imgtitle . "_" . $contentid . "_" . $image->index . "_t.jpg";
         $src = $dir . $image->medium;
         $dest = $dirfinal . $imgtitle . "_" . $contentid . "_" . $image->index . "_m.jpg";
         JFile::move($src, $dest);
         $image->medium = $imgtitle . "_" . $contentid . "_" . $image->index . "_m.jpg";
         $current_images[] = $image;
     }
     $orderlist = $this->data['orderimages'];
     $newlistimages = array();
     foreach ($orderlist as $o) {
         foreach ($current_images as $image) {
             if ($image->index == $o) {
                 $newlistimages[] = $image;
             }
         }
     }
     $row = new JObject();
     $row->id = $contentid;
     $row->images = json_encode($newlistimages);
     $this->images = $newlistimages;
     $ret = $this->_db->updateObject('#__adsmanager_ads', $row, 'id');
     if (function_exists('savePaidAd')) {
         savePaidAd($this, $contentid);
     }
     $this->id = $contentid;
     $this->_db->setQuery("DELETE FROM #__adsmanager_pending_ads WHERE contentid=" . intval($contentid));
     $this->_db->query();
     cleanAdsManagerCache();
 }
Beispiel #5
0
 function remove()
 {
     $app = JFactory::getApplication();
     $mail = JTable::getInstance('mail', 'AdsmanagerTable');
     $ids = JRequest::getVar('cid', array(0));
     if (!is_array($ids)) {
         $table = array();
         $table[0] = $ids;
         $ids = $table;
     }
     foreach ($ids as $id) {
         $mail->deleteContent($id);
     }
     cleanAdsManagerCache();
     $app->redirect('index.php?option=com_adsmanager&c=mails', JText::_('ADSMANAGER_MAIL_REMOVED'), 'message');
 }
Beispiel #6
0
 function required()
 {
     $app = JFactory::getApplication();
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $required = JRequest::getInt('required', 0);
     JArrayHelper::toInteger($cid);
     if (count($cid) < 1) {
         $action = $required ? 'required' : 'unrequired';
         JError::raiseError(500, JText::_('Select an item to' . $action, true));
     }
     $model = $this->getModel("adsmanager");
     $model->changeState("#__adsmanager_fields", "fieldid", "required", $required, $cid);
     cleanAdsManagerCache();
     $app->redirect('index.php?option=com_adsmanager&c=fields');
 }
Beispiel #7
0
 function saveorder()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Initialize variables
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $total = count($cid);
     $order = JRequest::getVar('order', array(0), 'post', 'array');
     JArrayHelper::toInteger($order, array(0));
     $row = JTable::getInstance('category', 'AdsmanagerTable');
     // update ordering values
     for ($i = 0; $i < $total; $i++) {
         $row->load((int) $cid[$i]);
         if ($row->ordering != $order[$i]) {
             $row->ordering = $order[$i];
             if (!$row->store()) {
                 JError::raiseError(500, $db->getErrorMsg());
             }
         }
     }
     cleanAdsManagerCache();
     // Check if i'm using an AJAX call, in this case there is no need to redirect
     $format = JRequest::getVar('format', '');
     $status = "";
     if ($format == 'json') {
         echo json_encode($status);
         return;
     }
     $msg = JText::_('ADSMANAGER_ORDERING_SAVED');
     $app->redirect('index.php?option=com_adsmanager&c=categories', $msg, 'message');
 }
Beispiel #8
0
 function _changeState()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $publish = $this->getTask() == 'publish' ? 1 : 0;
     JArrayHelper::toInteger($cid);
     if (count($cid) < 1) {
         $action = $publish ? 'publish' : 'unpublish';
         JError::raiseError(500, JText::_('Select an item to' . $action, true));
     }
     $model = $this->getModel("adsmanager");
     $model->changeState("#__adsmanager_ads", "id", "published", $publish, $cid);
     cleanAdsManagerCache();
     $app->redirect('index.php?option=com_adsmanager&c=contents');
 }