Exemplo n.º 1
0
function getAdsmanagerUser($userid)
{
    $db = JFactory::getDBO();
    $sql = "SELECT username FROM #__users WHERE id = " . (int) $userid;
    $db->setQuery($sql);
    $result = $db->loadResult();
    $result = TTools::stringURLSafe($result);
    $result = JString::substr($result, 0, 30);
    return $result;
}
Exemplo n.º 2
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_ROOT . "/images/com_adsmanager/ads/waiting/";
     $dirfinal = JPATH_ROOT . "/images/com_adsmanager/ads/";
     $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_ROOT . "/images/com_adsmanager/ads/" . $image->image)) {
             JFile::delete(JPATH_ROOT . "/images/com_adsmanager/ads/" . $image->image);
         }
         /*   if(is_file(JPATH_ROOT."/images/com_adsmanager/ads/".$image->thumbnail)) {
                         JFile::delete(JPATH_ROOT."/images/com_adsmanager/ads/".$image->thumbnail);
                     }
         			if(is_file(JPATH_ROOT."/images/com_adsmanager/ads/".$image->medium)) {
                         @JFile::delete(JPATH_ROOT."/images/com_adsmanager/ads/".$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();
     $cache =& JFactory::getCache('com_adsmanager');
     $cache->clean();
 }