Cheetah
ChEventsSearchResult.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbTwigSearchResult');
9 
11 {
12  var $aCurrent = array(
13  'name' => 'ch_events',
14  'title' => '_ch_events_caption_browse',
15  'table' => 'ch_events_main',
16  'ownFields' => array('ID', 'Title', 'EntryUri', 'Country', 'City', 'Place', 'EventStart', 'EventEnd', 'ResponsibleID', 'PrimPhoto', 'FansCount', 'Rate', 'Description'),
17  'searchFields' => array('Title', 'Description', 'City', 'Place', 'Tags', 'Categories'),
18  'join' => array(
19  'profile' => array(
20  'type' => 'left',
21  'table' => 'Profiles',
22  'mainField' => 'ResponsibleID',
23  'onField' => 'ID',
24  'joinFields' => array('NickName'),
25  ),
26  ),
27  'restriction' => array(
28  'activeStatus' => array('value' => 'approved', 'field'=>'Status', 'operator'=>'='),
29  'owner' => array('value' => '', 'field' => 'ResponsibleID', 'operator' => '='),
30  'tag' => array('value' => '', 'field' => 'Tags', 'operator' => 'against'),
31  'category' => array('value' => '', 'field' => 'Category', 'operator' => '=', 'table' => 'sys_categories'),
32  'category_type' => array('value' => '', 'field' => 'Type', 'operator' => '=', 'table' => 'sys_categories'),
33  'country' => array('value' => '', 'field' => 'Country', 'operator' => '='),
34  'public' => array('value' => '', 'field' => 'allow_view_event_to', 'operator' => '='),
35  ),
36  'paginate' => array('perPage' => 14, 'page' => 1, 'totalNum' => 0, 'totalPages' => 1),
37  'sorting' => 'last',
38  'rss' => array(
39  'title' => '',
40  'link' => '',
41  'image' => '',
42  'profile' => 0,
43  'fields' => array (
44  'Link' => '',
45  'Title' => 'Title',
46  'DateTimeUTS' => 'Date',
47  'Desc' => 'Description',
48  'Image' => 'PrimPhoto',
49  ),
50  ),
51  'ident' => 'ID'
52  );
53 
54  function __construct($sMode = '', $sValue = '', $sValue2 = '', $sValue3 = '')
55  {
56  $oMain = $this->getMain();
57 
58  switch ($sMode) {
59 
60  case 'pending':
61  if (false !== ch_get('ch_events_filter'))
62  $this->aCurrent['restriction']['keyword'] = array('value' => process_db_input(ch_get('ch_events_filter'), CH_TAGS_STRIP), 'field' => '','operator' => 'against');
63  $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
64  $this->sBrowseUrl = "administration";
65  $this->aCurrent['title'] = _t('_ch_events_pending_approval');
66  unset($this->aCurrent['rss']);
67  break;
68 
69  case 'my_pending':
70  $this->aCurrent['restriction']['owner']['value'] = $oMain->_iProfileId;
71  $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
72  $this->sBrowseUrl = "browse/user/" . getNickName($oMain->_iProfileId);
73  $this->aCurrent['title'] = _t('_ch_events_pending_approval');
74  unset($this->aCurrent['rss']);
75  break;
76 
77  case 'search':
78  if ($sValue)
79  $this->aCurrent['restriction']['keyword'] = array('value' => $sValue,'field' => '','operator' => 'against');
80 
81  if ($sValue2)
82  if (is_array($sValue2)) {
83  $this->aCurrent['restriction']['country'] = array('value' => $sValue2, 'field' => 'Country', 'operator' => 'in');
84  } else {
85  $this->aCurrent['restriction']['country']['value'] = $sValue2;
86  }
87 
88  $sValue = $GLOBALS['MySQL']->unescape($sValue);
89  $sValue2 = $GLOBALS['MySQL']->unescape($sValue2);
90  $this->sBrowseUrl = "search/$sValue/" . (is_array($sValue2) ? implode(',',$sValue2) : $sValue2);
91  $this->aCurrent['title'] = _t('_ch_events_caption_search_results') . ' ' . (is_array($sValue2) ? implode(', ',$sValue2) : $sValue2) . ' ' . $sValue;
92  unset($this->aCurrent['rss']);
93  break;
94 
95  case 'user':
96  $iProfileId = $GLOBALS['oChEventsModule']->_oDb->getProfileIdByNickName ($sValue, false);
97  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId); // select profile subtab, instead of events
98  if (!$iProfileId)
99  $this->isError = true;
100  else
101  $this->aCurrent['restriction']['owner']['value'] = $iProfileId;
102  $sValue = $GLOBALS['MySQL']->unescape($sValue);
103  $this->sBrowseUrl = "browse/user/$sValue";
104 
105  $iProfileId = getID($sValue);
106  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_author', $iProfileId ? getNickName($iProfileId) : $sValue);
107 
108  if (ch_get('rss')) {
109  $aData = getProfileInfo($iProfileId);
110  if ($aData['PrimPhoto']) {
111  $a = array ('ID' => $aData['ResponsibleID'], 'Avatar' => $aData['PrimPhoto']);
112  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
113  if (!$aImage['no_image'])
114  $this->aCurrent['rss']['image'] = $aImage['file'];
115  }
116  }
117  break;
118 
119  case 'joined':
120  $iProfileId = $GLOBALS['oChEventsModule']->_oDb->getProfileIdByNickName ($sValue, false);
121  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId); // select profile subtab, instead of module tab
122 
123  if (!$iProfileId) {
124 
125  $this->isError = true;
126 
127  } else {
128 
129  $this->aCurrent['join']['fans'] = array(
130  'type' => 'inner',
131  'table' => 'ch_events_participants',
132  'mainField' => 'ID',
133  'onField' => 'id_entry',
134  'joinFields' => array('id_profile'),
135  );
136  $this->aCurrent['restriction']['fans'] = array(
137  'value' => $iProfileId,
138  'field' => 'id_profile',
139  'operator' => '=',
140  'table' => 'ch_events_participants',
141  );
142  $this->aCurrent['restriction']['confirmed_fans'] = array(
143  'value' => 1,
144  'field' => 'confirmed',
145  'operator' => '=',
146  'table' => 'ch_events_participants',
147  );
148  }
149 
150  $sValue = $GLOBALS['MySQL']->unescape($sValue);
151  $this->sBrowseUrl = "browse/joined/$sValue";
152 
153  $iProfileId = getID($sValue);
154  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_author_joined_events', $iProfileId ? getNickName($iProfileId) : $sValue);
155 
156  if (ch_get('rss')) {
157  $aData = getProfileInfo($iProfileId);
158  if ($aData['Avatar']) {
159  $a = array ('ID' => $aData['author_id'], 'Avatar' => $aData['thumb']);
160  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
161  if (!$aImage['no_image'])
162  $this->aCurrent['rss']['image'] = $aImage['file'];
163  }
164  }
165  break;
166 
167  case 'admin':
168  if (ch_get('ch_events_filter'))
169  $this->aCurrent['restriction']['keyword'] = array('value' => process_db_input(ch_get('ch_events_filter'), CH_TAGS_STRIP), 'field' => '','operator' => 'against');
170  $this->aCurrent['restriction']['owner']['value'] = $oMain->_iProfileId;
171  $this->sBrowseUrl = "browse/admin";
172  $this->aCurrent['title'] = _t('_ch_events_admin_events');
173  break;
174 
175  case 'category':
176  $this->aCurrent['join']['category'] = array(
177  'type' => 'inner',
178  'table' => 'sys_categories',
179  'mainField' => 'ID',
180  'onField' => 'ID',
181  'joinFields' => '',
182  );
183  $this->aCurrent['restriction']['category_type']['value'] = $this->aCurrent['name'];
184  $this->aCurrent['restriction']['category']['value'] = $sValue;
185  $sValue = $GLOBALS['MySQL']->unescape($sValue);
186  $this->sBrowseUrl = "browse/category/" . title2uri($sValue);
187  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_category', $sValue);
188  break;
189 
190  case 'tag':
191  $this->aCurrent['restriction'][$sMode]['value'] = $sValue;
192  $sValue = $GLOBALS['MySQL']->unescape($sValue);
193  $this->sBrowseUrl = "browse/$sMode/" . title2uri($sValue);
194  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_'.$sMode, $sValue);
195  break;
196 
197  case 'country':
198  $this->aCurrent['restriction'][$sMode]['value'] = $sValue;
199  $this->sBrowseUrl = "browse/$sMode/$sValue";
200  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_'.$sMode, $sValue);
201  break;
202 
203  case 'upcoming':
204  $this->aCurrent['restriction']['upcoming'] = array('value' => time(), 'field' => 'EventEnd', 'operator' => '>');
205  $this->aCurrent['sorting'] = 'upcoming';
206  $this->sBrowseUrl = 'browse/upcoming';
207  $this->aCurrent['title'] = _t('_ch_events_caption_browse_upcoming');
208  break;
209 
210  case 'past':
211  $this->aCurrent['restriction']['past'] = array('value' => time(), 'field' => 'EventEnd', 'operator' => '<');
212  $this->aCurrent['sorting'] = 'past';
213  $this->sBrowseUrl = 'browse/past';
214  $this->aCurrent['title'] = _t('_ch_events_caption_browse_past');
215  break;
216 
217  case 'recent':
218  $this->sBrowseUrl = 'browse/recent';
219  $this->aCurrent['title'] = _t('_ch_events_caption_browse_recently_added');
220  break;
221 
222  case 'top':
223  $this->sBrowseUrl = 'browse/top';
224  $this->aCurrent['sorting'] = 'top';
225  $this->aCurrent['title'] = _t('_ch_events_caption_browse_top_rated');
226  break;
227 
228  case 'popular':
229  $this->sBrowseUrl = 'browse/popular';
230  $this->aCurrent['sorting'] = 'popular';
231  $this->aCurrent['title'] = _t('_ch_events_caption_browse_popular');
232  break;
233 
234  case 'featured':
235  $this->aCurrent['restriction']['featured'] = array('value' => 1, 'field' => 'Featured', 'operator' => '=');
236  $this->sBrowseUrl = 'browse/featured';
237  $this->aCurrent['title'] = _t('_ch_events_caption_browse_featured');
238  break;
239 
240  case 'calendar':
241  $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 00:00:00')", 'field' => 'EventEnd', 'operator' => '>=', 'no_quote_value' => true);
242  $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 23:59:59')", 'field' => 'EventStart', 'operator' => '<=', 'no_quote_value' => true);
243  $this->sBrowseUrl = "browse/calendar/{$sValue}/{$sValue2}/{$sValue3}";
244 
245  $this->aCurrent['title'] = _t('_ch_events_caption_browse_by_day', getLocaleDate(strtotime("{$sValue}-{$sValue2}-{$sValue3}"), CH_WSB_LOCALE_DATE_SHORT));
246  break;
247 
248  case '':
249  $this->sBrowseUrl = 'browse/';
250  $this->aCurrent['title'] = _t('_ch_events');
251  unset($this->aCurrent['rss']);
252  break;
253 
254  default:
255  $this->isError = true;
256  }
257 
258  $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('ch_events_perpage_browse');
259 
260  if (isset($this->aCurrent['rss']))
261  $this->aCurrent['rss']['link'] = CH_WSB_URL_ROOT . $oMain->_oConfig->getBaseUri() . $this->sBrowseUrl;
262 
263  if (ch_get('rss')) {
264  $this->aCurrent['ownFields'][] = 'Description';
265  $this->aCurrent['ownFields'][] = 'Date';
266  $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('ch_events_max_rss_num');
267  }
268 
269  ch_events_import('Voting', $this->getModuleArray());
270  $oVotingView = new ChEventsVoting ('ch_events', 0);
271  $this->oVotingView = $oVotingView->isEnabled() ? $oVotingView : null;
272 
273  parent::__construct();
274  }
275 
276  function getAlterOrder()
277  {
278  if ($this->aCurrent['sorting'] == 'last') {
279  $aSql = array();
280  $aSql['order'] = " ORDER BY `ch_events_main`.`Date` DESC";
281  return $aSql;
282  } elseif ($this->aCurrent['sorting'] == 'upcoming') {
283  $aSql = array();
284  $aSql['order'] = " ORDER BY `EventStart` ASC";
285  return $aSql;
286  } elseif ($this->aCurrent['sorting'] == 'past') {
287  $aSql = array();
288  $aSql['order'] = " ORDER BY `EventEnd` DESC";
289  return $aSql;
290  } elseif ($this->aCurrent['sorting'] == 'top') {
291  $aSql = array();
292  $aSql['order'] = " ORDER BY `ch_events_main`.`Rate` DESC, `ch_events_main`.`RateCount` DESC";
293  return $aSql;
294  } elseif ($this->aCurrent['sorting'] == 'popular') {
295  $aSql = array();
296  $aSql['order'] = " ORDER BY `ch_events_main`.`FansCount` DESC, `ch_events_main`.`Views` DESC";
297  return $aSql;
298  }
299  return array();
300  }
301 
302  function displayResultBlock ()
303  {
305  $s = parent::displayResultBlock ();
306  if ($s) {
307  $oMain = $this->getMain();
308  $GLOBALS['oSysTemplate']->addDynamicLocation($oMain->_oConfig->getHomePath(), $oMain->_oConfig->getHomeUrl());
309  $GLOBALS['oSysTemplate']->addCss(array('unit.css', 'twig.css'));
310  return $GLOBALS['oSysTemplate']->parseHtmlByName('default_padding.html', array('content' => $s));
311  }
312  return '';
313  }
314 
315  function getModuleArray()
316  {
317  return db_arr ("SELECT * FROM `sys_modules` WHERE `title` = 'Events' AND `class_prefix` = 'ChEvents' LIMIT 1");
318  }
319 
320  function getMain()
321  {
322  return ChWsbModule::getInstance('ChEventsModule');
323  }
324 
325  function getRssUnitLink (&$a)
326  {
327  $oMain = $this->getMain();
328  return CH_WSB_URL_ROOT . $oMain->_oConfig->getBaseUri() . 'view/' . $a['EntryUri'];
329  }
330 
331  function _getPseud ()
332  {
333  return array(
334  'ID' => 'ID',
335  'Title' => 'Title',
336  'EntryUri' => 'EntryUri',
337  'EventStart' => 'EventStart',
338  'Place' => 'Place',
339  'Country' => 'Country',
340  'City' => 'City',
341  'ResponsibleID' => 'ResponsibleID',
342  'NickName' => 'NickName',
343  'PrimPhoto' => 'PrimPhoto',
344  );
345  }
346 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChEventsSearchResult\getModuleArray
getModuleArray()
Definition: ChEventsSearchResult.php:315
$sMode
else $sMode
Definition: antispam.php:362
ChEventsSearchResult\_getPseud
_getPseud()
Definition: ChEventsSearchResult.php:331
ChEventsVoting
Definition: ChEventsVoting.php:11
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChEventsSearchResult\getAlterOrder
getAlterOrder()
Definition: ChEventsSearchResult.php:276
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
ChEventsSearchResult\displayResultBlock
displayResultBlock()
Definition: ChEventsSearchResult.php:302
php
ChEventsSearchResult\getRssUnitLink
getRssUnitLink(&$a)
Definition: ChEventsSearchResult.php:325
ChWsbTwigSearchResult\$oVotingView
$oVotingView
Definition: ChWsbTwigSearchResult.php:15
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
ChEventsSearchResult\__construct
__construct($sMode='', $sValue='', $sValue2='', $sValue3='')
Definition: ChEventsSearchResult.php:54
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
title2uri
title2uri($sValue)
Definition: utils.inc.php:42
ChWsbTwigSearchResult
Definition: ChWsbTwigSearchResult.php:14
ch_events_import
ch_events_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChEventsModule.php:8
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChEventsSearchResult
Definition: ChEventsSearchResult.php:11
_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
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
$s
$s
Definition: embed.php:13
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChWsbTwigSearchResult\$sBrowseUrl
$sBrowseUrl
Definition: ChWsbTwigSearchResult.php:17
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
ChEventsSearchResult\$aCurrent
$aCurrent
Definition: ChEventsSearchResult.php:12
ChEventsSearchResult\getMain
getMain()
Definition: ChEventsSearchResult.php:320
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10