1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -----------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2006 BoonEx Group
|
---|
8 | * website : http://www.boonex.com/
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
---|
12 | * http://creativecommons.org/licenses/by/3.0/
|
---|
13 | *
|
---|
14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 | * See the Creative Commons Attribution 3.0 License for more details.
|
---|
17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
---|
18 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
19 | ***************************************************************************/
|
---|
20 |
|
---|
21 | require_once( 'inc/header.inc.php' );
|
---|
22 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
23 | require_once( BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php' );
|
---|
24 |
|
---|
25 | bx_import('BxDolPrivacy');
|
---|
26 | bx_import('BxTemplPrivacyView');
|
---|
27 |
|
---|
28 | check_logged();
|
---|
29 | if(!isLogged()) {
|
---|
30 | login_form();
|
---|
31 | exit;
|
---|
32 | }
|
---|
33 |
|
---|
34 | $iId = getLoggedId();
|
---|
35 | $oPrivacyView = new BxTemplPrivacyView($iId);
|
---|
36 |
|
---|
37 | if(isset($_POST['ps_action']) && $_POST['ps_action'] == 'get_chooser' && $iId != 0) {
|
---|
38 | $sPageName = (int)$_POST['ps_page_name'];
|
---|
39 | $iProfileId = (int)$_POST['ps_profile_id'];
|
---|
40 | $iBlockId = (int)$_POST['ps_block_id'];
|
---|
41 |
|
---|
42 | $oPrivacy = new BxDolPrivacy('sys_page_compose_privacy', 'id', 'user_id');
|
---|
43 |
|
---|
44 | $sCode = "";
|
---|
45 | $iMemberId = getLoggedId();
|
---|
46 | if($iMemberId == $iProfileId) {
|
---|
47 | $aSelect = $oPrivacy->getGroupChooser($iMemberId, $sPageName, 'view_block');
|
---|
48 |
|
---|
49 | $iCurGroupId = (int)$GLOBALS['MySQL']->getOne("SELECT `allow_view_block_to` FROM `sys_page_compose_privacy` WHERE `user_id`='" . $iMemberId . "' AND `block_id`='" . $iBlockId . "' LIMIT 1");
|
---|
50 | if($iCurGroupId == 0)
|
---|
51 | $iCurGroupId = (int)$aSelect['value'];
|
---|
52 |
|
---|
53 | $aItems = array();
|
---|
54 | foreach($aSelect['values'] as $aValue) {
|
---|
55 | if($aValue['key'] == $iCurGroupId)
|
---|
56 | $sAlt = $aValue['value'];
|
---|
57 | $aItems[] = array(
|
---|
58 | 'block_id' => $iBlockId,
|
---|
59 | 'group_id' => $aValue['key'],
|
---|
60 | 'class' => $aValue['key'] == $iCurGroupId ? 'dbPrivacyGroupActive' : 'dbPrivacyGroup',
|
---|
61 | 'title' => $aValue['value']
|
---|
62 | );
|
---|
63 | }
|
---|
64 |
|
---|
65 | $sCode = $GLOBALS['oSysTemplate']->parseHtmlByName('ps_page_menu.html', array('bx_repeat:items' => $aItems));
|
---|
66 | $sCode = PopupBox('dbPrivacyMenu' . $iBlockId, _t('_ps_bcpt_block_privacy'), $sCode);
|
---|
67 | }
|
---|
68 |
|
---|
69 | $oJson = new Services_JSON();
|
---|
70 | header('Content-Type:text/javascript');
|
---|
71 | echo $oJson->encode(array(
|
---|
72 | 'code' => !empty($sCode) ? 0 : 1,
|
---|
73 | 'data' => $sCode,
|
---|
74 | ));
|
---|
75 | exit;
|
---|
76 | }
|
---|
77 | else if (isset($_POST['ps_action']) && $_POST['ps_action'] == 'view_block' && $iId != 0) {
|
---|
78 | $iBlockId = (int)$_POST['ps_block_id'];
|
---|
79 | $iGroupId = (int)$_POST['ps_group_id'];
|
---|
80 |
|
---|
81 | $iPrivacyId = (int)$GLOBALS['MySQL']->getOne("SELECT `id` FROM `sys_page_compose_privacy` WHERE `user_id`='" . $iId . "' AND `block_id`='" . $iBlockId . "' LIMIT 1");
|
---|
82 | if($iPrivacyId != 0)
|
---|
83 | $sSql = "UPDATE `sys_page_compose_privacy` SET `allow_view_block_to`='" . $iGroupId . "' WHERE `id`='" . $iPrivacyId . "'";
|
---|
84 | else
|
---|
85 | $sSql = "INSERT INTO `sys_page_compose_privacy`(`user_id`, `block_id`, `allow_view_block_to`) VALUES('" . $iId . "', '" . $iBlockId . "', '" . $iGroupId . "')";
|
---|
86 |
|
---|
87 | $sGroupTitle = "";
|
---|
88 | if(($bResult = (int)$GLOBALS['MySQL']->query($sSql)) > 0) {
|
---|
89 | $aGroup = $GLOBALS['MySQL']->getRow("SELECT `id`, `title` FROM `sys_privacy_groups` WHERE `id`='" . $iGroupId . "' LIMIT 1");
|
---|
90 | $sGroupTitle = !empty($aGroup['title']) ? $aGroup['title'] : getParam('sys_ps_group_' . $aGroup['id'] . '_title');
|
---|
91 | }
|
---|
92 |
|
---|
93 | $oJson = new Services_JSON();
|
---|
94 | header('Content-Type:text/javascript');
|
---|
95 | echo $oJson->encode(array(
|
---|
96 | 'code' => $bResult ? 0 : 1,
|
---|
97 | 'group' => $sGroupTitle,
|
---|
98 | ));
|
---|
99 | exit;
|
---|
100 | }
|
---|
101 | else if(isset($_POST['ps_action']) && $_POST['ps_action'] == 'search') {
|
---|
102 | echo $oPrivacyView->searchMembers(isset($_POST['ps_value']) ? $_POST['ps_value'] : '');
|
---|
103 | exit;
|
---|
104 | }
|
---|
105 | else if(isset($_POST['ps_action']) && $_POST['ps_action'] == 'members') {
|
---|
106 | echo $oPrivacyView->getBlockCode_GetMembers(isset($_POST['ps_value']) ? (int)$_POST['ps_value'] : 0);
|
---|
107 | exit;
|
---|
108 | }
|
---|
109 | else if(isset($_POST['ps-add-members-add']) && !empty($_POST['ps-add-members-add'])) {
|
---|
110 | $iGroupId = !empty($_POST['ps-add-member-group']) ? (int)$_POST['ps-add-member-group'] : 0;
|
---|
111 | $aIds = !empty($_POST['ps-add-member-ids']) ? $_POST['ps-add-member-ids'] : array();
|
---|
112 | $oPrivacyView->addMembers($iGroupId, $aIds);
|
---|
113 | }
|
---|
114 | else if(isset($_POST['ps-del-members-delete']) && !empty($_POST['ps-del-members-delete'])) {
|
---|
115 | $iGroupId = !empty($_POST['ps-del-member-group']) ? (int)$_POST['ps-del-member-group'] : 0;
|
---|
116 | $aIds = !empty($_POST['ps-del-member-ids']) ? $_POST['ps-del-member-ids'] : array();
|
---|
117 | $oPrivacyView->deleteMembers($iGroupId, $aIds);
|
---|
118 | }
|
---|
119 | else if(isset($_POST['ps-my-groups-delete']) && !empty($_POST['ps-my-groups-delete'])) {
|
---|
120 | $aIds = !empty($_POST['ps-my-groups-ids']) ? $_POST['ps-my-groups-ids'] : array();
|
---|
121 | $oPrivacyView->deleteGroups($aIds);
|
---|
122 | }
|
---|
123 | else if(isset($_POST['ps-default-group-save']) && !empty($_POST['ps-default-group-save'])) {
|
---|
124 | $iId = !empty($_POST['ps-default-group-ids']) ? (int)$_POST['ps-default-group-ids'] : 0;
|
---|
125 | $oPrivacyView->setDefaultGroup($iId);
|
---|
126 | }
|
---|
127 | else if(isset($_POST['ps-default-values-save']) && !empty($_POST['ps-default-values-save'])) {
|
---|
128 | $oPrivacyView->setDefaultValues($_POST);
|
---|
129 | }
|
---|
130 |
|
---|
131 |
|
---|
132 | // --------------- page components
|
---|
133 | $iIndex = 82;
|
---|
134 | $_page['css_name'] = 'privacy_settings.css';
|
---|
135 | $_page['header'] = _t( "_ps_pcpt_privacy_settings" );
|
---|
136 | $_page['header_text'] = "";
|
---|
137 | $_page['name_index'] = $iIndex;
|
---|
138 | $_page_cont[$iIndex]['page_code_add_members'] = $oPrivacyView->getBlockCode_AddMembers();
|
---|
139 | $_page_cont[$iIndex]['page_code_delete_members'] = $oPrivacyView->getBlockCode_DeleteMembers();
|
---|
140 | $_page_cont[$iIndex]['page_code_my_groups'] = $oPrivacyView->getBlockCode_MyGroups();
|
---|
141 | $_page_cont[$iIndex]['page_code_create_group'] = $oPrivacyView->getBlockCode_CreateGroup();
|
---|
142 | $_page_cont[$iIndex]['page_code_default_group'] = $oPrivacyView->getBlockCode_DefaultGroup();
|
---|
143 | $_page_cont[$iIndex]['page_code_default_values'] = $oPrivacyView->getBlockCode_DefaultValues();
|
---|
144 |
|
---|
145 | // --------------- [END] page components
|
---|
146 |
|
---|
147 | PageCode();
|
---|
148 | // --------------- page components functions
|
---|
149 |
|
---|
150 | ?> |
---|