4 Interfaces to user variables,
8 $ewiki_user_gui_fields = array(
9 "First Name" => "", "Middle Name" => "","Last Name" => "","Title" => "",
10 "Company" => "", "E-Mail Address" => "", "Phone Number" => "",
11 "Address" => "", "City" => "", "State" => "","Zip Code" => "",
14 $ewiki_t["en"]["USERDATAUPDATESUCCESS"] = "Your user data has been successfully updated.";
17 Add the pages you would like to use to your config file.
19 $ewiki_plugins["page"]["AdminFullUser"]="ewiki_page_uservars_full";
21 //The current search function has a bug in it, some web browsers (Mozilla at least)
22 //automatically convert "." to "_" in control names, use at your own risk.
23 //$ewiki_plugins["page"]["AdminSearchAccounts"]="ewiki_page_uservars_search";
24 $ewiki_plugins["page"]["UserInfo"]="ewiki_page_uservars_user";
27 /**admin fulluser gui for viewing all info about a specified user.
31 * @param string action
32 * @return string page output response
34 function ewiki_page_uservars_search($id, $data, $action)
40 $success=TRUE; //used for displaying update status
41 $editing=FALSE; //used for displaying update status
43 echo ewiki_make_title($id, "Search User Data", 2);
45 if(isset($_REQUEST['search_fieldname'])){ //set fieldname variable
46 $fieldname=$_REQUEST['search_fieldname'];
48 if(strlen($_REQUEST['search_fieldvalue'])){ //set fieldvalue variable
49 $fieldvalue=$_REQUEST['search_fieldvalue'];
52 if(isset($_REQUEST['submit_clearuservars'])){ //check if the user clicked the "Delete Selected" button
53 echo("Deleting user variables.... ");
54 $editing=TRUE; //we are performing an edit
55 foreach($_REQUEST as $request_key => $request_value){
56 if(strstr($request_key, "chk_")){ //find all checkboxes
57 $varname=substr($request_key,4); //strip chk_ from the beginning of the value
58 $username=$request_value;
59 if(!ewiki_clear_uservar($varname, $username)){ //clear the selected value
60 $success=FALSE; //there was an error
66 if(isset($_REQUEST['submit_changeaccount'])){ //check if we are modifying an existing field
67 $editing=TRUE; //we are performing an edit
68 foreach($_REQUEST as $request_key => $request_value){
69 if(strstr($request_key, "text_")){ //find all text boxes
70 $username=substr($request_key,5); //remove prefix text_ from value
71 if(!ewiki_set_uservar($fieldname, $request_value, $username)){ //set the desired information
78 if($editing){ //check to see if we performed an edit
79 echo ($success ? ewiki_t("USERDATASUCCESS") : $ewiki_errmsg); //if we did and there was an error display it, otherwise display success
82 if(!empty($fieldname)){
83 $userdata = ewiki_search_uservar($fieldname, $fieldvalue); //get data for the given fieldname/fieldvalue combination
87 <form method="post" action="">
89 <tr><td>Field Name</td><td><input type="text" name="search_fieldname"></td></tr>
90 <tr><td>Value</td><td><input type="text" name="search_fieldvalue"></td></tr>
92 <input value="Search" type="submit" name="submit_searchaccount" />
97 if(is_array($userdata)){
98 echo '<h4>Query Results</h4><form action="" method="post"><table border=1>';
99 echo '<tr><th>Select</th><th>UserID</th><th>'.$fieldname.'</th></tr>';
100 foreach($userdata as $username => $value){
102 <tr><td><input type="checkbox" name="chk_<?echo $fieldname?>" value="<?echo $username?>"></td><th><?echo $username?></th>
103 <td><input type="text" name="text_<?echo $username?>" value="<?echo $value?>"></td></tr>
108 <input value="<?echo $fieldname?>" type="hidden" name="search_fieldname">
109 <input value="<?echo $fieldvalue?>" type="hidden" name="search_fieldvalue">
110 <input value="Submit Changes" type="submit" name="submit_changeaccount" />
111 <input value="Delete Selected" type="submit" name="submit_clearuservars" />
116 $o = ob_get_contents();
121 /**admin fulluser gui for viewing all info about a specified user.
125 * @param string action
126 * @return string page output response
128 function ewiki_page_uservars_full($id, $data, $action)
130 global $ewiki_errmsg;
136 // resolve username if none submitted use current username
137 if(isset($_REQUEST['accountname_text'])){
138 $user=$_REQUEST['accountname_text'];
140 $user =$GLOBALS['ewiki_auth_user'];
143 echo ewiki_make_title($id, "User info for $user", 2);
146 // check to see if we are clearing fields
147 if(isset($_REQUEST['submit_clearuservars'])){ //check if we are clearing values
148 $editing=TRUE; //we are editing
149 foreach($_REQUEST as $request_key => $request_value){
150 if(strstr($request_key, "chk_") && $request_value ="on"){ //only use chk_ inputs
151 $varname=substr($request_key,4); //remove the chk_ prefix
152 if(!ewiki_clear_uservar($varname, $user)){ //clear the selected values
153 $success=FALSE; //there was an error
157 } elseif(isset($_REQUEST['submit_changeaccount'])){ //check to see if we are editing fields
159 foreach($_REQUEST as $request_key => $request_value){
160 if(strstr($request_key, "text_")){ //only work on fields with the text_ prefix
161 $varname=substr($request_key,5); //remove the text_ prefix
162 if(!ewiki_set_uservar($varname, $request_value, $user)){ //set appropriate data
166 } //check to see if we are adding/editing a group of fields
167 } elseif(isset($_REQUEST['submit_batchfields']) && !empty($_REQUEST['batch_fieldnames']) && !empty($_REQUEST['batch_fieldvalues'])){
169 $newfields = explode("\n", $_REQUEST['batch_fieldnames']); //split up the batch
170 $newvalues = explode("\n", $_REQUEST['batch_fieldvalues']); //split up the batch
171 foreach($newfields as $key => $field){
173 $value=(isset($newvalues[$key])?trim($newvalues[$key]):"");
174 if(strlen($field)){ //cannot add blank fieldnames
175 if(!ewiki_set_uservar($field, $value, $user)){
179 } //check if we are adding multiple users
180 } elseif(isset($_REQUEST['submit_batchusers']) && !empty($_REQUEST['batch_usernames']) && !empty($_REQUEST['text_fieldname'])){
181 $newusers=explode("\n", $_REQUEST['batch_usernames']);
182 $field=trim($_REQUEST['text_fieldname']);
183 $value=trim($_REQUEST['text_fieldvalue']);
184 foreach($newusers as $username){
185 $username=trim($username);
186 if(!ewiki_set_uservar($field, $value, $username)){
190 } elseif(isset($_REQUEST['submit_bulkset']) && strlen($_REQUEST['bulk_items'])){
192 $bulk=explode("\n", $_REQUEST['bulk_items']);
193 foreach($bulk as $items){
194 $values=explode(",", $items);
195 $username=trim($values[0]);
196 $varname=trim($values[1]);
197 $value=trim($values[2]);
198 if(strlen($varname)){
199 if(!ewiki_set_uservar($varname, $value, $username)){
204 } elseif(isset($_REQUEST['submit_accountaddfield']) && !empty($_REQUEST['new_accountfield']) && !empty($_REQUEST['new_accountfield'])){
206 if(!ewiki_set_uservar($_REQUEST['new_accountfield'], $_REQUEST['new_accountfieldvalue'], $user)){
213 echo ($success ? ewiki_t("USERDATASUCCESS") : $ewiki_errmsg);
216 $account_uservars=ewiki_getall_uservar($user);
219 <form method="post" action="">
220 <p>User Name <input type="text" name="accountname_text"><input value="View Info" type="submit" name="submit_viewaccount" /></p>
222 <h3>User Information</h3>
223 <p><form method="post" action=""><table border="1" cellpadding="1">
225 if(!empty($account_uservars)){
226 foreach($account_uservars as $field => $value){
227 echo '<tr><td><input type="checkbox" name="chk_'.$field.'"></td><th>'.$field.'</th>'.
228 '<td><input name="text_'.$field.'" type="text" value="'.$value.'"></td></tr>';
232 <input value="Submit Changes" type="submit" name="submit_changeaccount" />
233 <input value="Delete Selected" type="submit" name="submit_clearuservars" />
234 <input value="<?echo $user?>" type="hidden" name="accountname_text">
236 <h3>Add/Edit a Field</h3>
237 <form method="post" action="">
238 <input value="<?echo $user?>" type="hidden" name="accountname_text">
240 <tr><td>Field Name</td><td><input type="text" name="new_accountfield"></td></tr>
241 <tr><td>Value</td><td><input type="text" name="new_accountfieldvalue"></td></tr>
243 <input type="submit" value="Add Field" name="submit_accountaddfield" />
245 <h3>Add/Edit Multiple Fields</h3>
246 <p>On the left insert one field name per line. On the right insert
247 a corresponding field value for the field. These will be processed
248 as a batch and each field will be created with its corresponding
250 <form method="post" action="">
251 <input value="<?echo $user?>" type="hidden" name="accountname_text">
253 <tr><td><textarea name="batch_fieldnames" rows="10" cols="25"></textarea></td>
254 <td><textarea name="batch_fieldvalues" rows="10" cols="25"></textarea></td></tr>
256 <input type="submit" name="submit_batchfields" value="Add Fields">
258 <h3>Add Field to Multiple Users</h3>
259 <p>In the box below, insert one username per line. Then insert a field
260 name and an optional value for that field. That field with that value
261 will be added to all of the users in the box.</p>
262 <form method="post" action="">
263 <input value="<?echo $user?>" type="hidden" name="accountname_text">
265 <tr><td colspan=2>User Names:</td></tr><tr><td colspan=2><textarea name="batch_usernames" rows="10" cols="24"></textarea></td></tr>
266 <tr><td>Field Name</td><td><input type="text" name="text_fieldname"></td></tr><tr><td>Field Value</td><td><input type="text" name="text_fieldvalue"></td></tr>
268 <input type="submit" name="submit_batchusers" value="Add Fields">
271 <p>In the box below insert username,fieldname,value. Only one per line.</p>
272 <form method="post" action="">
273 <input value="<?echo $user?>" type="hidden" name="accountname_text">
275 <tr><td><textarea name="bulk_items" rows="10" cols="50"></textarea></td></tr>
277 <input type="submit" name="submit_bulkset" value="Submit Bulk">
280 $o = ob_get_contents();
285 /**user gui for viewing predetermined user fields for current user only.
289 * @param string action
290 * @return string page output response
292 function ewiki_page_uservars_user($id, $data, $action)
294 global $ewiki_errmsg, $ewiki_user_gui_fields;
298 //set user name to currently logged in user
299 $user =$GLOBALS['ewiki_auth_user'];
301 $o = ewiki_make_title($id, "User info for $user", 2);
303 //check to see if we are editing fields and that we have a username
304 if(isset($_REQUEST['submit_changeaccount']) && !empty($user)){
306 foreach($_REQUEST as $request_key => $request_value){
307 if(strstr($request_key, "text_")){ //only use the text_ inputs
308 $varname=substr($request_key,5); //remove the text_ prefix
309 if(!ewiki_set_uservar($varname, $request_value, $user)){ //set the appropriate info
310 $success=FALSE; //something failed
314 $o .= ($success ? ewiki_t("USERDATAUPDATESUCCESS") : $ewiki_errmsg);
317 $account_uservars=ewiki_getall_uservar($user); //get user info
320 if(!empty($account_uservars)){ //if data exists for this user
321 $o .= '<p><form method="post" action=""><table border="1" cellpadding="1">';
322 foreach($account_uservars as $field => $value){
323 if(isset($ewiki_user_gui_fields[$field])){ //check if this is a field we want the user to be able to edit
324 $o .= '<tr><th>'.$field.'</th><td><input name="text_'.$field.'" type="text" value="'.$value.'"></td></tr>';
328 '<input value="Submit Changes" type="submit" name="submit_changeaccount" />'.
331 $o .= ewiki_t("USERDATANODATA");