|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Extended User Profile |
|
5
|
|
|
* |
|
6
|
|
|
* You may not change or alter any portion of this comment or credits |
|
7
|
|
|
* of supporting developers from this source code or any supporting source code |
|
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
* This program is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
|
14
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
|
15
|
|
|
* @since 2.3.0 |
|
16
|
|
|
* @author Jan Pedersen |
|
17
|
|
|
* @author Taiwen Jiang <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
23
|
|
|
xoops_cp_header(); |
|
24
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
25
|
|
|
$op = Request::getCmd('op', 'edit'); |
|
26
|
|
|
$perm_desc = ''; |
|
27
|
|
|
switch ($op) { |
|
28
|
|
|
case 'visibility': |
|
29
|
|
|
//redirect_header("fieldsvisibility.php", 0, _AM_SUICO_PROF_VISIBLE); |
|
30
|
|
|
header('Location: fieldsvisibility.php'); |
|
31
|
|
|
break; |
|
32
|
|
|
case 'edit': |
|
33
|
|
|
$title_of_form = _AM_SUICO_PROF_EDITABLE; |
|
34
|
|
|
$perm_name = 'profile_edit'; |
|
35
|
|
|
$restriction = 'field_edit'; |
|
36
|
|
|
$anonymous = false; |
|
37
|
|
|
break; |
|
38
|
|
|
case 'search': |
|
39
|
|
|
$title_of_form = _AM_SUICO_PROF_SEARCH; |
|
40
|
|
|
$perm_name = 'profile_search'; |
|
41
|
|
|
$restriction = ''; |
|
42
|
|
|
$anonymous = true; |
|
43
|
|
|
break; |
|
44
|
|
|
case 'access': |
|
45
|
|
|
$title_of_form = _AM_SUICO_PROF_ACCESS; |
|
46
|
|
|
$perm_name = 'profile_access'; |
|
47
|
|
|
$perm_desc = _AM_SUICO_PROF_ACCESS_DESC; |
|
48
|
|
|
$restriction = ''; |
|
49
|
|
|
$anonymous = true; |
|
50
|
|
|
break; |
|
51
|
|
|
} |
|
52
|
|
|
require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
|
53
|
|
|
$opform = new \XoopsSimpleForm('', 'opform', 'fieldspermissions.php', 'get'); |
|
54
|
|
|
$op_select = new \XoopsFormSelect('', 'op', $op); |
|
55
|
|
|
$op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
56
|
|
|
$op_select->addOption('visibility', _AM_SUICO_PROF_VISIBLE); |
|
57
|
|
|
$op_select->addOption('edit', _AM_SUICO_PROF_EDITABLE); |
|
58
|
|
|
$op_select->addOption('search', _AM_SUICO_PROF_SEARCH); |
|
59
|
|
|
$op_select->addOption('access', _AM_SUICO_PROF_ACCESS); |
|
60
|
|
|
$opform->addElement($op_select); |
|
61
|
|
|
$opform->display(); |
|
62
|
|
|
$module_id = $GLOBALS['xoopsModule']->getVar('mid'); |
|
63
|
|
|
require_once $GLOBALS['xoops']->path('/class/xoopsform/grouppermform.php'); |
|
64
|
|
|
$form = new \XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/fieldspermissions.php?op=' . $op, $anonymous); |
|
65
|
|
|
if ('access' === $op) { |
|
66
|
|
|
/** @var XoopsMemberHandler $memberHandler */ |
|
67
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
68
|
|
|
$glist = $memberHandler->getGroupList(); |
|
69
|
|
|
foreach (array_keys($glist) as $i) { |
|
70
|
|
|
if (XOOPS_GROUP_ANONYMOUS != $i) { |
|
71
|
|
|
$form->addItem($i, $glist[$i]); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} else { |
|
75
|
|
|
$profileHandler = $helper->getHandler('Profile'); |
|
76
|
|
|
$fields = $profileHandler->loadFields(); |
|
77
|
|
|
if ('search' !== $op) { |
|
78
|
|
|
foreach (array_keys($fields) as $i) { |
|
79
|
|
|
if ('' == $restriction || $fields[$i]->getVar($restriction)) { |
|
80
|
|
|
$form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} else { |
|
84
|
|
|
$searchable_types = [ |
|
85
|
|
|
'textbox', |
|
86
|
|
|
'select', |
|
87
|
|
|
'radio', |
|
88
|
|
|
'yesno', |
|
89
|
|
|
'date', |
|
90
|
|
|
'datetime', |
|
91
|
|
|
'timezone', |
|
92
|
|
|
'language', |
|
93
|
|
|
]; |
|
94
|
|
|
foreach (array_keys($fields) as $i) { |
|
95
|
|
|
if (in_array($fields[$i]->getVar('field_type'), $searchable_types, true)) { |
|
96
|
|
|
$form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
$form->display(); |
|
102
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
103
|
|
|
//xoops_cp_footer(); |
|
104
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: