Cheetah
profiles.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( '../inc/header.inc.php' );
9 
10 $GLOBALS['iAdminPage'] = 1;
11 
12 require_once( CH_DIRECTORY_PATH_INC . 'design.inc.php' );
13 require_once( CH_DIRECTORY_PATH_INC . 'profiles.inc.php' );
14 require_once( CH_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
15 require_once( CH_DIRECTORY_PATH_INC . 'utils.inc.php' );
16 
17 ch_import('ChTemplSearchResult');
18 ch_import('ChTemplBrowse');
19 ch_import('ChTemplTags');
20 ch_import('ChTemplFunctions');
21 ch_import('ChWsbAlerts');
22 ch_import('ChWsbEmailTemplates');
23 
24 $sDefaultOverViewMode = strtolower(getParam('default_overview_mode'));
25 $sDefaultMemberMode = strtolower(getParam('default_view_mode'));
26 $iDefaultPerPage = (int)getParam('default_per_page');
27 if($sDefaultOverViewMode == 'quick links') $sDefaultOverViewMode = 'qlinks';
28 
29 define('CH_WSB_ADM_MP_CTL', $sDefaultOverViewMode);
30 define('CH_WSB_ADM_MP_VIEW', $sDefaultMemberMode);
31 define('CH_WSB_ADM_MP_JS_NAME', 'oMP');
32 define('CH_WSB_ADM_MP_PER_PAGE', $iDefaultPerPage);
33 define('CH_WSB_ADM_MP_PER_PAGE_STEP', 16);
34 
35 $logged['admin'] = member_auth( 1, true, true );
36 
37 $sCtlType = isset($_POST['adm-mp-members-ctl-type']) && in_array($_POST['adm-mp-members-ctl-type'], array('qlinks', 'browse', 'calendar', 'tags', 'search', 'settings')) ? $_POST['adm-mp-members-ctl-type'] : CH_WSB_ADM_MP_CTL;
38 $aCtlType = array();
39 
40 $sViewType = isset($_POST['adm-mp-members-view-type']) && in_array($_POST['adm-mp-members-view-type'], array('geeky', 'simple', 'extended')) ? $_POST['adm-mp-members-view-type'] : CH_WSB_ADM_MP_VIEW;
41 
42 // If settings form was submitted, then set the ctl type to settings.
43 if (isset($_POST['save']) && isset($_POST['cat'])) {
44  $sCtlType = 'settings';
45 }
46 
47 //--- Process Actions ---//
48 if(isset($_POST['adm-mp-activate']) && (bool)$_POST['members']) {
49  ch_admin_profile_change_status($_POST['members'], 'Active', TRUE);
50  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
51  exit;
52 } else if(isset($_POST['adm-mp-deactivate']) && (bool)$_POST['members']) {
53  ch_admin_profile_change_status($_POST['members'], 'Approval');
54 
55  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
56  exit;
57 } else if(isset($_POST['adm-mp-ban']) && (bool)$_POST['members']) {
58  $iBanDuration = isset($_POST['adm-mp-members-ban-duration']) ? (int)$_POST['adm-mp-members-ban-duration'] : 0;
59 
60  foreach($_POST['members'] as $iId)
61  ch_admin_profile_ban_control($iId, true, $iBanDuration);
62 
63  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
64  exit;
65 } else if(isset($_POST['adm-mp-unban']) && (bool)$_POST['members']) {
66  ch_import('ChWsbForm');
67  $oChecker = new ChWsbFormCheckerHelper();
68  $GLOBALS['MySQL']->query("DELETE FROM `sys_admin_ban_list` WHERE `ProfID` IN ('" . implode("','", $oChecker->passInt($_POST['members'])) . "')");
69 
70  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
71  exit;
72 
73 } else if(isset($_POST['adm-mp-set-admin']) && (bool)$_POST['members']) {
74  $iIdCurr = getLoggedId();
75  foreach($_POST['members'] as $iId) {
76  $iId = (int)$iId;
77  if ($iIdCurr != $iId)
78  $GLOBALS['MySQL']->query("UPDATE `Profiles` SET `Role` = 3 WHERE `ID` = '$iId'");
79  }
80 
81  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
82  exit;
83 
84  } else if(isset($_POST['adm-mp-unset-admin']) && (bool)$_POST['members']) {
85 
86  $iIdCurr = getLoggedId();
87  foreach($_POST['members'] as $iId) {
88  $iId = (int)$iId;
89  if ($iIdCurr != $iId)
90  $GLOBALS['MySQL']->query("UPDATE `Profiles` SET `Role` = 1 WHERE `ID` = '$iId'");
91  }
92 
93  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
94  exit;
95 
96 } else if((isset($_POST['adm-mp-delete']) || isset($_POST['adm-mp-delete-spammer'])) && (bool)$_POST['members']) {
97  $iIdCurr = getLoggedId();
98  foreach($_POST['members'] as $iId) {
99  $iId = (int)$iId;
100  if ($iIdCurr != $iId)
101  $bResult = profile_delete($iId, isset($_POST['adm-mp-delete-spammer']));
102  }
103 
104  echo "<script>window.parent." . CH_WSB_ADM_MP_JS_NAME . ".reload();</script>";
105  exit;
106 } else if(isset($_POST['adm-mp-confirm']) && (bool)$_POST['members']) {
107  foreach($_POST['members'] as $iId)
108  activation_mail((int)$iId, 0);
109 
110  echo "<script>alert('" . _t('_adm_txt_mp_activation_sent') . "')</script>";
111  exit;
112 } else if(isset($_POST['action']) && $_POST['action'] == 'get_members') {
113  $aParams = array();
114  if(is_array($_POST['ctl_value']))
115  foreach($_POST['ctl_value'] as $sValue) {
116  $aValue = explode('=', $sValue);
117  $aParams[$aValue[0]] = $aValue[1];
118  }
119 
120  echo json_encode(array('code' => 0, 'content' => getMembers(array(
121  'view_type' => $_POST['view_type'],
122  'view_start' => (int)$_POST['view_start'],
123  'view_per_page' => (int)$_POST['view_per_page'],
124  'view_order' => $_POST['view_order'],
125  'ctl_type' => $_POST['ctl_type'],
126  'ctl_params' => $aParams
127  ))));
128  exit;
129 } else if(isset($_POST['action']) && $_POST['action'] == 'get_controls') {
130 
131  $sCtlType = process_db_input($_POST['ctl_type'], CH_TAGS_STRIP);
132  $sMethodName = 'getBlock' . ucfirst($sCtlType);
133  if(!function_exists($sMethodName)) {
134  echo '{}';
135  exit;
136  }
137 
138  echo json_encode(array(
139  'code' => 0,
140  'content' => $oAdmTemplate->parseHtmlByName('mp_ctl_type_' . $sCtlType . '.html', $sMethodName($sCtlType))
141  ));
142  exit;
143 }
144 
145 //--- Process Query String ---//
146 if(isset($_GET['action']) && $_GET['action'] == 'browse') {
147  $aCtlType = array(
148  'ctl_type' => 'qlinks',
149  'ctl_params' => array(
150  'by' => process_db_input(ch_get('by'), CH_TAGS_STRIP),
151  'value' => process_db_input(ch_get('value'), CH_TAGS_STRIP)
152  )
153  );
154 }
155 
157 $_page = array(
158  'name_index' => $iNameIndex,
159  'css_name' => array('forms_adv.css', 'profiles.css'),
160  'js_name' => array('profiles.js'),
161  'header' => _t('_adm_page_cpt_manage_members')
162 );
164  'page_code_controls' => PageCodeControls($sCtlType),
165  'page_code_members' => PageCodeMembers(!empty($aCtlType) ? $aCtlType : $sCtlType, $sViewType),
166  'obj_name' => CH_WSB_ADM_MP_JS_NAME,
167  'actions_url' => $GLOBALS['site']['url_admin'] . 'profiles.php',
168  'sel_control' => $sCtlType,
169  'sel_view' => $sViewType,
170  'per_page' => CH_WSB_ADM_MP_PER_PAGE,
171  'order_by' => ''
172 );
173 
174 PageCodeAdmin();
175 
176 function PageCodeControls($sDefault = CH_WSB_ADM_MP_CTL)
177 {
179 
180  $aTopMenu = array(
181  'ctl-type-qlinks' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_qlinks'), 'active' => $sDefault == 'qlinks' ? 1 : 0),
182  //'ctl-type-browse' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_browse'), 'active' => $sDefault == 'browse' ? 1 : 0),
183  //'ctl-type-calendar' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_calendar'), 'active' => $sDefault == 'calendar' ? 1 : 0),
184  'ctl-type-tags' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_tags'), 'active' => $sDefault == 'tags' ? 1 : 0),
185  'ctl-type-search' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_search'), 'active' => $sDefault == 'search' ? 1 : 0),
186  'ctl-type-settings' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeControl(this);', 'title' => _t('_adm_btn_mp_settings'), 'active' => $sDefault == 'settings' ? 1 : 0)
187  );
188 
189  $aParams = array_merge(
190  getBlockQlinks($sDefault),
191  getBlockBrowse($sDefault),
192  getBlockCalendar($sDefault),
193  getBlockTags($sDefault),
194  getBlockSearch($sDefault),
195  getBlockSettings($sDefault),
196  array(
197  'loading' => LoadingBox('adm-mp-controls-loading')
198  )
199  );
200  return DesignBoxAdmin(_t('_adm_box_cpt_mp_controls'), $oAdmTemplate->parseHtmlByName('mp_controls.html', $aParams), $aTopMenu, '', 11);
201 }
202 function getBlockQlinks($sDefault)
203 {
204  global $MySQL;
205 
206  $aResult = array();
207  $sBaseUrl = $GLOBALS['site']['url_admin'] . 'profiles.php?type=qlinks&value=';
208 
209  $aItems = array();
210  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'all' AS `by`, 'all' AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE 1 AND (`Couple`='0' OR `Couple`>`ID`)"));
211  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'status' AS `by`, `Status` AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE 1 AND (`Couple`='0' OR `Couple`>`ID`) GROUP BY `Status`"));
212  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'featured' AS `by`, 'featured' AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE `Featured`='1'"));
213  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'banned' AS `by`, 'banned' AS `value`, COUNT(`ProfID`) AS `count` FROM `sys_admin_ban_list` WHERE `Time`='0' OR (`Time`<>'0' AND DATE_ADD(`DateTime`, INTERVAL `Time` HOUR)>NOW())"));
214  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'membership' AS `by`, `tl`.`Name` AS `value`, COUNT(`tlm`.`IDMember`) AS `count` FROM `sys_acl_levels` AS `tl` LEFT JOIN `sys_acl_levels_members` AS `tlm` ON `tl`.`ID`=`tlm`.`IDLevel` WHERE `tl`.`Active`='yes' AND (`tl`.`Purchasable`='yes' OR `tl`.`Name`='Promotion') AND `tlm`.`DateStarts` < NOW() AND (`tlm`.`DateExpires`>NOW() || ISNULL(`tlm`.`DateExpires`)) GROUP BY `tl`.`ID`"));
215  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'sex' AS `by`, `Sex` AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE NOT ISNULL(`Sex`) AND `Sex` <> '' AND `Couple` = 0 GROUP BY `Sex`"));
216  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'type' AS `by`, 'single' AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE `Couple`='0'"));
217  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'type' AS `by`, 'couple' AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE `Couple`<>'0' AND `Couple`>`ID`"));
218  $aItems = array_merge($aItems, $MySQL->getAll("SELECT 'role' AS `by`, 'admins' AS `value`, COUNT(`ID`) AS `count` FROM `Profiles` WHERE `Role` & " . CH_WSB_ROLE_ADMIN . ""));
219 
220  foreach($aItems as $aItem)
221  $aResult[] = array('link' => 'javascript:void(0)', 'on_click' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeFilterQlinks(\'' . strtolower($aItem['by']) . '\', \'' . strtolower($aItem['value']) . '\')', 'title' => _t('_adm_txt_mp_' . strtolower($aItem['value'])), 'count' => $aItem['count']);
222 
223  return array(
224  'styles_qlinks' => $sDefault != 'qlinks' ? "display: none;" : "",
225  'ch_repeat:content_qlinks' => $aResult
226  );
227 }
228 function getBlockBrowse($sDefault)
229 {
230  return array(
231  'styles_browse' => $sDefault != 'browse' ? "display: none;" : "",
232  'content_browse' => ''
233  );
234 }
235 function getBlockCalendar($sDefault)
236 {
237  return array(
238  'styles_calendar' => $sDefault != 'calendar' ? "display: none;" : "",
239  'content_calendar' => ''
240  );
241 }
242 function getBlockTags($sDefault)
243 {
244  $oTags = new ChTemplTags();
245  $oTags->setTemplateContent('<span class="one_tag" style="font-size:__tagSize__px;"><a href="javascript:void(0)" onclick="javascript:__tagHref__" title="__countCapt__: __countNum__">__tag__</a></span>');
246 
247  $aTags = $oTags->getTagList(array('type' => 'profile'));
248  return array(
249  'styles_tags' => $sDefault != 'tags' ? "display: none;" : "",
250  'content_tags' => $oTags->getTagsView($aTags, CH_WSB_ADM_MP_JS_NAME . '.changeFilterTags(\'{tag}\')')
251  );
252 }
253 function getBlockSearch($sDefault)
254 {
255  $aForm = array(
256  'form_attrs' => array(
257  'id' => 'adm-mp-search',
258  'action' => $GLOBALS['site']['url_admin'] . 'profiles.php',
259  'method' => 'post',
260  'enctype' => 'multipart/form-data',
261  'onsubmit' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeFilterSearch(); return false;'
262  ),
263  'inputs' => array (
264  'adm-mp-filter' => array(
265  'type' => 'text',
266  'name' => 'adm-mp-filter',
267  'caption' => _t('_adm_txt_mp_filter'),
268  'value' => '',
269  ),
270  'search' => array(
271  'type' => 'button',
272  'name' => 'search',
273  'value' => _t('_adm_btn_mp_search'),
274  'attrs' => array(
275  'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeFilterSearch()'
276  )
277  ),
278  )
279  );
280 
282  return array(
283  'styles_search' => $sDefault != 'search' ? "display: none;" : "",
284  'content_search' => $oForm->getCode()
285  );
286 }
287 
288 function getBlockSettings($sDefault)
289 {
290  ch_import('ChWsbAdminSettings');
291  $oSettings = new ChWsbAdminSettings(18);
292 
293  if (isset($_POST['save']) && isset($_POST['cat'])) {
294  $sResult = $oSettings->saveChanges($_POST);
295  }
296 
297  $s = $oSettings->getForm();
298  if ($sResult)
299  $s = $sResult . $s;
300 
301  return array(
302  'styles_settings' => $sDefault != 'settings' ? "display: none;" : "",
303  'content_settings' => $s
304  );
305 }
306 
307 
308 function PageCodeMembers($sDefaultCtl = CH_WSB_ADM_MP_CTL, $sDefaultView = CH_WSB_ADM_MP_VIEW)
309 {
310  $aTopMenu = array(
311  'view-type-simple' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeView(this);', 'title' => _t('_adm_btn_mp_simple'), 'active' => $sDefaultView == 'simple' ? 1 : 0),
312  'view-type-extended' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeView(this);', 'title' => _t('_adm_btn_mp_extended'), 'active' => $sDefaultView == 'extended' ? 1 : 0),
313  'view-type-geeky' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . CH_WSB_ADM_MP_JS_NAME . '.changeTypeView(this);', 'title' => _t('_adm_btn_mp_geeky'), 'active' => $sDefaultView == 'geeky' ? 1 : 0)
314  );
315 
316  $oPaginate = new ChWsbPaginate(array(
317  'per_page' => CH_WSB_ADM_MP_PER_PAGE,
318  'per_page_step' => CH_WSB_ADM_MP_PER_PAGE_STEP,
319  'on_change_per_page' => CH_WSB_ADM_MP_JS_NAME . '.changePerPage(this);'
320  ));
321 
322  $sSelected1 = '';
323  $sSelected2 = '';
324  $sSelected3 = '';
325  $sSelected4 = '';
326 
327  $sSelected = getParam('default_order_by');
328  if($sSelected == 'None') $sSelected1 = 'selected="selected"';
329  if($sSelected == 'User Name') $sSelected2 = 'selected="selected"';
330  if($sSelected == 'Last Join') $sSelected3 = 'selected="selected"';
331  if($sSelected == 'Last Activity') $sSelected4 = 'selected="selected"';
332 
333  $sTopControls = $GLOBALS['oAdmTemplate']->parseHtmlByName('mp_members_top_controls.html', array(
334  'change_order' => CH_WSB_ADM_MP_JS_NAME . '.changeOrder(this);',
335  'reload' => CH_WSB_ADM_MP_JS_NAME . '.reloadSelected();',
336  'selected1' => $sSelected1,
337  'selected2' => $sSelected2,
338  'selected3' => $sSelected3,
339  'selected4' => $sSelected4,
340  'per_page' => $oPaginate->getPages(),
341  ));
342 
343  $aResult = array(
344  'action_url' => $GLOBALS['site']['url_admin'] . 'profiles.php',
345  'ctl_type' => is_array($sDefaultCtl) && !empty($sDefaultCtl) ? $sDefaultCtl['ctl_type'] : $sDefaultCtl,
346  'view_type' => $sDefaultView,
347  'top_controls' => $sTopControls,
348  'loading' => LoadingBox('adm-mp-members-loading')
349  );
350 
351  foreach(array('simple', 'extended', 'geeky') as $sType)
352  if($sType == $sDefaultView) {
353  $aParams = array('view_type' => $sType);
354  if(is_array($sDefaultCtl) && !empty($sDefaultCtl))
355  $aParams = array_merge($aParams, $sDefaultCtl);
356 
357  $aResult = array_merge($aResult, array('style_' . $sType => '', 'content_' . $sType => getMembers($aParams)));
358  } else
359  $aResult = array_merge($aResult, array('style_' . $sType => 'display: none;', 'content_' . $sType => ''));
360 
361  return DesignBoxAdmin(_t('_adm_box_cpt_mp_members'), $GLOBALS['oAdmTemplate']->parseHtmlByName('mp_members.html', $aResult), $aTopMenu);
362 }
363 
364 function getMembers($aParams)
365 {
366  if(!isset($aParams['view_order']) || empty($aParams['view_order'])) {
367  $sSelected = getParam('default_order_by');
368  $aParams['view_order'] = 'ID';
369  if($sSelected == 'None') $aParams['view_order'] = 'ID';
370  if($sSelected == 'User Name') $aParams['view_order'] = 'NickName';
371  if($sSelected == 'Last Join') $aParams['view_order'] = 'DateReg DESC';
372  if($sSelected == 'Last Activity') $aParams['view_order'] = 'DateLastNav DESC';
373  }
374 
375  if(!isset($aParams['view_start']) || empty($aParams['view_start']))
376  $aParams['view_start'] = 0;
377 
378  if(!isset($aParams['view_per_page']) || empty($aParams['view_per_page']))
379  $aParams['view_per_page'] = CH_WSB_ADM_MP_PER_PAGE;
380 
381  $aParams['view_order_way'] = 'ASC';
382  if(!isset($aParams['view_order']) || empty($aParams['view_order']))
383  $aParams['view_order'] = 'ID';
384  else {
385  $aOrder = explode(' ', $aParams['view_order']);
386  if(count($aOrder) > 1) {
387  $aParams['view_order'] = $aOrder[0];
388  $aParams['view_order_way'] = $aOrder[1];
389  }
390  }
391 
393 
394  $sSelectClause = $sJoinClause = $sWhereClause = $sGroupClause = '';
395  if(isset($aParams['ctl_type'])) {
396  switch ($aParams['ctl_type']) {
397  case 'qlinks':
398  switch ($aParams['ctl_params']['by']) {
399  case 'status':
400  $sWhereClause .= " AND `tp`.`Status`='" . ucfirst($aParams['ctl_params']['value']) . "'";
401  break;
402  case 'featured':
403  $sWhereClause .= " AND `tp`.`Featured`='1'";
404  break;
405  case 'banned':
406  $sWhereClause .= " AND (`tbl`.`Time`='0' OR (`tbl`.`Time`<>'0' AND DATE_ADD(`tbl`.`DateTime`, INTERVAL `tbl`.`Time` HOUR)>NOW()))";
407  break;
408  case 'type':
409  $sWhereClause .= $aParams['ctl_params']['value'] == 'single' ? " AND `tp`.`Couple`='0'" : " AND `tp`.`Couple`<>'0' AND `tp`.`Couple`>`tp`.`ID`";
410  break;
411  case 'role':
412  $iRole = CH_WSB_ROLE_MEMBER;
413  if ($aParams['ctl_params']['value'] == 'admins') {
414  $iRole = CH_WSB_ROLE_ADMIN;
415  }
416 
417  $sWhereClause .= " AND `tp`.`Role` & " . $iRole . "";
418  break;
419  case 'sex':
420  $sWhereClause .= " AND LOWER(`tp`.`Sex`)='" . strtolower($aParams['ctl_params']['value']) . "' AND `tp`.`Couple` = 0 ";
421  break;
422  case 'membership':
423  $sWhereClause .= " AND LOWER(`tl`.`Name`)='" . strtolower($aParams['ctl_params']['value']) . "'";
424  break;
425  }
426  break;
427 
428  case 'tags':
429  $sWhereClause .= " AND `tp`.`Tags` LIKE '%" . $aParams['ctl_params']['value'] . "%'";
430  break;
431 
432  case 'search':
433  $sWhereClause .= " AND (
434  `tp`.`ID` LIKE '%" . $aParams['ctl_params']['value'] . "%' OR
435  `tp`.`NickName` LIKE '%" . $aParams['ctl_params']['value'] . "%' OR
436  `tp`.`Email` LIKE '%" . $aParams['ctl_params']['value'] . "%' OR
437  `tp`.`DescriptionMe` LIKE '%" . $aParams['ctl_params']['value'] . "%' OR
438  `tp`.`Tags` LIKE '%" . $aParams['ctl_params']['value'] . "%'
439  )";
440  break;
441 
442  case 'settings':
443  //$sWhereClause .= " AND `tp`.`Tags` LIKE '%" . $aParams['ctl_params']['value'] . "%'";
444  break;
445  }
446  }
447 
448  //--- Get Paginate ---//
449  $oPaginate = new ChWsbPaginate(array(
450  'start' => $aParams['view_start'],
451  'count' => (int)db_value("SELECT COUNT(`tp`.`ID`) FROM `Profiles` AS `tp` LEFT JOIN `sys_admin_ban_list` AS `tbl` ON `tp`.`ID`=`tbl`.`ProfID` LEFT JOIN `sys_acl_levels_members` AS `tlm` ON `tp`.`ID`=`tlm`.`IDMember` AND `tlm`.`DateStarts` < NOW() AND (`tlm`.`DateExpires`>NOW() || ISNULL(`tlm`.`DateExpires`)) LEFT JOIN `sys_acl_levels` AS `tl` ON `tlm`.`IDLevel`=`tl`.`ID` " . $sJoinClause . " WHERE 1 AND (`tp`.`Couple`=0 OR `tp`.`Couple`>`tp`.`ID`)" . $sWhereClause),
452  'per_page' => $aParams['view_per_page'],
453  'page_url' => $GLOBALS['site']['url_admin'] . 'profiles.php?start={start}',
454  'on_change_page' => CH_WSB_ADM_MP_JS_NAME . '.changePage({start})'
455  ));
456  $sPaginate = $oPaginate->getPaginate();
457 
458  //--- Get Controls ---//
459  $GLOBALS['oAdmTemplate']->addJsTranslation(array('_adm_btn_mp_ban_duration'));
460 
461  $aButtons = array(
462  'adm-mp-activate' => _t('_adm_btn_mp_activate'),
463  'adm-mp-deactivate' => _t('_adm_btn_mp_deactivate'),
464  'adm-mp-ban' => array(
465  'type' => 'submit',
466  'name' => 'adm-mp-ban',
467  'value' => _t('_adm_btn_mp_ban'),
468  'onclick' => 'onclick="javascript: return ' . CH_WSB_ADM_MP_JS_NAME . '.actionBan(this);"',
469  ),
470  'adm-mp-unban' => _t('_adm_btn_mp_unban'),
471  'adm-mp-confirm' => _t('_adm_btn_mp_confirm'),
472  'adm-mp-delete' => _t('_adm_btn_mp_delete'),
473  'adm-mp-delete-spammer' => _t('_adm_btn_mp_delete_spammer'),
474  'adm-mp-set-admin' => _t('_adm_btn_mp_set_admin'),
475  'adm-mp-unset-admin' => _t('_adm_btn_mp_unset_admin'),
476  );
477  $sControls = ChTemplSearchResult::showAdminActionsPanel('adm-mp-members-' . $aParams['view_type'], $aButtons, 'members');
478 
479  //--- Get Items ---//
480  $sQuery = "
481  SELECT
482  `tp`.`ID` as `id`,
483  `tp`.`NickName` AS `username`,
484  `tp`.`Sex` AS `sex`,
485  `tp`.`DateOfBirth` AS `date_of_birth`,
486  `tp`.`Country` AS `country`,
487  `tp`.`City` AS `city`,
488  `tp`.`DescriptionMe` AS `description`,
489  `tp`.`Email` AS `email`,
490  `tp`.`CurrentPageTitle` AS `pagetitle`,
491  DATE_FORMAT(`tp`.`DateReg`, '" . $sDateFormat . "' ) AS `registration`,
492  DATE_FORMAT(`tp`.`DateLastLogin`, '" . $sDateFormat . "' ) AS `last_login`,
493  DATE_FORMAT(`tp`.`DateLastNav`, '" . $sDateFormat . "' ) AS `last_activity`,
494  `tp`.`Status` AS `status`,
495  IF(`tbl`.`Time`='0' OR DATE_ADD(`tbl`.`DateTime`, INTERVAL `tbl`.`Time` HOUR)>NOW(), 1, 0) AS `banned`,
496  `tl`.`ID` AS `ml_id`,
497  IF(ISNULL(`tl`.`Name`),'', `tl`.`Name`) AS `ml_name`
498  " . $sSelectClause . "
499  FROM `Profiles` AS `tp`
500  LEFT JOIN `sys_admin_ban_list` AS `tbl` ON `tp`.`ID`=`tbl`.`ProfID`
501  LEFT JOIN `sys_acl_levels_members` AS `tlm` ON `tp`.`ID`=`tlm`.`IDMember` AND `tlm`.`DateStarts` < NOW() AND (`tlm`.`DateExpires`>NOW() || ISNULL(`tlm`.`DateExpires`))
502  LEFT JOIN `sys_acl_levels` AS `tl` ON `tlm`.`IDLevel`=`tl`.`ID`
503  " . $sJoinClause . "
504  WHERE
505  1 AND (`tp`.`Couple`=0 OR `tp`.`Couple`>`tp`.`ID`)" . $sWhereClause . "
506  " . $sGroupClause . "
507  ORDER BY `tp`.`" . $aParams['view_order'] . "` " . $aParams['view_order_way'] . "
508  LIMIT " . $aParams['view_start'] . ", " . $aParams['view_per_page'];
509  $aProfiles = $GLOBALS['MySQL']->getAll($sQuery);
510 
511  //--- Display ---//
512  $sFunction = 'getMembers' . ucfirst($aParams['view_type']);
513  return $sFunction($aProfiles, $sPaginate, $sControls);
514 }
515 
516 function getMembersGeeky($aProfiles, $sPaginate, $sControls)
517 {
518  $iEmailLength = 20;
519  $aItems = array();
520  foreach($aProfiles as $aProfile){
521  $sEmail = ( mb_strlen($aProfile['email']) > $iEmailLength ) ? mb_substr($aProfile['email'], 0, $iEmailLength) . '...' : $aProfile['email'];
522 
523  $aItems[$aProfile['id']] = array(
524  'id' => $aProfile['id'],
525  'username' => getNickName($aProfile['id']),
526  'email' => $sEmail,
527  'full_email' => $aProfile['email'],
528  'page' => $aProfile['pagetitle'],
529  'edit_link' => $GLOBALS['site']['url'] . 'pedit.php?ID=' . $aProfile['id'],
530  'edit_class' => (int)$aProfile['banned'] == 1 ? 'adm-mp-banned' : ($aProfile['status'] != 'Active' ? 'adm-mp-inactive' : 'adm-mp-active'),
531  'registration' => $aProfile['registration'],
532  'last_activity' => $aProfile['last_activity'],
533  'status' => $aProfile['status'],
534  'ml_id' => !empty($aProfile['ml_id']) ? (int)$aProfile['ml_id'] : 2,
535  'ml_name' => !empty($aProfile['ml_name']) ? $aProfile['ml_name'] : 'Standard'
536  );
537  }
538 
539  return $GLOBALS['oAdmTemplate']->parseHtmlByName('mp_members_geeky.html', array(
540  'ch_repeat:items' => array_values($aItems),
541  'paginate' => $sPaginate,
542  'control' => $sControls
543  ));
544 }
545 function getMembersSimple($aProfiles, $sPaginate, $sControls)
546 {
547  $aItems = array();
548  foreach($aProfiles as $aProfile)
549  $aItems[$aProfile['id']] = array(
550  'id' => $aProfile['id'],
551  'thumbnail' => get_member_thumbnail($aProfile['id'], 'none'),
552  'edit_link' => $GLOBALS['site']['url'] . 'pedit.php?ID=' . $aProfile['id'],
553  'edit_class' => (int)$aProfile['banned'] == 1 ? 'adm-mp-banned' : ($aProfile['status'] != 'Active' ? 'adm-mp-inactive' : 'adm-mp-active'),
554  'edit_width' => defined('CH_AVA_W') ? CH_AVA_W : 70,
555  'username' => getNickName($aProfile['id']),
556  'info' => $GLOBALS['oFunctions']->getUserInfo($aProfile['id'])
557  );
558 
559  return $GLOBALS['oAdmTemplate']->parseHtmlByName('mp_members_simple.html', array(
560  'ch_repeat:items' => array_values($aItems),
561  'paginate' => $sPaginate,
562  'control' => $sControls
563  ));
564 }
565 function getMembersExtended($aProfiles, $sPaginate, $sControls)
566 {
567  $aItems = array();
568  foreach($aProfiles as $aProfile)
569  $aItems[$aProfile['id']] = array(
570  'id' => $aProfile['id'],
571  'thumbnail' => get_member_thumbnail($aProfile['id'], 'none'),
572  'edit_link' => $GLOBALS['site']['url'] . 'pedit.php?ID=' . $aProfile['id'],
573  'edit_class' => (int)$aProfile['banned'] == 1 ? 'adm-mp-banned' : ($aProfile['status'] != 'Active' ? 'adm-mp-inactive' : 'adm-mp-active'),
574  'username' => getNickName($aProfile['id']),
575  'info' => $GLOBALS['oFunctions']->getUserInfo($aProfile['id']),
576  'description' => strmaxtextlen($aProfile['description'], 130),
577  );
578  return $GLOBALS['oAdmTemplate']->parseHtmlByName('mp_members_extended.html', array(
579  'ch_repeat:items' => array_values($aItems),
580  'paginate' => $sPaginate,
581  'control' => $sControls
582  ));
583 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
PageCodeMembers
PageCodeMembers($sDefaultCtl=CH_WSB_ADM_MP_CTL, $sDefaultView=CH_WSB_ADM_MP_VIEW)
Definition: profiles.php:308
CH_WSB_LOCALE_DATE
const CH_WSB_LOCALE_DATE
Definition: utils.inc.php:16
$oSettings
$oSettings
Definition: advanced_settings.php:20
$oAdmTemplate
$oAdmTemplate
Definition: admin_design.inc.php:18
ChTemplFormView
Definition: ChTemplFormView.php:11
activation_mail
activation_mail( $ID, $text=1)
Definition: admin.inc.php:63
TRUE
URI MungeSecretKey $secret_key</pre >< p > If the output is TRUE
Definition: URI.MungeSecretKey.txt:17
$_page
$_page
Definition: profiles.php:157
LoadingBox
LoadingBox($sName)
Definition: design.inc.php:185
ch_admin_profile_ban_control
ch_admin_profile_ban_control($iProfileId, $bBan=true, $iDuration=0)
Definition: admin.inc.php:415
getBlockBrowse
getBlockBrowse($sDefault)
Definition: profiles.php:228
$sResult
$sResult
Definition: advanced_settings.php:26
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
CH_WSB_ADM_MP_PER_PAGE_STEP
const CH_WSB_ADM_MP_PER_PAGE_STEP
Definition: profiles.php:33
$GLOBALS
$GLOBALS['iAdminPage']
Definition: profiles.php:10
ch_admin_profile_change_status
ch_admin_profile_change_status($mixedIds, $sStatus, $bSendActMail=FALSE)
Definition: admin.inc.php:436
php
$sCtlType
$sCtlType
Definition: profiles.php:37
CH_WSB_ADM_MP_PER_PAGE
const CH_WSB_ADM_MP_PER_PAGE
Definition: profiles.php:32
$iId
$iId
Definition: license.php:15
PageCodeControls
PageCodeControls($sDefault=CH_WSB_ADM_MP_CTL)
Definition: profiles.php:176
getBlockCalendar
getBlockCalendar($sDefault)
Definition: profiles.php:235
profile_delete
profile_delete($ID, $isDeleteSpammer=false)
Definition: admin.inc.php:316
CH_WSB_ADM_MP_JS_NAME
const CH_WSB_ADM_MP_JS_NAME
Definition: profiles.php:31
$sDefaultMemberMode
$sDefaultMemberMode
Definition: profiles.php:25
CH_WSB_ADM_MP_CTL
const CH_WSB_ADM_MP_CTL
Definition: profiles.php:29
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
getBlockSearch
getBlockSearch($sDefault)
Definition: profiles.php:253
$oForm
$oForm
Definition: host_tools.php:42
getBlockTags
getBlockTags($sDefault)
Definition: profiles.php:242
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
exit
exit
Definition: cart.php:21
$sType
$sType
Definition: actions.inc.php:11
$_GET
$_GET['debug']
Definition: index.php:67
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
$logged
$logged['admin']
Definition: profiles.php:35
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$aProfile
$aProfile
Definition: flash.php:14
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
strmaxtextlen
strmaxtextlen($sInput, $iMaxLen=60)
Definition: utils.inc.php:207
getMembersExtended
getMembersExtended($aProfiles, $sPaginate, $sControls)
Definition: profiles.php:565
getMembersSimple
getMembersSimple($aProfiles, $sPaginate, $sControls)
Definition: profiles.php:545
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
$iDefaultPerPage
$iDefaultPerPage
Definition: profiles.php:26
ChWsbPaginate
Definition: ChWsbPaginate.php:69
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
PageCodeAdmin
PageCodeAdmin($oTemplate=null)
Definition: admin_design.inc.php:45
$bResult
$bResult
Definition: get_file.php:11
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
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
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
getBlockQlinks
getBlockQlinks($sDefault)
Definition: profiles.php:202
CH_WSB_ROLE_MEMBER
const CH_WSB_ROLE_MEMBER
Definition: profiles.inc.php:16
ChWsbAdminSettings
Definition: ChWsbAdminSettings.php:35
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
$sDefaultOverViewMode
$sDefaultOverViewMode
Definition: profiles.php:24
CH_WSB_LOCALE_DB
const CH_WSB_LOCALE_DB
Definition: utils.inc.php:19
$s
$s
Definition: embed.php:13
$_page_cont
$_page_cont[$iNameIndex]
Definition: profiles.php:163
db_value
db_value($query, $bindings=[], $error_checking=true, $index=0)
Definition: db.inc.php:98
$iNameIndex
if(isset($_POST['save']) &&isset($_POST['cat'])) if(isset($_POST['adm-mp-activate']) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-deactivate']) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-ban']) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-unban']) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-set-admin']) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-unset-admin']) &&(bool) $_POST['members']) else if((isset($_POST['adm-mp-delete'])||isset($_POST['adm-mp-delete-spammer'])) &&(bool) $_POST['members']) else if(isset($_POST['adm-mp-confirm']) &&(bool) $_POST['members']) else if(isset($_POST['action']) && $_POST['action']=='get_members') else if(isset($_POST['action']) && $_POST['action']=='get_controls') if(isset($_GET['action']) && $_GET['action']=='browse') $iNameIndex
Definition: profiles.php:156
getLocaleFormat
getLocaleFormat($iCode=CH_WSB_LOCALE_DATE_SHORT, $iType=CH_WSB_LOCALE_PHP)
Definition: utils.inc.php:89
$aForm
$aForm
Definition: forgot.php:43
ChBaseSearchResult\showAdminActionsPanel
static showAdminActionsPanel($sWrapperId, $aButtons, $sCheckboxName='entry', $bSelectAll=true, $bSelectAllChecked=false, $sCustomHtml='')
Definition: ChBaseSearchResult.php:81
getMembersGeeky
getMembersGeeky($aProfiles, $sPaginate, $sControls)
Definition: profiles.php:516
CH_WSB_ADM_MP_VIEW
const CH_WSB_ADM_MP_VIEW
Definition: profiles.php:30
getUserInfo
$f getUserInfo
Definition: callback.php:18
getBlockSettings
getBlockSettings($sDefault)
Definition: profiles.php:288
ChWsbFormCheckerHelper
Definition: ChWsbForm.php:461
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
tags
AutoFormat AutoParagraph where double newlines are converted in to paragraphs whenever possible Auto</li >< li > Applies to elements or text with double newlines in nodes that allow paragraph tags
Definition: AutoFormat.AutoParagraph.txt:14
$sViewType
$sViewType
Definition: profiles.php:40
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
CH_WSB_ROLE_ADMIN
const CH_WSB_ROLE_ADMIN
Definition: profiles.inc.php:17
getMembers
getMembers($aParams)
Definition: profiles.php:364
$aCtlType
$aCtlType
Definition: profiles.php:38