appdb/ ./preferences.php include/form_edit.php

WineHQ wineowner at wine.codeweavers.com
Tue Apr 17 18:21:34 CDT 2007


ChangeSet ID:	31048
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/04/17 18:21:34

Modified files:
	.              : preferences.php 
	include        : form_edit.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Allow setting admin privileges in the user mananger

Patch: http://cvs.winehq.org/patch.py?id=31048

Old revision  New revision  Changes     Path
 1.34          1.35          +24 -11     appdb/preferences.php
 1.11          1.12          +0 -12      appdb/include/form_edit.php

Index: appdb/preferences.php
diff -u -p appdb/preferences.php:1.34 appdb/preferences.php:1.35
--- appdb/preferences.php:1.34	17 Apr 2007 23:21:34 -0000
+++ appdb/preferences.php	17 Apr 2007 23:21:34 -0000
@@ -11,10 +11,9 @@
  *  - sUserEmail, e-mail address
  *  - sUserRealname, user's real name
  *  - sWineRelease, user's Wine release
- *  - sHasAdmin, "on" if user is an administrator
+ *  - bIsAdmin, true if user is an administrator
  * 
  * TODO:
- *  - rename sHasAdmin with bIsAdmin
  *  - document iLimit and sOrderBy
  *  - replace sOrderBy with iOrderBy and use constants for each accepted value
  *  - add a field to prefs_list to flag the user level for the pref
@@ -46,7 +45,7 @@ function build_prefs_list($oUser)
                     if($r->name == "debug")
                         continue;
             }
-                
+
             $input = html_select("pref_$r->name", explode('|', $r->value_list), 
                                  $oUser->getpref($r->name, $r->def_value));
             echo html_tr(array("&nbsp; $r->description", $input));
@@ -59,12 +58,22 @@ function show_user_fields($oUser)
     $sUserEmail = $oUser->sEmail;
     $sWineRelease = $oUser->sWineRelease;
     if($oUser->hasPriv("admin"))
-        $sHasAdmin = 'checked="true"';
+        $sAdminChecked = 'checked="true"';
     else
-        $sHasAdmin = "";
-    
+        $sAdminChecked = "";
+
     include(BASE."include/form_edit.php");
 
+    // Edit admin privilege
+    if($_SESSION['current']->hasPriv("admin"))
+    {
+        echo html_tr(array(
+                "&nbsp; Administrator",
+                "<input type=\"checkbox\" name=\"bIsAdmin\" value=\"true\" ".
+                        "$sAdminChecked />"
+                        ));
+    }
+
     echo "<tr><td>&nbsp; Wine version </td><td>";
     make_bugzilla_version_list("sWineRelease", $sWineRelease);
     echo "</td></tr>";
@@ -79,7 +88,7 @@ if($_SESSION['current']->hasPriv("admin"
    is_numeric($aClean['iUserId']) &&
    is_numeric($aClean['iLimit']) &&
    in_array($aClean['sOrderBy'],array("email","realname","created"))
-) 
+)
 {
     $oUser = new User($aClean['iUserId']);
 } else
@@ -123,14 +132,18 @@ if($aClean['sSubmit'] == "Update")
     if ($oUser->update() == SUCCESS)
     {
         addmsg("Preferences Updated", "green");
-        // we were managing an user, let's go back to the admin after updating tha admin status
-        if($oUser->iUserId == $aClean['iUserId'] && $_SESSION['current']->hasPriv("admin"))
+        // we were managing an user, let's go back to the admin after
+        // updating tha admin status
+        if($oUser->iUserId == $aClean['iUserId'] &&
+                $_SESSION['current']->hasPriv("admin"))
         {
-            if($aClean['sHasAdmin']=="on") 
+            if($aClean['bIsAdmin'] == "true") 
                 $oUser->addPriv("admin");
             else 
                 $oUser->delPriv("admin");
-            util_redirect_and_exit(BASE."admin/adminUsers.php?iUserId=".$oUser->iUserId."&sSearch=".$aClean['sSearch']."&iLimit=".$aClean['iLimit']."&sOrderBy=".$aClean['sOrderBy']."&sSubmit=true");
+            util_redirect_and_exit(BASE."admin/adminUsers.php?iUserId=".$oUser->iUserId.
+                    "&sSearch=".$aClean['sSearch']."&iLimit=".$aClean['iLimit'].
+                    "&sOrderBy=".$aClean['sOrderBy']."&sSubmit=true");
         }
     }
     else
Index: appdb/include/form_edit.php
diff -u -p appdb/include/form_edit.php:1.11 appdb/include/form_edit.php:1.12
--- appdb/include/form_edit.php:1.11	17 Apr 2007 23:21:34 -0000
+++ appdb/include/form_edit.php	17 Apr 2007 23:21:34 -0000
@@ -23,18 +23,6 @@ require_once(BASE."include/util.php");
     <td> &nbsp; Real Name </td>
     <td> <input type="text" name="sUserRealname" value="<?php echo $sUserRealname; ?>"> </td>
 </tr>
-<?php
-// if we manage another user we can give him administrator rights
-if($oUser->iUserId == $aClean['iUserId'])
-{
-?>
-<tr>
-    <td> &nbsp; Administrator </td>
-    <td> <input type="checkbox" name="sHasAdmin" "<?php echo $sHasAdmin; ?>" value="on"> </td>
-</tr>
-<?php
-}
-?>
 <tr>
     <td colspan=2>&nbsp;</td>
 </tr>



More information about the wine-cvs mailing list