cvs: pear /Perm_LiveUser/Admin/Auth/Container DB.php

From: Date: Tue, 17 Feb 2004 14:32:03 +0000
Subject: cvs: pear /Perm_LiveUser/Admin/Auth/Container DB.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-16621@lists.php.net to get a copy of this message
krausbn Tue Feb 17 09:32:03 2004 EDT Modified files: /pear/Perm_LiveUser/Admin/Auth/Container DB.php Log: is_active, owner_user_id and owner_group_id are optional in addUser() and getUsers() http://cvs.php.net/diff.php/pear/Perm_LiveUser/Admin/Auth/Container/DB.php?r1=1.34&r2=1.35&ty=u Index: pear/Perm_LiveUser/Admin/Auth/Container/DB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.34 pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.35 --- pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.34 Tue Feb 10 12:31:55 2004 +++ pear/Perm_LiveUser/Admin/Auth/Container/DB.php Tue Feb 17 09:32:03 2004 @@ -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: DB.php,v 1.34 2004/02/10 17:31:55 lsmith Exp $ + * @version $Id: DB.php,v 1.35 2004/02/17 14:32:03 krausbn Exp $ * @package LiveUser * @category authentication */ @@ -211,11 +211,34 @@ $authId = $this->dbc->nextId($this->authTable); } - if ($active == true) { - $active = 'Y'; - } else { - $active = 'N'; + // is_active, owner_user_id and owner_group_id are optional + $col = $val = ''; + + if (isset($this->authTableCols['is_active'])) { + if ($active == true) { + $active = 'Y'; + } else { + $active = 'N'; + } + $col[] = $this->authTableCols['is_active']; + $val[] = $this->dbc->quote($active); + } + + if (isset($this->authTableCols['owner_user_id'])) { + $col[] = $this->authTableCols['owner_user_id']; + $val[] = (int)$owner_user_id; + } + + if (isset($this->authTableCols['owner_group_id'])) { + $col[] = $this->authTableCols['owner_group_id']; + $val[] = (int)$owner_group_id; + } + + if (count($col) > 0) { + $col = ',' . implode(',', $col); + $val = ',' . implode(',', $val); } + // Register new user in auth table $query = ' @@ -224,19 +247,15 @@ ( ' . $this->authTableCols['user_id'] . ', ' . $this->authTableCols['handle'] . ', - ' . $this->authTableCols['passwd'] . ', - ' . $this->authTableCols['is_active'] . ', - ' . $this->authTableCols['owner_user_id'] . ', - ' . $this->authTableCols['owner_group_id'] . ' + ' . $this->authTableCols['passwd'] . ' + ' . $col . ' ) VALUES ( ' . $this->dbc->quote($authId) . ', ' . $this->dbc->quote($handle) . ', - ' . $this->dbc->quote($this->encryptPW($password)) . ', - ' . $this->dbc->quote($active) . ', - ' . (int)$owner_user_id . ', - ' . (int)$owner_group_id . ' + ' . $this->dbc->quote($this->encryptPW($password)) . ' + ' . $val . ' )'; $result = $this->dbc->query($query); @@ -415,8 +434,21 @@ return false; } - $fields = $where =''; + $fields = $where = ''; + + if (isset($this->authTableCols['is_active'])) { + $customFields[] = "CASE {$this->authTableCols['is_active']} + WHEN 'Y' THEN 1 + WHEN 'N' THEN 0 END + AS is_active"; + } + + if (isset($this->authTableCols['owner_user_id'])) + $customFields[] = $this->authTableCols['owner_group_id'] . 'AS owner_user_id'; + if (isset($this->authTableCols['owner_group_id'])) + $customFields[] = $this->authTableCols['owner_group_id'] . 'AS owner_group_id'; + if (sizeof($customFields) > 0) { $fields = ','; $fields .= implode(',', $customFields); @@ -428,7 +460,7 @@ if (is_array($v)) { $where .= $v['cond'] . " $f" . $v['op'] . $this->dbc->quote($v['value']); } else { - $where .= "$f=$v AND"; + $where .= $f.'='.$this->dbc->quote($v).' AND'; } } $where = substr($where, 0, -3); @@ -440,13 +472,7 @@ {$this->authTableCols['user_id']} AS auth_user_id, {$this->authTableCols['handle']} AS handle, {$this->authTableCols['passwd']} AS passwd, - {$this->authTableCols['lastlogin']} AS lastlogin, - CASE {$this->authTableCols['is_active']} - WHEN 'Y' THEN 1 - WHEN 'N' THEN 0 END - AS is_active, - {$this->authTableCols['owner_group_id']} AS owner_user_id, - {$this->authTableCols['owner_user_id']} AS owner_group_id + {$this->authTableCols['lastlogin']} AS lastlogin $fields FROM {$this->authTable}

« previous php.pear.cvs (#16621) next »