cvs: pear /Perm_LiveUser/Admin/Auth/Container MDB.php /Perm_LiveUser/Admin/Perm MDB_Common.php /Perm_LiveUser/Admin/Perm/Container MDB_Complex.php
MDB_Medium.php /Perm_LiveUser/Auth/Container MDB.php /Perm_LiveUser/Perm/Container MDB_Complex.php MDB_Medium.php MDB_Simple.php

From: Date: Tue, 30 Sep 2003 19:51:38 +0000
Subject: cvs: pear /Perm_LiveUser/Admin/Auth/Container MDB.php /Perm_LiveUser/Admin/Perm MDB_Common.php /Perm_LiveUser/Admin/Perm/Container MDB_Complex.php
MDB_Medium.php /Perm_LiveUser/Auth/Container MDB.php /Perm_LiveUser/Perm/Container MDB_Complex.php MDB_Medium.php MDB_Simple.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13197@lists.php.net to get a copy of this message
lsmith Tue Sep 30 15:51:38 2003 EDT Modified files: /pear/Perm_LiveUser/Perm/Container MDB_Simple.php MDB_Medium.php MDB_Complex.php /pear/Perm_LiveUser/Admin/Perm/Container MDB_Medium.php MDB_Complex.php /pear/Perm_LiveUser/Admin/Perm MDB_Common.php /pear/Perm_LiveUser/Admin/Auth/Container MDB.php /pear/Perm_LiveUser/Auth/Container MDB.php Log: - since MDB 1.x doesnt enforce the keys we have to do it manually in liveuser until we start using MDB 2.x - fixed missing checks of var values are arrays in front of foreach's (needs to be ported to DB container as well)

