XOOPS  2.6.0
user.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
13 
25 {
31  public function __construct(XoopsUser &$obj)
32  {
34  if ($obj->isNew()) {
35  //Add user
36  $uid_value = "";
37  $uname_value = "";
38  $name_value = "";
39  $email_value = "";
40  $email_cbox_value = 0;
41  $url_value = "";
42  $timezone_value = $xoops->getConfig('default_TZ');
43  $icq_value = "";
44  $aim_value = "";
45  $yim_value = "";
46  $msnm_value = "";
47  $location_value = "";
48  $occ_value = "";
49  $interest_value = "";
50  $sig_value = "";
51  $sig_cbox_value = 0;
52  $bio_value = "";
53  $rank_value = 0;
54  $mailok_value = 0;
55  $form_title = SystemLocale::ADD_USER;
56  $form_isedit = false;
57  $groups = array(FixedGroups::USERS);
58  } else {
59  //Edit user
60  $uid_value = $obj->getVar("uid", "E");
61  $uname_value = $obj->getVar("uname", "E");
62  $name_value = $obj->getVar("name", "E");
63  $email_value = $obj->getVar("email", "E");
64  $email_cbox_value = $obj->getVar("user_viewemail") ? 1 : 0;
65  $url_value = $obj->getVar("url", "E");
66  $timezone_value = $obj->getVar("timezone_offset");
67  $icq_value = $obj->getVar("user_icq", "E");
68  $aim_value = $obj->getVar("user_aim", "E");
69  $yim_value = $obj->getVar("user_yim", "E");
70  $msnm_value = $obj->getVar("user_msnm", "E");
71  $location_value = $obj->getVar("user_from", "E");
72  $occ_value = $obj->getVar("user_occ", "E");
73  $interest_value = $obj->getVar("user_intrest", "E");
74  $sig_value = $obj->getVar("user_sig", "E");
75  $sig_cbox_value = ($obj->getVar("attachsig") == 1) ? 1 : 0;
76  $bio_value = $obj->getVar("bio", "E");
77  $rank_value = $obj->rank(false);
78  $mailok_value = $obj->getVar('user_mailok', 'E');
79  $form_title = sprintf(SystemLocale::F_UPDATE_USER, $obj->getVar("uname"));
80  $form_isedit = true;
81  $groups = array_values($obj->getGroups());
82  }
83 
84  //Affichage du formulaire
85  parent::__construct($form_title, "form_user", "admin.php", "post", true);
86 
87  $this->addElement(new Xoops\Form\Text(XoopsLocale::USER_NAME, "username", 4, 25, $uname_value), true);
88  $this->addElement(new Xoops\Form\Text(XoopsLocale::NAME, "name", 5, 60, $name_value));
90  $email_text = new Xoops\Form\Text("", "email", 5, 60, $email_value);
91  $email_tray->addElement($email_text, true);
92  $email_cbox = new Xoops\Form\Checkbox("", "user_viewemail", $email_cbox_value);
93  $email_cbox->addOption(1, XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL);
94  $email_tray->addElement($email_cbox);
95  $this->addElement($email_tray, true);
96  $this->addElement(new Xoops\Form\Text(XoopsLocale::WEB_URL, "url", 5, 100, $url_value));
97  $this->addElement(new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, "timezone_offset", $timezone_value));
98  $this->addElement(new Xoops\Form\Text(XoopsLocale::ICQ, "user_icq", 3, 15, $icq_value));
99  $this->addElement(new Xoops\Form\Text(XoopsLocale::AIM, "user_aim", 3, 18, $aim_value));
100  $this->addElement(new Xoops\Form\Text(XoopsLocale::YIM, "user_yim", 3, 25, $yim_value));
101  $this->addElement(new Xoops\Form\Text(XoopsLocale::MSNM, "user_msnm", 3, 100, $msnm_value));
102  $this->addElement(new Xoops\Form\Text(XoopsLocale::LOCATION, "user_from", 5, 100, $location_value));
103  $this->addElement(new Xoops\Form\Text(XoopsLocale::OCCUPATION, "user_occ", 5, 100, $occ_value));
104  $this->addElement(new Xoops\Form\Text(XoopsLocale::INTEREST, "user_intrest", 5, 150, $interest_value));
105  $sig_tray = new Xoops\Form\ElementTray(XoopsLocale::SIGNATURE, "<br />");
106  $sig_tarea = new Xoops\Form\TextArea("", "user_sig", $sig_value, 5, 5);
107  $sig_tray->addElement($sig_tarea);
108  $sig_cbox = new Xoops\Form\Checkbox("", "attachsig", $sig_cbox_value);
109  $sig_cbox->addOption(1, XoopsLocale::ALWAYS_ATTACH_MY_SIGNATURE);
110  $sig_tray->addElement($sig_cbox);
111  $this->addElement($sig_tray);
112  $this->addElement(new Xoops\Form\TextArea(XoopsLocale::EXTRA_INFO, "bio", $bio_value, 5, 5));
113 
114  if ($xoops->isActiveModule('userrank')) {
115  $rank_select = new Xoops\Form\Select(XoopsLocale::RANK, "rank", $rank_value);
116  $ranklist = XoopsLists::getUserRankList();
117  $rank_select->addOption(0, "--------------");
118  if (count($ranklist) > 0) {
119  $rank_select->addOptionArray($ranklist);
120  }
121  $this->addElement($rank_select);
122  } else {
123  $this->addElement(new Xoops\Form\Hidden("rank", $rank_value));
124  }
125  // adding a new user requires password fields
126  if (!$form_isedit) {
127  $this->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, "password", 3, 32), true);
128  $this->addElement(new Xoops\Form\Password(XoopsLocale::RETYPE_PASSWORD, "pass2", 3, 32), true);
129  } else {
130  $this->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, "password", 3, 32));
131  $this->addElement(new Xoops\Form\Password(XoopsLocale::RETYPE_PASSWORD, "pass2", 3, 32));
132  }
133  $this->addElement(
134  new Xoops\Form\RadioYesNo(XoopsLocale::ONLY_USERS_THAT_ACCEPT_EMAIL, 'user_mailok', $mailok_value)
135  );
136 
137  //Groups administration addition XOOPS 2.0.9: Mith
138  $gperm_handler = $xoops->getHandlerGroupperm();
139  $group_select = array();
140  //If user has admin rights on groups
141  if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, $xoops->user->getGroups(), 1)) {
142  //add group selection
143  $group_select[] = new Xoops\Form\SelectGroup(XoopsLocale::GROUPS, 'groups', false, $groups, 5, true);
144  } else {
145  //add each user groups
146  foreach ($groups as $key => $group) {
147  $group_select[] = new Xoops\Form\Hidden('groups[' . $key . ']', $group);
148  }
149  }
150  foreach ($group_select as $group) {
151  $this->addElement($group);
152  unset($group);
153  }
154 
155  $this->addElement(new Xoops\Form\Hidden("fct", "users"));
156  $this->addElement(new Xoops\Form\Hidden("op", "users_save"));
157  $this->addElement(new Xoops\Form\Button("", "submit", XoopsLocale::A_SUBMIT, "submit"));
158 
159  if (!empty($uid_value)) {
160  $this->addElement(new Xoops\Form\Hidden("uid", $uid_value));
161  }
162  }
163 }
__construct(XoopsUser &$obj)
Definition: user.php:31
const A_SUBMIT
Definition: en_US.php:128
const ONLY_USERS_THAT_ACCEPT_EMAIL
Definition: en_US.php:885
static getInstance()
Definition: Xoops.php:160
$email_text
addElement(Element $formElement, $required=false)
Definition: Form.php:206
const F_UPDATE_USER
Definition: en_US.php:311
const USER_NAME
Definition: en_US.php:1083
rank()
Definition: user.php:224
$gperm_handler
getVar($key, $format= 's')
const TIME_ZONE
Definition: en_US.php:1052
const INTEREST
Definition: en_US.php:484
const ADD_USER
Definition: en_US.php:32
const OCCUPATION
Definition: en_US.php:872
getGroups()
Definition: user.php:177
const PASSWORD
Definition: en_US.php:895
$groups
const SIGNATURE
Definition: en_US.php:1005
const EXTRA_INFO
Definition: en_US.php:309
const GROUPS
Definition: en_US.php:456
$xoops
Definition: user.php:29
const XOOPS_SYSTEM_GROUP
Definition: constants.php:22
const ALWAYS_ATTACH_MY_SIGNATURE
Definition: en_US.php:67
const ALLOW_OTHER_USERS_TO_VIEW_EMAIL
Definition: en_US.php:60
const LOCATION
Definition: en_US.php:515
$email_tray
const RETYPE_PASSWORD
Definition: en_US.php:959