[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/accounts/class.accounts_sql.php, 1.1.1.1.2.14
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/accounts/class.accounts_sql.php, 1.1.1.1.2.14 |
Date: |
Thu, 20 May 2004 15:06:19 -0000 |
Update of /api/accounts
Modified Files:
Branch: proposal-branch
class.accounts_sql.php
date: 2004/04/16 20:59:49; author: seek3r; state: Exp; lines: +64 -63
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/accounts/class.accounts_sql.php
diff -u api/accounts/class.accounts_sql.php:1.1.1.1.2.13
api/accounts/class.accounts_sql.php:1.1.1.1.2.14
--- api/accounts/class.accounts_sql.php:1.1.1.1.2.13 Sat Feb 28 23:03:01 2004
+++ api/accounts/class.accounts_sql.php Fri Apr 16 20:59:49 2004
@@ -36,26 +36,26 @@
function api_accounts()
{
$args = new safe_args();
- $args->set('account', '##REQUIRED##', 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('account', REQUIRED, 'any');
+ $args = $args->get(func_get_args());
- if (sanitize($args['account'],'number'))
+ if (validate($args['account'],'number'))
{
$this->account_id = intval($args['account']);
}
- elseif (sanitize($args['account'],'string'))
+ elseif (validate($args['account'],'string'))
{
$this->account_id =
$this->cross_reference($args['account']);
}
$this->data = $this->read_repository();
}
- function pre_serialize()
+ function __sleep()
{
// stub so its gets cache'd. No cleanup needed.
}
- function post_serialize()
+ function __wakeup()
{
}
@@ -65,7 +65,7 @@
if($GLOBALS['phpgw']->session->is_anon() &&
!isset($this->data['id']))
{
$this->data['id'] = 999999999;
- $this->data['lid'] =
$GLOBALS['phpgw_session']['session_lid'];
+ $this->data['lid'] =
$_SESSION['phpgw_session']['session_lid'];
$this->data['firstname'] = 'Anonymous';
$this->data['lastname'] = 'User';
$this->data['fullname'] = 'Anonymous User';
@@ -79,7 +79,7 @@
function read_repository()
{
- $dbresult = $GLOBALS['phpgw']->db->execute('SELECT *
FROM phpgw_accounts WHERE account_id=' . $this->account_id,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute('SELECT *
FROM phpgw_accounts WHERE account_id=' . $this->account_id);
$this->data['id'] =
$dbresult->fields['account_id'];
$this->data['lid'] =
$dbresult->fields['account_lid'];
@@ -96,31 +96,31 @@
function save_repository()
{
- $dbresult = $GLOBALS['phpgw']->db->execute("UPDATE
phpgw_accounts SET "
+ $dbresult = $GLOBALS['phpgw']->db->Execute("UPDATE
phpgw_accounts SET "
. "account_firstname='" .
$this->data['firstname'] . "',"
. "account_lastname='" .
$this->data['lastname'] . "',"
. "account_status='" . $this->data['status'] .
"',"
. "account_expires='" .
$this->db->to_timestamp($this->data['expires']) . "' "
. ($this->data['account_lid']?",
account_lid='".$this->data['account_lid']."'":'')
- . ' WHERE account_id=' .
$this->account_id,__LINE__,__FILE__);
+ . ' WHERE account_id=' . $this->account_id);
- return ($GLOBALS['phpgw']->db->Affected_Rows() ? True :
False);
+ return ($GLOBALS['phpgw']->db->Affected_Rows() ? true :
false);
}
function delete($account_id)
{
$args = new safe_args();
- $args->set('account_id', '##REQUIRED##', 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('account_id', REQUIRED, 'any');
+ $args = $args->get(func_get_args());
if ($GLOBALS['phpgw']->acl->check('.', 63))
{
- $GLOBALS['phpgw']->db->execute('DELETE FROM
phpgw_accounts WHERE account_id=' . $account_id);
- return ($GLOBALS['phpgw']->db->Affected_Rows()
? True : False);
+ $GLOBALS['phpgw']->db->Execute('DELETE FROM
phpgw_accounts WHERE account_id=' . $account_id);
+ return ($GLOBALS['phpgw']->db->Affected_Rows()
? true : false);
}
else
{
- return False;
+ return false;
}
}
@@ -128,7 +128,7 @@
{
$args = new safe_args();
$args->set('_type', 'both');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
switch ($args['_type'])
{
@@ -144,7 +144,7 @@
return -1;
}
- $dbresult = $GLOBALS['phpgw']->db->execute("select
count(*) from phpgw_accounts $whereclause",__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute("select
count(*) from phpgw_accounts $whereclause");
return $dbresult->fields[0];
}
@@ -153,12 +153,12 @@
{
$args = new safe_args();
$args->set('_type', 'both');
- $args->set('start', '##NOTSET##', 'any');
- $args->set('sort', '##NOTSET##', 'any');
- $args->set('order', '##NOTSET##', 'any');
- $args->set('query', '##NOTSET##', 'any');
- $args->set('offset', '##NOTSET##', 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('start', NOTSET, 'any');
+ $args->set('sort', NOTSET, 'any');
+ $args->set('order', NOTSET, 'any');
+ $args->set('query', NOTSET, 'any');
+ $args->set('offset', NOTSET, 'any');
+ $args = $args->get(func_get_args());
if (! $args['sort'])
{
@@ -209,13 +209,13 @@
{
$dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql,$args['offset'], $args['start']);
}
- elseif ($args['start'] != '##NOTSET##')
+ elseif ($args['start'] != NOTSET)
{
$dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql,$GLOBALS['phpgw_data']['user']['prefs']['api.maxmatchs'],
$args['start']);
}
else
{
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute($sql);
}
// Set to an array type, in case there are no results
@@ -247,14 +247,14 @@
$return_values = array();
foreach($account as $lid)
{
- $dbresult =
$GLOBALS['phpgw']->db->execute("select account_id from phpgw_accounts where
account_lid='$lid'",__LINE__,__FILE__);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("select account_id from phpgw_accounts where
account_lid='$lid'");
$return_values[$lid] =
$dbresult->fields['account_id'];
}
return $return_values;
}
else
{
- $dbresult =
$GLOBALS['phpgw']->db->execute("select account_id from phpgw_accounts where
account_lid='$account'",__LINE__,__FILE__);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("select account_id from phpgw_accounts where
account_lid='$account'");
return $dbresult->fields['account_id'];
}
}
@@ -266,14 +266,14 @@
$return_values = array();
foreach($account as $id)
{
- $dbresult =
$GLOBALS['phpgw']->db->execute("select account_lid from phpgw_accounts where
account_id='$id'",__LINE__,__FILE__);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("select account_lid from phpgw_accounts where
account_id='$id'");
$return_values[$id] =
$dbresult->fields['account_lid'];
}
return $return_values;
}
else
{
- $dbresult =
$GLOBALS['phpgw']->db->execute("select account_lid from phpgw_accounts where
account_id='$account'",__LINE__,__FILE__);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("select account_lid from phpgw_accounts where
account_id='$account'");
return $dbresult->fields['account_lid'];
}
}
@@ -281,8 +281,8 @@
function cross_reference()
{
$args = new safe_args();
- $args->set('account','##REQUIRED##','any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('account',REQUIRED,'any');
+ $args = $args->get(func_get_args());
switch (gettype($args['account']))
{
@@ -294,28 +294,28 @@
break;
case 'array':
// This will only detect the FIRST key,
if the others are wrong, well ... :P
- if (sanitize($account[0],'string'))
+ if (validate($account[0],'string'))
{
return
$this->name2id($args['account']);
}
- if (sanitize($account[0],'number'))
+ if (validate($account[0],'number'))
{
return
$this->id2name($args['account']);
}
break;
default:
- return False;
- $GLOBALS['msgbox']->add(lang('Unknown
parameter typed passed to cross_reference()'),__LINE__,__FILE__, 'debug');
+ return false;
+ $GLOBALS['msgbox']->add(lang('Unknown
parameter typed passed to cross_reference()'), 'debug');
}
}
function get_type($account_id)
{
- if (! sanitize($account_id,'number'))
+ if (! validate($account_id,'number'))
{
- return False;
+ return false;
}
if (isset($this->data['account_type']) && $account_id
== $this->account_id)
@@ -328,14 +328,14 @@
return $this->account_type_cache[$account_id];
}
- $dbresult = $GLOBALS['phpgw']->db->execute('SELECT
account_type FROM phpgw_accounts WHERE account_id=' .
$account_id,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute('SELECT
account_type FROM phpgw_accounts WHERE account_id=' . $account_id);
if($dbresult !== false)
{
$this->account_type_cache[$account_id] =
$dbresult->fields['account_type'];
}
else
{
- $this->account_type_cache[$account_id] = False;
+ $this->account_type_cache[$account_id] = false;
}
return $this->account_type_cache[$account_id];
@@ -344,41 +344,42 @@
function create()
{
$args = new safe_args();
- $args->set('account_lid', '##REQUIRED##');
- $args->set('account_type', '##REQUIRED##', 'any');
- $args->set('account_passwd', '##NOTSET##', 'any');
- $args->set('account_firstname', '##NOTSET##', 'any');
- $args->set('account_lastname', '##NOTSET##', 'any');
- $args->set('account_status', '##NOTSET##', 'any');
- $args->set('account_expires', '##NOTSET##', 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('account_lid', REQUIRED);
+ $args->set('account_type', REQUIRED, 'any');
+ $args->set('account_passwd', NOTSET, 'any');
+ $args->set('account_firstname', NOTSET, 'any');
+ $args->set('account_lastname', NOTSET, 'any');
+ $args->set('account_status', NOTSET, 'any');
+ $args->set('account_expires', NOTSET, 'any');
+ $args = $args->get(func_get_args());
if(is_object($GLOBALS['phpgw']->acl))
{
if(!$GLOBALS['phpgw']->acl->check('.',63))
{
- $GLOBALS['msgbox']->add('Only admins
can create accounts!',__LINE__,__FILE__, 'access');
- return False;
+ $GLOBALS['msgbox']->add('Only admins
can create accounts!', 'access');
+ return false;
}
}
-
- $GLOBALS['phpgw']->db->execute("SELECT * FROM
phpgw_accounts WHERE account_lid='" .
$args['account_lid']."'",__LINE__,__FILE__);
- if($dbresult === false)
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
account_id FROM phpgw_accounts WHERE account_lid='" . $args['account_lid']."'");
+ if($dbresult->EOF)
{
$sql = 'insert into phpgw_accounts
(account_lid, account_type, account_pwd, '
. "account_firstname, account_lastname,
account_status, account_expires) values ('"
. $args['account_lid'] . "','" .
$args['account_type'] . "','"
. md5($args['account_passwd']) . "','"
. $args['account_firstname']
. "','" . $args['account_lastname'] .
"','" . $args['account_status']
- . "','" .
$this->db->to_timestamp($args['account_expires']) . "')";
-
- $account_id =
$GLOBALS['phpgw']->db->Insert_ID();
-// $account_id =
$this->db->get_last_insert_id('phpgw_accounts','account_id');
-
- return $account_id;
+ . "'," .
$GLOBALS['phpgw']->db->dbtimestamp($args['account_expires']) . ")";
+
+ $GLOBALS['phpgw']->db->Execute($sql);
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT account_id FROM phpgw_accounts WHERE
account_lid='" . $args['account_lid']."'");
+ return $dbresult->fields['account_id'];
+ }
+ else
+ {
+ $GLOBALS['msgbox']->add('Account name
('.$args['account_lid'].') is already in use!', 'notice');
+ return false;
}
- $GLOBALS['msgbox']->add('Account name is already in
use!',__LINE__,__FILE__, 'notice');
- return False;
}
function auto_create($account_values)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/accounts/class.accounts_sql.php, 1.1.1.1.2.14,
nomail <=