Index: pear/Perm_LiveUser/Perm/Container/MDB_Simple.php diff -u pear/Perm_LiveUser/Perm/Container/MDB_Simple.php:1.5 pear/Perm_LiveUser/Perm/Container/MDB_Simple.php:1.6 --- pear/Perm_LiveUser/Perm/Container/MDB_Simple.php:1.5 Fri Sep 12 08:57:13 2003 +++ pear/Perm_LiveUser/Perm/Container/MDB_Simple.php Tue Sep 30 15:51:34 2003 @@ -40,7 +40,7 @@ * - userrights * * @author Björn Kraus <krausbn@php.net> - * @version $Id: MDB_Simple.php,v 1.5 2003/09/12 12:57:13 lsmith Exp $ + * @version $Id: MDB_Simple.php,v 1.6 2003/09/30 19:51:34 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -136,6 +136,7 @@ return $result; } + $result = array_change_key_case($result); $this->permUserId = $result['userid']; $this->userType = $result['usertype']; Index: pear/Perm_LiveUser/Perm/Container/MDB_Medium.php diff -u pear/Perm_LiveUser/Perm/Container/MDB_Medium.php:1.4 pear/Perm_LiveUser/Perm/Container/MDB_Medium.php:1.5 --- pear/Perm_LiveUser/Perm/Container/MDB_Medium.php:1.4 Fri Sep 12 08:57:13 2003 +++ pear/Perm_LiveUser/Perm/Container/MDB_Medium.php Tue Sep 30 15:51:34 2003 @@ -43,7 +43,7 @@ * - AuthAreas * * @author Arnaud Limbourg - * @version $Id: MDB_Medium.php,v 1.4 2003/09/12 12:57:13 lsmith Exp $ + * @version $Id: MDB_Medium.php,v 1.5 2003/09/30 19:51:34 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -137,6 +137,7 @@ return $result; } + $result = array_change_key_case($result); $this->permUserId = $result['userid']; $this->userType = $result['usertype']; @@ -206,6 +207,7 @@ $allRights = array(); if(is_array($result)) { + $result = array_change_key_case($result); foreach ($result as $record) { $allRights[$record['rightid']] = 1; $this->groupIds = array($record['groupid']); Index: pear/Perm_LiveUser/Perm/Container/MDB_Complex.php diff -u pear/Perm_LiveUser/Perm/Container/MDB_Complex.php:1.5 pear/Perm_LiveUser/Perm/Container/MDB_Complex.php:1.6 --- pear/Perm_LiveUser/Perm/Container/MDB_Complex.php:1.5 Fri Sep 12 08:57:13 2003 +++ pear/Perm_LiveUser/Perm/Container/MDB_Complex.php Tue Sep 30 15:51:34 2003 @@ -47,7 +47,7 @@ * * @author Lukas Smith <smith@backendmedia.com> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: MDB_Complex.php,v 1.5 2003/09/12 12:57:13 lsmith Exp $ + * @version $Id: MDB_Complex.php,v 1.6 2003/09/30 19:51:34 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -142,6 +142,7 @@ if (MDB::isError($result)) { $success = $result; } else { + $result = array_change_key_case($result); $this->permUserId = $result['perm_user_id']; $this->userType = $result['type']; @@ -232,6 +233,7 @@ $result = $this->dbc->queryAll($query, array('integer', 'integer', 'boolean'), MDB_FETCHMODE_ASSOC); if (!MDB::isError($result)) { + $result = array_change_key_case($result); $allRights = array(); foreach ($result as $rdata) { @@ -256,6 +258,7 @@ if (MDB::isError($result2)) { break; } elseif (is_array($result2)) { + $result2 = array_change_key_case($result2); foreach ($result2 as $key => $val) { $impliedRights[$key] = $val; } @@ -334,6 +337,7 @@ $result = $this->dbc->queryAll($query, array('integer', 'integer', 'integer', 'boolean'), MDB_FETCHMODE_ASSOC); if (!MDB::isError($result)) { + $result = array_change_key_case($result); foreach($result as $grdata) { $currentGroup = $grdata['group_id']; $currentRight = $grdata['right_id']; @@ -357,6 +361,7 @@ if (MDB::isError($result2)) { break; } elseif( count($result2)>0 ) { + $result2 = array_change_key_case($result2); foreach ($result2 as $key => $val) { $impliedRights[$currentGroup][$key] = $val; } Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.6 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.7 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.6 Thu Sep 25 15:11:47 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php Tue Sep 30 15:51:35 2003 @@ -47,7 +47,7 @@ * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: MDB_Medium.php,v 1.6 2003/09/25 19:11:47 arnaud Exp $ + * @version $Id: MDB_Medium.php,v 1.7 2003/09/30 19:51:35 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_Container_MDB_Medium extends LiveUser_Admin_Perm_MDB_Common @@ -444,24 +444,25 @@ translations.section_type = '.LIVEUSER_SECTION_GROUP . ' AND translations.language_id = ' . $this->dbc->getIntegerValue($this->_langs[$this->getCurrentLanguage()]); - $_groups = $this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC); + $groups = $this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC); - if (MDB::isError($_groups)) { - return $_groups; + if (MDB::isError($groups)) { + return $groups; }; - if (!is_array($_groups)) { - return $_groups; + if (!is_array($groups)) { + return null; }; - $groups = array(); - foreach($_groups as $key => $value) { + $groups = array_change_key_case($groups); + $_groups = array(); + foreach($groups as $key => $value) { if (isset($options['with_rights'])) { $_options = $options; $_options['where_group_id'] = $value['group_id']; $value['rights'] = $this->getRights($_options); }; - $groups[$value['group_id']] = $value; + $_groups[$value['group_id']] = $value; }; return $groups; Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.9 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.10 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.9 Wed Sep 17 13:43:54 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php Tue Sep 30 15:51:35 2003 @@ -46,7 +46,7 @@ * @author Christian Dickmann <dickmann@php.net> * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> - * @version $Id: MDB_Complex.php,v 1.9 2003/09/17 17:43:54 arnaud Exp $ + * @version $Id: MDB_Complex.php,v 1.10 2003/09/30 19:51:35 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_Container_MDB_Complex extends LiveUser_Admin_Perm_MDB_Common @@ -675,24 +675,25 @@ translations.section_type = '.LIVEUSER_SECTION_GROUP . ' AND translations.language_id = ' . $this->dbc->getIntegerValue($this->_langs[$this->getCurrentLanguage()]); - $_groups = $this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC); + $groups = $this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC); if (MDB::isError($_groups)) { return $_groups; }; - if (!is_array($_groups)) { - return $_groups; + if (!is_array($groups)) { + return $nulls; }; - $groups = array(); - foreach($_groups as $key => $value) { + $groups = array_change_key_case($groups); + $_groups = array(); + foreach($groups as $key => $value) { if (isset($options['with_rights'])) { $_options = $options; $_options['where_group_id'] = $value['group_id']; $value['rights'] = $this->getRights($_options); }; - $groups[$value['group_id']] = $value; + $_groups[$value['group_id']] = $value; }; $query = 'SELECT @@ -707,23 +708,26 @@ return $subgroups; }; - foreach($groups as $id => $group) { - $in_array = false; - foreach($subgroups as $subgroup) { - if ($id == $subgroup['subgroup_id']) { - $in_array = true; - break; + if (is_array($subgroups)) { + $subgroups = array_change_key_case($subgroups); + foreach($_groups as $id => $group) { + $in_array = false; + foreach($subgroups as $subgroup) { + if ($id == $subgroup['subgroup_id']) { + $in_array = true; + break; + }; + }; + if (!$in_array) { + $result[$id] = $group; + $result[$id]['subgroups'] = $this->getGroups($options, $id); }; - }; - if (!$in_array) { - $result[$id] = $group; - $result[$id]['subgroups'] = $this->getGroups($options, $id); }; }; } else { foreach($subgroups as $subgroup) { if ($subgroup['group_id'] == $parentgroup) { - $result[$subgroup['subgroup_id']] = $groups[$subgroup['subgroup_id']]; + $result[$subgroup['subgroup_id']] = $_groups[$subgroup['subgroup_id']]; $result[$subgroup['subgroup_id']]['subgroups'] = $this->getGroups($options, $subgroup['subgroup_id']); }; }; Index: pear/Perm_LiveUser/Admin/Perm/MDB_Common.php diff -u pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.10 pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.11 --- pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.10 Sun Sep 21 11:37:52 2003 +++ pear/Perm_LiveUser/Admin/Perm/MDB_Common.php Tue Sep 30 15:51:36 2003 @@ -33,7 +33,7 @@ * MDB based containers used to maintain * the permission database. * - * @version $Id: MDB_Common.php,v 1.10 2003/09/21 15:37:52 arnaud Exp $ + * @version $Id: MDB_Common.php,v 1.11 2003/09/30 19:51:36 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_MDB_Common extends LiveUser_Admin_Perm_Common @@ -147,10 +147,12 @@ { if (sizeof($this->_langs) < 1) { $query = 'SELECT two_letter_name, language_id FROM ' . $this->prefix . 'languages'; - $this->_langs = $this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC, true); - if (MDB::isError($this->_langs)) { - return $this->_langs; + $langs = this->dbc->queryAll($query, null, MDB_FETCHMODE_ASSOC, true); + if (MDB::isError($langs)) { + return $langs; }; + $langs = array_change_key_case($langs); + $this->_langs = $langs; }; return true; } @@ -375,6 +377,7 @@ }; // Translation name (and comment) removed ... + $translations = array_change_key_case($translations); return $translation; } @@ -664,10 +667,13 @@ } // Delete all areas within the application - foreach($areas as $area) { - $res = $this->removeArea($area['area_id']); - if (MDB::isError($res)) { - return $res; + if ($areas) { + $areas = array_change_key_case($areas); + foreach($areas as $area) { + $res = $this->removeArea($area['area_id']); + if (MDB::isError($res)) { + return $res; + } } } @@ -1211,6 +1217,7 @@ return $applications; } + $applications = array_change_key_case($applications); return $applications; } @@ -1263,18 +1270,21 @@ } $_areas = array(); - foreach($areas as $key => $value) - { - $id = $value['area_id']; - $_areas[$id] = $value; - - if (isset($options['with_applications'])) { - $_areas[$id]['application'] = $this->getTranslation($value['application_id'], LIVEUSER_SECTION_APPLICATION); - if (MDB::isError($_areas[$id]['application'])) { - return $_areas[$id]['application']; - } + if (is_array($areas)) { + $areas = array_change_key_case($areas); + foreach($areas as $key => $value) + { + $id = $value['area_id']; + $_areas[$id] = $value; + + if (isset($options['with_applications'])) { + $_areas[$id]['application'] = $this->getTranslation($value['application_id'], LIVEUSER_SECTION_APPLICATION); + if (MDB::isError($_areas[$id]['application'])) { + return $_areas[$id]['application']; + } + }; }; - } + }; return $_areas; } @@ -1328,20 +1338,24 @@ }; }; - foreach($langs as $key => $value) { - unset($langs[$key]); - $code = $value['two_letter_code']; - unset($value['two_letter_code']); - $langs[$code] = $value; - - if ($options['with_translations'] == true) { - foreach($trans as $translation) { - if ($translation['native_language_id'] == $value['language_id']) { - $langs[$code]['translations'][$translation['two_letter_code']] = $translation['name']; + if (is_array($langs)) { + $langs = array_change_key_case($langs); + foreach($langs as $key => $value) { + unset($langs[$key]); + $code = $value['two_letter_code']; + unset($value['two_letter_code']); + $langs[$code] = $value; + + if ($options['with_translations'] == true && is_array($trans)) { + $rights = array_change_key_case($rights); + foreach($trans as $translation) { + if ($translation['native_language_id'] == $value['language_id']) { + $langs[$code]['translations'][$translation['two_letter_code']] = $translation['name']; + }; }; }; }; - } + }; return $langs; } @@ -1447,33 +1461,36 @@ }; $_rights = array(); - foreach($rights as $key => $value) - { - $id = $value['right_id']; - $_rights[$id] = $value; - - if (isset($options['with_areas'])) { - // Add area - $_rights[$id]['area'] = - $this->getTranslation($value['area_id'], LIVEUSER_SECTION_AREA); - - if (MDB::isError($_rights[$id]['area'])) { - return $_rights[$id]['area']; - }; - - if (isset($options['with_applications'])) { - // Add application - $_rights[$id]['application'] = - $this->getTranslation( - $value['application_id'], - LIVEUSER_SECTION_APPLICATION - ); - - if (MDB::isError($_rights[$id]['application'])) { - return $_rights[$id]['application']; + if (is_array($rights)) { + $rights = array_change_key_case($rights); + foreach($rights as $key => $value) + { + $id = $value['right_id']; + $_rights[$id] = $value; + + if (isset($options['with_areas'])) { + // Add area + $_rights[$id]['area'] = + $this->getTranslation($value['area_id'], LIVEUSER_SECTION_AREA); + + if (MDB::isError($_rights[$id]['area'])) { + return $_rights[$id]['area']; + }; + + if (isset($options['with_applications'])) { + // Add application + $_rights[$id]['application'] = + $this->getTranslation( + $value['application_id'], + LIVEUSER_SECTION_APPLICATION + ); + + if (MDB::isError($_rights[$id]['application'])) { + return $_rights[$id]['application']; + }; }; }; - }; + } } return $_rights; Index: pear/Perm_LiveUser/Admin/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.17 pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.18 --- pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.17 Fri Sep 26 10:32:15 2003 +++ pear/Perm_LiveUser/Admin/Auth/Container/MDB.php Tue Sep 30 15:51:36 2003 @@ -47,7 +47,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Bj?rn Kraus <krausbn@php.net> - * @version $Id: MDB.php,v 1.17 2003/09/26 14:32:15 lsmith Exp $ + * @version $Id: MDB.php,v 1.18 2003/09/30 19:51:36 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Auth_Container_MDB extends LiveUser_Admin_Auth_Common @@ -367,7 +367,10 @@ return $userData; } - return $userData; + if (!is_array($userData)) { + return null; + } + return $userData = array_change_key_case($userData); } // end func getAllUsers } ?> Index: pear/Perm_LiveUser/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Auth/Container/MDB.php:1.15 pear/Perm_LiveUser/Auth/Container/MDB.php:1.16 --- pear/Perm_LiveUser/Auth/Container/MDB.php:1.15 Fri Sep 26 10:32:16 2003 +++ pear/Perm_LiveUser/Auth/Container/MDB.php Tue Sep 30 15:51:38 2003 @@ -48,7 +48,7 @@ * 'allowDuplicateHandles' => 1); * * @author Markus Wolff <wolff@21st.de> - * @version $Id: MDB.php,v 1.15 2003/09/26 14:32:16 lsmith Exp $ + * @version $Id: MDB.php,v 1.16 2003/09/30 19:51:38 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -250,7 +250,7 @@ // If a user was found, read data into class variables and set // return value to true if (!MDB::isError($result) && is_array($result)) { - $udata = $result; + $udata = array_change_key_case($result); $this->handle = $udata['handle']; $this->passwd = $this->decryptPW($udata['passwd']);
« previous php.pear.cvs (#13197) next »