Cheetah
ChAdsModule.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_INC . 'header.inc.php');
9 require_once(CH_DIRECTORY_PATH_INC . 'design.inc.php');
10 require_once(CH_DIRECTORY_PATH_INC . 'profiles.inc.php');
11 require_once(CH_DIRECTORY_PATH_INC . 'utils.inc.php');
12 
13 ch_import('ChTemplCmtsView');
14 ch_import('ChWsbPaginate');
15 ch_import('ChWsbModule');
16 
109 {
110  //max sizes of pictures for resizing during upload
111  var $iIconSize = 32;
112  var $iThumbSize = 140;
113  var $iBigThumbSize = 340;
114  var $iImgSize = 600;
115 
116  //upload URL to dir
117  var $sUploadDir = '';
118 
119  //max upload file size
120  var $iMaxUplFileSize = 1048576; //1mb
121 
122  //path to image with Point
124 
125  //path to image pic_not_avail.gif
126  var $sPicNotAvail = '';
128 
129  //admin mode, can All actions
131 
132  //current file, for actions of forms and other
134 
136 
137  //use permalink
139 
140  //for page blocks
144  var $sTAInfoContent = '';
145  var $sTARateContent = '';
147  var $sTADescription = '';
148  var $sTAOtherInfo = '';
149 
152 
155 
157 
158  // Constructor
160  {
161  global $site;
162 
163  parent::__construct($aModule);
164 
165  $this->sHomeUrl = $this->_oConfig->getHomeUrl();
166  $this->sHomePath = $this->_oConfig->getHomePath();
167 
168  $this->sUploadDir = 'media/images/classifieds/';
169 
170  $this->bUseFriendlyLinks = getParam('permalinks_module_ads') == 'on' ? true : false;
171  $this->_oConfig->bUseFriendlyLinks = $this->bUseFriendlyLinks;
172 
173  $this->sPicNotAvail = $this->_oTemplate->getImageUrl('no-image-thumb.png');
174  $this->sPicNotAvailPath = $this->_oTemplate->getImagePath('no-image-thumb.png');
175  $this->sSpacerPath = getTemplateIcon('spacer.gif');
176 
177  $this->_iVisitorID = isLogged() ? getLoggedId() : 0;
178  $this->bAdminMode = ($this->isAdmin() == true) ? true : false;
179  $this->_oConfig->bAdminMode = ($this->isAdmin() == true) ? true : false;
180 
181  $this->sCurrBrowsedFile = $this->sHomeUrl . 'classifieds.php';
182  $this->_oConfig->sCurrBrowsedFile = $this->sCurrBrowsedFile;
183 
184  ch_import('Privacy', $this->_aModule);
185  $this->oPrivacy = new ChAdsPrivacy($this);
186 
187  $this->aPageTmpl['name_index'] = 71;
188  }
189 
190  function actionGetList($sMode = '', $sOwnerId = '', $sAdd = '', $sAdd1 = '', $sAdd2 = '')
191  {
192  //input values
194  $iOwnerId = (int)$sOwnerId;
195  $aAdd = array($sAddParam, $sAddParam1, $sAddParam2);
196 
197  ch_import('SearchUnit', $this->_aModule);
198  $oTmpAdsSearch = new ChAdsSearchUnit();
199  $oTmpAdsSearch->bShowCheckboxes = false;
200  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
201  $oTmpAdsSearch->aCurrent['restriction']['owner']['value'] = $iOwnerId;
202  switch ($sMode) {
203  case 'manage':
204  $oTmpAdsSearch->bShowCheckboxes = true;
205  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'active';
206  $oTmpAdsSearch->aCurrent['second_restr'] = 'manage';
207  break;
208  case 'pending':
209  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'new';
210  $oTmpAdsSearch->aCurrent['second_restr'] = 'outtime';
211  break;
212  case 'expired':
213  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'active';
214  $oTmpAdsSearch->aCurrent['second_restr'] = 'expired';
215  break;
216  case 'disapproved':
217  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'inactive';
218  $oTmpAdsSearch->aCurrent['second_restr'] = 'outtime';
219  break;
220  case 'view':
221  default:
222  $oTmpAdsSearch->aCurrent['second_restr'] = 'manage';
223  }
224  $sCode = $oTmpAdsSearch->displayResultBlock();
225  $sPgn = '';
226  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
227  $sCode = MsgBox(_t('_Empty'));
228  } else {
229  ch_import('ChWsbPaginate');
230  $sBoxId = 'ads_' . $iOwnerId . '_' . $sMode;
231  $sLink = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'get_list/' . $sMode . '/' . $iOwnerId;
232  $oPgn = new ChWsbPaginate(array(
233  'page_url' => 'javascript:void();',
234  'count' => $oTmpAdsSearch->aCurrent['paginate']['totalNum'],
235  'per_page' => $oTmpAdsSearch->aCurrent['paginate']['perPage'],
236  'page' => $oTmpAdsSearch->aCurrent['paginate']['page'],
237  'on_change_page' => 'getHtmlData(\'' . $sBoxId . '\', \'' . $sLink . '&page={page}&per_page={per_page}\');',
238  'on_change_per_page' => 'getHtmlData(\'' . $sBoxId . '\', \'' . $sLink . '&page=1&per_page=\' + this.value);'
239  ));
240  $sPgn = '<div class="clear_both"></div>' . $oPgn->getPaginate();
241  }
242  header('Content-Type: text/xml; charset=UTF-8');
243  echo $sCode . $sPgn;
244  exit;
245  }
246 
252  function actionSearch()
253  {
254  global $aPreValues;
255 
256  $this->isAllowedSearch(true); // perform action
257 
258  $sCategory = (int)ch_get('FilterCat');
259  $sSubCategory = (int)ch_get('FilterSubCat');
260  $sCountry = process_db_input(ch_get('FilterCountry'), CH_TAGS_STRIP);
261  $sCountry = (isset($aPreValues['Country'][$sCountry]) == true) ? $sCountry : '';
262  $sKeywords = process_db_input(ch_get('FilterKeywords'), CH_TAGS_STRIP);
263 
264  $sSubCats = '';
265  if ($sSubCategory <= 0) {
266  if ($sCategory > 0) {
267  $aSubCats = array();
268  $vSubCats = $this->_oDb->getAllSubCatsInfo($sCategory);
269  while ($aSubCat = $vSubCats->fetch()) {
270  $aSubCats[] = (int)$aSubCat['ID'];
271  }
272  sort($aSubCats);
273  if (count($aSubCats) > 0) {
274  $sSubCats = "`{$this->_oConfig->sSQLSubcatTable}`.`ID` IN (" . implode(",", $aSubCats) . ")";
275  } else {
276  return $oFunctions->MsgBox(_t('_SubCategory is required'));
277  }
278  }
279  }
280 
281  $sCustomFieldCaption1 = process_db_input(ch_get('CustomFieldCaption1'), CH_TAGS_STRIP);
282  $sCustomFieldCaption2 = process_db_input(ch_get('CustomFieldCaption2'), CH_TAGS_STRIP);
283 
284  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
285  $oTmpAdsSearch = new ChAdsSearchUnit();
286  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
287  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
288 
289  if ($sCategory > 0) {
290  $oTmpAdsSearch->aCurrent['restriction']['categoryID']['value'] = $sCategory;
291  }
292 
293  if (count($aSubCats) > 0) {
294  $oTmpAdsSearch->aCurrent['third_restr'] = "`{$this->_oConfig->sSQLSubcatTable}`.`ID` IN (" . implode(",",
295  $aSubCats) . ")";
296  } else {
297  if ($sSubCategory > 0) {
298  $oTmpAdsSearch->aCurrent['restriction']['subcategoryID']['value'] = $sSubCategory;
299  }
300  }
301 
302  if ($sCountry != '') {
303  $oTmpAdsSearch->aCurrent['restriction']['country']['value'] = $sCountry;
304  }
305 
306  if ($sKeywords != '') {
307  $oTmpAdsSearch->aCurrent['restriction']['message_filter']['value'] = $sKeywords;
308  }
309 
310  $oTmpAdsSearch->aCurrent['restriction']['categoryID']['value'] = $iSafeCatID;
311  $sFilteredAds = $oTmpAdsSearch->displayResultBlock();
312  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
313  $sFilteredAds = MsgBox(_t('_Empty'));
314  } else {
315  // Prepare link to pagination
316  $sRequest = ch_html_attribute($_SERVER['PHP_SELF']) . '?';
317  foreach ($_GET as $sKey => $sValue) {
318  $sRequest .= '&' . $sKey . '=' . $sValue;
319  }
320  $sRequest .= '&page={page}&per_page={per_page}';
321  // End of prepare link to pagination
322  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
323  $sPagination = $oTmpAdsSearch->showPagination();
324  }
325 
326  $sFilterForm = $this->PrintFilterForm();
327  $sCode = DesignBoxContent(_t('_SEARCH_RESULT_H'), $sFilterForm . $sFilteredAds . $sPagination, 1);
328 
329  $sJS = <<<EOF
330 <script language="JavaScript" type="text/javascript">
331  <!--
332  var sAdsSiteUrl = "{$this->sHomeUrl}";
333  -->
334 </script>
335 EOF;
336 
337  //--------------------------- output -------------------------------------------
338 
339  $this->aPageTmpl['header'] = _t('_ch_ads_Filter');
340  $this->aPageTmpl['css_name'] = array('ads.css', 'twig.css');
341  $this->aPageTmpl['js_name'] = array('main.js');
342  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => $sJS . $sCode));
343  }
344 
345  function actionSharePopup($iEntryId)
346  {
347  header('Content-type:text/html;charset=utf-8');
348 
349  $iEntryId = (int)$iEntryId;
350  if (!($aDataEntry = $this->_oDb->getAdInfo($iEntryId))) {
351  echo MsgBox(_t('_Empty'));
352  exit;
353  }
354 
355  $sEntryUrl = $this->genUrl($iEntryId, $aDataEntry['EntryUri'], 'entry');
356 
357  require_once(CH_DIRECTORY_PATH_INC . "shared_sites.inc.php");
358  echo getSitesHtml($sEntryUrl);
359  exit;
360  }
361 
367  function PrintCommandForms()
368  {
369  $sAdsLink = ($this->bUseFriendlyLinks) ? 'ads/' : $this->sCurrBrowsedFile;
370 
371  $this->_oTemplate->addJs('main.js');
372 
373  return <<<EOF
374 <script language="JavaScript" type="text/javascript">
375  <!--
376  var sAdsSiteUrl = "{$this->sHomeUrl}";
377  -->
378 </script>
379 <form action="{$sAdsLink}" method="post" name="command_activate_advertisement">
380  <input type="hidden" name="ActivateAdvertisementID" id="ActivateAdvertisementID" value="" />
381  <input type="hidden" name="ActType" id="ActType" value="" />
382 </form>
383 <form action="{$sAdsLink}" method="post" name="command_delete_advertisement">
384  <input type="hidden" name="DeleteAdvertisementID" id="DeleteAdvertisementID" value="" />
385 </form>
386 EOF;
387  }
388 
394  function GetHeaderString()
395  {
396  $sMsgMain = $sMsgAdd = '';
397  switch (ch_get('action')) {
398  case 'show_featured':
399  $sMsgMain = '_ch_ads_Featured';
400  break;
401  case 'show_top_rated':
402  $sMsgMain = '_ch_ads_Top_Rated';
403  break;
404  case 'show_all_ads':
405  $sMsgMain = '_ch_ads_All_ads';
406  break;
407  case 'show_popular':
408  $sMsgMain = '_ch_ads_Popular';
409  break;
410  case 'tags':
411  $sMsgMain = '_Tags';
412  break;
413  case 'show_categories':
414  $sMsgMain = '_ch_ads_Categories';
415  break;
416  case 'show_calendar':
417  $sMsgMain = '_ch_ads_Calendar';
418  break;
419  case 'show_calendar_ads':
420  $sDate = ch_get('date');
421  $aDate = explode('/', $sDate);
422 
423  $iValue1 = (int)$aDate[0];
424  $iValue2 = (int)$aDate[1];
425  $iValue3 = (int)$aDate[2];
426 
427  $sMsgMain = '_ch_ads_caption_browse_by_day';
428  $sMsgAdd = getLocaleDate(strtotime("{$iValue1}-{$iValue2}-{$iValue3}"), CH_WSB_LOCALE_DATE_SHORT);
429  break;
430  case 'my_page':
431  switch (ch_get('mode')) {
432  case 'add':
433  $sMsgMain = '_ch_ads_Add';
434  break;
435  case 'manage':
436  $sMsgMain = '_ch_ads_Manage_ads';
437  break;
438  case 'pending':
439  $sMsgMain = '_ch_ads_pending_approval';
440  break;
441  case 'expired':
442  $sMsgMain = '_ch_ads_expired';
443  break;
444  case 'disapproved':
445  $sMsgMain = '_ch_ads_Disapproved';
446  break;
447  default:
448  $sMsgMain = '_ch_ads_My_Ads';
449  }
450  break;
451  case '3':
452  $sMsgMain = '_ch_ads_Filtered_ads';
453  break;
454  default:
455  if (false !== ch_get('ShowAdvertisementID')) {
456  $sMsgAdd = $this->_oDb->getAdSubjectByID((int)ch_get('ShowAdvertisementID'));
457  } elseif (false !== ch_get('entryUri')) {
458  $sMsgAdd = $this->_oDb->getAdSubjectByUri(process_db_input(ch_get('entryUri'), CH_TAGS_STRIP));
459  } elseif (false !== ch_get('UsersOtherListing') && (int)ch_get('IDProfile') > 0) {
460  $sMsgMain = '_ch_ads_Users_other_listing';
461  } elseif (false !== ch_get('bClassifiedID') || false !== ch_get('catUri')) {
462  if (false !== ch_get('bClassifiedID') && (int)ch_get('bClassifiedID') > 0) {
463  $sMsgAdd = $this->_oDb->getCategoryNameByID((int)ch_get('bClassifiedID'));
464  } elseif (false !== ch_get('catUri') && ch_get('catUri') != '') {
465  $sMsgAdd = $this->_oDb->getCategoryNameByUri(process_db_input(ch_get('catUri'), CH_TAGS_STRIP));
466  }
467  } elseif (false !== ch_get('bSubClassifiedID') || false !== ch_get('scatUri')) {
468  $aSubcatRes = null;
469  if (false !== ch_get('bSubClassifiedID') && (int)ch_get('bSubClassifiedID') > 0) {
470  $aSubcatRes = $this->_oDb->getCatSubCatNameBySubCatID((int)ch_get('bSubClassifiedID'));
471  } elseif (false !== ch_get('scatUri') && ch_get('scatUri') != '') {
472  $aSubcatRes = $this->_oDb->getCatSubCatNameBySubCatUri(process_db_input(ch_get('scatUri'),
473  CH_TAGS_STRIP));
474  }
475 
476  if ($aSubcatRes) {
477  $sMsgAdd = $aSubcatRes['Name'] . ' / ' . $aSubcatRes['NameSub'];
478  }
479  } else {
480  $sMsgMain = '_ch_ads_Ads_Home';
481  }
482  }
483  if (!empty($sMsgMain)) {
484  $sMsgMain = _t($sMsgMain) . ' ';
485  }
486 
487  return trim($sMsgMain . $sMsgAdd);
488  }
489 
490  // ================================== permissions
491 
492  function isAllowedComments(&$aAdPost)
493  {
494  if (($aAdPost['IDProfile'] == $this->_iVisitorID && isMember()) || $this->isAdmin()) {
495  return true;
496  }
497 
498  return $this->oPrivacy->check('comment', $aAdPost['ID'], $this->_iVisitorID);
499  }
500 
501  function isAllowedView($iOwnerID, $isPerformAction = false)
502  {
503  if ($this->isAdmin() || $iOwnerID == $this->_iVisitorID) {
504  return true;
505  }
506  $this->_defineActions();
507  $aCheck = checkAction($this->_iVisitorID, CH_ADS_VIEW, $isPerformAction);
508 
510  }
511 
512  function isAllowedBrowse($isPerformAction = false)
513  {
514  if ($this->isAdmin()) {
515  return true;
516  }
517  $this->_defineActions();
518  $aCheck = checkAction($this->_iVisitorID, CH_ADS_BROWSE, $isPerformAction);
519 
521  }
522 
523  function isAllowedSearch($isPerformAction = false)
524  {
525  if ($this->isAdmin()) {
526  return true;
527  }
528  $this->_defineActions();
529  $aCheck = checkAction($this->_iVisitorID, CH_ADS_SEARCH, $isPerformAction);
530 
532  }
533 
534  function isAllowedAdd($isPerformAction = false)
535  {
536  if ($this->isAdmin()) {
537  return true;
538  }
539  if (isMember() == false) {
540  return false;
541  }
542  $this->_defineActions();
543  $aCheck = checkAction($this->_iVisitorID, CH_ADS_ADD, $isPerformAction);
544 
546  }
547 
548  function isAllowedEdit($iOwnerID, $isPerformAction = false)
549  {
550  if ($this->isAdmin() || (isMember() && $iOwnerID == $this->_iVisitorID)) {
551  return true;
552  }
553  $this->_defineActions();
554  $aCheck = checkAction($this->_iVisitorID, CH_ADS_EDIT_ANY_AD, $isPerformAction);
555 
557  }
558 
559  function isAllowedDelete($iOwnerID, $isPerformAction = false)
560  {
561  if ($this->isAdmin() || (isMember() && $iOwnerID == $this->_iVisitorID)) {
562  return true;
563  }
564  $this->_defineActions();
565  $aCheck = checkAction($this->_iVisitorID, CH_ADS_DELETE_ANY_AD, $isPerformAction);
566 
568  }
569 
570  function isAllowedApprove($isPerformAction = false)
571  {
572  if ($this->isAdmin()) {
573  return true;
574  }
575  if (isMember() == false) {
576  return false;
577  }
578  $this->_defineActions();
579  $aCheck = checkAction($this->_iVisitorID, CH_ADS_APPROVING, $isPerformAction);
580 
582  }
583 
584  function isAllowedShare(&$aDataEntry)
585  {
586  if ($aDataEntry['AllowView'] != CH_WSB_PG_ALL) {
587  return false;
588  }
589 
590  return true;
591  }
592 
593  function isAdmin()
594  {
595  return isAdmin($this->_iVisitorID) || isModerator($this->_iVisitorID);
596  }
597 
598  function _defineActions()
599  {
601  'ads view',
602  'ads browse',
603  'ads search',
604  'ads add',
605  'ads edit any ad',
606  'ads delete any ad',
607  'ads approving'
608  ));
609  }
610 
611  function CheckLogged()
612  {
613  if (!getLoggedId()) {
614  member_auth(0);
615  }
616  }
617 
619  {
620  $iId = $this->_oDb->getSettingsCategory();
621  if (empty($iId)) {
622  return MsgBox(_t('_sys_request_page_not_found_cpt'));
623  }
624 
625  ch_import('ChWsbAdminSettings');
626 
627  $mixedResult = '';
628  if (isset($_POST['save']) && isset($_POST['cat'])) {
630  $mixedResult = $oSettings->saveChanges($_POST);
631  }
632 
634  $sResult = $oSettings->getForm();
635 
636  if ($mixedResult !== true && !empty($mixedResult)) {
637  $sResult = $mixedResult . $sResult;
638  }
639 
640  return $sResult;
641  }
642 
644  {
645  $sCatID = (int)ch_get('id');
646  $iCatID = ($sCatID) ? $sCatID : 0;
647 
648  $sPendingTab = $this->GenAdsAdminIndex();
649  $sSettingsTab = $this->getAdministrationSettings();
650  $sManageCatsTab = $this->getManageClassifiedsForm($iCatID);
651 
652  $sContent = '';
653  $sContent .= DesignBoxAdmin(_t('_Settings'), $sSettingsTab, '', '', 11);
654  $sContent .= DesignBoxAdmin(_t('_ch_ads_pending_approval'), $sPendingTab);
655  $sContent .= $sManageCatsTab;
656 
657  return $sContent;
658  }
659 
660  function GenMyPageAdmin($sForceMode = '')
661  {
662  $this->CheckLogged();
663 
664  $sAdministrationC = _t('_ch_ads_Administration');
665  $sMyAdsC = _t('_ch_ads_My_Ads');
666  $sPendApprC = _t('_ch_ads_pending_approval');
667  $sDisApprC = _t('_ch_ads_Disapproved');
668  $sAddC = _t('_ch_ads_Add');
669 
670  if (ch_get('action_delete') && is_array(ch_get('ads'))) {
671  foreach (ch_get('ads') as $iAdID) {
672  $this->ActionDeleteAdvertisement((int)$iAdID);
673  }
674  }
675 
676  ch_import('SearchUnit', $this->_aModule);
677  $oTmpAdsSearch = new ChAdsSearchUnit();
678  $oTmpAdsSearch->bShowCheckboxes = false;
679  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
680  $oTmpAdsSearch->aCurrent['restriction']['owner']['value'] = $this->_iVisitorID;
681  $oTmpAdsSearch->aCurrent['second_restr'] = 'manage';
682 
683  $GLOBALS['oTopMenu']->setCurrentProfileID($this->_iVisitorID);
684  $sMyAds = $oTmpAdsSearch->displayResultBlock();
685  if ($this->bUseFriendlyLinks) {
686  $sAdsMainLink = $sAdsAddLink = $sAdsManageLink = $sAdsPendingLink = $sAdsDisapprovedLink = $sAdsExpiredLink = CH_WSB_URL_ROOT;
687  $sAdsMainLink .= 'ads/my_page/';
688  $sAdsAddLink .= 'ads/my_page/add/';
689  $sAdsManageLink .= 'ads/my_page/manage/';
690  $sAdsPendingLink .= 'ads/my_page/pending/';
691  $sAdsExpiredLink .= 'ads/my_page/expired/';
692  $sAdsDisapprovedLink .= 'ads/my_page/disapproved/';
693  $sPgnAdd = '?';
694  } else {
695  $sAdsMainLink = "{$this->sCurrBrowsedFile}?action=my_page";
696  $sAdsAddLink = "{$this->sCurrBrowsedFile}?action=my_page&mode=add";
697  $sAdsManageLink = "{$this->sCurrBrowsedFile}?action=my_page&mode=manage";
698  $sAdsPendingLink = "{$this->sCurrBrowsedFile}?action=my_page&mode=pending";
699  $sAdsExpiredLink = "{$this->sCurrBrowsedFile}?action=my_page&mode=expired";
700  $sAdsDisapprovedLink = "{$this->sCurrBrowsedFile}?action=my_page&mode=disapproved";
701  $sPgnAdd = '&';
702  }
703  $sPgn = '';
704 
705  $sBoxId = '';
706  $sAjLink = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'get_list/';
707  $sAddPages = '&page={page}&per_page={per_page}';
708  ch_import('ChWsbPaginate');
709  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
710  $sMyAds = MsgBox(_t('_Empty'));
711  } else {
712  if ($oTmpAdsSearch->aCurrent['paginate']['perPage'] < $oTmpAdsSearch->aCurrent['paginate']['totalNum']) {
713  $sBoxId = 'ads_' . $this->_iVisitorID . '_view';
714  $oPgn = new ChWsbPaginate(array(
715  'page_url' => $sAdsMainLink . $sAddPages,
716  'count' => $oTmpAdsSearch->aCurrent['paginate']['totalNum'],
717  'per_page' => $oTmpAdsSearch->aCurrent['paginate']['perPage'],
718  'page' => $oTmpAdsSearch->aCurrent['paginate']['page'],
719  'on_change_page' => "getHtmlData('$sBoxId', '{$sAjLink}view/{$this->_iVisitorID}{$sAddPages}');",
720  'on_change_per_page' => "getHtmlData('$sBoxId', '{$sAjLink}view/{$this->_iVisitorID}&page=1&per_page=' + this.value);"
721  ));
722  $sPgn = '<div class="clear_both"></div>' . $oPgn->getPaginate();
723  }
724  }
725  $sMyAdsBox = DesignBoxContent($sMyAdsC, '<div id="' . $sBoxId . '">' . $sMyAds . $sPgn . '</div>', 1);
726 
727  $sAdmContent = '';
728  $sCaption = '';
729  $sMainTabClass = $sAddTabClass = $sManageTabClass = $sPendingTabClass = $sDisapprovedTabClass = $sExpiredTabClass = 0;
730  $sMode = ($sForceMode != '') ? $sForceMode : ch_get('mode');
731 
732  //spec block data
733  $sBoxIdSpec = 'ads_' . $this->_iVisitorID . '_' . $sMode;
734  $aPgn = array(
735  'on_change_page' => "getHtmlData('$sBoxIdSpec', '{$sAjLink}{$sMode}/{$this->_iVisitorID}{$sAddPages}');",
736  'on_change_per_page' => "getHtmlData('$sBoxIdSpec', '{$sAjLink}{$sMode}/{$this->_iVisitorID}&page=1&per_page=' + this.value);"
737  );
738  $sPgn = '<div class="clear_both"></div>';
739  $aButtons = array('action_delete' => '_Delete');
740  $oTmpAdsSearch->aCurrent['second_restr'] = '';
741  switch ($sMode) {
742  case 'add':
743  $sAddTabClass = 1;
744  $sNewPostForm = $this->AddNewPostForm((int)ch_get('EditPostID'), false);
745 
746  $sAdmContent = $sNewPostForm;
747  $sCaption = $sAddC;
748  break;
749  case 'expired':
750  $sExpiredTabClass = 1;
751  $oTmpAdsSearch->bShowCheckboxes = true;
752  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'active';
753  $oTmpAdsSearch->aCurrent['second_restr'] = 'expired';
754  $sAdmContent = $this->getManageArea($oTmpAdsSearch,
755  $sBoxIdSpec, $aButtons, $sAdsExpiredLink . $sPgnAdd . $sAddPages, $aPgn);
756  $sCaption = $sMyAdsC;
757  break;
758  case 'manage':
759  $sManageTabClass = 1;
760  $oTmpAdsSearch->bShowCheckboxes = true;
761  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'active';
762  $oTmpAdsSearch->aCurrent['second_restr'] = 'manage';
763  $sAdmContent = $this->getManageArea($oTmpAdsSearch,
764  $sBoxIdSpec, $aButtons, $sAdsManageLink . $sPgnAdd . $sAddPages, $aPgn);
765  $sCaption = $sMyAdsC;
766  break;
767  case 'pending':
768  $sPendingTabClass = 1;
769  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'new';
770  $oTmpAdsSearch->aCurrent['second_restr'] = 'outtime';
771  $sAdmContent = $this->getManageArea($oTmpAdsSearch,
772  $sBoxIdSpec, $aButtons, $sAdsPendingLink . $sPgnAdd . $sAddPages, $aPgn);
773  $sCaption = $sPendApprC;
774  break;
775  case 'disapproved':
776  $sDisapprovedTabClass = 1;
777  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'inactive';
778  $oTmpAdsSearch->aCurrent['second_restr'] = 'outtime';
779  $sAdmContent = $this->getManageArea($oTmpAdsSearch,
780  $aButtons, $sBoxIdSpec, $sAdsDisapprovedLink . $sPgnAdd . $sAddPages, $aPgn);
781  $sCaption = $sDisApprC;
782  break;
783  case 'main':
784  default:
785  $sMainTabClass = 1;
786 
787  $iMyAdsCnt = $this->_oDb->getMemberAdsCnt($this->_iVisitorID, 'active', true);
788  $sAdministrationDescC = _t('_ch_ads_admin_box_desc', $iMyAdsCnt, $sAdsManageLink, $sAdsAddLink);
789  $sAdmContent = $sAdministrationDescC;
790  $sCaption = $sAdministrationC;
791  break;
792  }
793 
794  ch_import('ChWsbPageView');
795  $sAdmPost = ChWsbPageView::getBlockCaptionMenu(time(), array(
796  'ads_main' => array(
797  'href' => $sAdsMainLink,
798  'title' => _t('_ch_ads_Manage_main'),
799  'active' => $sMainTabClass
800  ),
801  'ads_add' => array('href' => $sAdsAddLink, 'title' => _t('_ch_ads_Add'), 'active' => $sAddTabClass),
802  'ads_manage' => array(
803  'href' => $sAdsManageLink,
804  'title' => _t('_ch_ads_Manage_ads'),
805  'active' => $sManageTabClass
806  ),
807  'ads_pending' => array(
808  'href' => $sAdsPendingLink,
809  'title' => _t('_ch_ads_pending_approval'),
810  'active' => $sPendingTabClass
811  ),
812  'ads_expired' => array(
813  'href' => $sAdsExpiredLink,
814  'title' => _t('_ch_ads_expired'),
815  'active' => $sExpiredTabClass
816  ),
817  'ads_disapproved' => array(
818  'href' => $sAdsDisapprovedLink,
819  'title' => _t('_ch_ads_Disapproved'),
820  'active' => $sDisapprovedTabClass
821  )
822  ));
823 
824  $sAdministrationUnitsSect = DesignBoxContent($sAdministrationC, $sAdmContent, 1, $sAdmPost);
825 
826  return $sAdministrationUnitsSect . $sMyAdsBox;
827  }
828 
835  function AddNewPostForm($iPostID = 0, $bBox = true)
836  {
837  ch_import('ChWsbProfileFields');
838 
839  $this->CheckLogged();
840 
841  if ($iPostID == 0) {
842  if (!$this->isAllowedAdd()) {
843  return $this->_oTemplate->displayAccessDenied();
844  }
845  } else {
846  $aAdUnitInfo = $this->_oDb->getAdInfo($iPostID);
847 
848  $iOwnerID = (int)$aAdUnitInfo['OwnerID'];
849  if (!$this->isAllowedEdit($iOwnerID)) {
850  return $this->_oTemplate->displayAccessDenied();
851  }
852  }
853 
854  $sMsgDeleteImage = '';
855  $sNewAdC = _t('_Add Post');
856  $sDaysC = _t('_days');
857  $iMaxLt = (int)getParam('ch_ads_max_live_days');
858  $sMaxedString = _t('_ch_ads_Warn_max_live_days');
859 
860  $sAdsAddLink = ($this->bUseFriendlyLinks) ? 'ads/my_page/add/' : "{$this->sCurrBrowsedFile}?action=my_page&mode=add";
861 
862  // Life time values
863  $aLifeTimeValues = array();
864  for ($i = 5; $i <= $iMaxLt; $i += 5) {
865  $aLifeTimeValues[] = array('key' => $i, 'value' => $i);
866  }
867 
868  // Categories and custom values
869  $iCategoryID = (int)ch_get('Classified');
870  $iSubCategoryID = (int)ch_get('IDClassifiedsSubs');
871  $sCustomValues = $sScriptHandle = '';
872  if (false !== ch_get('IDClassifiedsSubs')) {
873  $sScriptHandle = <<<EOF
874 <script type="text/javascript">
875  addEvent( window, 'load', function(){ $('#Classified').val('{$iCategoryID}'); } );
876 </script>
877 EOF;
878  }
879 
880  $sCity = $sCountry = '';
881  $aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'view', array(),
882  _t('_ch_ads_privacy_view'));
883  $aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'rate', array(),
884  _t('_ch_ads_privacy_rate'));
885  $aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'comment', array(),
886  _t('_ch_ads_privacy_comment'));
887 
888  $sSubsRows = '';
889  if ($iPostID > 0) {
890  $sMsgDeleteImage = $this->ActionDeletePicture();
891  if ($sMsgDeleteImage) {
892  $aAdUnitInfo = $this->_oDb->getAdInfo($iPostID);
893  }
894 
895  $sAdsAddLink = ($this->bUseFriendlyLinks) ? 'ads/my_page/edit/' . $iPostID : "{$this->sCurrBrowsedFile}?action=my_page&mode=add&EditPostID={$iPostID}";
896  $aAdUnitInfo = (is_array($aAdUnitInfo) && count($aAdUnitInfo) > 0) ? $aAdUnitInfo : $this->_oDb->getAdInfo($iPostID);
897  $iCategoryID = (int)$aAdUnitInfo['CatID'];
898  $iSubCategoryID = (int)$aAdUnitInfo['SubID'];
899 
900  $sCity = $aAdUnitInfo['City'];
901  $sCountry = $aAdUnitInfo['Country'];
902 
903  $sScriptHandle = <<<EOF
904 <script type="text/javascript">
905  addEvent( window, 'load', function(){ $('#Classified').val('{$iCategoryID}'); } );
906  addEvent( window, 'load', function(){ $('#SubClassified').val('{$iSubCategoryID}'); } );
907 </script>
908 EOF;
909 
910  $vSubs = $this->_oDb->getSubsNameIDCountAdsByAdID($iCategoryID);
911  while ($aSub = $vSubs->fetch()) {
912  $iSubID = (int)$aSub['ID'];
913  $iSubName = $aSub['Name'];
914  $sSubsRows .= '<option value="' . $iSubID . '">' . $iSubName . '</option>';
915  }
916  $sFieldSec = $aAdUnitInfo['CustomFieldName2'] ? "{$aAdUnitInfo['CustomFieldName2']} {$aAdUnitInfo['Unit2']} <input type=\"text\" name=\"CustomFieldValue2\" value=\"{$aAdUnitInfo['CustomFieldValue2']}\" size=\"20\" maxlength=\"20\" />" : "";
917 
918  $sCustomValues = <<<EOF
919 {$aAdUnitInfo['CustomFieldName1']} {$aAdUnitInfo['Unit1']} <input type="text" name="CustomFieldValue1" value="{$aAdUnitInfo['CustomFieldValue1']}" size="20" maxlength="20" />
920 {$sFieldSec}
921 EOF;
922 
923  $sNewAdC = _t('_Save Changes');
924  $sMaxedString = _t('_ch_ads_Warn_max_live_days');
925  }
926 
927  //Main categories
928  $vSqlRes = $this->_oDb->getAllCatsInfo();
929  if (!$vSqlRes) {
930  return _t('_Error Occured');
931  }
932  $sCatOptions = '';
933  while ($aSqlResStr = $vSqlRes->fetch()) {
934  $sCatOptions .= "<option value=\"{$aSqlResStr['ID']}\">{$aSqlResStr['Name']}</option>\n";
935  }
936 
937  $iSubCatID = (int)ch_get('IDClassifiedsSubs');
938  $sExclamationIcon = $GLOBALS['oSysTemplate']->getIconUrl('exclamation.png');
939 
940  $aVars = array(
941  'sCatOptions' => $sCatOptions,
942  'sSubsRows' => $sSubsRows,
943  'sScriptHandle' => $sScriptHandle,
944  'sCustomValues' => $sCustomValues,
945  'ch_if:cat_warning' => array(
946  'condition' => (false !== ch_get('add_button') && !$iSubCatID),
947  'content' => array()
948  ),
949  );
950  $sCustomCategories = $this->_oTemplate->parseHtmlByName('ads_add_categ_form.html', $aVars);
951 
952  $oProfileFields = new ChWsbProfileFields(0);
953  $aCountries = $oProfileFields->convertValues4Input('#!Country');
954 
955  //adding form
956  $aForm = array(
957  'form_attrs' => array(
958  'name' => 'CreateAdsForm',
959  'action' => $sAdsAddLink,
960  'method' => 'post',
961  'enctype' => 'multipart/form-data',
962  ),
963  'params' => array(
964  'db' => array(
965  'table' => $this->_oConfig->sSQLPostsTable,
966  'key' => 'ID',
967  'submit_name' => 'add_button',
968  ),
969  ),
970  'inputs' => array(
971  'CustomCategories' => array(
972  'caption' => _t('_Category'),
973  'type' => 'custom',
974  'name' => 'CustomCategories',
975  'content' => $sCustomCategories
976  ),
977  'Subject' => array(
978  'type' => 'text',
979  'name' => 'Subject',
980  'caption' => _t('_Caption'),
981  'required' => true,
982  'checker' => array(
983  'func' => 'length',
984  'params' => array(3, 100),
985  'error' => _t('_ch_ads_Caption_error'),
986  ),
987  'db' => array(
988  'pass' => 'Xss',
989  ),
990  ),
991  'LifeTime' => array(
992  'type' => 'select',
993  'name' => 'LifeTime',
994  'caption' => _t('_ch_ads_Life_Time') . " ({$sDaysC})",
995  'info' => $sMaxedString,
996  'value' => $iMaxLt,
997  'values' => $aLifeTimeValues,
998  'required' => true,
999  'checker' => array(
1000  'func' => 'length',
1001  'params' => array(1, 3),
1002  'error' => _t('_Error Occured'),
1003  ),
1004  'db' => array(
1005  'pass' => 'Int',
1006  ),
1007  ),
1008  'Tags' => array(
1009  'type' => 'text',
1010  'name' => 'Tags',
1011  'caption' => _t('_Tags'),
1012  'info' => _t('_sys_tags_note'),
1013  'required' => false,
1014  'db' => array(
1015  'pass' => 'Xss',
1016  ),
1017  ),
1018  'Message' => array(
1019  'type' => 'textarea',
1020  'name' => 'Message',
1021  'caption' => _t('_ch_ads_post_text'),
1022  'required' => true,
1023  'html' => 2,
1024  'checker' => array(
1025  'func' => 'length',
1026  'params' => array(3, 65535),
1027  'error' => _t('_ch_ads_Text_error'),
1028  ),
1029  'db' => array(
1030  'pass' => 'XssHtml',
1031  ),
1032  ),
1033  'Country' => array(
1034  'type' => 'select',
1035  'name' => 'Country',
1036  'caption' => _t('_ch_ads_caption_country'),
1037  'values' => $aCountries,
1038  'value' => $sCountry,
1039  'required' => true,
1040  'checker' => array(
1041  'func' => 'preg',
1042  'params' => array('/^[a-zA-Z]{2}$/'),
1043  'error' => _t('_ch_ads_err_country'),
1044  ),
1045  'db' => array(
1046  'pass' => 'Preg',
1047  'params' => array('/([a-zA-Z]{2})/'),
1048  ),
1049  ),
1050  'City' => array(
1051  'type' => 'text',
1052  'name' => 'City',
1053  'caption' => _t('_ch_ads_caption_city'),
1054  'required' => true,
1055  'value' => $sCity,
1056  'checker' => array(
1057  'func' => 'length',
1058  'params' => array(3, 50),
1059  'error' => _t('_ch_ads_err_city'),
1060  ),
1061  'db' => array(
1062  'pass' => 'Xss',
1063  ),
1064  ),
1065  'File' => array(
1066  'type' => 'file',
1067  'name' => 'userfile[]',
1068  'caption' => _t('_associated_image'),
1069  'attrs' => array(
1070  'multiplyable' => 'true',
1071  )
1072  ),
1073  'ExistedImages' => array(
1074  'type' => 'hidden',
1075  ),
1076  'allowView' => $aAllowView,
1077  'allowRate' => $aAllowRate,
1078  'allowComment' => $aAllowComment,
1079  'add_button' => array(
1080  'type' => 'submit',
1081  'name' => 'add_button',
1082  'value' => $sNewAdC,
1083  ),
1084  ),
1085  );
1086 
1087  $sExistedMedia = '';
1088  if ($iPostID > 0) {
1089  $aAdUnitInfo = (is_array($aAdUnitInfo) && count($aAdUnitInfo) > 0) ? $aAdUnitInfo : $this->_oDb->getAdInfo($iPostID);
1090  $sExistedMedia = $aAdUnitInfo['Media'];
1091  $sSubject = $aAdUnitInfo['Subject'];
1092  $sMessage = $aAdUnitInfo['Message'];
1093  $sPostTags = $aAdUnitInfo['Tags'];
1094 
1095  $sPostLifeTime = (int)$aAdUnitInfo['LifeTime'];
1096 
1097  $sPostPictureElements = $sMsgDeleteImage . $this->getImageManagingCode($aAdUnitInfo['Media'], $iPostID);
1098  if ($sPostPictureElements != '') {
1099  $aForm['inputs']['ExistedImages']['type'] = 'custom';
1100  $aForm['inputs']['ExistedImages']['content'] = $sPostPictureElements;
1101  $aForm['inputs']['ExistedImages']['caption'] = _t('_ch_ads_Existed_images');
1102  }
1103 
1104  $aForm['inputs']['Subject']['value'] = $sSubject;
1105  $aForm['inputs']['Message']['value'] = $sMessage;
1106  $aForm['inputs']['Tags']['value'] = $sPostTags;
1107  $aForm['inputs']['LifeTime']['value'] = $sPostLifeTime;
1108 
1109  $aForm['inputs']['allowView']['value'] = $aAdUnitInfo['AllowView'];
1110  $aForm['inputs']['allowRate']['value'] = $aAdUnitInfo['AllowRate'];
1111  $aForm['inputs']['allowComment']['value'] = $aAdUnitInfo['AllowComment'];
1112 
1113  $aForm['inputs']['hidden_postid'] = array(
1114  'type' => 'hidden',
1115  'name' => 'EditPostID',
1116  'value' => $iPostID,
1117  );
1118  }
1119 
1120  if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) {
1121  $aForm['inputs']['allowView']['value'] = CH_WSB_PG_ALL;
1122  }
1123  if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) {
1124  $aForm['inputs']['allowRate']['value'] = CH_WSB_PG_ALL;
1125  }
1126  if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
1127  $aForm['inputs']['allowComment']['value'] = CH_WSB_PG_ALL;
1128  }
1129 
1130  $oForm = new ChTemplFormView($aForm);
1131  $oForm->initChecker();
1132  if ($oForm->isSubmittedAndValid() && $iSubCatID) {
1133  $this->CheckLogged();
1134 
1135  $sCurTime = time();
1136  $sPostUri = uriGenerate(ch_get('Subject'), $this->_oConfig->sSQLPostsTable, 'EntryUri');
1137  $sAutoApprovalVal = (getParam('ch_ads_auto_approving') == 'on') ? 'active' : 'new';
1138 
1139  $sCustomFieldValue1 = floatval(ch_get('CustomFieldValue1'));
1140  $sCustomFieldValue2 = floatval(ch_get('CustomFieldValue2'));
1141 
1142  ob_start();
1143  $sMedIds = $this->parseUploadedFiles();
1144  $sErrorImageProcessing = ob_get_clean();
1145 
1146  $aValsAdd = array(
1147  'DateTime' => $sCurTime,
1148  'Status' => $sAutoApprovalVal,
1149  'IDClassifiedsSubs' => $iSubCatID,
1150  'CustomFieldValue1' => $sCustomFieldValue1,
1151  'CustomFieldValue2' => $sCustomFieldValue2
1152  );
1153  if ($sMedIds != '') {
1154  $sMedIds = ($sExistedMedia != '') ? $sExistedMedia . ',' . $sMedIds : $sMedIds;
1155  $aValsAdd['Media'] = $sMedIds;
1156  }
1157 
1158  $iLastId = -1;
1159  if ($iPostID > 0) {
1160  $oForm->update($iPostID, $aValsAdd);
1161  $iLastId = $iPostID;
1162  } else {
1163  $aValsAdd['EntryUri'] = $sPostUri;
1164  $aValsAdd['IDProfile'] = $this->_iVisitorID;
1165  $iLastId = $oForm->insert($aValsAdd);
1166  }
1167 
1168  if ($iLastId > 0) {
1169  ($iPostID > 0) ? $this->isAllowedEdit($iAdvOwner, true) : $this->isAllowedAdd(true); // perform action
1170 
1171  //reparse tags
1172  ch_import('ChWsbTags');
1173  $oTags = new ChWsbTags();
1174  $oTags->reparseObjTags('ad', $iLastId);
1175 
1176  if (ChWsbModule::getInstance('ChWmapModule')) {
1177  ChWsbService::call('wmap', $iPostID ? 'response_entry_change' : 'response_entry_add',
1178  array($this->_oConfig->getUri(), $iLastId ? $iLastId : $iPostID));
1179  }
1180 
1181  ch_import('ChWsbAlerts');
1182  $sAlertAction = ($iPostID) ? 'edit' : 'create';
1183  $oZ = new ChWsbAlerts('ads', $sAlertAction, $iLastId, $this->_iVisitorID);
1184  $oZ->alert();
1185 
1186  $sResult = ($iPostID > 0) ? _t('_ch_ads_Ad_succ_updated') : _t('_ch_ads_Ad_succ_added');
1187 
1188  return ($sErrorImageProcessing ? $sErrorImageProcessing : '') . MsgBox($sResult) . (!$iPostID ? '<script>setTimeout(function () { document.location="' . $this->genUrl($iLastId,
1189  '', 'entry', true) . '"; } , 1000);</script>' : '');
1190  } else {
1191  return MsgBox(_t('_Error Occured'));
1192  }
1193  } else {
1194  $sNewAdFormVal = '<div class="blogs-view ch-def-bc-margin">' . $oForm->getCode() . '</div>';
1195 
1196  return ($bBox) ? DesignBoxContent(_t('_ch_ads_Add_ad'), $sNewAdFormVal, 1) : $sNewAdFormVal;
1197  }
1198  }
1199 
1207  {
1208  $sCurrentTime = time();
1209 
1210  if ($_FILES) {
1211  $aIDs = array();
1212 
1213  for ($i = 0; $i < count($_FILES['userfile']['tmp_name']); $i++) {
1214  if ($_FILES['userfile']['error'][$i]) {
1215  continue;
1216  }
1217  if ($_FILES['userfile']['size'][$i] > $this->iMaxUplFileSize) {
1218  echo _t_err('_ch_ads_Warn_max_file_size', $_FILES['userfile']['name'][$i]);
1219  continue;
1220  }
1221 
1222  list($width, $height, $type, $attr) = getimagesize($_FILES['userfile']['tmp_name'][$i]);
1223 
1224  if ($type != 1 && $type != 2 && $type != 3) {
1225  continue;
1226  }
1227 
1228  $sBaseName = $this->_iVisitorID . '_' . $sCurrentTime . '_' . ($i + 1);
1229  $sExt = strrchr($_FILES['userfile']['name'][$i], '.');
1230  $sExt = strtolower(trim($sExt));
1231 
1232  $sImg = CH_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}img_{$sBaseName}{$sExt}";
1233  $sImgThumb = CH_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}thumb_{$sBaseName}{$sExt}";
1234  $sImgThumbBig = CH_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}big_thumb_{$sBaseName}{$sExt}";
1235  $sImgIcon = CH_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}icon_{$sBaseName}{$sExt}";
1236  $vResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImg, $this->iImgSize,
1237  $this->iImgSize);
1238  $vThumbResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgThumb, $this->iThumbSize,
1239  $this->iThumbSize);
1240  $vBigThumbResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgThumbBig,
1241  $this->iBigThumbSize, $this->iBigThumbSize);
1242  $vIconResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgIcon, $this->iIconSize,
1243  $this->iIconSize);
1244  if ($vResizeRes || $vThumbResizeRes || $vBigThumbResizeRes || $vIconResizeRes) {
1245  echo _t_err("_ERROR_WHILE_PROCESSING");
1246  continue;
1247  }
1248 
1249  $iImgId = $this->_oDb->insertMedia($this->_iVisitorID, $sBaseName, $sExt);
1250  if (!$iImgId) {
1251  @unlink($sImg);
1252  @unlink($sImgThumb);
1253  @unlink($sImgThumbBig);
1254  @unlink($sImgIcon);
1255  continue;
1256  }
1257  $aIDs[] = $iImgId;
1258  }
1259 
1260  return implode(',', $aIDs);
1261  }
1262  }
1263 
1264  function getManageArea($oSearch, $sBoxIdSpec, $aButtons = array(), $sPgnUrl = '', $aPgn = array())
1265  {
1266  $sCode = $oSearch->displayResultBlock();
1267  if ($oSearch->aCurrent['paginate']['totalNum'] == 0) {
1268  $sCode = MsgBox(_t('_Empty'));
1269  } else {
1270  if ($oSearch->aCurrent['paginate']['perPage'] < $oSearch->aCurrent['paginate']['totalNum']) {
1271  $aPgnSpec = array(
1272  'page_url' => $sPgnUrl,
1273  'count' => $oSearch->aCurrent['paginate']['totalNum'],
1274  'per_page' => $oSearch->aCurrent['paginate']['perPage'],
1275  'page' => $oSearch->aCurrent['paginate']['page'],
1276  );
1277  $sPgn = '<div class="clear_both"></div>';
1278  $aPgnParams = array_merge($aPgn, $aPgnSpec);
1279  $oPgnSpec = new ChWsbPaginate($aPgnParams);
1280  $sPgn .= $oPgnSpec->getPaginate();
1281  $sCode = '<div id="' . $sBoxIdSpec . '">' . $sCode . $sPgn . '</div>';
1282  $sPgn = '<div class="clear_both"></div>';
1283  }
1284  }
1285  if (!empty($aButtons) && $oSearch->bShowCheckboxes) {
1286  $sActionsPanel = $oSearch->showAdminActionsPanel('ads_box', $aButtons, 'ads');
1287  $sCode = <<<EOF
1288 <form id="ch_ads_user_form" method="post">
1289  <div id="ads_box">
1290  {$sCode}
1291  {$sPgn}
1292  </div>
1293  {$sActionsPanel}
1294 </form>
1295 EOF;
1296  }
1297 
1298  return $sCode;
1299  }
1300 
1306  function getMemberAds($iOtherProfileID = 0, $iRandLim = 0, $iExceptUnit = 0)
1307  {
1308  $sBrowseAllAds = _t('_ch_ads_Browse_All_Ads');
1309  $sUserListC = _t('_ch_ads_Users_other_listing');
1310 
1311  $sHomeLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
1312 
1313  $sSiteUrl = CH_WSB_URL_ROOT;
1314 
1315  $sBreadCrumbs = <<<EOF
1316 <div class="paginate ch-def-padding-left ch-def-padding-right">
1317  <div class="view_all">
1318  <a href="{$sHomeLink}">{$sBrowseAllAds}</a>
1319  </div>
1320 </div>
1321 EOF;
1322 
1323  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
1324  $oTmpAdsSearch = new ChAdsSearchUnit();
1325  if ($iRandLim > 0) {
1326  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = (int)$iRandLim;
1327  } else {
1328  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
1329  }
1330  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
1331  $oTmpAdsSearch->aCurrent['restriction']['owner']['value'] = $iOtherProfileID;
1332  if ($iExceptUnit > 0) {
1333  $oTmpAdsSearch->aCurrent['restriction']['id']['value'] = $iExceptUnit;
1334  $oTmpAdsSearch->aCurrent['restriction']['id']['operator'] = '!=';
1335  }
1336 
1337  $sMemberAds = $oTmpAdsSearch->displayResultBlock();
1338  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
1339  $sMemberAds = MsgBox(_t('_Empty'));
1340  }
1341 
1342  if ($iRandLim == 0) {
1343  $GLOBALS['oTopMenu']->setCurrentProfileID($iOtherProfileID);
1344 
1345  return DesignBoxContent($sUserListC, $sMemberAds . $sBreadCrumbs, 1);
1346  }
1347 
1348  return $sMemberAds;
1349  }
1350 
1351  function DeleteProfileAdvertisement($iProfileID)
1352  {
1353  if ($this->bAdminMode == true) {
1354  $vDelSQL = $this->_oDb->getMemberAds((int)$iProfileID);
1355  while ($aAdv = $vDelSQL->fetch()) {
1356  $this->ActionDeleteAdvertisement($aAdv['ID']);
1357  }
1358  }
1359  }
1360 
1368  {
1369  $iDeleteAdvertisementID = (int)$iID;
1370 
1371  $iAdvOwner = $this->_oDb->getOwnerOfAd($iDeleteAdvertisementID);
1372 
1373  if (!$this->isAllowedDelete($iAdvOwner)) {
1374  return $this->_oTemplate->displayAccessDenied();
1375  }
1376 
1377  if ($iDeleteAdvertisementID > 0) {
1378  $sSuccDel = _t("_ch_ads_Ad_succ_deleted");
1379  $sFailDel = _t("_ch_ads_Ad_fail_delete");
1380 
1381  $sRetHtml = '';
1382  $sMediaIDs = $this->_oDb->getMediaOfAd($iDeleteAdvertisementID);
1383  if ($sMediaIDs != '') {
1384  $aChunks = explode(',', $sMediaIDs);
1385  foreach ($aChunks as $sMedId) {
1386  $iMedId = (int)$sMedId;
1387  if ($iMedId) {
1388  $sMediaFileName = $this->_oDb->getMediaFile($iMedId);
1389  if ($sMediaFileName != '') {
1390  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'img_' . $sMediaFileName);
1391  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'thumb_' . $sMediaFileName);
1392  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'big_thumb_' . $sMediaFileName);
1393  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'icon_' . $sMediaFileName);
1394  }
1395  $this->_oDb->deleteMedia($iMedId);
1396  }
1397  }
1398  }
1399 
1400  if ($this->_oDb->deleteAd($iDeleteAdvertisementID)) {
1401  $this->isAllowedDelete($iAdvOwner, true); // perform action
1402 
1403  $oCmts = new ChWsbCmts('ads', $iDeleteAdvertisementID);
1404  $oCmts->onObjectDelete();
1405 
1406  //reparse tags
1407  ch_import('ChWsbTags');
1408  $oTags = new ChWsbTags();
1409  $oTags->reparseObjTags('ad', $iDeleteAdvertisementID);
1410 
1411  // delete views
1412  ch_import('ChWsbViews');
1413  $oViews = new ChWsbViews('ads', $iDeleteAdvertisementID, false);
1414  $oViews->onObjectDelete();
1415 
1416  // delete associated locations
1417  if (ChWsbModule::getInstance('ChWmapModule')) {
1418  ChWsbService::call('wmap', 'response_entry_delete',
1419  array($this->_oConfig->getUri(), $iDeleteAdvertisementID));
1420  }
1421 
1422  //delete all subscriptions
1424  $oSubscription->unsubscribe(array(
1425  'type' => 'object_id',
1426  'unit' => 'ads',
1427  'object_id' => $iDeleteAdvertisementID
1428  ));
1429 
1430  ch_import('ChWsbAlerts');
1431  $oZ = new ChWsbAlerts('ads', 'delete', $iDeleteAdvertisementID, $iDeleteAdvertisementID);
1432  $oZ->alert();
1433 
1434  $sRetHtml .= MsgBox(_t($sSuccDel));
1435  } else {
1436  $sRetHtml .= MsgBox(_t($sFailDel));
1437  }
1438 
1439  return $sRetHtml;
1440  } else {
1441  return MsgBox(_t('_Error Occured'));
1442  }
1443  }
1444 
1445  function getImageManagingCode($sMediaIDs, $iPostID)
1446  {
1447  $sDeleteC = _t('_Delete');
1448 
1449  if ($sMediaIDs != '') {
1450  $aChunks = explode(',', $sMediaIDs);
1451  foreach ($aChunks as $sMedId) {
1452  $iMedId = (int)$sMedId;
1453  if (is_numeric($iMedId) && $iMedId) {
1454  $aSqlRes = $this->_oDb->getMediaInfo($iMedId);
1455  if ($aSqlRes) {
1456  $sFileName = CH_WSB_URL_ROOT . $this->sUploadDir . 'thumb_' . $aSqlRes['MediaFile'];
1457  $sAdsEditLink = ($this->bUseFriendlyLinks ? CH_WSB_URL_ROOT . "ads/my_page/edit/{$iPostID}/dimg/{$iMedId}" : "{$this->sCurrBrowsedFile}?action=my_page&mode=add&EditPostID={$iPostID}&dimg={$iMedId}");
1458  $sImgTag .= <<<EOF
1459 <div style="float:left;">
1460  <img class="photo1 ch-def-round-corners ch-def-shadow ch-def-margin-sec-right" src="{$sFileName}" style="width:{$this->iThumbSize}px;" />
1461  <br />
1462  <a href="{$sAdsEditLink}">{$sDeleteC}</a>
1463 </div>
1464 EOF;
1465  }
1466  }
1467  }
1468 
1469  return <<<EOF
1470 <div class="cls_edit_imgs_cont">
1471  {$sImgTag}
1472  <div class="clear_both"></div>
1473 </div>
1474 EOF;
1475  }
1476  }
1477 
1478  function getAdCover($sMediaIDs, $sType = 'thumb', $isSubstituteNoImage = true)
1479  {
1480  $sFileName = false;
1481  if ($isSubstituteNoImage) {
1482  $sFileName = ($sType != 'icon') ? $this->sPicNotAvail : $GLOBALS['oSysTemplate']->getIconUrl('no-photo-64.png');
1483  }
1484 
1485  if ($sMediaIDs != '') {
1486  $aChunks = explode(',', $sMediaIDs);
1487  $iMedId = (int)$aChunks[0];
1488 
1489  if (is_numeric($iMedId) && $iMedId) {
1490  $aSqlRes = $this->_oDb->getMediaInfo($iMedId);
1491  if ($aSqlRes) {
1492  if (file_exists(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . $sType . '_' . $aSqlRes['MediaFile'])) {
1493  $sFileName = CH_WSB_URL_ROOT . $this->sUploadDir . $sType . '_' . $aSqlRes['MediaFile'];
1494  }
1495  }
1496  }
1497  }
1498 
1499  return $sFileName;
1500  }
1501 
1502  function getAdCoverPath($sMediaIDs, $sType = 'thumb', $isSubstituteNoImage = true)
1503  {
1504  $sFileName = false;
1505  if ($isSubstituteNoImage) {
1506  $sFileName = ($sType != 'icon') ? $this->sPicNotAvailPath : $GLOBALS['oSysTemplate']->getIconPath('no-photo-64.png');
1507  }
1508 
1509  if ($sMediaIDs != '') {
1510  $aChunks = explode(',', $sMediaIDs);
1511  $iMedId = (int)$aChunks[0];
1512 
1513  if (is_numeric($iMedId) && $iMedId) {
1514  $aSqlRes = $this->_oDb->getMediaInfo($iMedId);
1515  if ($aSqlRes) {
1516  if (file_exists(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . $sType . '_' . $aSqlRes['MediaFile'])) {
1517  $sFileName = CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . $sType . '_' . $aSqlRes['MediaFile'];
1518  }
1519  }
1520  }
1521  }
1522 
1523  return $sFileName;
1524  }
1525 
1532  function ActionBuyAdvertisement($iAdvertisementID)
1533  {
1534  $sRetHtml = '';
1535  if ($this->_iVisitorID > 0) {
1536  $aSqlResStr = $this->_oDb->getAdInfo($iAdvertisementID);
1537  if ($aSqlResStr) {
1538  $sCustDetails = ($aSqlResStr['CustomFieldName1'] != null && $aSqlResStr['CustomFieldValue1']) ? "{$aSqlResStr['Unit1']} {$aSqlResStr['CustomFieldValue1']}" : '';
1539  $sBuyMsg1 = _t('_ch_ads_BuyMsg1');
1540  $sBuyDet1 = _t('_ch_ads_BuyDetails1');
1541  $sContinue = _t('_Continue');
1542 
1543  $sBoxTag = <<<EOF
1544 <div class="dbContent">
1545  <div>
1546  <b>{$sBuyMsg1}</b>
1547  </div><br/>
1548  <div>
1549  <b>{$sBuyDet1}</b>&nbsp;&nbsp;&nbsp;{$sCustDetails}
1550  </div><br/>
1551  <div>
1552  <input class="button ch-btn" type="submit" onclick="javascript:this.value='Wait...';this.disabled=true;document.bid_form.submit();" value="{$sContinue}" />
1553  <div class="clear_both"></div>
1554  </div>
1555 </div>
1556 EOF;
1557 
1558  $sRetHtml .= DesignBoxContent($aSqlResStr['Subject'], $sBoxTag, 11);
1559  $sRetHtml .= <<<EOF
1560 <form action="{$this->sCurrBrowsedFile}" name="bid_form" method="post">
1561  <input type="hidden" name="BuySendNow" value="BuySendNow" />
1562  <input type="hidden" name="IDAdv" value="{$iAdvertisementID}" />
1563  <input type="hidden" name="IDSeller" value="{$aSqlResStr['IDProfile']}" />
1564 </form>
1565 EOF;
1566  }
1567  }
1568 
1569  return $sRetHtml;
1570  }
1571 
1578  function ActionBuySendMailAdvertisement($iAdvertisementID)
1579  {
1580  global $site;
1581 
1582  $iSellerId = (int)ch_get('IDSeller');
1583  $sRetHtml = _t('_WARNING');
1584  if ($this->_iVisitorID > 0) {
1585  $aSqlResStr = $this->_oDb->getAdInfo($iAdvertisementID);
1586  $aSqlSellerRes = getProfileInfo($iSellerId);
1587  $aSqlMemberRes = getProfileInfo($this->_iVisitorID);
1588  if ($aSqlResStr) {
1589  $sCustDetails = ($aSqlResStr['CustomFieldName1'] != null && $aSqlResStr['CustomFieldValue1']) ? "{$aSqlResStr['Unit1']} {$aSqlResStr['CustomFieldValue1']}" : '';
1590 
1591  $sPowDol = _t('_powered_by_Cheetah');
1592  $sBuyMsg2 = _t('_ch_ads_BuyMsg2');
1593  $sBuyDet1 = _t('_ch_ads_BuyDetails1');
1594  $sReturnBackC = _t('_ch_ads_Back');
1595 
1596  ch_import('ChWsbEmailTemplates');
1597  $rEmailTemplate = new ChWsbEmailTemplates();
1598  $aTemplate = $rEmailTemplate->getTemplate('t_BuyNow', $this->_iVisitorID);
1599  $aTemplateS = $rEmailTemplate->getTemplate('t_BuyNowS', $this->_iVisitorID);
1600 
1601  // Send email notification
1602  $sMessageB = $aTemplate['Body'];
1603  $sMessageS = $aTemplateS['Body'];
1604  $sSubject = $aTemplate['Subject'];
1605  $sSubjectS = $aTemplateS['Subject'];
1606 
1607  $aPlus = array();
1608  $aPlus['Subject'] = $aSqlResStr['Subject'];
1609  $aPlus['NickName'] = getNickName($aSqlSellerRes['ID']);
1610  $aPlus['EmailS'] = $aSqlSellerRes['Email'];
1611  $aPlus['NickNameB'] = getNickName($aSqlMemberRes['ID']);
1612  $aPlus['EmailB'] = $aSqlMemberRes['Email'];
1613  $aPlus['sCustDetails'] = $sCustDetails;
1614 
1615  $sGenUrl = $this->genUrl($iAdvertisementID, $aSqlResStr['EntryUri']);
1616  $aPlus['ShowAdvLnk'] = $sGenUrl;
1617 
1618  $aPlus['sPowDol'] = $sPowDol;
1619  $aPlus['site_email'] = $site['email'];
1620 
1621  $sRetHtml = '';
1622  $aPlus['Who'] = 'buyer';
1623  $aPlus['String1'] = _t('_ch_ads_you_have_purchased_an_item');
1624  sendMail($aSqlMemberRes['Email'], $sSubject, $sMessageB, $aSqlSellerRes['ID'], $aPlus, 'html');
1625 
1626  $aPlus['Who'] = 'seller';
1627  $aPlus['String1'] = _t('_ch_ads_someone_wants_to_purchase');
1628  if (sendMail($aSqlSellerRes['Email'], $sSubjectS, $sMessageS, $aSqlSellerRes['ID'], $aPlus, 'html')) {
1629  $sRetHtml .= MsgBox(_t('_Email was successfully sent'));
1630  ch_import('ChWsbAlerts');
1631  $oZ = new ChWsbAlerts('ads', 'buy', $iAdvertisementID, $this->_iVisitorID);
1632  $oZ->alert();
1633  }
1634 
1635  $sBoxContent = <<<EOF
1636  <div>
1637  <b>{$sBuyMsg2}</b>
1638  </div><br/>
1639  <div>
1640  <b>{$sBuyDet1}</b>&nbsp;&nbsp;&nbsp;{$sCustDetails}
1641  </div><br/>
1642  <div>
1643  <a class="ch-btn" href="{$sGenUrl}">{$sReturnBackC}</a>
1644  <div class="clear_both"></div>
1645  </div>
1646 EOF;
1647  $sRetHtml .= DesignBoxContent($aSqlResStr['Subject'], $sBoxContent, 11);
1648  }
1649  }
1650 
1651  return $sRetHtml;
1652  }
1653 
1661  {
1662  global $site;
1663  global $aPreValues;
1664 
1665  $iAdvertisementID = (int)$iID;
1666  $sRetHtml = '';
1667  $sSiteUrl = CH_WSB_URL_ROOT;
1668 
1669  if ($this->bAdminMode && $iAdvertisementID > 0) {
1670  $iFeaturedStatus = $this->_oDb->getFeaturedStatus($iAdvertisementID);
1671  $iNewStatus = ($iFeaturedStatus == 1) ? 0 : 1;
1672  if (ch_get('do') == 'cfs') {
1673  $this->_oDb->UpdateFeatureStatus($iAdvertisementID, $iNewStatus);
1674  }
1675  }
1676 
1677  $aSqlResStr = $this->_oDb->getAdInfo($iAdvertisementID);
1678  if ($aSqlResStr) {
1679  $iOwnerID = (int)$aSqlResStr['IDProfile'];
1680 
1681  $bPossibleToView = $this->oPrivacy->check('view', $iAdvertisementID, $this->_iVisitorID);
1682  if ($this->isAllowedView($iOwnerID, true) == false || $bPossibleToView == false) {
1683  return $this->_oTemplate->displayAccessDenied();
1684  }
1685 
1686  ch_import('ChWsbViews');
1687  new ChWsbViews('ads', $iAdvertisementID);
1688 
1689  $aNameRet = getProfileInfo($aSqlResStr['IDProfile']);
1690  $sCountryName = $aSqlResStr['Country'];
1691  $sCountryPic = ($sCountryName == '') ? '' : ' <img alt="' . $sCountryName . '" src="' . ($site['flags'] . strtolower($sCountryName)) . '.gif"/>';
1692  $sCountryName = _t($aPreValues['Country'][$sCountryName]['LKey']);
1693 
1694  $sPostedByC = _t('_ch_ads_Posted_by');
1695  $sPhoneC = _t('_Phone');
1696  $sDetailsC = _t('_ch_ads_Details');
1697  $sUserOtherListC = _t('_ch_ads_Users_other_listing');
1698  $sActionsC = _t('_Actions');
1699  $sSureC = _t('_Are_you_sure');
1700 
1701  $sPostedBy .= '<div class="cls_res_info">';
1702  $sPostedBy .= $sPostedByC . ': <span style="color:#333333;"><a href="' . getProfileLink($aNameRet['ID']) . '">' . $aNameRet['NickName'] . '</a></span>';
1703  $sPostedBy .= '</div>';
1704  if ($aNameRet['Phone'] != "") {
1705  $sPostedBy .= '<div class="cls_res_info">';
1706  $sPostedBy .= $sPhoneC . ": <div class=\"clr3\">{$aNameRet['Phone']}</div>";
1707  $sPostedBy .= '</div>';
1708  }
1709 
1710  $sTimeAgo = defineTimeInterval($aSqlResStr['DateTime_UTS'], false);
1711 
1712  $aTags = array();
1713  $aTagsLinks = array();
1714 
1715  $aTags = preg_split("/[;,]/", $aSqlResStr['Tags']);
1716  foreach ($aTags as $sTag) {
1717  $sSubLink = ($this->bUseFriendlyLinks) ? "ads/tag/" : $this->sHomeUrl . "classifieds_tags.php?tag=";
1718  $sTagS = htmlspecialchars(title2uri($sTag));
1719  $aTagsLinks[] = '<a href="' . "{$sSubLink}{$sTagS}" . '">' . $sTag . '</a>';
1720  }
1721  $sTags .= implode(", ", $aTagsLinks);
1722 
1723  $sMemberActionForms = '';
1724  if ($this->_iVisitorID > 0 && $this->_iVisitorID != $aNameRet['ID']) {//print Send PM button and other actions
1725  if (getParam('ch_ads_enable_paid') == 'on') {
1726  $sMemberActionForms .= <<<EOF
1727 <form action="{$this->sCurrBrowsedFile}" name="BuyNowForm" method="post">
1728  <input type="hidden" name="BuyNow" value="BuyNow" />
1729  <input type="hidden" name="IDAdv" value="{$iAdvertisementID}" />
1730  <input type="hidden" name="IDSeller" value="{$aSqlResStr['IDProfile']}" />
1731 </form>
1732 EOF;
1733  }
1734  $sMemberActionForms .= <<<EOF
1735 <form action="{$sSiteUrl}mail.php" name="post_pm" id="post_pm" method="get">
1736  <input type="hidden" name="mode" value="compose" />
1737  <input type="hidden" name="recipient_id" value="{$aSqlResStr['IDProfile']}" />
1738  <input type="hidden" name="subject" value="{$aSqlResStr['Subject']}" />
1739 </form>
1740 EOF;
1741  }
1742 
1743  $sEntryUrl = $this->genUrl($iAdvertisementID, $aSqlResStr['EntryUri'], 'entry');
1744 
1745  $sMediaIDs = $this->_oDb->getMediaOfAd($iAdvertisementID);
1746  if ($sMediaIDs != '') {
1747  $aReadyMedia = explode(',', $sMediaIDs);
1748  $sPictureSectContent = $this->_blockPhoto($aReadyMedia, $iOwnerID);
1749  }
1750 
1751  $sPictureSect = ($sPictureSectContent != '') ? DesignBoxContent(_t('_ch_ads_Ad_photos'),
1752  $sPictureSectContent, 1) : '';
1753  $this->sTAPhotosContent = $sPictureSectContent;
1754 
1755  ch_import('ChWsbSubscription');
1757  $aButton = $oSubscription->getButton($this->_iVisitorID, $this->_oConfig->getUri(), '',
1758  $iAdvertisementID);
1759  $sSubsAddon = $oSubscription->getData();
1760 
1761  $aActionKeys = array(
1762  'BaseUri' => $this->_oConfig->getBaseUri(),
1763  'visitor_id' => $this->_iVisitorID,
1764  'owner_id' => $aNameRet['ID'],
1765  'admin_mode' => "'" . $this->bAdminMode . "'",
1766  'ads_id' => $iAdvertisementID,
1767  'ads_status' => $aSqlResStr['Status'],
1768  'ads_act_type' => $aSqlResStr['Status'] == 'active' ? 'inactive' : 'active',
1769  'ads_featured' => (int)$aSqlResStr['Featured'],
1770  'sure_label' => $sSureC,
1771  'ads_entry_url' => $sEntryUrl,
1772  'only_menu' => 0,
1773  'sbs_ads_title' => $aButton['title'],
1774  'sbs_ads_script' => $aButton['script'],
1775  'TitleShare' => $this->isAllowedShare($aSqlResStr) ? _t('_Share') : '',
1776  );
1777 
1778  $aActionKeys['repostCpt'] = $aActionKeys['repostScript'] = '';
1779  if(ChWsbRequest::serviceExists('wall', 'get_repost_js_click')) {
1780  $sSubsAddon .= ChWsbService::call('wall', 'get_repost_js_script');
1781 
1782  $aActionKeys['repostCpt'] = _t('_Repost');
1783  $aActionKeys['repostScript'] = ChWsbService::call('wall', 'get_repost_js_click',
1784  array($this->_iVisitorID, 'ads', 'create', $iAdvertisementID));
1785  }
1786  $sActionsTable = $GLOBALS['oFunctions']->genObjectsActions($aActionKeys, 'ch_ads', false);
1787 
1788  $sActionsSectContent = $sSubsAddon . $sMemberActionForms . $sActionsTable;
1789  $sActionsSect = ($this->_iVisitorID > 0 || $this->bAdminMode) ? DesignBoxContent($sActionsC,
1790  $sActionsSectContent, 1) : '';
1791  $this->sTAActionsContent = ($this->_iVisitorID > 0 || $this->bAdminMode) ? $sActionsSectContent : '';
1792 
1793  ch_import('Cmts', $this->_aModule);
1794  $this->oCmtsView = new ChAdsCmts ($this->_oConfig->getCommentSystemName(), $iAdvertisementID);
1795  $sCommentsSectContent = $this->oCmtsView->getExtraCss();
1796  $sCommentsSectContent .= $this->oCmtsView->getExtraJs();
1797  $sCommentsSectContent .= (!$this->oCmtsView->isEnabled()) ? '' : $this->oCmtsView->getCommentsFirst();
1798  $this->sTACommentsContent = $sCommentsSectContent;
1799  $sCommSect = DesignBoxContent($aCaptions['Comments'], $sCommentsSectContent, 1);
1800 
1801  $sUserOtherListing = $this->getMemberAds($aSqlResStr['IDProfile'], 2, $iAdvertisementID);
1802 
1803  $sDataTimeFormatted = getLocaleDate($aSqlResStr['DateTime_UTS']);
1804  $iViews = (int)$aSqlResStr['Views'];
1805 
1806  $sOwnerThumb = get_member_thumbnail($aSqlResStr['IDProfile'], 'none', true);
1807  $sAdsMessage = process_html_output($aSqlResStr['Message']);
1808 
1809  $sCategLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/cat/' . $aSqlResStr['CEntryUri'] : "{$this->sCurrBrowsedFile}?bClassifiedID={$aSqlResStr['CatID']}";
1810  $sSCategLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/subcat/' . $aSqlResStr['SEntryUri'] : "{$this->sCurrBrowsedFile}?bSubClassifiedID={$aSqlResStr['SubID']}";
1811 
1812  $aSubjVariables = array(
1813  'author_unit' => $sOwnerThumb,
1814  'date' => $sDataTimeFormatted,
1815  'date_ago' => $sTimeAgo,
1816  'cats' => $this->_oTemplate->parseHtmlByTemplateName('category', array(
1817  'cat_link' => $sCategLink,
1818  'sub_cat_link' => $sSCategLink,
1819  'cat_name' => $aSqlResStr['Name'],
1820  'sub_cat_name' => $aSqlResStr['NameSub']
1821  )),
1822  'tags' => $sTags,
1823  'fields' => '',
1824  );
1825  $sSubjectSectContent = $this->_oTemplate->parseHtmlByName('entry_view_block_info.html', $aSubjVariables);
1826 
1827  $sSubjectSect = DesignBoxContent(_t('_Info'), $sSubjectSectContent, 1);
1828  $this->sTAInfoContent = $sSubjectSectContent;
1829 
1830  $sDescriptionContent = '<div class="dbContent ch-def-bc-margin ch-def-font-large">' . $sAdsMessage . '</div>';
1831  $sDescriptionSect = DesignBoxContent(_t('_Description'), $sDescriptionContent, 1);
1832  $this->sTADescription = $sDescriptionContent;
1833 
1834  //adding form
1835  $aForm = array(
1836  'form_attrs' => array(
1837  'name' => 'custom_values_form',
1838  'action' => $oAds->sCurrBrowsedFile,
1839  ),
1840  'inputs' => array(
1841  'Country' => array(
1842  'type' => 'value',
1843  'name' => 'Country',
1844  'caption' => _t('_Country'),
1845  'value' => $sCountryName . $sCountryPic,
1846  ),
1847  'City' => array(
1848  'type' => 'value',
1849  'name' => 'City',
1850  'caption' => _t('_City'),
1851  'value' => $aSqlResStr['City'],
1852  ),
1853  ),
1854  );
1855 
1856  if ($aSqlResStr['CustomFieldName1'] && $aSqlResStr['CustomFieldValue1']) {
1857  $aForm['inputs']['Custom1'] = array(
1858  'type' => 'value',
1859  'name' => 'Custom1',
1860  'caption' => $aSqlResStr['CustomFieldName1'],
1861  'value' => $aSqlResStr['Unit1'] . $aSqlResStr['CustomFieldValue1'],
1862  );
1863  }
1864  if ($aSqlResStr['CustomFieldName2'] && $aSqlResStr['CustomFieldValue2']) {
1865  $aForm['inputs']['Custom2'] = array(
1866  'type' => 'value',
1867  'name' => 'Custom2',
1868  'caption' => $aSqlResStr['CustomFieldName2'],
1869  'value' => $aSqlResStr['Unit2'] . $aSqlResStr['CustomFieldValue2'],
1870  );
1871  }
1872 
1873  $oForm = new ChTemplFormView($aForm);
1874  $sOtherInfoContent = $oForm->getCode();
1875  $sOtherInfoSect = DesignBoxContent(_t('_ch_ads_Custom_Values'), $sOtherInfoContent, 1);
1876  $this->sTAOtherInfo = $sOtherInfoContent;
1877 
1878  $bPossibleToRate = $this->oPrivacy->check('rate', $iAdvertisementID, $this->_iVisitorID);
1879  $oVotingView = new ChTemplVotingView ('ads', $iAdvertisementID);
1880  $iVote = ($oVotingView && $oVotingView->isEnabled() && $bPossibleToRate) ? 1 : 0;
1881  $sVotePostRating = $oVotingView->getBigVoting($iVote);
1882 
1883  $sRatingSect = DesignBoxContent(_t('_Rate'), $sVotePostRating, 1);
1884  $this->sTARateContent = '<div class="ch-def-bc-margin">' . $sVotePostRating . '</div>';
1885 
1886  $sOtherListingContent = <<<EOF
1887 <div class="dbContent">
1888  {$sUserOtherListing}
1889 </div>
1890 EOF;
1891 
1892  $sSPaginateActions = <<<EOF
1893 <div class="paginate ch-def-padding-left ch-def-padding-right">
1894  <div class="view_all">
1895  <a href="{$this->sCurrBrowsedFile}" onclick="document.forms['UsersOtherListingForm'].submit(); return false;">{$sUserOtherListC}</a>
1896  <form action="{$this->sCurrBrowsedFile}" name="UsersOtherListingForm" method="post">
1897  <input type="hidden" name="UsersOtherListing" value="1" />
1898  <input type="hidden" name="IDProfile" value="{$aSqlResStr['IDProfile']}" />
1899  </form>
1900  </div>
1901  <div class="pages_section"></div>
1902 </div>
1903 EOF;
1904 
1905  $sOtherListingSect = DesignBoxContent($sUserOtherListC,
1906  $sOtherListingContent . $sSPaginateActions, 1);
1907  $this->sTAOtherListingContent = $sOtherListingContent . $sSPaginateActions;
1908 
1909  $sHomeLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
1910 
1911  $sBrowseAllAds = _t('_ch_ads_Browse_All_Ads');
1912  $sBreadCrumbs = <<<EOF
1913 <div class="breadcrumbs">
1914 <a href="{$sHomeLink}">{$sBrowseAllAds}</a>
1915 /
1916 <a href="{$sCategLink}">{$aSqlResStr['Name']}</a>
1917 /
1918 <a href="{$sSCategLink}">{$aSqlResStr['NameSub']}</a>
1919 </div>
1920 EOF;
1921 
1922  $aBlocks[1] .= $sActionsSect;
1923  $aBlocks[1] .= $sSubjectSect;
1924  $aBlocks[1] .= $sRatingSect;
1925  $aBlocks[1] .= $sOtherListingSect;
1926  $aBlocks[2] .= $sPictureSect;
1927  $aBlocks[2] .= $sCommSect;
1928 
1929  $sRetHtml = <<<EOF
1930 {$sBreadCrumbs}
1931 <div>
1932  <div class="clear_both"></div>
1933  <div class="cls_info_left">
1934  {$aBlocks['1']}
1935  </div>
1936  <div class="cls_info">
1937  {$sDescriptionSect}
1938  {$aBlocks['2']}
1939  </div>
1940  <div class="clear_both"></div>
1941 </div>
1942 <div class="clear_both"></div>
1943 EOF;
1944 
1945  ch_import('ChWsbAlerts');
1946  $oZ = new ChWsbAlerts('ads', 'view', $iAdvertisementID, $this->_iVisitorID);
1947  $oZ->alert();
1948 
1949  $sAdCover = $this->getAdCover($aSqlResStr['Media'], 'icon');
1950  if ($sAdCover != '' && $aSqlResStr['Media']) {
1951  $GLOBALS['oTopMenu']->setCustomSubIconUrl($sAdCover);
1952  }
1953 
1954  $GLOBALS['oTopMenu']->setCustomSubHeader(htmlspecialchars($aSqlResStr['Subject']));
1955  $GLOBALS['oTopMenu']->setCustomSubHeaderUrl($sEntryUrl);
1956 
1957  $GLOBALS['oTopMenu']->setCustomBreadcrumbs(array(
1958  _t('_ch_ads_Ads') => $sHomeLink,
1959  $aSqlResStr['Subject'] => '',
1960  ));
1961 
1962  $this->_oTemplate->setPageDescription(htmlspecialchars($aSqlResStr['Subject']));
1963  $this->_oTemplate->addPageKeywords(htmlspecialchars($aSqlResStr['Tags']));
1964  }
1965 
1966  return $sRetHtml;
1967  }
1968 
1970  {
1971  $aPostInfo = $this->_oDb->getAdInfo($iEntryId);
1972  if (isset($aPostInfo['EntryUri']) && isset($aPostInfo['Subject'])) {
1973  $sEntryUrl = $this->genUrl($iEntryId, $aPostInfo['EntryUri']);
1974  $sEntryCaption = $aPostInfo['Subject'];
1975  } else {
1976  return array('skip' => true);
1977  }
1978 
1979  $aActionList = array(
1980  'commentPost' => '_ch_ads_sbs_comments'
1981  );
1982 
1983  $sActionName = isset($aActionList[$sAction]) ? ' (' . _t($aActionList[$sAction]) . ')' : '';
1984 
1985  return array(
1986  'skip' => false,
1987  'template' => array(
1988  'Subscription' => $sEntryCaption . $sActionName,
1989  'ViewLink' => $sEntryUrl,
1990  ),
1991  );
1992  }
1993 
2000  {
2001  $oMemberMenu = ch_instance('ChWsbMemberMenu');
2002  $aLinkInfo = array(
2003  'item_img_src' => 'money',
2004  'item_img_alt' => _t('_ch_ads_Ads'),
2005  'item_link' => CH_WSB_URL_ROOT . (getParam('permalinks_module_ads') == 'on' ? 'ads/my_page/' : 'modules/cheetah/ads/classifieds.php?action=my_page'),
2006  'item_title' => _t('_ch_ads_Ads'),
2007  'extra_info' => $this->_oDb->getMemberAdsCnt(getLoggedId(), 'active', true),
2008  );
2009 
2010  return $oMemberMenu->getGetExtraMenuLink($aLinkInfo);
2011  }
2012 
2019  {
2020  if (!$this->isAllowedAdd()) {
2021  return '';
2022  }
2023 
2024  $oMemberMenu = ch_instance('ChWsbMemberMenu');
2025  $aLinkInfo = array(
2026  'item_img_src' => 'money',
2027  'item_img_alt' => _t('_ch_ads_Ad'),
2028  'item_link' => CH_WSB_URL_ROOT . (getParam('permalinks_module_ads') == 'on' ? 'ads/my_page/add/' : 'modules/cheetah/ads/classifieds.php?action=my_page&mode=add'),
2029  'item_title' => _t('_ch_ads_Ad'),
2030  );
2031 
2032  return $oMemberMenu->getGetExtraMenuLink($aLinkInfo);
2033  }
2034 
2039  {
2040  if (!ChWsbModule::getInstance('ChWmapModule')) {
2041  return false;
2042  }
2043 
2044  return ChWsbService::call('wmap', 'part_install', array(
2045  'ads',
2046  array(
2047  'part' => 'ads',
2048  'title' => '_ch_ads_Ads',
2049  'title_singular' => '_ch_ads_Ad',
2050  'icon' => 'modules/cheetah/ads/|map_marker.png',
2051  'icon_site' => 'money',
2052  'join_table' => 'ch_ads_main',
2053  'join_where' => "AND `p`.`Status` = 'active' AND UNIX_TIMESTAMP() - `p`.`LifeTime`*24*60*60 < `p`.`DateTime`",
2054  'join_field_id' => 'ID',
2055  'join_field_country' => 'Country',
2056  'join_field_city' => 'City',
2057  'join_field_state' => '',
2058  'join_field_zip' => '',
2059  'join_field_address' => '',
2060  'join_field_title' => 'Subject',
2061  'join_field_uri' => 'EntryUri',
2062  'join_field_author' => 'IDProfile',
2063  'join_field_privacy' => 'AllowView',
2064  'permalink' => 'modules/cheetah/ads/classifieds.php?entryUri=',
2065  )
2066  ));
2067  }
2068 
2075  function PrintAllSubRecords($iClassifiedID)
2076  {
2077  $iSafeCatID = (int)$iClassifiedID;
2078  $sSiteUrl = CH_WSB_URL_ROOT;
2079 
2080  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
2081  $oTmpAdsSearch = new ChAdsSearchUnit();
2082  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
2083  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
2084  $oTmpAdsSearch->aCurrent['restriction']['categoryID']['value'] = $iSafeCatID;
2085  $sCategoryAds = $oTmpAdsSearch->displayResultBlock();
2086 
2087  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
2088  $sCategoryAds = MsgBox(_t('_Empty'));
2089  } else {
2090  // Prepare link to pagination
2091  if ($this->bUseFriendlyLinks == false) { //old variant
2092  $sRequest = ch_html_attribute($_SERVER['PHP_SELF']) . '?bClassifiedID=' . $iSafeCatID . '&page={page}&per_page={per_page}';
2093  } else {
2094  $sRequest = CH_WSB_URL_ROOT . 'ads/all/cat/';
2095  $sPaginAddon = '/' . process_db_input(ch_get('catUri'), CH_TAGS_STRIP);
2096  $sRequest .= '{per_page}/{page}' . $sPaginAddon;
2097  }
2098  // End of prepare link to pagination
2099 
2100  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
2101  $sCategoryAds .= $oTmpAdsSearch->showPagination();
2102  }
2103 
2104  // Breadcrumb creating
2105  $sBrowseAllAds = _t('_ch_ads_Browse_All_Ads');
2106  $sHomeLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
2107  $sNameCat = $this->_oDb->getCategoryNameByID($iSafeCatID);
2108 
2109  $sBreadCrumbs = <<<EOF
2110 <div class="breadcrumbs">
2111 <a href="{$sHomeLink}">{$sBrowseAllAds}</a>
2112 <span class="bullet">&#8594;</span>
2113 <span class="active_link">{$sNameCat}</span>
2114 </div>
2115 EOF;
2116  // End of Breadcrumb creating
2117 
2118  $sFilter = $this->PrintFilterForm($iClassifiedID);
2119 
2120  $sCategoryAdsPageContent = DesignBoxContent($sBreadCrumbs, $sFilter . $sCategoryAds, 1);
2121 
2122  return $sCategoryAdsPageContent;
2123  }
2124 
2131  function PrintSubRecords($iIDClassifiedsSubs)
2132  {
2133  $iIDClassifiedsSubs = (int)$iIDClassifiedsSubs;
2134  $sSiteUrl = CH_WSB_URL_ROOT;
2135 
2136  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
2137  $oTmpAdsSearch = new ChAdsSearchUnit();
2138  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
2139  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
2140  $oTmpAdsSearch->aCurrent['restriction']['subcategoryID']['value'] = $iIDClassifiedsSubs;
2141  $sSubAds = $oTmpAdsSearch->displayResultBlock();
2142  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
2143  $sSubAds = MsgBox(_t('_Empty'));
2144  } else {
2145  // Prepare link to pagination
2146  if ($this->bUseFriendlyLinks == false) { //old variant
2147  $sRequest = ch_html_attribute($_SERVER['PHP_SELF']) . '?bSubClassifiedID=' . $iIDClassifiedsSubs . '&page={page}&per_page={per_page}';
2148  } else {
2149  $sRequest = CH_WSB_URL_ROOT . 'ads/all/subcat/';
2150  $sPaginAddon = '/' . process_db_input(ch_get('scatUri'), CH_TAGS_STRIP);
2151  $sRequest .= '{per_page}/{page}' . $sPaginAddon;
2152  }
2153  // End of prepare link to pagination
2154 
2155  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
2156  $sSubAds .= $oTmpAdsSearch->showPagination();
2157  }
2158 
2159  // Breadcrumb creating
2160  $aSubcatRes = $this->_oDb->getCatAndSubInfoBySubID($iIDClassifiedsSubs);
2161  $sCaption = "<div class=\"fl\">{$aSubcatRes['Name']}->{$aSubcatRes['NameSub']}</div>\n";
2162 
2163  $sDesc = "<div class=\"cls_result_row\">{$aSubcatRes['Description']}</div>";
2164 
2165  $sHomeLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
2166  $sCategLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/cat/' . $aSubcatRes['CEntryUri'] : "{$this->sCurrBrowsedFile}?bClassifiedID={$aSubcatRes['ClassifiedsID']}";
2167 
2168  $sBrowseAllAds = _t('_ch_ads_Browse_All_Ads');
2169  $sBreadCrumbs = <<<EOF
2170 <div class="breadcrumbs">
2171 <a href="{$sHomeLink}">{$sBrowseAllAds}</a>
2172 <span class="bullet">&#8594;</span>
2173 <a href="{$sCategLink}">{$aSubcatRes['Name']}</a>
2174 <span class="bullet">&#8594;</span>
2175 <span class="active_link">{$aSubcatRes['NameSub']}</span>
2176 </div>
2177 EOF;
2178  // End of Breadcrumb creating
2179 
2180  $sFilter = $this->PrintFilterForm(0, $iIDClassifiedsSubs);
2181  $sSubPageContent = DesignBoxContent($sBreadCrumbs, $sFilter . $sSubAds, 1);
2182 
2183  return $sSubPageContent;
2184  }
2185 
2191  function PrintBackLink()
2192  {
2193  $sHomeLink = ($this->bUseFriendlyLinks && $this->bAdminMode == false) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
2194 
2195  $sReturnBackC = _t('_ch_ads_Back');
2196  $sRetHtml = <<<EOF
2197 <div>
2198  <b>
2199  <a href="{$sHomeLink}">{$sReturnBackC}</a>
2200  </b>
2201 </div>
2202 EOF;
2203 
2204  return $sRetHtml;
2205  }
2206 
2207  function GenAllAds($sType = 'last', $isSimplePaginage = false)
2208  {
2209  $sCaption = _t('_ch_ads_last_ads');
2210  $sDisplayMode = '';
2211  $sTypeMode = '';
2212  switch ($sType) {
2213  case 'last':
2214  $sCaption = _t('_ch_ads_All_ads');
2215  $sDisplayMode = 'last';
2216  break;
2217  case 'featured':
2218  $sCaption = _t('_ch_ads_Featured');
2219  $sTypeMode = 'featured';
2220  $sDisplayMode = 'last';
2221  break;
2222  case 'popular':
2223  $sCaption = _t('_ch_ads_Popular');
2224  $sDisplayMode = 'popular';
2225  break;
2226  case 'top':
2227  default:
2228  $sCaption = _t('_ch_ads_Top_Rated');
2229  $sDisplayMode = 'top';
2230  break;
2231  }
2232 
2233  $aParams = array();
2234  if (false !== ch_get('action')) {
2235  $aParams[] = 'action=' . ch_get('action');
2236  } else {
2237  $aParams[] = 'Browse=1';
2238  }
2239  $aParams[] = 'page={page}';
2240  $aParams[] = 'per_page={per_page}';
2241  $sParams = implode('&', $aParams);
2242  $sRequest = ch_html_attribute($_SERVER['PHP_SELF']) . '?' . $sParams;
2243 
2244  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
2245  $oTmpAdsSearch = new ChAdsSearchUnit();
2246  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
2247  $oTmpAdsSearch->aCurrent['sorting'] = $sDisplayMode;
2248  if ($sTypeMode != '' && $sTypeMode == 'featured') {
2249  $oTmpAdsSearch->aCurrent['restriction']['featuredStatus']['value'] = 1;
2250  }
2251 
2252  // privacy changes
2253  if ($sType == 'last') {
2254  $oTmpAdsSearch->aCurrent['restriction']['allow_view']['value'] = $this->_iVisitorID ? array(
2255  CH_WSB_PG_ALL,
2257  ) : array(CH_WSB_PG_ALL);
2258  }
2259 
2260  $sLastAds = $oTmpAdsSearch->displayResultBlock();
2261  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
2262  $sLastAds = MsgBox(_t('_Empty'));
2263  } else {
2264  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
2265  $sLastAds .= $isSimplePaginage ? $oTmpAdsSearch->showPagination2() : $oTmpAdsSearch->showPagination();
2266  }
2267 
2268  $sLastAdsSection = DesignBoxContent($sCaption, $sLastAds, 1);
2269 
2270  return $sLastAdsSection;
2271  }
2272 
2274  {
2275  $sCategoriesHtml = '';
2276  $iColumnsCnt = 2;
2277 
2278  $iColumnWidth = (100 / $iColumnsCnt);
2279 
2280  $vSqlRes = $this->_oDb->getAllCatsInfo();
2281  $iCategoriesCnt = $vSqlRes->rowCount();
2282  $iCategPerColumn = ceil($iCategoriesCnt / $iColumnsCnt);
2283 
2284  $iCounter = 0;
2285  while ($aSqlResStr = $vSqlRes->fetch()) {
2286  $iID = $aSqlResStr['ID'];
2287  $sCatName = htmlspecialchars($aSqlResStr['Name']);
2288  $sCatUri = $aSqlResStr['CEntryUri'];
2289 
2290  $sCategLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/cat/' . $sCatUri : "{$this->sCurrBrowsedFile}?bClassifiedID={$iID}";
2291 
2292  $sqlResSubs = $this->_oDb->getAllSubCatsInfo($aSqlResStr['ID']);
2293  if (!$sqlResSubs) {
2294  return _t('_Error Occured');
2295  }
2296  $sSubsHtml = '';
2297  while ($aSqlResSubsStr = $sqlResSubs->fetch()) {
2298  $iSubID = (int)$aSqlResSubsStr['ID'];
2299 
2300  $iAdsCnt = $this->_oDb->getCountOfAdsInSubCat($iSubID);
2301  $sCntSub = ($iAdsCnt > 0) ? " ({$iAdsCnt})" : '';
2302 
2303  $sNameSubUp = htmlspecialchars(ucwords($aSqlResSubsStr['NameSub']));
2304  $sSCategLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/subcat/' . $aSqlResSubsStr['SEntryUri'] : "{$this->sCurrBrowsedFile}?bSubClassifiedID={$iSubID}";
2305 
2306  $sSubsHtml .= <<<EOF
2307 <div>
2308  <a class="sub_l" href="{$sSCategLink}">
2309  {$sNameSubUp}
2310  </a>
2311  {$sCntSub}
2312 </div>
2313 EOF;
2314  }
2315 
2316  $sCaption = <<<EOF
2317 <a href="{$sCategLink}">
2318  {$sCatName}
2319 </a>
2320 EOF;
2321 
2322  $sOpenColDiv = $sCloseColDiv = '';
2323  $iResidueOfDiv = $iCounter % $iCategPerColumn;
2324 
2325  if ($iResidueOfDiv == 0) {
2326  $sOpenColDiv = <<<EOF
2327 <div class="ch_ads_categories_col" style="width:{$iColumnWidth}%;">
2328 EOF;
2329  }
2330  if ($iResidueOfDiv == $iCategPerColumn - 1) {
2331  $sCloseColDiv = <<<EOF
2332 </div>
2333 EOF;
2334  }
2335 
2336  $sCategoryBlock = DesignBoxContent($sCaption, $sSubsHtml, 1);
2337 
2338  $sCategoryCover = false == strpos($aSqlResStr['Picture'],
2339  '.') ? $aSqlResStr['Picture'] : $this->_oTemplate->getIconUrl($aSqlResStr['Picture']);
2340 
2341  $aCategoryVariables = array(
2342  'category_cover_image' => $GLOBALS['oFunctions']->sysImage($sCategoryCover, '', $sCatName, '', false,
2343  48),
2344  'category_url' => $sCategLink,
2345  'category_name' => $sCatName,
2346  'sub_categories_list' => $sSubsHtml,
2347  'onclick' => '',
2348  'target' => '',
2349  'unit_id' => $iID
2350  );
2351  $sCategoryBlock = $this->_oTemplate->parseHtmlByName('category_unit.html', $aCategoryVariables);
2352 
2353  $sCategoriesHtml .= $sOpenColDiv . $sCategoryBlock . $sCloseColDiv;
2354  $iCounter++;
2355  }
2356 
2357  if ($iCounter == 0) {
2358  return MsgBox(_t('_Empty'));
2359  }
2360 
2361  $iResidueOfDivLast = $iCounter % $iCategPerColumn;
2362  if ($iCounter > 0 && $iResidueOfDivLast > 0 && $iResidueOfDivLast < $iCategPerColumn) {
2363  $sCategoriesHtml .= '</div>';
2364  }
2365 
2366  $sAddJS = <<<EOF
2367 <script type="text/javascript">
2368  function ShowHideController()
2369  {
2370  this.ShowHideToggle = function(rObject) {
2371  var sChildID = $(rObject).attr("bxchild");
2372  var sBlockState = $("#" + sChildID).css("display");
2373 
2374  if ( sBlockState == 'block' ){
2375  $("#" + sChildID).slideUp(300);
2376  $(rObject).css({ backgroundPosition : "0 -17px"});
2377  } else {
2378  $(rObject).css({ backgroundPosition : "0 0"});
2379  $("#" + sChildID).slideDown(300);
2380  }
2381  }
2382  }
2383 </script>
2384 EOF;
2385 
2386  $sCategoriesBlocks = <<<EOF
2387 <div class="ch_ads_categories_cols ch-def-bc-padding-thd">
2388  {$sAddJS}
2389  {$sCategoriesHtml}
2390  <div class="clear_both"></div>
2391 </div>
2392 EOF;
2393  $this->_oTemplate->addCss(array('ads_phone.css'));
2394 
2395  return DesignBoxContent(_t('_ch_ads_Categories'), $sCategoriesBlocks, 1);
2396  }
2397 
2403  function getAdsMainPage()
2404  {
2405  if (!$this->isAllowedBrowse()) {
2406  return $this->_oTemplate->displayAccessDenied();
2407  }
2408  ch_import('PageHome', $this->_aModule);
2409  $oAdsPageHome = new ChAdsPageHome($this);
2410 
2411  return $oAdsPageHome->getCode();
2412  }
2413 
2419  function PrintFilterForm($iClassifiedID = 0, $iSubClassifiedID = 0)
2420  {
2421  global $aPreValues;
2422 
2423  if (!$this->isAllowedSearch()) {
2424  return;
2425  }
2426 
2427  $sCategoriesC = _t('_ch_ads_Categories');
2428  $sViewAllC = _t('_View All');
2429 
2430  $iClassifiedID = (false !== ch_get('FilterCat') && (int)ch_get('FilterCat') > 0) ? (int)ch_get('FilterCat') : (int)$iClassifiedID;
2431  $iSubClassifiedID = (false !== ch_get('FilterSubCat') && (int)ch_get('FilterSubCat') > 0) ? (int)ch_get('FilterSubCat') : (int)$iSubClassifiedID;
2432  $sCountry = process_db_input(ch_get('FilterCountry'), CH_TAGS_STRIP);
2433  $sCountry = (isset($aPreValues['Country'][$sCountry]) == true) ? $sCountry : -1;
2434 
2435  $sKeywords = process_db_input(ch_get('FilterKeywords'), CH_TAGS_STRIP);
2436 
2437  $iFilterStyleHeight = 38;
2438  $sSubDspStyle = ($sCategorySub != "") ? '' : 'none';
2439 
2440  $sClassifiedsOptions = '';
2441  $vSqlRes = $this->_oDb->getAllCatsInfo();
2442  if (!$vSqlRes) {
2443  return _t('_Error Occured');
2444  }
2445 
2446  while ($aSqlResStr = $vSqlRes->fetch()) {
2447  $sClassifiedsOptions .= "<option value=\"{$aSqlResStr['ID']}\"" . (($aSqlResStr['ID'] == $iClassifiedID) ? " selected" : '') . ">{$aSqlResStr['Name']}</option>\n";
2448  }
2449 
2450  $sCountryOptions = '';
2451  $sSelCountry = $sCountry;
2452  foreach ($aPreValues['Country'] as $key => $value) {
2453  $sCountrySelected = ($sSelCountry == $key) ? 'selected="selected"' : '';
2454  $sCountryOptions .= "<option value=\"{$key}\" " . $sCountrySelected . " >" . _t($value['LKey']) . "</option>";
2455  }
2456 
2457  $sKeywordsStr = ($sKeywords != '') ? $sKeywords : '';
2458  $sCateg = '';
2459  $sSubCateg = '';
2460  if ($iClassifiedID == 0 && $iSubClassifiedID == 0) {
2461  $iFilterStyleHeight = 70;
2462 
2463  $sOnChange = ($iClassifiedID > 0) ? '' : <<<EOF
2464 onchange="AjaxyAskForSubcatsWithInfo('FilterSubCat', this.value, 'custom_values');"
2465 EOF;
2466 
2467  $sCateg = <<<EOF
2468 <br />
2469 <div class="ordered_block_select ch-def-margin-sec-top ch-def-margin-sec-right">
2470 <span>{$sCategoriesC}:</span>
2471 <div class="input_wrapper input_wrapper_select ch-def-margin-sec-left clearfix">
2472 <select class="form_input_select ch-def-font-inputs" name="FilterCat" id="FilterCat" {$sOnChange} style="width:250px;">
2473  <option value="-1">{$sViewAllC}</option>{$sClassifiedsOptions}
2474 </select>
2475 </div>
2476 </div>
2477 EOF;
2478 
2479  $sSubCateg = <<<EOF
2480 <div class="ordered_block_select ch-def-margin-sec-top ch-def-margin-sec-right">
2481 <div class="input_wrapper input_wrapper_select clearfix">
2482 <select class="form_input_select ch-def-font-inputs" name="FilterSubCat" id="FilterSubCat" style="display:{$sSubDspStyle};"></select>
2483 </div>
2484 </div>
2485 <input id="unit" type="text" value="" size="3" maxlength="8" style="display:none;" />
2486 <br />
2487 EOF;
2488  }
2489 
2490  if ($iClassifiedID > 0) {
2491  $sCateg .= '<input type="hidden" name="FilterCat" value="' . $iClassifiedID . '" />';
2492  $sSubCateg = '';
2493  }
2494  if ($iSubClassifiedID > 0) {
2495  $sCateg .= '<input type="hidden" name="FilterSubCat" value="' . $iSubClassifiedID . '" />';
2496  $sSubCateg = '';
2497  }
2498 
2499  $aVariables = array(
2500  'sCurrBrowsedFile' => $this->sCurrBrowsedFile,
2501  'sCountryOptions' => $sCountryOptions,
2502  'sCateg' => $sCateg,
2503  'sSubCateg' => $sSubCateg,
2504  'sKeywordsStr' => ch_html_attribute($sKeywordsStr),
2505  );
2506  $sContent = $this->_oTemplate->parseHtmlByTemplateName('filter_form', $aVariables);
2507 
2508  return $this->_oTemplate->parseHtmlByName('designbox_top_controls.html', array('top_controls' => $sContent));
2509  }
2510 
2516  function getManageClassifiedsForm($iCategoryID = 0, $bOnlyForm = false)
2517  {
2518  $sAction = 'add_main_category';
2519 
2520  $sTitle = $sDescription = '';
2521  $sCustomName1 = $sCustomName2 = $sUnit = $sUnit2 = $sPicture = '';
2522 
2523  if ($iCategoryID) {
2524  $aCatInfos = $this->_oDb->getCatInfo($iCategoryID);
2525  $sTitle = $aCatInfos[0]['Name'];
2526  $sDescription = $aCatInfos[0]['Description'];
2527  $sCustomName1 = $aCatInfos[0]['CustomFieldName1'];
2528  $sCustomName2 = $aCatInfos[0]['CustomFieldName2'];
2529  $sUnit = $aCatInfos[0]['Unit1'];
2530  $sUnit2 = $aCatInfos[0]['Unit2'];
2531  $sPicture = $aCatInfos[0]['Picture'];
2532  }
2533 
2534  //adding form
2535  $aForm = array(
2536  'form_attrs' => array(
2537  'name' => 'create_main_cats_form',
2538  'action' => $this->sCurrBrowsedFile,
2539  'method' => 'post',
2540  ),
2541  'params' => array(
2542  'db' => array(
2543  'table' => $this->_oConfig->sSQLCatTable,
2544  'key' => 'ID',
2545  'submit_name' => 'add_button',
2546  ),
2547  ),
2548  'inputs' => array(
2549  'action' => array(
2550  'type' => 'hidden',
2551  'name' => 'action',
2552  'value' => $sAction,
2553  ),
2554  'Name' => array(
2555  'type' => 'text',
2556  'name' => 'Name',
2557  'caption' => _t('_Title'),
2558  'required' => true,
2559  'value' => $sTitle,
2560  'checker' => array(
2561  'func' => 'length',
2562  'params' => array(3, 64),
2563  'error' => _t('_ch_ads_title_error_desc', 64),
2564  ),
2565  'db' => array(
2566  'pass' => 'Xss',
2567  ),
2568  ),
2569  'Description' => array(
2570  'type' => 'text',
2571  'name' => 'Description',
2572  'caption' => _t('_Description'),
2573  'required' => true,
2574  'value' => $sDescription,
2575  'checker' => array(
2576  'func' => 'length',
2577  'params' => array(3, 128),
2578  'error' => _t('_ch_ads_description_error_desc', 128),
2579  ),
2580  'db' => array(
2581  'pass' => 'Xss',
2582  ),
2583  ),
2584  'CustomFieldName1' => array(
2585  'type' => 'text',
2586  'name' => 'CustomFieldName1',
2587  'caption' => _t('_ch_ads_customFieldName1'),
2588  'required' => false,
2589  'value' => $sCustomName1,
2590  'db' => array(
2591  'pass' => 'Xss',
2592  ),
2593  ),
2594  'Unit1' => array(
2595  'type' => 'text',
2596  'name' => 'Unit1',
2597  'caption' => _t('_ch_ads_Unit') . ' 1',
2598  'required' => false,
2599  'value' => $sUnit,
2600  'db' => array(
2601  'pass' => 'Xss',
2602  ),
2603  ),
2604  'CustomFieldName2' => array(
2605  'type' => 'text',
2606  'name' => 'CustomFieldName2',
2607  'caption' => _t('_ch_ads_customFieldName2'),
2608  'required' => false,
2609  'value' => $sCustomName2,
2610  'db' => array(
2611  'pass' => 'Xss',
2612  ),
2613  ),
2614  'Unit2' => array(
2615  'type' => 'text',
2616  'name' => 'Unit2',
2617  'caption' => _t('_ch_ads_Unit') . ' 2',
2618  'required' => false,
2619  'value' => $sUnit2,
2620  'db' => array(
2621  'pass' => 'Xss',
2622  ),
2623  ),
2624  'Picture' => array(
2625  'type' => 'text',
2626  'name' => 'Picture',
2627  'caption' => _t('_Picture'),
2628  'info' => _t('_In') . ' \modules\cheetah\ads\templates\base\images\icons\'',
2629  'value' => $sPicture,
2630  'db' => array(
2631  'pass' => 'Xss',
2632  ),
2633  ),
2634  'add_button' => array(
2635  'type' => 'submit',
2636  'name' => 'add_button',
2637  'value' => ($iCategoryID) ? _t('_Edit') : _t('_ch_ads_add_main_category'),
2638  ),
2639  ),
2640  );
2641 
2642  if ($iCategoryID) {
2643  $aForm['inputs']['hidden_postid'] = array(
2644  'type' => 'hidden',
2645  'name' => 'id',
2646  'value' => $iCategoryID,
2647  );
2648  }
2649 
2650  $sCode = '';
2651  $oForm = new ChTemplFormView($aForm);
2652  $oForm->initChecker();
2653  if ($oForm->isSubmittedAndValid()) {
2654  $aValsAdd = array();
2655  if ($iCategoryID == 0) {
2656  $sCategUri = uriGenerate(ch_get('Name'), $this->_oConfig->sSQLCatTable, 'CEntryUri');
2657  $aValsAdd['CEntryUri'] = $sCategUri;
2658  }
2659 
2660  $iLastId = -1;
2661  if ($iCategoryID > 0) {
2662  $oForm->update($iCategoryID, $aValsAdd);
2663  $iLastId = $iCategoryID;
2664  } else {
2665  $iLastId = $oForm->insert($aValsAdd);
2666  }
2667 
2668  if ($iLastId > 0) {
2669  $sCode = MsgBox(_t('_ch_ads_Main_category_successfully_added'), 3);
2670  } else {
2671  $sCode = MsgBox(_t('_ch_ads_Main_category_failed_add'), 3);
2672  }
2673  }
2674 
2675  if ($bOnlyForm) {
2676  return $sCode . $oForm->getCode();
2677  }
2678 
2679  $sActions = array(
2680  'add_subcat' => array(
2681  'href' => 'javascript: void(0);',
2682  'title' => _t('_ch_ads_add_subcategory'),
2683  'onclick' => 'loadHtmlInPopup(\'ads_add_sub_category\', \'modules/cheetah/ads/post_mod_ads.php?action=add_sub_category\');',
2684  'active' => 0
2685  ),
2686  'manager' => array(
2687  'href' => 'javascript: void(0);',
2688  'title' => _t('_ch_ads_category_manager'),
2689  'onclick' => 'loadHtmlInPopup(\'ads_category_manager\', \'modules/cheetah/ads/post_mod_ads.php?action=category_manager\');',
2690  'active' => 0
2691  )
2692  );
2693 
2694  return DesignBoxAdmin(_t('_ch_ads_Manage_categories_form'), $sCode . $oForm->getCode(), $sActions, '', 11);
2695  }
2696 
2697  function getAddSubcatForm($iSubCategoryID = 0, $bOnlyForm = false)
2698  { //admin side only
2699  $sAction = 'add_sub_category';
2700  $sSubmitC = !empty($iSubCategoryID) ? _t('_Edit') : _t('_ch_ads_add_subcategory');
2701 
2702  $aParentCategories = array();
2703  $vParentValues = $this->_oDb->getAllCatsInfo();
2704  while ($aCategInfo = $vParentValues->fetch()) {
2705  $iID = $aCategInfo['ID'];
2706  $sName = $aCategInfo['Name'];
2707  $aParentCategories[$iID] = $sName;
2708  }
2709 
2710  $sTitle = $sDescription = '';
2711  $iParentID = 0;
2712  if ($iSubCategoryID) {
2713  $aSubcatInfos = $this->_oDb->getSubcatInfo($iSubCategoryID);
2714  $sTitle = $aSubcatInfos[0]['NameSub'];
2715  $sDescription = $aSubcatInfos[0]['Description'];
2716  $iParentID = (int)$aSubcatInfos[0]['IDClassified'];
2717  }
2718 
2719  //adding form
2720  $aForm = array(
2721  'form_attrs' => array(
2722  'name' => 'create_sub_cats_form',
2723  'action' => 'javascript: void(0)',
2724  'method' => 'post',
2725  ),
2726  'params' => array(
2727  'db' => array(
2728  'table' => $this->_oConfig->sSQLSubcatTable,
2729  'key' => 'ID',
2730  'submit_name' => 'add_button',
2731  ),
2732  ),
2733  'inputs' => array(
2734  'action' => array(
2735  'type' => 'hidden',
2736  'name' => 'action',
2737  'value' => $sAction,
2738  ),
2739  'IDClassified' => array(
2740  'type' => 'select',
2741  'name' => 'IDClassified',
2742  'caption' => _t('_ch_ads_parent_category'),
2743  'values' => $aParentCategories,
2744  'value' => $iParentID,
2745  'db' => array(
2746  'pass' => 'Int',
2747  ),
2748  ),
2749  'NameSub' => array(
2750  'type' => 'text',
2751  'name' => 'NameSub',
2752  'caption' => _t('_Title'),
2753  'required' => true,
2754  'value' => $sTitle,
2755  'checker' => array(
2756  'func' => 'length',
2757  'params' => array(3, 128),
2758  'error' => _t('_ch_ads_title_error_desc', 128),
2759  ),
2760  'db' => array(
2761  'pass' => 'Xss',
2762  ),
2763  ),
2764  'Description' => array(
2765  'type' => 'text',
2766  'name' => 'Description',
2767  'caption' => _t('_Description'),
2768  'value' => $sDescription,
2769  'db' => array(
2770  'pass' => 'Xss',
2771  ),
2772  ),
2773  'add_button' => array(
2774  'type' => 'submit',
2775  'name' => 'add_button',
2776  'value' => $sSubmitC,
2777  'attrs' => array(
2778  'onClick' => "AdmCreateSubcategory(this, '{$this->sHomeUrl}{$this->sCurrBrowsedFile}'); return false;"
2779  )
2780  ),
2781  ),
2782  );
2783 
2784  if ($iSubCategoryID) {
2785  $aForm['inputs']['hidden_postid'] = array(
2786  'type' => 'hidden',
2787  'name' => 'id',
2788  'value' => $iSubCategoryID,
2789  );
2790  }
2791 
2792  $sCode = '';
2793 
2794  $sJS = $this->_oTemplate->addJs('main.js', true);
2795 
2796  $oForm = new ChTemplFormView($aForm);
2797  $oForm->initChecker();
2798  if ($oForm->isSubmittedAndValid()) {
2799  $aValsAdd = array();
2800  if ($iSubCategoryID == 0) {
2801  $sCategUri = uriGenerate(ch_get('NameSub'), $this->_oConfig->sSQLSubcatTable, 'SEntryUri');
2802  $aValsAdd['SEntryUri'] = $sCategUri;
2803  }
2804 
2805  $iLastId = -1;
2806  $sMessage = '';
2807  if ($iSubCategoryID > 0) {
2808  $oForm->update($iSubCategoryID, $aValsAdd);
2809 
2810  $iLastId = $iSubCategoryID;
2811  $sMessage = '_ch_ads_Sub_category_successfully_updated';
2812  } else {
2813  $iLastId = $oForm->insert($aValsAdd);
2814  $sMessage = '_ch_ads_Sub_category_successfully_added';
2815  }
2816 
2817  $sCode = MsgBox(_t($iLastId > 0 ? $sMessage : '_ch_ads_Sub_category_failed_add'), 3);
2818  }
2819 
2820  if ($bOnlyForm) {
2821  return $sCode . $oForm->getCode();
2822  }
2823 
2824  $sResult = $sJS . $sCode . $oForm->getCode();
2825 
2826  if (ch_get('mode') == 'json') {
2827  return json_encode($sResult);
2828  }
2829 
2830  $sResult = $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sResult));
2831 
2832  return $GLOBALS['oFunctions']->popupBox('ads_add_sub_category', _t('_ch_ads_add_subcategory'), $sResult);
2833  }
2834 
2836  {
2837  $sCatID = (int)ch_get('id');
2838  if ($sCatID && false !== ch_get('sa')) {
2839  switch (ch_get('sa')) {
2840  case 'editcat':
2841  $sResult = $this->getManageClassifiedsForm($sCatID, true);
2842  $sResult = '<div class="ch-def-margin-sec-bottom">' . $sResult . '</div>';
2843  break;
2844  case 'editscat':
2845  $sResult = $this->getAddSubcatForm($sCatID, true);
2846  $sResult = '<div class="ch-def-margin-sec-bottom">' . $sResult . '</div>';
2847  break;
2848  case 'delcat':
2849  $sResult = MsgBox(_t('_ch_ads_Main_category_failed_delete'), 1);
2850  if ($this->_oDb->deleteCat($sCatID)) {
2851  $sResult = MsgBox(_t('_ch_ads_Main_category_successfully_deleted'), 1);
2852  }
2853 
2854  $vSubCats = $this->_oDb->getAllSubCatsInfo($sCategory);
2855  while ($aSubCat = $vSubCats->fetch()) {
2856  $iSubcat = (int)$aSubCat['ID'];
2857  $this->_oDb->deleteSubCat($iSubcat);
2858  }
2859 
2860  break;
2861  case 'delscat':
2862  $sResult = MsgBox(_t('_ch_ads_Sub_category_failed_deleted'), 1);
2863  if ($this->_oDb->deleteSubCat($sCatID)) {
2864  $sResult = MsgBox(_t('_ch_ads_Sub_category_successfully_delete'), 1);
2865  }
2866  break;
2867  }
2868  }
2869 
2870  $sJS = $this->_oTemplate->addJs('main.js', true);
2871  $sRootCaptionC = _t('_ch_ads_root');
2872  $sViewC = _t('_View');
2873  $sEditC = _t('_Edit');
2874  $sDeleteC = _t('_Delete');
2875 
2876  $sFolder2Icon = $this->_oTemplate->getImageUrl('folder_s.gif');
2877  $vSqlRes = $this->_oDb->getAllCatsInfo();
2878  if (!$vSqlRes) {
2879  return _t('_Error Occured');
2880  }
2881  $sTreeRows = '';
2882  while ($aSqlResCls = $vSqlRes->fetch()) {
2883  $iID = (int)$aSqlResCls['ID'];
2884  $sName = $aSqlResCls['Name'];
2885  $sCUri = $aSqlResCls['CEntryUri'];
2886  $sCategLink = $this->genUrl($iID, $sCUri, 'cat');
2887  $sCategDelLink = $this->sCurrBrowsedFile . '?action=category_manager&sa=delcat&id=' . $iID;
2888  $sCategEditLink = $this->sCurrBrowsedFile . '?action=category_manager&sa=editcat&id=' . $iID;
2889 
2890  $vSubs = $this->_oDb->getSubsNameIDCountAdsByAdID($iID);
2891  $sSubsRows = '';
2892  while ($aSub = $vSubs->fetch()) {
2893  $iSubID = (int)$aSub['ID'];
2894  $iSubName = $aSub['Name'];
2895  $sSUri = $aSub['SEntryUri'];
2896  $sSubCategLink = $this->genUrl($iSubID, $sSUri, 'subcat');
2897  $sSubCategDelLink = $this->sCurrBrowsedFile . '?action=category_manager&sa=delscat&id=' . $iSubID;
2898  $sSubCategEditLink = $this->sCurrBrowsedFile . '?action=category_manager&sa=editscat&id=' . $iSubID;
2899 
2900  $sSubsRows .= <<<EOF
2901 <li id='{$iSubID}'><span>{$iSubName} </span><a href="{$sSubCategLink}">({$sViewC})</a><a href="javascript: void(0)" onclick="AdmAction2Category('{$this->sCurrBrowsedFile}?action=category_manager', 'editscat', {$iSubID}); return false;">({$sEditC})</a><a href="javascript: void(0)" onclick="AdmAction2Category('{$this->sCurrBrowsedFile}?action=category_manager', 'delscat', {$iSubID}); return false;">({$sDeleteC})</a></li>
2902 EOF;
2903  }
2904 
2905  $sTreeRows .= <<<EOF
2906 <li id='{$iID}'><span>{$sName}</span><a href="{$sCategLink}">({$sViewC})</a><a href="javascript: void(0)" onclick="AdmAction2Category('{$this->sCurrBrowsedFile}?action=category_manager', 'editcat', {$iID}); return false;">({$sEditC})</a><a href="javascript: void(0)" onclick="AdmAction2Category('{$this->sCurrBrowsedFile}?action=category_manager', 'delcat', {$iID}); return false;">({$sDeleteC})</a>
2907  <ul>
2908  {$sSubsRows}
2909  </ul>
2910 </li>
2911 EOF;
2912  }
2913 
2914  $sResult .= <<<EOF
2915 <script type="text/javascript">
2916 var simpleTreeCollection;
2917 $(document).ready(function(){
2918  simpleTreeCollection = $('.simpleTree').simpleTree({
2919  autoclose: true,
2920  afterClick:function(node){
2921  //alert("text-"+$('span:first',node).text());
2922  },
2923  afterDblClick:function(node){
2924  //alert("text-"+$('span:first',node).text());
2925  },
2926  afterMove:function(destination, source, pos){
2927  //alert("destination-"+destination.attr('id')+" source-"+source.attr('id')+" pos-"+pos);
2928  },
2929  afterAjax:function() {
2930  //alert('Loaded');
2931  },
2932  animate:true,
2933  drag:false
2934  //,docToFolderConvert:true
2935  });
2936 });
2937 </script>
2938 
2939 <ul class="simpleTree">
2940  <li class="root" id='1'><span>{$sRootCaptionC}</span>
2941  <ul>
2942  {$sTreeRows}
2943  </ul>
2944  </li>
2945 </ul>
2946 <div class="clear_both"></div>
2947 <!-- <div id="cat_manage_div"></div>
2948 <div class="clear_both"></div> -->
2949 EOF;
2950 
2951  if (ch_get('mode') == 'json') {
2952  return json_encode($sResult);
2953  }
2954 
2955  $sResult = $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sJS . $sResult));
2956 
2957  return $GLOBALS['oFunctions']->popupBox('ads_category_manager', _t('_ch_ads_category_manager'), $sResult);
2958  }
2959 
2960  function GenAdsAdminIndex()
2961  {
2962  if ($this->bAdminMode) {
2963  //actions
2964  if (ch_get('action_approve') && is_array(ch_get('ads'))) {
2965  foreach (ch_get('ads') as $iAdID) {
2966  if ($this->_oDb->setPostStatus((int)$iAdID, 'active')) {
2967  }
2968  }
2969  } elseif (ch_get('action_disapprove') && is_array(ch_get('ads'))) {
2970  foreach (ch_get('ads') as $iAdID) {
2971  $this->_oDb->setPostStatus((int)$iAdID);
2972  }
2973  } elseif (ch_get('action_delete') && is_array(ch_get('ads'))) {
2974  foreach (ch_get('ads') as $iAdID) {
2975  $this->ActionDeleteAdvertisement((int)$iAdID);
2976  }
2977  }
2978 
2979  $sCap2C = _t('_ch_ads_Moderating');
2980  $sAct = _t("_ch_ads_Activate");
2981  $sWholesaleC = _t("_ch_ads_wholesale");
2982 
2983  $sActivateAdvWholesale = <<<EOF
2984 <h2>{$sCap2C} ( <a href=\"{$this->sCurrBrowsedFile}?ActivateAdvWholesale=1\">{$sAct} {$sWholesaleC}</a> )</h2>
2985 EOF;
2986 
2987  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
2988  $oTmpAdsSearch = new ChAdsSearchUnit();
2989  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
2990  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
2991  $oTmpAdsSearch->aCurrent['restriction']['activeStatus']['value'] = 'new';
2992  $oTmpAdsSearch->bShowCheckboxes = true;
2993  $sAdminSideAds = $oTmpAdsSearch->displayResultBlock();
2994  $sAdminSideAds = ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) ? MsgBox(_t('_Empty')) : $sAdminSideAds;
2995 
2996  $sAdmPanel = $oTmpAdsSearch->showAdminActionsPanel('ads_box', array(
2997  'action_approve' => '_Approve',
2998  'action_disapprove' => '_Disapprove',
2999  'action_delete' => '_Delete'
3000  ), 'ads');
3001 
3002  // Prepare link to pagination
3003  $sRequest = $this->sCurrBrowsedFile . '?page={page}&per_page={per_page}';
3004  // End of prepare link to pagination
3005  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
3006  $sPostPagination = $oTmpAdsSearch->showPagination();
3007 
3008  $sPostsBox = $sAdminSideAds . '<div class="clear_both"></div>' . $sPostPagination;
3009 
3010  return <<<EOF
3011 <form action="{$this->sCurrBrowsedFile}" method="post" name="ads_moderation">
3012  <div id="ads_box">
3013  {$sPostsBox}
3014  </div>
3015  {$sAdmPanel}
3016 </form>
3017 EOF;
3018  }
3019  }
3020 
3021  function GenReportSubmitForm($iCommentID)
3022  {
3023  if ($iCommentID) {
3024  $iClsID = (int)ch_get('clsID');
3025  $sMessageC = _t("_Message text");
3026 
3027  $sCurrBrowsedFile = $this->sHomeUrl . 'classifieds.php';
3028 
3029  return <<<EOF
3030 <div class="mediaInfo">
3031  <form name="submitAction" method="post" action="{$sCurrBrowsedFile}">
3032  <input type="hidden" name="commentID" value="{$iCommentID}" />
3033  <input type="hidden" name="clsID" value="{$iClsID}" />
3034  <input type="hidden" name="action" value="post_report" />
3035  <div>{$sMessageC}</div>
3036  <div><textarea cols="30" rows="10" name="messageText"></textarea></div>
3037  <div>
3038  <input type="submit" size="15" name="send" value="Send" />
3039  <input type="reset" size="15" name="send" value="Reset" />
3040  </div>
3041  </form>
3042 </div>
3043 EOF;
3044  }
3045  }
3046 
3047  function ActionReportSubmit()
3048  {
3049  global $site;
3050 
3051  $iClsID = (int)ch_get('clsID');
3052  $iCommID = (int)ch_get('commentID');
3053  $aUser = getProfileInfo($this->_iVisitorID);
3054 
3055  $sMailHeader = "From: {$site['title']} <{$site['email_notify']}>";
3056  $sMailParameters = "-f{$site['email_notify']}";
3057 
3058  $sMessage = process_db_input(ch_get('messageText'), CH_TAGS_VALIDATE);
3059 
3060  $sMailHeader = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $sMailHeader;
3061  $sMailSubject = $aUser['NickName'] . ' bad comment report';
3062 
3063  $sGenUrl = $this->genUrl($iClsID, '', 'entry', true);
3064 
3065  $sMailBody = "Hello,\n
3066  {$aUser['NickName']} bad classified comment (comm num {$iCommID}): <a href=\"{$sGenUrl}\">See it</a>\n
3067  {$sMessage}\n
3068  Regards";
3069 
3070  $sMail = $site['email_notify'];
3071 
3072  if (sendMail($sMail, sMailSubject, nl2br($sMailBody), '', '', 'html')) {
3073  $sCode = '<div class="mediaInfo">' . _t("_File info was sent") . '</div>';
3074 
3075  return MsgBox($sCode);
3076  }
3077  }
3078 
3086  {
3087  $sSiteUrl = CH_WSB_URL_ROOT;
3088 
3089  $sSafeTag = addslashes(trim(strtolower($sTag)));
3090  $sTagResultC = _t('_ch_ads_search_results_by_tag');
3091  $sBrowseAllAds = _t('_ch_ads_Browse_All_Ads');
3092 
3093  $sHomeLink = ($this->bUseFriendlyLinks) ? CH_WSB_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
3094 
3095  $sBreadCrumbs = <<<EOF
3096 <a href="{$sHomeLink}">{$sBrowseAllAds}</a> / {$sTagResultC} - {$sSafeTag}
3097 EOF;
3098 
3099  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
3100  $oTmpAdsSearch = new ChAdsSearchUnit();
3101  if ($iRandLim > 0) {
3102  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = (int)$iRandLim;
3103  } else {
3104  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
3105  }
3106  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
3107  $oTmpAdsSearch->aCurrent['restriction']['tag']['value'] = $sSafeTag;
3108 
3109  $sAdsByTags = $oTmpAdsSearch->displayResultBlock();
3110  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
3111  $sAdsByTags = MsgBox(_t('_Empty'));
3112  } else {
3113  // Prepare link to pagination
3114  $sSafeTagS = title2uri($sSafeTag);
3115  if ($this->bUseFriendlyLinks == false) {
3116  $sRequest = $this->sHomeUrl . "classifieds_tags.php?tag={$sSafeTagS}&page={page}&per_page={per_page}";
3117  } else {
3118  $sRequest = CH_WSB_URL_ROOT . "ads/tag/{$sSafeTagS}/{per_page}/{page}";
3119  }
3120  // End of prepare link to pagination
3121  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
3122  $sAdsByTags .= $oTmpAdsSearch->showPagination();
3123  }
3124 
3125  return DesignBoxContent($sBreadCrumbs, $sAdsByTags, 1);
3126  }
3127 
3128  function GenAdsCalendar()
3129  {
3130  $aDateParams = array();
3131  $sDate = ch_get('date');
3132  if ($sDate) {
3133  $aDateParams = explode('/', $sDate);
3134  }
3135 
3136  require_once($this->_oConfig->getClassPath() . 'ChAdsCalendar.php');
3137  $oCalendar = new ChAdsCalendar((int)$aDateParams[0], (int)$aDateParams[1], $this);
3138  $sAdsCalendar = $oCalendar->display();
3139 
3140  return DesignBoxContent(_t('_ch_ads_Calendar'), $sAdsCalendar, 1);
3141  }
3142 
3143  function GenAdsByDate()
3144  {
3145  $sCode = MsgBox(_t('_Empty'));
3146 
3147  $sDate = ch_get('date');
3148  $aDate = explode('/', $sDate);
3149 
3150  $iValue1 = (int)$aDate[0];
3151  $iValue2 = (int)$aDate[1];
3152  $iValue3 = (int)$aDate[2];
3153 
3154  if ($iValue1 > 0 && $iValue2 > 0 && $iValue3 > 0) {
3155 
3156  $sCaption = _t('_ch_ads_caption_browse_by_day')
3157  . getLocaleDate(strtotime("{$iValue1}-{$iValue2}-{$iValue3}"), CH_WSB_LOCALE_DATE_SHORT);
3158 
3159  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
3160  $oTmpAdsSearch = new ChAdsSearchUnit();
3161  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
3162  $oTmpAdsSearch->aCurrent['restriction']['calendar-min'] = array(
3163  'value' => "UNIX_TIMESTAMP('{$iValue1}-{$iValue2}-{$iValue3} 00:00:00')",
3164  'field' => 'DateTime',
3165  'operator' => '>=',
3166  'no_quote_value' => true
3167  );
3168  $oTmpAdsSearch->aCurrent['restriction']['calendar-max'] = array(
3169  'value' => "UNIX_TIMESTAMP('{$iValue1}-{$iValue2}-{$iValue3} 23:59:59')",
3170  'field' => 'DateTime',
3171  'operator' => '<=',
3172  'no_quote_value' => true
3173  );
3174  $sLastAds = $oTmpAdsSearch->displayResultBlock();
3175  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
3176  $sLastAds = MsgBox(_t('_Empty'));
3177  } else {
3178  $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
3179  $sLastAds .= $oTmpAdsSearch->showPagination();
3180  }
3181 
3182  $sRetHtmlVal = <<<EOF
3183 <div class="dbContent">
3184  {$sLastAds}
3185 </div>
3186 EOF;
3187 
3188  return DesignBoxContent($sCaption, $sRetHtmlVal, 1);
3189  }
3190  }
3191 
3193  {
3194  $iMediaID = (int)ch_get('dimg');
3195  if (!$iMediaID) {
3196  return '';
3197  }
3198 
3199  if (!($iEditAdvertisementID = (int)ch_get('EditPostID'))) {
3200  return '';
3201  }
3202 
3203  if (!($iAdvOwner = $this->_oDb->getOwnerOfAd($iEditAdvertisementID))) {
3204  return '';
3205  }
3206 
3207  if (!$this->isAllowedEdit($iAdvOwner)) {
3208  return MsgBox(_t('_Access denied'));
3209  }
3210 
3211  //1. get media array
3212  $aAdvData = $this->_oDb->getAdInfo($iEditAdvertisementID);
3213  $sMediaIDs = $aAdvData['Media'];
3214 
3215  if (!$sMediaIDs) {
3216  return;
3217  }
3218 
3219  $aChunks = explode(',', $sMediaIDs);
3220 
3221  //2. don`t get deleted element
3222  $aNewMediaIDs = array();
3223  foreach ($aChunks as $iMedId) {
3224  if ($iMedId != $iMediaID) {
3225  $aNewMediaIDs[] = $iMedId;
3226  }
3227  }
3228 
3229  //3. collect new array of media
3230  $sNewMedia = implode(",", $aNewMediaIDs);
3231 
3232  //4. update field Media in classifieds with new array of media
3233  if ($this->_oDb->updatePostMedia($iEditAdvertisementID, $sNewMedia)) {
3234  //5. physycally delete file
3235  $sMediaFileName = $this->_oDb->getMediaFile($iMediaID);
3236  if ($sMediaFileName != '') {
3237  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'img_' . $sMediaFileName);
3238  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'thumb_' . $sMediaFileName);
3239  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'big_thumb_' . $sMediaFileName);
3240  @unlink(CH_DIRECTORY_PATH_ROOT . $this->sUploadDir . 'icon_' . $sMediaFileName);
3241  }
3242  //6. delete record from table with media of Classifieds about deleted object
3243  if ($this->_oDb->deleteMedia($iMediaID)) {
3244  return MsgBox(_t('_ch_ads_img_succ_deleted'));
3245  }
3246 
3247  } else {
3248  return MsgBox(_t('_Error Occured'));
3249  }
3250 
3251  return '';
3252  }
3253 
3254  function _blockPhoto(&$aReadyMedia, $iAuthorId, $sPrefix = false)
3255  {
3256  if (!$aReadyMedia) {
3257  return '';
3258  }
3259 
3260  $aImages = array();
3261 
3262  foreach ($aReadyMedia as $sMedId) {
3263  $iMedId = (int)$sMedId;
3264  if (!is_numeric($iMedId) || !$iMedId) {
3265  continue;
3266  }
3267 
3268  $aSqlRes = $this->_oDb->getMediaInfo($iMedId);
3269  if (!$aSqlRes) {
3270  continue;
3271  }
3272 
3273  $aImages[] = array(
3274  'icon_url' => CH_WSB_URL_ROOT . $this->sUploadDir . 'icon_' . $aSqlRes['MediaFile'],
3275  'image_url' => CH_WSB_URL_ROOT . $this->sUploadDir . 'img_' . $aSqlRes['MediaFile'],
3276  'title' => '',
3277  );
3278  }
3279 
3280  if (!$aImages) {
3281  return '';
3282  }
3283 
3284  return $GLOBALS['oFunctions']->genGalleryImages($aImages);
3285  }
3286 
3292  function GenTagsPage()
3293  {
3294  ch_import('ChTemplTagsModule');
3295  $aParam = array(
3296  'type' => 'ad',
3297  'orderby' => 'popular'
3298  );
3299  $oTags = new ChTemplTagsModule($aParam, _t('_all'), CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
3300 
3301  return $oTags->getCode();
3302  }
3303 
3304  function genUrl($iEntryId, $sEntryUri, $sType = 'entry', $bForce = false)
3305  {
3306  if ($bForce) {
3307  $sEntryUri = $this->_oDb->getAdUriByID($iEntryId);
3308  }
3309 
3310  if ($this->bUseFriendlyLinks) {
3311  $sUrl = CH_WSB_URL_ROOT . "ads/{$sType}/{$sEntryUri}";
3312  } else {
3313  $sUrl = '';
3314  switch ($sType) {
3315  case 'entry':
3316  $sUrl = "{$this->sCurrBrowsedFile}?ShowAdvertisementID={$iEntryId}";
3317  break;
3318  }
3319  }
3320 
3321  return $sUrl;
3322  }
3323 
3330  {
3331  require_once($this->_oConfig->getClassPath() . 'ChAdsSearchUnit.php');
3332  $oTmpAdsSearch = new ChAdsSearchUnit();
3333  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 4;
3334  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
3335 
3336  //privacy changes
3337  $oTmpAdsSearch->aCurrent['restriction']['allow_view']['value'] = $this->_iVisitorID ? array(
3338  CH_WSB_PG_ALL,
3340  ) : array(CH_WSB_PG_ALL);
3341 
3342  $sPostPagination = '';
3343  $sAllAds = $oTmpAdsSearch->displayResultBlock();
3344  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] > 0) {
3345  $sPostPagination = $oTmpAdsSearch->showPagination2();
3346 
3347  $aMenu = $oTmpAdsSearch->displayMenu();
3348 
3349  return array($sAllAds, $aMenu[0], $sPostPagination);
3350  }
3351  }
3352 
3360  function serviceAdsProfilePage($_iProfileID)
3361  {
3362  $GLOBALS['oTopMenu']->setCurrentProfileID($_iProfileID);
3363 
3364  ch_import('SearchUnit', $this->_aModule);
3365  $oTmpAdsSearch = new ChAdsSearchUnit();
3366  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
3367  $oTmpAdsSearch->aCurrent['sorting'] = 'last';
3368  $oTmpAdsSearch->aCurrent['restriction']['owner']['value'] = $_iProfileID;
3369  $sMemberAds = $oTmpAdsSearch->displayResultBlock();
3370 
3371  if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] > 0) {
3372  $sClr = '<div class="clear_both"></div>';
3373  if ($oTmpAdsSearch->aCurrent['paginate']['perPage'] < $oTmpAdsSearch->aCurrent['paginate']['totalNum']) {
3374  $sAjLink = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'get_list/';
3375  ch_import('ChWsbPaginate');
3376  $sBoxId = 'ads_' . $_iProfileID . '_view';
3377  $oPgn = new ChWsbPaginate(array(
3378  'page_url' => 'javascript:void();',
3379  'count' => $oTmpAdsSearch->aCurrent['paginate']['totalNum'],
3380  'per_page' => $oTmpAdsSearch->aCurrent['paginate']['perPage'],
3381  'page' => $oTmpAdsSearch->aCurrent['paginate']['page'],
3382  'on_change_page' => "getHtmlData('$sBoxId', '{$sAjLink}view/{$_iProfileID}&page={page}&per_page={per_page}');",
3383  'on_change_per_page' => "getHtmlData('$sBoxId', '{$sAjLink}view/{$_iProfileID}&page=1&per_page=' + this.value);"
3384  ));
3385  $sMemberAds = '<div id="' . $sBoxId . '">' . $sMemberAds . $sClr . $oPgn->getPaginate() . '</div>';
3386  }
3387 
3388  return <<<EOF
3389 <div class="clear_both"></div>
3390 <div class="dbContent">
3391  {$sMemberAds}
3392  {$sClr}
3393 </div>
3394 EOF;
3395  }
3396  }
3397 
3405  function serviceAdsRss()
3406  {
3407  $iPID = (int)ch_get('pid');
3408  $aRssUnits = $this->_oDb->getMemberAdsRSS($iPID);
3409  if (is_array($aRssUnits) && count($aRssUnits) > 0) {
3410 
3411  foreach ($aRssUnits as $iUnitID => $aUnitInfo) {
3412  $iPostID = (int)$aUnitInfo['UnitID'];
3413  $sPostLink = $this->genUrl($iPostID, $aUnitInfo['UnitUri']);
3414 
3415  $aRssUnits[$iUnitID]['UnitLink'] = $sPostLink;
3416  $aRssUnits[$iUnitID]['UnitIcon'] = $this->getAdCover($aUnitInfo['UnitIcon'], 'big_thumb');
3417  }
3418 
3419  $sUnitTitleC = _t('_ch_ads_Ads');
3420  $sMainLink = 'modules/cheetah/ads/classifieds.php';
3421 
3422  ch_import('ChWsbRssFactory');
3423  $oRssFactory = new ChWsbRssFactory();
3424  $oRssFactory->SetRssHeader();
3425 
3426  echo $oRssFactory->GenRssByData($aRssUnits, $sUnitTitleC, $sMainLink);
3427  }
3428  }
3429 
3435  function serviceGetCommonCss($bText = false)
3436  {
3437  return $this->_oTemplate->addCss(array('ads.css', 'twig.css'), $bText);
3438  }
3439 
3440  /*
3441  * Service - response profile delete
3442  */
3444  {
3445  if (!($iProfileId = (int)$oAlert->iObject)) {
3446  return false;
3447  }
3448  $this->bAdminMode = true;
3450 
3451  return true;
3452  }
3453 
3460  {
3461  return array(
3462  'handlers' => array(
3463  array(
3464  'alert_unit' => 'ads',
3465  'alert_action' => 'create',
3466  'module_uri' => 'ads',
3467  'module_class' => 'Module',
3468  'module_method' => 'get_spy_post'
3469  ),
3470  array(
3471  'alert_unit' => 'ads',
3472  'alert_action' => 'rate',
3473  'module_uri' => 'ads',
3474  'module_class' => 'Module',
3475  'module_method' => 'get_spy_post'
3476  ),
3477  array(
3478  'alert_unit' => 'ads',
3479  'alert_action' => 'commentPost',
3480  'module_uri' => 'ads',
3481  'module_class' => 'Module',
3482  'module_method' => 'get_spy_post'
3483  )
3484  ),
3485  'alerts' => array(
3486  array('unit' => 'ads', 'action' => 'create'),
3487  array('unit' => 'ads', 'action' => 'rate'),
3488  array('unit' => 'ads', 'action' => 'delete'),
3489  array('unit' => 'ads', 'action' => 'commentPost'),
3490  array('unit' => 'ads', 'action' => 'commentRemoved')
3491  )
3492  );
3493  }
3494 
3504  function serviceGetSpyPost($sAction, $iObjectId = 0, $iSenderId = 0, $aExtraParams = array())
3505  {
3506  $aRet = array();
3507 
3508  $aPostInfo = $this->_oDb->getAdInfo($iObjectId);
3509  if (!$aPostInfo['IDProfile']) {
3510  return $aRet;
3511  }
3512 
3513  $sRecipientNickName = getNickName($aPostInfo['IDProfile']);
3514  $sRecipientProfileLink = getProfileLink($aPostInfo['IDProfile']);
3515  $sSenderNickName = $iSenderId ? getNickName($iSenderId) : _t('_Guest');
3516  $sSenderProfileLink = $iSenderId ? getProfileLink($iSenderId) : 'javascript:void(0)';
3517  $sCaption = $aPostInfo['Subject'];
3518  $sEntryUrl = $this->genUrl($iObjectId, $aPostInfo['EntryUri'], 'entry');
3519 
3520  $sLangKey = '';
3521  $iRecipientId = 0;
3522  switch ($sAction) {
3523  case 'create':
3524  $sLangKey = '_ch_ads_added_spy';
3525  $iRecipientId = 0;
3526  break;
3527 
3528  case 'rate' :
3529  $sLangKey = '_ch_ads_rated_spy';
3530  $iRecipientId = $aPostInfo['OwnerID'];
3531  break;
3532 
3533  case 'commentPost' :
3534  $sLangKey = '_ch_ads_commented_spy';
3535  $iRecipientId = $aPostInfo['OwnerID'];
3536  break;
3537  }
3538 
3539  return array(
3540  'lang_key' => $sLangKey,
3541  'params' => array(
3542  'recipient_p_link' => $sRecipientProfileLink,
3543  'recipient_p_nick' => $sRecipientNickName,
3544  'profile_nick' => $sSenderNickName,
3545  'profile_link' => $sSenderProfileLink,
3546  'ads_url' => $sEntryUrl,
3547  'ads_caption' => $sCaption,
3548  ),
3549  'recipient_id' => $iRecipientId,
3550  'spy_type' => 'content_activity',
3551  );
3552  }
3553 
3555  {
3556  $sUri = $this->_oConfig->getUri();
3557 
3558  return array(
3559  'handlers' => array(
3560  array(
3561  'alert_unit' => $sUri,
3562  'alert_action' => 'create',
3563  'module_uri' => $sUri,
3564  'module_class' => 'Module',
3565  'module_method' => 'get_wall_post',
3566  'groupable' => 0,
3567  'group_by' => '',
3568  'timeline' => 1,
3569  'outline' => 1
3570  ),
3571  array(
3572  'alert_unit' => $sUri,
3573  'alert_action' => 'comment_add',
3574  'module_uri' => $sUri,
3575  'module_class' => 'Module',
3576  'module_method' => 'get_wall_add_comment',
3577  'groupable' => 0,
3578  'group_by' => '',
3579  'timeline' => 1,
3580  'outline' => 0
3581  ),
3582 
3583  //DEPRICATED, saved for backward compatibility
3584  array(
3585  'alert_unit' => $sUri,
3586  'alert_action' => 'commentPost',
3587  'module_uri' => $sUri,
3588  'module_class' => 'Module',
3589  'module_method' => 'get_wall_post_comment',
3590  'groupable' => 0,
3591  'group_by' => '',
3592  'timeline' => 1,
3593  'outline' => 0
3594  )
3595  ),
3596  'alerts' => array(
3597  array('unit' => $sUri, 'action' => 'create')
3598  )
3599  );
3600  }
3601 
3602  function serviceGetWallPost($aEvent)
3603  {
3604  $aObjectIds = strpos($aEvent['object_id'], ',') !== false ? explode(',',
3605  $aEvent['object_id']) : array($aEvent['object_id']);
3606  rsort($aObjectIds);
3607 
3608  $iDeleted = 0;
3609  $aItems = array();
3610  foreach ($aObjectIds as $iId) {
3611  $aItem = $this->_oDb->getAdInfo($iId);
3612  if (empty($aItem)) {
3613  $iDeleted++;
3614  } else {
3615  if ($aItem['Status'] == 'active' && $this->oPrivacy->check('view', $aItem['ID'], $this->_iVisitorID)) {
3616  $aItems[] = $aItem;
3617  }
3618  }
3619  }
3620 
3621  if ($iDeleted == count($aObjectIds)) {
3622  return array('perform_delete' => true);
3623  }
3624 
3625  $iOwner = 0;
3626  if(!empty($aEvent['owner_id']))
3627  $iOwner = (int)$aEvent['owner_id'];
3628 
3629  $iDate = 0;
3630  if(!empty($aEvent['date']))
3631  $iDate = (int)$aEvent['date'];
3632 
3633  $bItems = !empty($aItems) && is_array($aItems);
3634  if($iOwner == 0 && $bItems && !empty($aItems[0]['OwnerID']))
3635  $iOwner = (int)$aItems[0]['OwnerID'];
3636 
3637  if($iDate == 0 && $bItems && !empty($aItems[0]['DateTime_UTS']))
3638  $iDate = (int)$aItems[0]['DateTime_UTS'];
3639 
3640  if($iOwner == 0 || empty($aItems))
3641  return '';
3642 
3643  $sCss = '';
3644  $sNoPhoto = $this->_oTemplate->getIconUrl('no-photo.png');
3645  if ($aEvent['js_mode']) {
3646  $sCss = $this->_oTemplate->addCss('wall_post.css', true);
3647  } else {
3648  $this->_oTemplate->addCss('wall_post.css');
3649  }
3650 
3651  $iItems = count($aItems);
3652  $sOwner = getNickName($iOwner);
3653 
3654  //--- Grouped events
3655  if ($iItems > 1) {
3656  if ($iItems > 4) {
3657  $aItems = array_slice($aItems, 0, 4);
3658  }
3659 
3660  $aTmplItems = array();
3661  foreach ($aItems as $aItem) {
3662  $aTmplItems[] = array(
3663  'unit' => $this->getUnit($aItem['ID']),
3664  );
3665  }
3666 
3667  return array(
3668  'owner_id' => $iOwner,
3669  'title' => _t('_ch_ads_wall_added_new_title_items', $sOwner, $iItems),
3670  'description' => '',
3671  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post_grouped.html', array(
3672  'cpt_user_name' => $sOwner,
3673  'cpt_added_new' => _t('_ch_ads_wall_added_new_items', $iItems),
3674  'ch_repeat:items' => $aTmplItems,
3675  'post_id' => $aEvent['id']
3676  )),
3677  'date' => $iDate
3678  );
3679  }
3680 
3681  //--- Single public event
3682  $aItem = $aItems[0];
3683  $aItem['url'] = $this->genUrl($aItem['ID'], $aItem['EntryUri'], 'entry');
3684 
3685  $sPostTxt = _t('_ch_ads_wall_object');
3686 
3687  return array(
3688  'owner_id' => $iOwner,
3689  'title' => _t('_ch_ads_wall_added_new_title', $sOwner, $sPostTxt),
3690  'description' => _t('_ch_ads_wall_added_new_title', $sOwner, $sPostTxt),
3691  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post.html', array(
3692  'cpt_user_name' => $sOwner,
3693  'cpt_added_new' => _t('_ch_ads_wall_added_new'),
3694  'cpt_object' => $sPostTxt,
3695  'cpt_item_url' => $aItem['url'],
3696  'unit' => $this->getUnit($aItem['ID']),
3697  'post_id' => $aEvent['id'],
3698  )),
3699  'date' => $iDate
3700  );
3701  }
3702 
3703  function serviceGetWallAddComment($aEvent)
3704  {
3705  $iId = (int)$aEvent['object_id'];
3706  $iOwner = (int)$aEvent['owner_id'];
3707  $sOwner = $iOwner != 0 ? getNickName($iOwner) : _t('_Anonymous');
3708 
3709  $aContent = unserialize($aEvent['content']);
3710  if (empty($aContent) || empty($aContent['object_id'])) {
3711  return '';
3712  }
3713 
3714  $iItem = (int)$aContent['object_id'];
3715  $aItem = $this->_oDb->getAdInfo($iItem);
3716  if (empty($aItem) || !is_array($aItem)) {
3717  return array('perform_delete' => true);
3718  }
3719 
3720  if (!$this->oPrivacy->check('view', $iItem, $this->_iVisitorID)) {
3721  return '';
3722  }
3723 
3724  ch_import('Cmts', $this->_aModule);
3725  $oCmts = new ChAdsCmts($this->_oConfig->getCommentSystemName(), $iItem);
3726  if (!$oCmts->isEnabled()) {
3727  return '';
3728  }
3729 
3730  $aComment = $oCmts->getCommentRow($iId);
3731  if(empty($aComment) || !is_array($aComment))
3732  return array('perform_delete' => true);
3733 
3734  $sCss = '';
3735  if ($aEvent['js_mode']) {
3736  $sCss = $this->_oTemplate->addCss('wall_post.css', true);
3737  } else {
3738  $this->_oTemplate->addCss('wall_post.css');
3739  }
3740 
3741  $aItem['url'] = $this->genUrl($aItem['ID'], $aItem['EntryUri'], 'entry');
3742 
3743  $sTextWallObject = _t('_ch_ads_wall_object');
3744 
3745  return array(
3746  'title' => _t('_ch_ads_wall_added_new_title_comment', $sOwner, $sTextWallObject),
3747  'description' => $aComment['cmt_text'],
3748  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post_comment.html', array(
3749  'cpt_user_name' => $sOwner,
3750  'cpt_added_new' => _t('_ch_ads_wall_added_new_comment'),
3751  'cpt_object' => $sTextWallObject,
3752  'cpt_item_url' => $aItem['url'],
3753  'cnt_comment_text' => $aComment['cmt_text'],
3754  'unit' => $this->getUnit($aItem['ID']),
3755  'post_id' => $aEvent['id'],
3756  ))
3757  );
3758  }
3759 
3763  function serviceGetWallPostComment($aEvent)
3764  {
3765  $iId = (int)$aEvent['object_id'];
3766  $iOwner = (int)$aEvent['owner_id'];
3767  $sOwner = getNickName($iOwner);
3768 
3769  $aItem = $this->_oDb->getAdInfo($iId);
3770  if (empty($aItem) || !is_array($aItem)) {
3771  return array('perform_delete' => true);
3772  }
3773 
3774  if (!$this->oPrivacy->check('view', $iId, $this->_iVisitorID)) {
3775  return '';
3776  }
3777 
3778  $aContent = unserialize($aEvent['content']);
3779  if (empty($aContent) || !isset($aContent['comment_id'])) {
3780  return '';
3781  }
3782 
3783  ch_import('Cmts', $this->_aModule);
3784  $oCmts = new ChAdsCmts($this->_oConfig->getCommentSystemName(), $iId);
3785  if (!$oCmts->isEnabled()) {
3786  return '';
3787  }
3788 
3789  $aItem['url'] = $this->genUrl($aItem['ID'], $aItem['EntryUri'], 'entry');
3790  $aComment = $oCmts->getCommentRow((int)$aContent['comment_id']);
3791  if(empty($aComment) || !is_array($aComment))
3792  return array('perform_delete' => true);
3793 
3794  $sCss = '';
3795  if ($aEvent['js_mode']) {
3796  $sCss = $this->_oTemplate->addCss('wall_post.css', true);
3797  } else {
3798  $this->_oTemplate->addCss('wall_post.css');
3799  }
3800 
3801  $sTextWallObject = _t('_ch_ads_wall_object');
3802 
3803  return array(
3804  'title' => _t('_ch_ads_wall_added_new_title_comment', $sOwner, $sTextWallObject),
3805  'description' => $aComment['cmt_text'],
3806  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post_comment.html', array(
3807  'cpt_user_name' => $sOwner,
3808  'cpt_added_new' => _t('_ch_ads_wall_added_new_comment'),
3809  'cpt_object' => $sTextWallObject,
3810  'cpt_item_url' => $aItem['url'],
3811  'cnt_comment_text' => $aComment['cmt_text'],
3812  'unit' => $this->getUnit($aItem['ID']),
3813  'post_id' => $aEvent['id'],
3814  ))
3815  );
3816  }
3817 
3818  function serviceGetWallPostOutline($aEvent)
3819  {
3820  $sPrefix = 'ch_' . $this->_oConfig->getUri();
3821  $aProfile = getProfileInfo($aEvent['owner_id']);
3822  if (!$aProfile) {
3823  return '';
3824  }
3825 
3826  $aObjectIds = strpos($aEvent['object_id'], ',') !== false ? explode(',',
3827  $aEvent['object_id']) : array($aEvent['object_id']);
3828  rsort($aObjectIds);
3829 
3830  $iItems = count($aObjectIds);
3831  $iItemsLimit = 3;
3832  if ($iItems > $iItemsLimit) {
3833  $aObjectIds = array_slice($aObjectIds, 0, $iItemsLimit);
3834  }
3835 
3836  $bSave = false;
3837  $aContent = array();
3838  if (!empty($aEvent['content'])) {
3839  $aContent = unserialize($aEvent['content']);
3840  }
3841 
3842  if (!isset($aContent['idims'])) {
3843  $aContent['idims'] = array();
3844  }
3845 
3846  $iDeleted = 0;
3847  $aItems = $aTmplItems = array();
3848  foreach ($aObjectIds as $iId) {
3849  $aItem = $this->_oDb->getAdInfo($iId);
3850  if (empty($aItem)) {
3851  $iDeleted++;
3852  } else {
3853  if ($aItem['Status'] == 'active' && $this->oPrivacy->check('view', $aItem['ID'], $this->_iVisitorID)) {
3854  $aItem['thumb_file'] = $this->getAdCover($aItem['Media'], 'big_thumb');
3855  $aItem['thumb_file_path'] = $this->getAdCoverPath($aItem['Media'], 'big_thumb');
3856  $sPath = file_exists($aItem['thumb_file_path']) ? $aItem['thumb_file_path'] : $aItem['thumb_file'];
3857 
3858  $aItem['thumb_dims'] = array();
3859  if (!empty($aItem['Media']) && !empty($sPath)) {
3860  if (!isset($aContent['idims'][$iId])) {
3861  $aContent['idims'][$iId] = ChWsbImageResize::instance()->getImageSize($sPath);
3862  $bSave = true;
3863  }
3864 
3865  $aItem['thumb_dims'] = $aContent['idims'][$iId];
3866  }
3867 
3868  $aItem['thumb_file_2x'] = $this->getAdCover($aItem['Media'], 'img');
3869  if (empty($aItem['thumb_file_2x'])) {
3870  $aItem['thumb_file_2x'] = $aItem['thumb_file'];
3871  }
3872 
3873  $aItem['thumb_file_2x_path'] = $this->getAdCoverPath($aItem['Media'], 'img');
3874  if (empty($aItem['thumb_file_2x_path'])) {
3875  $aItem['thumb_file_2x_path'] = $aItem['thumb_file_path'];
3876  }
3877 
3878  $aItem['EntryUri'] = $this->genUrl($aItem['ID'], $aItem['EntryUri'], 'entry');
3879  $aItems[] = $aItem;
3880 
3881  $aTmplItems[] = array(
3882  'mod_prefix' => $sPrefix,
3883  'item_width' => isset($aItem['thumb_dims']['w']) ? $aItem['thumb_dims']['w'] : $this->iThumbSize,
3884  'item_height' => isset($aItem['thumb_dims']['h']) ? $aItem['thumb_dims']['h'] : $this->iThumbSize,
3885  'item_icon' => $aItem['thumb_file'],
3886  'item_icon_2x' => $aItem['thumb_file_2x'],
3887  'item_page' => $aItem['EntryUri'],
3888  'item_title' => $aItem['Subject']
3889  );
3890  }
3891  }
3892  }
3893 
3894  if ($iDeleted == count($aObjectIds)) {
3895  return array('perform_delete' => true);
3896  }
3897 
3898  if (empty($aItems)) {
3899  return '';
3900  }
3901 
3902  $aResult = array();
3903  if ($bSave) {
3904  $aResult['save']['content'] = serialize($aContent);
3905  }
3906 
3907  $sCss = '';
3908  if ($aEvent['js_mode']) {
3909  $sCss = $this->_oTemplate->addCss(array('wall_outline.css'), true);
3910  } else {
3911  $this->_oTemplate->addCss(array('wall_outline.css'));
3912  }
3913 
3914  $iItems = count($aItems);
3915  $iOwner = (int)$aEvent['owner_id'];
3916  $sOwner = getNickName($iOwner);
3917  $sOwnerLink = getProfileLink($iOwner);
3918 
3919  //--- Grouped events
3920  $iItems = count($aItems);
3921  if ($iItems > 1) {
3922  $sTmplName = 'wall_outline_grouped.html';
3923  $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array(
3924  'mod_prefix' => $sPrefix,
3925  'mod_icon' => 'money',
3926  'user_name' => $sOwner,
3927  'user_link' => $sOwnerLink,
3928  'ch_repeat:items' => $aTmplItems,
3929  'item_comments' => 0 ? _t('_wall_n_comments', 0) : _t('_wall_no_comments'),
3930  'item_comments_link' => '',
3931  'post_id' => $aEvent['id'],
3932  'post_ago' => $aEvent['ago']
3933  ));
3934 
3935  return $aResult;
3936  }
3937 
3938  //--- Single public event
3939  $aItem = $aItems[0];
3940  $aTmplItem = $aTmplItems[0];
3941 
3942  $sTmplName = 'modules/cheetah/wall/|outline_item_image.html';
3943  $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array_merge($aTmplItem, array(
3944  'mod_prefix' => $sPrefix,
3945  'mod_icon' => 'money',
3946  'user_name' => $sOwner,
3947  'user_link' => $sOwnerLink,
3948  'item_page' => $aItem['EntryUri'],
3949  'item_title' => $aItem['Subject'],
3950  'item_description' => $this->_formatSnippetTextForOutline($aItem),
3951  'item_comments' => (int)$aItem['CommentsCount'] > 0 ? _t('_wall_n_comments',
3952  $aItem['CommentsCount']) : _t('_wall_no_comments'),
3953  'item_comments_link' => $aItem['EntryUri'] . '#cmta-' . $this->_oConfig->getUri() . '-' . $aItem['ID'],
3954  'post_id' => $aEvent['id'],
3955  'post_ago' => $aEvent['ago']
3956  )));
3957 
3958  return $aResult;
3959  }
3960 
3961  function getUnit($iId, $sUnitTemplate = false)
3962  {
3963  ch_import('SearchUnit', $this->_aModule);
3964  $oTmpAdsSearch = new ChAdsSearchUnit();
3965  if ($sUnitTemplate) {
3966  $oTmpAdsSearch->sSelectedUnit = $sUnitTemplate;
3967  }
3968  $oTmpAdsSearch->aCurrent['paginate']['forcePage'] = 1;
3969  $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 1;
3970  $oTmpAdsSearch->aCurrent['restriction']['id']['value'] = (int)$iId;
3971  $s = $oTmpAdsSearch->displayResultBlock(false);
3972 
3973  return $oTmpAdsSearch->aCurrent['paginate']['totalNum'] > 0 ? $s : '';
3974  }
3975 
3976  function _formatSnippetTextForOutline($aEntryData)
3977  {
3978  return $this->getUnit($aEntryData['ID'], 'wall_outline_extra_info');
3979  }
3980 }
ChAdsModule\$sSpacerPath
$sSpacerPath
Definition: ChAdsModule.php:123
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChAdsCalendar
Definition: ChAdsCalendar.php:11
$oSettings
$oSettings
Definition: advanced_settings.php:20
ChAdsModule\GenAllAds
GenAllAds($sType='last', $isSimplePaginage=false)
Definition: ChAdsModule.php:2207
ChAdsModule\PrintSubRecords
PrintSubRecords($iIDClassifiedsSubs)
Definition: ChAdsModule.php:2131
document
Output SortAttr HTML Purifier will sort attributes by name before writing them back to the document
Definition: Output.SortAttr.txt:8
ChAdsModule\isAllowedBrowse
isAllowedBrowse($isPerformAction=false)
Definition: ChAdsModule.php:512
$sMessage
$sMessage
Definition: actions.inc.php:17
ChTemplFormView
Definition: ChTemplFormView.php:11
ChAdsModule\_defineActions
_defineActions()
Definition: ChAdsModule.php:598
true
if(!defined("TRUE_VAL")) define("TRUE_VAL" true
Definition: constants.inc.php:8
ChAdsSearchUnit
Definition: ChAdsSearchUnit.php:12
$sMode
else $sMode
Definition: antispam.php:362
ChTemplTagsModule
Definition: ChTemplTagsModule.php:11
ChAdsModule\__construct
__construct($aModule)
Definition: ChAdsModule.php:159
ChAdsModule\getAdsMainPage
getAdsMainPage()
Definition: ChAdsModule.php:2403
ChWsbProfileFields
Definition: ChWsbProfileFields.php:13
ChAdsModule\$sTAOtherListingContent
$sTAOtherListingContent
Definition: ChAdsModule.php:146
ChAdsModule\GenAdsCalendar
GenAdsCalendar()
Definition: ChAdsModule.php:3128
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChWsbModule\isLogged
isLogged()
Definition: ChWsbModule.php:113
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
$sBoxContent
$sBoxContent
Definition: db.php:35
ChAdsModule\$sCurrBrowsedFile
$sCurrBrowsedFile
Definition: ChAdsModule.php:133
ChAdsModule\isAllowedEdit
isAllowedEdit($iOwnerID, $isPerformAction=false)
Definition: ChAdsModule.php:548
uriGenerate
uriGenerate($s, $sTable, $sField, $iMaxLen=255)
Definition: utils.inc.php:900
ChAdsModule\$sTAActionsContent
$sTAActionsContent
Definition: ChAdsModule.php:142
Version
GNU LESSER GENERAL PUBLIC LICENSE Version
Definition: license.txt:2
name
Core AllowHostnameUnderscore underscores are not permitted in host most browsers do the right thing when faced with an underscore in the host name
Definition: Core.AllowHostnameUnderscore.txt:11
$sCode
$sCode
Definition: explanation.php:19
CHECK_ACTION_RESULT_ALLOWED
const CHECK_ACTION_RESULT_ALLOWED
Definition: membership_levels.inc.php:60
$sResult
$sResult
Definition: advanced_settings.php:26
ChAdsModule\DeleteProfileAdvertisement
DeleteProfileAdvertisement($iProfileID)
Definition: ChAdsModule.php:1351
ChAdsModule\serviceGetCommonCss
serviceGetCommonCss($bText=false)
Definition: ChAdsModule.php:3435
ChAdsModule\getCategoryManager
getCategoryManager()
Definition: ChAdsModule.php:2835
post
post($sTable, $sId, $sAuthor, $sParent, $sMood, $sFileId)
Definition: customFunctions.inc.php:8
$aModule
$aModule
Definition: classifieds.php:21
ChAdsModule\GenAdminTabbedPage
GenAdminTabbedPage()
Definition: ChAdsModule.php:643
$oAds
$oAds
Definition: classifieds.php:23
ChAdsModule\CheckLogged
CheckLogged()
Definition: ChAdsModule.php:611
ChWsbEmailTemplates
Definition: ChWsbEmailTemplates.php:11
ChAdsModule\isAllowedComments
isAllowedComments(&$aAdPost)
Definition: ChAdsModule.php:492
ChAdsModule\isAllowedView
isAllowedView($iOwnerID, $isPerformAction=false)
Definition: ChAdsModule.php:501
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ChAdsModule\$sTADescription
$sTADescription
Definition: ChAdsModule.php:147
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
$oAlert
$oAlert
Definition: embed.php:15
ChWsbPageView\getBlockCaptionMenu
static getBlockCaptionMenu( $iBlockID, $aLinks)
Definition: ChWsbPageView.php:586
CHECK_ACTION_RESULT
const CHECK_ACTION_RESULT
Definition: membership_levels.inc.php:54
ChAdsModule\$iImgSize
$iImgSize
Definition: ChAdsModule.php:114
sendMail
sendMail( $sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID=0, $aPlus=array(), $sEmailFlag='html', $isDisableAlert=false, $bForceSend=false)
Definition: utils.inc.php:461
ChAdsModule\$iThumbSize
$iThumbSize
Definition: ChAdsModule.php:112
ChAdsModule\$sPicNotAvailPath
$sPicNotAvailPath
Definition: ChAdsModule.php:127
ChAdsModule\PrintFilterForm
PrintFilterForm($iClassifiedID=0, $iSubClassifiedID=0)
Definition: ChAdsModule.php:2419
ChAdsModule\serviceAdsProfilePage
serviceAdsProfilePage($_iProfileID)
Definition: ChAdsModule.php:3360
$sUrl
$sUrl
Definition: cart.php:15
ChAdsModule\genCategoriesBlock
genCategoriesBlock()
Definition: ChAdsModule.php:2273
php
ChAdsModule\isAllowedAdd
isAllowedAdd($isPerformAction=false)
Definition: ChAdsModule.php:534
$oZ
$oZ
Definition: db.php:20
ChWsbTags
Definition: ChWsbTags.php:15
$iId
$iId
Definition: license.php:15
ChAdsModule\GenTagsPage
GenTagsPage()
Definition: ChAdsModule.php:3292
ChAdsModule\$sHomePath
$sHomePath
Definition: ChAdsModule.php:154
ChAdsModule\actionSearch
actionSearch()
Definition: ChAdsModule.php:252
ChAdsModule\$sTAPhotosContent
$sTAPhotosContent
Definition: ChAdsModule.php:141
$sExt
$sExt
Definition: get_file.php:14
sCurrBrowsedFile
$oAds sCurrBrowsedFile
Definition: classifieds.php:24
ChAdsModule\PrintAdvertisementsByTag
PrintAdvertisementsByTag($sTag)
Definition: ChAdsModule.php:3085
ChAdsModule\getManageArea
getManageArea($oSearch, $sBoxIdSpec, $aButtons=array(), $sPgnUrl='', $aPgn=array())
Definition: ChAdsModule.php:1264
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
ChAdsModule\getAdministrationSettings
getAdministrationSettings()
Definition: ChAdsModule.php:618
ChAdsModule\serviceMapInstall
serviceMapInstall()
Definition: ChAdsModule.php:2038
ChAdsModule\getAddSubcatForm
getAddSubcatForm($iSubCategoryID=0, $bOnlyForm=false)
Definition: ChAdsModule.php:2697
process_html_output
process_html_output($text, $maxwordlen=100)
Definition: utils.inc.php:333
ChAdsModule\parseUploadedFiles
parseUploadedFiles()
Definition: ChAdsModule.php:1206
ChAdsModule\$iPerPageElements
$iPerPageElements
Definition: ChAdsModule.php:135
ChAdsModule\$sTARateContent
$sTARateContent
Definition: ChAdsModule.php:145
isModerator
isModerator($iId=0)
Definition: profiles.inc.php:58
ChAdsModule\ActionPrintAdvertisement
ActionPrintAdvertisement($iID)
Definition: ChAdsModule.php:1660
ChAdsModule\$sTAOtherInfo
$sTAOtherInfo
Definition: ChAdsModule.php:148
$aDate
$aDate
Definition: cron.php:133
a
Filter ExtractStyleBlocks Scope FilterParam ExtractStyleBlocksScope DESCRIPTION< p > If you would like users to be able to define external but only allow them to specify CSS declarations for a specific node and prevent them from fiddling with other use this directive It accepts any valid CSS and will prepend this to any CSS declaration extracted from the document For if this directive is set to< code > selector< code > a
Definition: Filter.ExtractStyleBlocks.Scope.txt:15
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
ChAdsModule\isAdmin
isAdmin()
Definition: ChAdsModule.php:593
ChWsbCmts
Definition: ChWsbCmts.php:99
$oForm
$oForm
Definition: host_tools.php:42
ChAdsModule\serviceGetSpyData
serviceGetSpyData()
Definition: ChAdsModule.php:3459
ChAdsModule\$_iVisitorID
$_iVisitorID
Definition: ChAdsModule.php:156
ChAdsModule\isAllowedDelete
isAllowedDelete($iOwnerID, $isPerformAction=false)
Definition: ChAdsModule.php:559
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
ChAdsModule\serviceGetWallPostComment
serviceGetWallPostComment($aEvent)
Definition: ChAdsModule.php:3763
ChWsbAlerts
Definition: ChWsbAlerts.php:39
getSitesHtml
getSitesHtml($sLink, $sTitle=false)
Definition: shared_sites.inc.php:37
ChAdsModule\getImageManagingCode
getImageManagingCode($sMediaIDs, $iPostID)
Definition: ChAdsModule.php:1445
exit
exit
Definition: cart.php:21
ChAdsModule\serviceGetWallAddComment
serviceGetWallAddComment($aEvent)
Definition: ChAdsModule.php:3703
$sType
$sType
Definition: actions.inc.php:11
ChAdsModule\GenAdsAdminIndex
GenAdsAdminIndex()
Definition: ChAdsModule.php:2960
$_GET
$_GET['debug']
Definition: index.php:67
ChAdsModule\ActionDeletePicture
ActionDeletePicture()
Definition: ChAdsModule.php:3192
ChAdsModule\ActionBuyAdvertisement
ActionBuyAdvertisement($iAdvertisementID)
Definition: ChAdsModule.php:1532
$oMemberMenu
$oMemberMenu
Definition: member_menu_queries.php:20
ChWsbImageResize\instance
static instance()
Definition: ChWsbImageResize.php:60
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChWsbRssFactory
Definition: ChWsbRssFactory.php:9
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
ChAdsModule\genUrl
genUrl($iEntryId, $sEntryUri, $sType='entry', $bForce=false)
Definition: ChAdsModule.php:3304
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChAdsModule\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChAdsModule.php:3818
$sTitle
$sTitle
Definition: actions.inc.php:13
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
comment
HTML AllowedCommentsRegexp which if it matches the body of a comment
Definition: HTML.AllowedCommentsRegexp.txt:6
$aProfile
$aProfile
Definition: flash.php:14
ChAdsModule\ActionDeleteAdvertisement
ActionDeleteAdvertisement($iID)
Definition: ChAdsModule.php:1367
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
$site
$site['ver']
Definition: version.inc.php:8
title2uri
title2uri($sValue)
Definition: utils.inc.php:42
charset
charset
Definition: Filter.ExtractStyleBlocks.txt:19
ChWsbViews
Definition: ChWsbViews.php:38
$sTags
$sTags
Definition: actions.inc.php:12
ChAdsModule\$iBigThumbSize
$iBigThumbSize
Definition: ChAdsModule.php:113
ChAdsModule\$sTAInfoContent
$sTAInfoContent
Definition: ChAdsModule.php:144
ChAdsModule\serviceGetSpyPost
serviceGetSpyPost($sAction, $iObjectId=0, $iSenderId=0, $aExtraParams=array())
Definition: ChAdsModule.php:3504
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
src
img src
Definition: URI.MungeResources.txt:8
ch_instance
ch_instance($sClassName, $aParams=array(), $aModule=array())
Definition: utils.inc.php:1264
ChAdsModule\$bAdminMode
$bAdminMode
Definition: ChAdsModule.php:130
ChAdsModule\serviceGetMemberMenuItem
serviceGetMemberMenuItem()
Definition: ChAdsModule.php:1999
ChAdsModule\isAllowedShare
isAllowedShare(&$aDataEntry)
Definition: ChAdsModule.php:584
ChWsbPaginate
Definition: ChWsbPaginate.php:69
ChAdsModule\ActionBuySendMailAdvertisement
ActionBuySendMailAdvertisement($iAdvertisementID)
Definition: ChAdsModule.php:1578
ChAdsModule\getAdCoverPath
getAdCoverPath($sMediaIDs, $sType='thumb', $isSubstituteNoImage=true)
Definition: ChAdsModule.php:1502
_t_err
_t_err( $str, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:504
ChAdsModule\serviceAdsIndexPage
serviceAdsIndexPage()
Definition: ChAdsModule.php:3329
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChWsbModule
Definition: ChWsbModule.php:41
ChAdsModule\$sTACommentsContent
$sTACommentsContent
Definition: ChAdsModule.php:143
ChAdsModule\$oPrivacy
$oPrivacy
Definition: ChAdsModule.php:151
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
value
URI Base such as when URI MakeAbsolute is on You may use a non absolute URI for this value
Definition: URI.Base.txt:11
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
$iDate
$iDate
Definition: cron.php:130
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
ChAdsModule\GetHeaderString
GetHeaderString()
Definition: ChAdsModule.php:394
method
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step method
Definition: license.txt:49
ChAdsModule\$oCmtsView
$oCmtsView
Definition: ChAdsModule.php:150
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
$aMenu
$aMenu
Definition: categories.php:257
ChAdsPageHome
Definition: ChAdsPageHome.php:11
ChAdsModule\PrintAllSubRecords
PrintAllSubRecords($iClassifiedID)
Definition: ChAdsModule.php:2075
ChWsbAdminSettings
Definition: ChWsbAdminSettings.php:35
ChAdsModule\getUnit
getUnit($iId, $sUnitTemplate=false)
Definition: ChAdsModule.php:3961
checkAction
checkAction($iMemberId, $actionID, $performAction=false, $iForcedProfID=0, $isCheckMemberStatus=true)
Definition: membership_levels.inc.php:313
ChAdsModule\serviceResponseProfileDelete
serviceResponseProfileDelete($oAlert)
Definition: ChAdsModule.php:3443
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
$aVars
$aVars
Definition: license.php:101
ChAdsModule\$iMaxUplFileSize
$iMaxUplFileSize
Definition: ChAdsModule.php:120
ChAdsModule\getAdCover
getAdCover($sMediaIDs, $sType='thumb', $isSubstituteNoImage=true)
Definition: ChAdsModule.php:1478
defineMembershipActions
defineMembershipActions($aActionsAll, $sPrefix='CH_')
Definition: membership_levels.inc.php:744
ChAdsModule\GenAdsByDate
GenAdsByDate()
Definition: ChAdsModule.php:3143
$s
$s
Definition: embed.php:13
ChAdsModule\PrintBackLink
PrintBackLink()
Definition: ChAdsModule.php:2191
ChAdsModule\isAllowedSearch
isAllowedSearch($isPerformAction=false)
Definition: ChAdsModule.php:523
ChAdsModule\actionGetList
actionGetList($sMode='', $sOwnerId='', $sAdd='', $sAdd1='', $sAdd2='')
Definition: ChAdsModule.php:190
ChAdsModule\$bUseFriendlyLinks
$bUseFriendlyLinks
Definition: ChAdsModule.php:138
$aUser
$aUser
Definition: profiles.inc.php:74
ChAdsModule\$sUploadDir
$sUploadDir
Definition: ChAdsModule.php:117
ChAdsModule\serviceGetSubscriptionParams
serviceGetSubscriptionParams($sAction, $iEntryId)
Definition: ChAdsModule.php:1969
ChAdsModule\$iIconSize
$iIconSize
Definition: ChAdsModule.php:111
ChAdsModule
Definition: ChAdsModule.php:109
ChAdsModule\$sHomeUrl
$sHomeUrl
Definition: ChAdsModule.php:153
$sCountry
$sCountry
Definition: browse.php:26
ChAdsPrivacy
Definition: ChAdsPrivacy.php:11
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
$aForm
$aForm
Definition: forgot.php:43
CH_WSB_PG_MEMBERS
const CH_WSB_PG_MEMBERS
Definition: ChWsbPrivacy.php:13
ChAdsModule\AddNewPostForm
AddNewPostForm($iPostID=0, $bBox=true)
Definition: ChAdsModule.php:835
$sCaption
$sCaption
Definition: tellfriend.php:39
ChAdsModule\serviceGetMemberMenuItemAddContent
serviceGetMemberMenuItemAddContent()
Definition: ChAdsModule.php:2018
ChAdsModule\_formatSnippetTextForOutline
_formatSnippetTextForOutline($aEntryData)
Definition: ChAdsModule.php:3976
ChAdsModule\getMemberAds
getMemberAds($iOtherProfileID=0, $iRandLim=0, $iExceptUnit=0)
Definition: ChAdsModule.php:1306
ChAdsModule\$sPicNotAvail
$sPicNotAvail
Definition: ChAdsModule.php:126
ChAdsModule\serviceGetWallData
serviceGetWallData()
Definition: ChAdsModule.php:3554
$sAction
$sAction
Definition: categories.php:274
b
el b
Definition: Output.SortAttr.txt:8
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
imageResize
imageResize( $srcFilename, $dstFilename, $sizeX, $sizeY, $forceJPGOutput=false, $isSquare=false)
Definition: images.inc.php:29
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
$sDesc
$sDesc
Definition: actions.inc.php:21
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
ChAdsModule\GenMyPageAdmin
GenMyPageAdmin($sForceMode='')
Definition: ChAdsModule.php:660
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChAdsModule\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChAdsModule.php:3602
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChAdsCmts
Definition: ChAdsCmts.php:11
ChAdsModule\actionSharePopup
actionSharePopup($iEntryId)
Definition: ChAdsModule.php:345
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
form
iii in the case of the organization that transmits the broadcast Work means the literary and or artistic work offered under the terms of this License including without limitation any production in the scientific and artistic whatever may be the mode or form of its expression including digital form
Definition: license.txt:19
ChAdsModule\PrintCommandForms
PrintCommandForms()
Definition: ChAdsModule.php:367
ChTemplVotingView
Definition: ChTemplVotingView.php:14
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
isMember
isMember($iId=0)
Definition: profiles.inc.php:44
ChAdsModule\_blockPhoto
_blockPhoto(&$aReadyMedia, $iAuthorId, $sPrefix=false)
Definition: ChAdsModule.php:3254
ChAdsModule\isAllowedApprove
isAllowedApprove($isPerformAction=false)
Definition: ChAdsModule.php:570
ChAdsModule\serviceAdsRss
serviceAdsRss()
Definition: ChAdsModule.php:3405
clear_xss
clear_xss($val)
Definition: utils.inc.php:700
ChAdsModule\getManageClassifiedsForm
getManageClassifiedsForm($iCategoryID=0, $bOnlyForm=false)
Definition: ChAdsModule.php:2516
$oSubscription
$oSubscription
Definition: notifies.php:28