]> git.mjollnir.org Git - moodle.git/commitdiff
Mnet: Rename field: access to accessctrl for Oracle interop: MDL-8237
authordonal72 <donal72>
Tue, 23 Jan 2007 21:27:50 +0000 (21:27 +0000)
committerdonal72 <donal72>
Tue, 23 Jan 2007 21:27:50 +0000 (21:27 +0000)
admin/mnet/access_control.php
admin/user.php
auth/mnet/auth.php
lib/db/install.xml
lib/db/upgrade.php
mnet/lib.php
version.php

index debb9f04ce5189029cf8a39c5223aef69538046d..99c9cffc412c4b9d8151483c06ac7d8e5e2ad147 100644 (file)
@@ -60,15 +60,15 @@ if (!empty($action) and confirm_sesskey()) {
         case "acl":
         
             // require the access parameter, and it must be 'allow' or 'deny'
-            $access = trim(strtolower(required_param('access', PARAM_ALPHA)));
-            if ($access != 'allow' and $access != 'deny') {
+            $accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA)));
+            if ($accessctrl != 'allow' and $accessctrl != 'deny') {
                 error(get_string('invalidaccessparam', 'mnet') , '/admin/mnet/access_control.php');
             }
 
-            if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $access)) {
-                if ($access == 'allow') {
+            if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
+                if ($accessctrl == 'allow') {
                     redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
-                } elseif ($access == 'deny') {
+                } elseif ($accessctrl == 'deny') {
                     redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
                 }
             }
@@ -94,8 +94,8 @@ if ($form = data_submitted() and confirm_sesskey()) {
     if (empty($form->mnet_host_id)) {
         $formerror['mnet_host_id'] = get_string('selectahost','mnet');
     }
-    if (empty($form->access)) {
-        $formerror['access'] = get_string('selectaccesslevel','mnet'); ;
+    if (empty($form->accessctrl)) {
+        $formerror['accessctrl'] = get_string('selectaccesslevel','mnet'); ;
     }
 
     // process if there are no errors
@@ -107,10 +107,10 @@ if ($form = data_submitted() and confirm_sesskey()) {
         foreach ($usernames as $username) {
             $username = trim(moodle_strtolower($username));
             if (!empty($username)) {
-                if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->access)) {
-                    if ($form->access == 'allow') {
+                if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
+                    if ($form->accessctrl == 'allow') {
                         redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($username, $mnethosts[$form->mnet_host_id])));
-                    } elseif ($form->access == 'deny') {
+                    } elseif ($form->accessctrl == 'deny') {
                         redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($username, $mnethosts[$form->mnet_host_id])));
                     }
                 }
@@ -173,13 +173,13 @@ if (!$acl) {
     $table->align = array('left', 'left', 'center');
     $table->width = "95%";
     foreach ($acl as $aclrecord) {
-        if ($aclrecord->access == 'allow') {
+        if ($aclrecord->accessctrl == 'allow') {
             $accesscolumn = get_string('allow', 'mnet')
-                . " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;access=deny&amp;sesskey={$USER->sesskey}\">"
+                . " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;accessctrl=deny&amp;sesskey={$USER->sesskey}\">"
                 . get_string('deny', 'mnet') . "</a>)";
         } else {
             $accesscolumn = get_string('deny', 'mnet')
-                . " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;access=allow&amp;sesskey={$USER->sesskey}\">"
+                . " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;accessctrl=allow&amp;sesskey={$USER->sesskey}\">"
                 . get_string('allow', 'mnet') . "</a>)";
         }
         $deletecolumn = "<a href=\"?id={$aclrecord->id}&amp;action=delete&amp;sesskey={$USER->sesskey}\">"
@@ -221,12 +221,12 @@ choose_from_menu($mnethosts, 'mnet_host_id');
 
 // choose an access level
 echo " " . get_string('accesslevel', 'mnet') . ":\n";
-if (!empty($formerror['access'])) {
+if (!empty($formerror['accessctrl'])) {
     echo '<span class="error"> * </span>';
 }
 $accessmenu['allow'] = get_string('allow', 'mnet');
 $accessmenu['deny'] = get_string('deny', 'mnet');
-choose_from_menu($accessmenu, 'access');
+choose_from_menu($accessmenu, 'accessctrl');
 
 // submit button
 echo '<input type="submit" value="' . get_string('addtoacl', 'mnet') . '" />';
index f1d9aec397585fd496478c4c505b521a1a94bf27..5d74bc5859e4be22f9d71e2a712ab41b314e28f2 100644 (file)
             if (!is_mnet_remote_user($user)) {
                 error('Users in the MNET access control list must be remote MNET users.');
             }
-            $access = strtolower(required_param('access', PARAM_ALPHA));
-            if ($access != 'allow' and $access != 'deny') {
+            $accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA));
+            if ($accessctrl != 'allow' and $accessctrl != 'deny') {
                 error('Invalid access parameter.');
             }
             $aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid);
                 $aclrecord = new object();
                 $aclrecord->mnet_host_id = $user->mnethostid;
                 $aclrecord->username = $user->username;
-                $aclrecord->access = $access;
+                $aclrecord->accessctrl = $accessctrl;
                 if (!insert_record('mnet_sso_access_control', $aclrecord)) {
                     error("Database error - Couldn't modify the MNET access control list.");
                 }
             } else {
-                $aclrecord->access = $access;
+                $aclrecord->accessctrl = $accessctrl;
                 if (!update_record('mnet_sso_access_control', $aclrecord)) {
                     error("Database error - Couldn't modify the MNET access control list.");
                 }
             $mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name');
             notify("MNET access control list updated: username '$user->username' from host '"
                     . $mnethosts[$user->mnethostid]->name
-                    . "' access now set to '$access'.");
+                    . "' access now set to '$accessctrl'.");
         }
 
         // Carry on with the user listing
 
                 // for remote users, shuffle columns around and display MNET stuff
                 if (is_mnet_remote_user($user)) {
-                    $access = 'allow';
+                    $accessctrl = 'allow';
                     if ($acl = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid)) {
-                        $access = $acl->access;
+                        $accessctrl = $acl->accessctrl;
                     }
-                    $changeaccessto = ($access == 'deny' ? 'allow' : 'deny');
+                    $changeaccessto = ($accessctrl == 'deny' ? 'allow' : 'deny');
                     // delete button in confirm column - remote users should already be confirmed
                     // TODO: no delete for remote users, for now. new userid, delete flag, unique on username/host...
                     $confirmbutton = "";
                     // ACL in delete column
-                    $deletebutton = ucfirst($access);
+                    $deletebutton = get_string($accessctrl, 'mnet');
                     if (has_capability('moodle/user:delete', $sitecontext)) {
                         // TODO: this should be under a separate capability
-                        $deletebutton .= " (<a href=\"?acl={$user->id}&amp;access=$changeaccessto&amp;sesskey={$USER->sesskey}\">"
-                                . ucfirst($changeaccessto) . " access</a>)";
+                        $deletebutton .= " (<a href=\"?acl={$user->id}&amp;accessctrl=$changeaccessto&amp;sesskey={$USER->sesskey}\">"
+                                . get_string($changeaccessto, 'mnet') . " access</a>)";
                     }
                     // mnet info in edit column
                     $editbutton = $mnethosts[$user->mnethostid]->name;
index 5b23e27a84a0c0d7cacf819d0661fb52dfa13d3f..c3a0bb16cb5b276b119b11ebde8c59ff7fdfecee 100644 (file)
@@ -1307,12 +1307,12 @@ class auth_plugin_mnet
      * @return bool              Whether the user can login from the remote host
      */
     function can_login_remotely($username, $mnethostid) {
-        $access = 'allow';
+        $accessctrl = 'allow';
         $aclrecord = get_record('mnet_sso_access_control', 'username', $username, 'mnet_host_id', $mnethostid);
         if (!empty($aclrecord)) {
-            $access = $aclrecord->access;
+            $accessctrl = $aclrecord->accessctrl;
         }
-        return $access == 'allow';
+        return $accessctrl == 'allow';
     }
 }
 
