Cheetah
ChBasePrivacyView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPrivacyView');
9 ch_import('ChWsbPrivacySearch');
10 ch_import('ChTemplFormView');
11 
13 {
17  function __construct($iOwnerId)
18  {
19  parent::__construct($iOwnerId);
20  }
21  function getBlockCode_GetMembers($iGroupId)
22  {
23  $sSearchUnitTmpl = $this->getHtml('ps_search_unit.html');
24  $aIds = $this->_oDb->getMembersIds($iGroupId);
25 
26  $sResult = "";
27  foreach($aIds as $aId)
28  $sResult .= $this->parseHtmlByContent($sSearchUnitTmpl, array(
29  'action' => 'del',
30  'member_id' => $aId['id'],
31  'member_thumbnail' => get_member_thumbnail($aId['id'], 'none', true)
32  ));
33 
34  return $sResult;
35  }
37  {
38  $aForm = array(
39  'form_attrs' => array(
40  'id' => 'ps-search-member-form',
41  'name' => 'ps-search-member-form',
42  'action' => CH_WSB_URL_ROOT . 'member_privacy.php',
43  'method' => 'post'
44  ),
45  'params' => array (
46  'db' => array(),
47  ),
48  'inputs' => array (
49  'keyword' => array(
50  'type' => 'text',
51  'name' => 'keyword',
52  'caption' => _t("_ps_fcpt_keyword"),
53  'value' => '',
54  'checker' => array (
55  'func' => 'length',
56  'params' => array(3,64),
57  'error' => _t('_ps_ferr_incorrect_length'),
58  ),
59  'db' => array (),
60  ),
61  'search' => array(
62  'type' => 'button',
63  'name' => 'search',
64  'value' => _t("_ps_btncpt_search"),
65  'attrs' => array(
66  'onclick' => 'javascript: ps_ad_search()'
67  )
68  ),
69  )
70  );
72 
73  //--- Get Control ---//
74  $aButtons = array(
75  'ps-add-members-add' => _t('_ps_btncpt_add')
76  );
77  $sControl = ChWsbPrivacySearch::showAdminActionsPanel('ps-add-member-form', $aButtons, 'ps-add-member-ids');
78 
79  return PopupBox('ps-add-members', _t('_ps_bcpt_add_members'), $this->parseHtmlByName('ps_group_members.html', array(
80  'wnd_action' => 'add',
81  'ch_if:search_form' => array(
82  'condition' => true,
83  'content' => array(
84  'form' => $oForm->getCode(),
85  )
86  ),
87  'js_site_url' => CH_WSB_URL_ROOT,
88  'results' => '',
89  'control' => $sControl,
90  'loading' => LoadingBox('ps-add-members-loading')
91  )));
92  }
94  {
95  //--- Get Control ---//
96  $aButtons = array(
97  'ps-del-members-delete' => _t('_ps_btncpt_delete')
98  );
99  $sControl = ChWsbPrivacySearch::showAdminActionsPanel('ps-del-member-form', $aButtons, 'ps-del-member-ids');
100 
101  return PopupBox('ps-del-members', _t('_ps_bcpt_delete_members'), $this->parseHtmlByName('ps_group_members.html', array(
102  'wnd_action' => 'del',
103  'ch_if:search_form' => array(
104  'condition' => false,
105  'content' => array()
106  ),
107  'js_site_url' => CH_WSB_URL_ROOT,
108  'results' => '',
109  'control' => $sControl,
110  'loading' => LoadingBox('ps-add-members-loading')
111  )));
112  }
114  {
115  $aActions = $this->_oDb->getActions($this->_iOwnerId);
116  $aValues = $this->_getSelectItems(array('type' => 'extendable', 'owner_id' => $this->_iOwnerId));
117 
118  $aForm = array(
119  'form_attrs' => array(
120  'id' => 'ps-default-values-form',
121  'name' => 'ps-default-values-form',
122  'action' => CH_WSB_URL_ROOT . 'member_privacy.php',
123  'method' => 'post',
124  'enctype' => 'multipart/form-data'
125  ),
126  'params' => array(),
127  'inputs' => array()
128  );
129  $sModuleUri = '';
130  $bCollapsed = false;
131  foreach($aActions as $aAction) {
132  if($sModuleUri != $aAction['module_uri']) {
133  if(!empty($sModuleUri))
134  $aForm['inputs'][$sModuleUri . '_end'] = array(
135  'type' => 'block_end'
136  );
137  $aForm['inputs'][$aAction['module_uri'] . '_begin'] = array(
138  'type' => 'block_header',
139  'caption' => ChWsbModule::getTitle($aAction['module_uri']),
140  'collapsable' => true,
141  'collapsed' => $bCollapsed
142  );
143 
144  $sModuleUri = $aAction['module_uri'];
145  $bCollapsed = true;
146  }
147 
148  $sName = 'ps-default-values_' . $aAction['action_id'];
149  $aForm['inputs'][$sName] = array(
150  'type' => 'select',
151  'name' => $sName,
152  'caption' => _t($aAction['action_title']),
153  'value' => !empty($aAction['default_value']) ? $aAction['default_value'] : $aAction['action_default_value'],
154  'values' => $aValues,
155  'checker' => array (
156  'func' => 'length',
157  'params' => array(1,4),
158  'error' => _t('_ps_ferr_incorrect_select'),
159  )
160  );
161  }
162  $aForm['inputs'][$sModuleUri . '_end'] = array(
163  'type' => 'block_end'
164  );
165  $aForm['inputs']['owner_id'] = array(
166  'type' => 'hidden',
167  'name' => 'owner_id',
168  'value' => $this->_iOwnerId,
169  );
170  $aForm['inputs']['ps-default-values-save'] = array(
171  'type' => 'submit',
172  'name' => 'ps-default-values-save',
173  'value' => _t("_ps_btncpt_save")
174  );
176  $sContent = $oForm->getCode();
177 
178  $sContent = $this->parseHtmlByName('ps_default_values.html', array(
179  'form' => !empty($sContent) ? $sContent : MsgBox(_t('_Empty'))
180  ));
181  return DesignBoxContent( _t("_ps_bcpt_default_values"), $sContent, 1);
182  }
184  {
185  $sValue = $this->_oDb->getDefaultGroup($this->_iOwnerId);
186  $aValues = $this->_getSelectItems(array('type' => 'extendable', 'owner_id' => $this->_iOwnerId));
187 
188  $aForm = array(
189  'form_attrs' => array(
190  'id' => 'ps-default-group-form',
191  'name' => 'ps-default-group-form',
192  'action' => CH_WSB_URL_ROOT . 'member_privacy.php',
193  'method' => 'post',
194  'enctype' => 'multipart/form-data'
195  ),
196  'inputs' => array (
197  'ps-default-group-ids' => array(
198  'type' => 'select',
199  'name' => 'ps-default-group-ids',
200  'caption' => _t("_ps_fcpt_groups"),
201  'info' => _t("_ps_fnote_default_group"),
202  'value' => $sValue,
203  'values' => $aValues,
204  'checker' => array (
205  'func' => 'length',
206  'params' => array(1,4),
207  'error' => _t('_ps_ferr_incorrect_select'),
208  ),
209  ),
210  'ps-default-group-save' => array(
211  'type' => 'submit',
212  'name' => 'ps-default-group-save',
213  'value' => _t("_ps_btncpt_save")
214  ),
215  )
216  );
218  $sContent = $oForm->getCode();
219 
220  $sContent = $this->parseHtmlByName('ps_default_group.html', array(
221  'form' => !empty($sContent) ? $sContent : MsgBox(_t('_Empty'))
222  ));
223  return DesignBoxContent( _t("_ps_bcpt_default_group"), $sContent, 1);
224  }
226  {
227  $sExtendedTxt = _t("_ps_cpt_extended");
228 
229  //--- Get Content ---//
230  $aContent = array();
231  $aGroups = $this->_oDb->getGroupsBy(array('type' => 'owner', 'owner_id' => $this->_iOwnerId));
232  foreach($aGroups as $aGroup) {
233  if(!empty($aGroup['parent_id'])) {
234  $aParentGroup = $this->_oDb->getGroupsBy(array('type' => 'id', 'id' => $aGroup['parent_id']));
235 
236  $sTitle = ((int)$aParentGroup['owner_id'] == 0 ? _t('_ps_group_' . $aParentGroup['id'] . '_title') : $aParentGroup['title']);
237  $sExtend = ' ' . $sExtendedTxt . ' ';
238  $sExtend .= !empty($aParentGroup['home_url']) ? '<a href="' . CH_WSB_URL_ROOT . $aParentGroup['home_url'] . '" target="_blank">' . $sTitle . '</a>' : $sTitle;
239  }
240  $aContent[] = array(
241  'group_id' => $aGroup['id'],
242  'group_title' => $aGroup['title'],
243  'group_members' => $aGroup['members_count'],
244  'ch_if:extended' => array(
245  'condition' => !empty($aGroup['parent_id']),
246  'content' => array(
247  'group_extended' => $sExtend,
248  )
249  ),
250  'add_img_url' => $sAddImgUrl,
251  'add_img_title' => $sAddImgTxt,
252  'delete_img_url' => $sDeleteImgUrl,
253  'delete_img_title' => $sDeleteImgTxt
254  );
255  }
256  //--- Get Control ---//
257  $aButtons = array(
258  'ps-my-groups-delete' => _t('_ps_btncpt_delete')
259  );
260  $sControl = ChWsbPrivacySearch::showAdminActionsPanel('ps-my-groups-form', $aButtons, 'ps-my-groups-ids');
261 
262  $sContent = $this->parseHtmlByName('ps_my_groups.html', array(
263  'ch_repeat:groups' => !empty($aContent) ? $aContent : MsgBox(_t('_Empty')),
264  'control' => $sControl
265  ));
266  return DesignBoxContent( _t("_ps_bcpt_my_groups"), $sContent, 1);
267  }
268 
270  {
271  $sContent = "";
272  $aValues = array_merge(array('0' => _t('_ps_cpt_none')), $this->_getSelectItems(array('type' => 'extendable', 'owner_id' => $this->_iOwnerId)));
273 
274  $aForm = array(
275  'form_attrs' => array(
276  'id' => 'ps-create-group-form',
277  'name' => 'ps-create-group-form',
278  'action' => CH_WSB_URL_ROOT . 'member_privacy.php',
279  'method' => 'post',
280  'enctype' => 'multipart/form-data'
281  ),
282  'params' => array (
283  'db' => array(
284  'table' => 'sys_privacy_groups',
285  'key' => 'id',
286  'submit_name' => 'create'
287  ),
288  ),
289  'inputs' => array (
290  'owner_id' => array(
291  'type' => 'hidden',
292  'name' => 'owner_id',
293  'value' => $this->_iOwnerId,
294  'db' => array (
295  'pass' => 'Int',
296  ),
297  ),
298  'title' => array(
299  'type' => 'text',
300  'name' => 'title',
301  'caption' => _t("_ps_fcpt_title"),
302  'value' => '',
303  'checker' => array (
304  'func' => 'length',
305  'params' => array(3,64),
306  'error' => _t('_ps_ferr_incorrect_length'),
307  ),
308  'db' => array (
309  'pass' => 'Xss',
310  ),
311  ),
312  'parent_id' => array(
313  'type' => 'select',
314  'name' => 'parent_id',
315  'caption' => _t("_ps_fcpt_extends"),
316  'value' => '',
317  'values' => $aValues,
318  'checker' => array (
319  'func' => 'length',
320  'params' => array(1,4),
321  'error' => _t('_ps_ferr_incorrect_select'),
322  ),
323  'db' => array (
324  'pass' => 'Int',
325  ),
326  ),
327  'create' => array(
328  'type' => 'submit',
329  'name' => 'create',
330  'value' => _t("_ps_btncpt_create"),
331  ),
332  )
333  );
335  $oForm->initChecker();
336 
337  if($oForm->isSubmittedAndValid()) {
338  $iId = $oForm->insert();
339 
340  header('Location: ' . $oForm->aFormAttrs['action']);
341  exit;
342  } else
343  $sContent = $oForm->getCode();
344 
345  $sContent = $this->parseHtmlByName('ps_create_group.html', array(
346  'form' => !empty($sContent) ? $sContent : MsgBox(_t('_Empty'))
347  ));
348  return DesignBoxContent( _t("_ps_bcpt_create_group"), $sContent, 1);
349  }
350 }
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
ChTemplFormView
Definition: ChTemplFormView.php:11
ChWsbPrivacyView
Definition: ChWsbPrivacyView.php:13
LoadingBox
LoadingBox($sName)
Definition: design.inc.php:185
ChBasePrivacyView\getBlockCode_DefaultGroup
getBlockCode_DefaultGroup()
Definition: ChBasePrivacyView.php:183
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChBasePrivacyView\getBlockCode_CreateGroup
getBlockCode_CreateGroup()
Definition: ChBasePrivacyView.php:269
$sResult
$sResult
Definition: advanced_settings.php:26
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
$iId
$iId
Definition: license.php:15
ChBasePrivacyView\__construct
__construct($iOwnerId)
Definition: ChBasePrivacyView.php:17
ChBasePrivacyView\getBlockCode_MyGroups
getBlockCode_MyGroups()
Definition: ChBasePrivacyView.php:225
$oForm
$oForm
Definition: host_tools.php:42
ChWsbTemplate\parseHtmlByContent
parseHtmlByContent($sContent, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:687
exit
exit
Definition: cart.php:21
ChWsbPrivacyView\_getSelectItems
_getSelectItems($aParams)
Definition: ChWsbPrivacyView.php:61
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
$sTitle
$sTitle
Definition: actions.inc.php:13
ChWsbModule\getTitle
static getTitle($sUri)
Definition: ChWsbModule.php:136
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbTemplate\getHtml
getHtml($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:643
PopupBox
PopupBox($sName, $sTitle, $sContent, $aActions=array())
Definition: design.inc.php:189
$aForm
$aForm
Definition: forgot.php:43
ChBaseSearchResult\showAdminActionsPanel
static showAdminActionsPanel($sWrapperId, $aButtons, $sCheckboxName='entry', $bSelectAll=true, $bSelectAllChecked=false, $sCustomHtml='')
Definition: ChBaseSearchResult.php:81
ChBasePrivacyView\getBlockCode_DefaultValues
getBlockCode_DefaultValues()
Definition: ChBasePrivacyView.php:113
ChBasePrivacyView\getBlockCode_AddMembers
getBlockCode_AddMembers()
Definition: ChBasePrivacyView.php:36
ChBasePrivacyView
Definition: ChBasePrivacyView.php:13
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
ChBasePrivacyView\getBlockCode_GetMembers
getBlockCode_GetMembers($iGroupId)
Definition: ChBasePrivacyView.php:21
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChBasePrivacyView\getBlockCode_DeleteMembers
getBlockCode_DeleteMembers()
Definition: ChBasePrivacyView.php:93
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660