index 5f9b4c5ea37f7f8abed92e74228e4ed9b5a94d9e..163602fea37a073bad2cfd2f864bd40fc89d3e55 100644 (file)
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Required ID field" NEXT="username"/>
         <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="Username" PREVIOUS="id" NEXT="mnet_host_id"/>
-        <FIELD NAME="mnet_host_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id of mnet host" PREVIOUS="username" NEXT="access"/>
-        <FIELD NAME="access" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="allow" SEQUENCE="false" ENUM="false" COMMENT="Whether or not this user/host can login" PREVIOUS="mnet_host_id"/>
+        <FIELD NAME="mnet_host_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id of mnet host" PREVIOUS="username" NEXT="accessctrl"/>
+        <FIELD NAME="accessctrl" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="allow" SEQUENCE="false" ENUM="false" COMMENT="Whether or not this user/host can login" PREVIOUS="mnet_host_id"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_sso_access_control table"/>
index fcb39fd66a6283086b954fcb40d2548364d67606..a6f91c1000de24ad1ce8e606abb90c8228a2a4ee 100644 (file)
@@ -578,6 +578,16 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && change_field_precision($table, $field);
     }
 
+    if ($result && $oldversion < 2007012400) {
+
+    /// Rename field access on table mnet_sso_access_control to accessctrl
+        $table = new XMLDBTable('mnet_sso_access_control');
+        $field = new XMLDBField('access');
+
+    /// Launch rename field accessctrl
+        $result = $result && rename_field($table, $field, 'accessctrl');
+    }
+
     return $result;
 
 }
index 61c9849f2a38416446e2918fa9159ba1c0cb07ed..8aba4009b6f4e4f5b71286a79e4764569225afc4 100644 (file)
@@ -461,11 +461,11 @@ function mnet_permit_rpc_call($includefile, $functionname, $class=false) {
     return RPC_OK;
 }
 
-function mnet_update_sso_access_control($username, $mnet_host_id, $access) {
+function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
     $mnethost = get_record('mnet_host', 'id', $mnet_host_id);
     if ($aclrecord = get_record('mnet_sso_access_control', 'username', $username, 'mnet_host_id', $mnet_host_id)) {
         // update
-        $aclrecord->access = $access;
+        $aclrecord->accessctrl = $accessctrl;
         if (update_record('mnet_sso_access_control', $aclrecord)) {
             add_to_log(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php',
                     "SSO ACL: $access user '$username' from {$mnethost->name}");
@@ -476,7 +476,7 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $access) {
     } else {
         // insert
         $aclrecord->username = $username;
-        $aclrecord->access = $access;
+        $aclrecord->accessctrl = $accessctrl;
         $aclrecord->mnet_host_id = $mnet_host_id;
         if ($id = insert_record('mnet_sso_access_control', $aclrecord)) {
             add_to_log(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php',
index d5bdd8cc88d0b9f478621e0e8ad82d138ebc3c36..e2778253e93db3c9b0d3bae283e7fe126906e987 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2007012101;  // YYYYMMDD = date
+   $version = 2007012400;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.8 dev';    // Human-friendly version name