changed the following table-names:

- phpgw_accounts --> egw_accounts
- phpgw_acl --> egw_acl
- phpgw_log(_msg) --> egw_log(_msg)
- phpgw_config --> egw_config
- phpgw_applications --> egw_applications
This requires code-changes in many apps. Quite often I was able to replace the db access, with calls to the appropreate classes.
This commit is contained in:
Ralf Becker 2005-11-02 11:45:52 +00:00
parent 0db87ad750
commit c85d34c0fe
52 changed files with 1224 additions and 1312 deletions

View File

@ -38,7 +38,7 @@ else
if (($all_accounts = $GLOBALS['egw']->accounts->search(array('type'=>'both')))) if (($all_accounts = $GLOBALS['egw']->accounts->search(array('type'=>'both'))))
{ {
$all_accounts = array_keys($all_accounts); $all_accounts = array_keys($all_accounts);
$GLOBALS['egw']->db->query("DELETE FROM phpgw_acl WHERE acl_account NOT IN (".implode(',',$all_accounts).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$all_accounts)."')",__LINE__,__FILE__); $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$all_accounts).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$all_accounts)."')",__LINE__,__FILE__);
$deleted = $GLOBALS['egw']->db->affected_rows(); $deleted = $GLOBALS['egw']->db->affected_rows();
} }
echo '<p align="center">'.lang('%1 ACL records of not (longer) existing accounts deleted.',$deleted)."</p>\n"; echo '<p align="center">'.lang('%1 ACL records of not (longer) existing accounts deleted.',$deleted)."</p>\n";

View File

@ -85,14 +85,6 @@
$account_id = (int)$_POST['account_id']; $account_id = (int)$_POST['account_id'];
$GLOBALS['egw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_app_sessions',
'phpgw_acl'
)
);
$old_group_list = $GLOBALS['egw']->acl->get_ids_for_location($account_id,1,'phpgw_group'); $old_group_list = $GLOBALS['egw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
@reset($old_group_list); @reset($old_group_list);
@ -115,8 +107,6 @@
$GLOBALS['egw']->accounts->delete($account_id); $GLOBALS['egw']->accounts->delete($account_id);
$GLOBALS['egw']->db->unlock();
Header('Location: '.$GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')); Header('Location: '.$GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['egw']->common->egw_exit(); $GLOBALS['egw']->common->egw_exit();
} }
@ -141,18 +131,11 @@
$singleHookValues = $GLOBALS['hook_values']+array('location' => 'deleteaccount'); $singleHookValues = $GLOBALS['hook_values']+array('location' => 'deleteaccount');
$db = clone($GLOBALS['egw']->db); foreach($GLOBALS['egw_info']['apps'] as $appname => $data)
$db->query('SELECT app_name,app_order FROM phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
if($db->num_rows())
{ {
while($db->next_record()) if($appname != 'admin' && $appname != 'preferences')
{ {
$appname = $db->f('app_name'); $GLOBALS['egw']->hooks->single($singleHookValues,$appname);
if($appname <> 'admin' || $appname <> 'preferences')
{
$GLOBALS['egw']->hooks->single($singleHookValues, $appname);
}
} }
} }
@ -213,19 +196,6 @@
$this->validate_group($group_info); $this->validate_group($group_info);
$GLOBALS['egw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_nextid',
'phpgw_preferences',
'phpgw_sessions',
'phpgw_acl',
'phpgw_applications',
'phpgw_app_sessions',
'phpgw_hooks'
)
);
$group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); $group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
$group->acct_type = 'g'; $group->acct_type = 'g';
$account_info = array( $account_info = array(
@ -291,8 +261,6 @@
{ {
$cd = 37; $cd = 37;
} }
$GLOBALS['egw']->db->unlock();
} }
ExecMethod('admin.uiaccounts.list_groups'); ExecMethod('admin.uiaccounts.list_groups');
@ -430,20 +398,6 @@
$this->validate_group($group_info); $this->validate_group($group_info);
// Lock tables
$GLOBALS['egw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_preferences',
'phpgw_config',
'phpgw_applications',
'phpgw_hooks',
'phpgw_sessions',
'phpgw_acl',
'phpgw_app_sessions'
)
);
$group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); $group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
$old_group_info = $group->read_repository(); $old_group_info = $group->read_repository();
@ -547,8 +501,6 @@
// for LDAP to update the memberuid attribute // for LDAP to update the memberuid attribute
$group->save_repository(); $group->save_repository();
$GLOBALS['egw']->db->unlock();
ExecMethod('admin.uiaccounts.list_groups'); ExecMethod('admin.uiaccounts.list_groups');
return False; return False;
} }

View File

@ -27,19 +27,6 @@
$userData['account_email'] = $userData['email']; $userData['account_email'] = $userData['email'];
} }
$GLOBALS['egw']->db->lock(
Array(
'phpgw_accounts',
'phpgw_nextid',
'phpgw_preferences',
'phpgw_sessions',
'phpgw_acl',
'phpgw_applications',
'phpgw_app_sessions',
'phpgw_hooks'
)
);
$GLOBALS['egw']->accounts->create($userData); $GLOBALS['egw']->accounts->create($userData);
$userData['account_id'] = $GLOBALS['egw']->accounts->name2id($userData['account_lid']); $userData['account_id'] = $GLOBALS['egw']->accounts->name2id($userData['account_lid']);
@ -104,8 +91,6 @@
$apps->account_apps = array(array()); $apps->account_apps = array(array());
$apps_after = array(array()); $apps_after = array(array());
$GLOBALS['egw']->db->unlock();
return $userData['account_id']; return $userData['account_id'];
} }
} }

View File

@ -14,6 +14,8 @@
class soapplications class soapplications
{ {
var $db; var $db;
var $applications_table = 'egw_applications';
var $hooks_table = 'phpgw_hooks';
function soapplications() function soapplications()
{ {
@ -22,7 +24,7 @@
function read($app_name) function read($app_name)
{ {
$sql = "SELECT * FROM phpgw_applications WHERE app_name='$app_name'"; $sql = "SELECT * FROM $this->applications_table WHERE app_name='$app_name'";
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
@ -38,7 +40,7 @@
function get_list() function get_list()
{ {
$this->db->query('SELECT * FROM phpgw_applications WHERE app_enabled!=3',__LINE__,__FILE__); $this->db->query("SELECT * FROM $this->applications_table WHERE app_enabled != 3",__LINE__,__FILE__);
if($this->db->num_rows()) if($this->db->num_rows())
{ {
while ($this->db->next_record()) while ($this->db->next_record())
@ -64,11 +66,11 @@
/* Yes, the sequence should work, but after a mass import in setup (new install) /* Yes, the sequence should work, but after a mass import in setup (new install)
it does not work on pg it does not work on pg
*/ */
$sql = 'SELECT MAX(app_id) from phpgw_applications'; $sql = "SELECT MAX(app_id) from $this->applications_table";
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$app_id = $this->db->f(0) + 1; $app_id = $this->db->f(0) + 1;
$sql = 'INSERT INTO phpgw_applications (app_id,app_name,app_enabled,app_order) VALUES(' $sql = "INSERT INTO $this->applications_table (app_id,app_name,app_enabled,app_order) VALUES("
. $app_id . ",'" . addslashes($data['n_app_name']) . "','" . $app_id . ",'" . addslashes($data['n_app_name']) . "','"
. $data['n_app_status'] . "','" . $data['app_order'] . "')"; . $data['n_app_status'] . "','" . $data['app_order'] . "')";
@ -78,7 +80,7 @@
function save($data) function save($data)
{ {
$sql = "UPDATE phpgw_applications SET " $sql = "UPDATE $this->applications_table SET "
. "app_enabled='" . $data['n_app_status'] . "',app_order='" . $data['app_order'] . "app_enabled='" . $data['n_app_status'] . "',app_order='" . $data['app_order']
. "' WHERE app_name='" . $data['app_name'] . "'"; . "' WHERE app_name='" . $data['app_name'] . "'";
@ -88,7 +90,7 @@
function exists($app_name) function exists($app_name)
{ {
$this->db->query("SELECT COUNT(app_name) FROM phpgw_applications WHERE app_name='" . addslashes($app_name) . "'",__LINE__,__FILE__); $this->db->query("SELECT COUNT(app_name) FROM $this->applications_table WHERE app_name='" . addslashes($app_name) . "'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
if ($this->db->f(0) != 0) if ($this->db->f(0) != 0)
@ -100,19 +102,19 @@
function app_order() function app_order()
{ {
$this->db->query('SELECT (MAX(app_order)+1) FROM phpgw_applications',__LINE__,__FILE__); $this->db->query("SELECT MAX(app_order)+1 FROM $this->applications_table",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
return $this->db->f(0); return $this->db->f(0);
} }
function delete($app_name) function delete($app_name)
{ {
$this->db->query("DELETE FROM phpgw_applications WHERE app_name='$app_name'",__LINE__,__FILE__); $this->db->query("DELETE FROM $this->applications_table WHERE app_name='$app_name'",__LINE__,__FILE__);
} }
function register_hook($app) function register_hook($app)
{ {
$this->db->query("INSERT INTO phpgw_hooks(hook_appname,hook_location,hook_filename) " $this->db->query("INSERT INTO $this->hooks_table (hook_appname,hook_location,hook_filename) "
. "VALUES ('".$app['app_name']."','".$app['hook']."','hook_".$app['hook'].".inc.php')",__LINE__,__FILE__ . "VALUES ('".$app['app_name']."','".$app['hook']."','hook_".$app['hook'].".inc.php')",__LINE__,__FILE__
); );
} }

View File

@ -156,11 +156,11 @@
#print "<br>DN: $accountDN<br>"; #print "<br>DN: $accountDN<br>";
ldap_mod_replace ($ldap, $accountDN, $newData); ldap_mod_replace ($ldap, $accountDN, $newData);
// also update the account_email field in phpgw_accounts // also update the account_email field in egw_accounts
// when using sql account storage // when using sql account storage
if($GLOBALS['egw_info']['server']['account_repository'] == 'sql') if($GLOBALS['egw_info']['server']['account_repository'] == 'sql')
{ {
$this->db->update('phpgw_accounts',array( $this->db->update('egw_accounts',array(
'account_email' => $_accountData["mail"] 'account_email' => $_accountData["mail"]
), ),
array( array(

View File

@ -17,6 +17,9 @@
class solog class solog
{ {
var $db; var $db;
var $accounts_table = 'egw_accounts';
var $log_table = 'egw_log';
var $msg_table = 'egw_log_msg';
var $owner; var $owner;
var $error_cols = ''; var $error_cols = '';
var $error_cols_e = ''; var $error_cols_e = '';
@ -38,16 +41,16 @@
{ {
$this->error_cols = array(); $this->error_cols = array();
/* fields from phpgw_log table */ /* fields from log table */
$clist = $this->db->metadata('phpgw_log'); $clist = $this->db->metadata($this->log_table);
for ($i=0; $i<count($clist); $i++) for ($i=0; $i<count($clist); $i++)
{ {
$name = $clist[$i]['name']; $name = $clist[$i]['name'];
$this->error_cols[$name] = array(); $this->error_cols[$name] = array();
} }
/* fields from phpgw_log_msg table */ /* fields from msg table */
$clist = $this->db->metadata('phpgw_log_msg'); $clist = $this->db->metadata($this->msg_table);
for ($i=0; $i<count($clist); $i++) for ($i=0; $i<count($clist); $i++)
{ {
$name = $clist[$i]['name']; $name = $clist[$i]['name'];
@ -64,8 +67,8 @@
/* Get Columns for Errors */ /* Get Columns for Errors */
$this->error_cols_e = $this->get_error_cols(); $this->error_cols_e = $this->get_error_cols();
/* Enhance with Columns for phpgw_accounts */ /* Enhance with Columns from accounts-table */
$clist = $this->db->metadata('phpgw_accounts'); $clist = $this->db->metadata($this->accounts_table);
for ($i=0; $i<count($clist); $i++) for ($i=0; $i<count($clist); $i++)
{ {
$name = $clist[$i]['name']; $name = $clist[$i]['name'];
@ -81,21 +84,21 @@
/* Fixed From */ /* Fixed From */
if (!isset($parms['from'])) if (!isset($parms['from']))
{ {
$parms['from'] = array('phpgw_accounts'); $parms['from'] = array($this->accounts_table);
} }
else else
{ {
$parms['from'][] = 'phpgw_accounts'; $parms['from'][] = $this->accounts_table;
} }
/* Fix Where */ /* Fix Where */
if (!isset($parms['where'])) if (!isset($parms['where']))
{ {
$parms['where'] = array('phpgw_log.log_user = phpgw_accounts.account_id'); $parms['where'] = array("$this->log_table.log_user = $this->accounts_table.account_id");
} }
else else
{ {
$parms['where'][] = 'phpgw_log.log_user = phpgw_accounts.account_id'; $parms['where'][] = "$this->log_table.log_user = $this->accounts_table.account_id";
} }
/* Fix Default Fields */ /* Fix Default Fields */
@ -110,9 +113,9 @@
function get_no_errors() function get_no_errors()
{ {
/* Get max ErrorId */ /* Get max ErrorId */
$this->db->query("select count(*) as max_id from phpgw_log, phpgw_log_msg WHERE phpgw_log.log_id = phpgw_log_msg.log_msg_log_id",__LINE__,__FILE__); $this->db->query("select count(*) as max_id from $this->log_table, $this->msg_table WHERE $this->log_table.log_id = $this->msg_table.log_msg_log_id",__LINE__,__FILE__);
$this->db->next_record();
return $this->db->f('max_id'); return $this->db->next_record() ? $this->db->f('max_id') : 0;
} }
function get_error($parms) function get_error($parms)
@ -124,24 +127,24 @@
$fields = $parms['fields']; $fields = $parms['fields'];
/* Build From_Clause */ /* Build From_Clause */
$from_clause = 'FROM phpgw_log, phpgw_log_msg '; $from_clause = "FROM $this->log_table , $this->msg_table ";
if (isset($from)) if (isset($from))
{ {
$from[] = 'phpgw_log'; $from[] = $this->log_table;
$from[] = 'phpgw_log_msg'; $from[] = $this->msg_table;
$from_clause = 'FROM '.implode(', ' , $from).' '; $from_clause = 'FROM '.implode(', ' , $from).' ';
} }
/* Build Where_Clause */ /* Build Where_Clause */
$where_clause = 'WHERE phpgw_log.log_id = phpgw_log_msg.log_msg_log_id '; $where_clause = "WHERE $this->log_table.log_id = $this->msg_table.log_msg_log_id ";
if (isset($where)) if (isset($where))
{ {
$where[] = 'phpgw_log.log_id = phpgw_log_msg.log_msg_log_id'; $where[] = "$this->log_table.log_id = $this->msg_table.log_msg_log_id";
$where_clause = 'WHERE ' . implode(' AND ',$where) . ' '; $where_clause = 'WHERE ' . implode(' AND ',$where) . ' ';
} }
/* Build Order_By_Clause */ /* Build Order_By_Clause */
$orderby_clause = 'ORDER BY phpgw_log.log_id, phpgw_log_msg.log_msg_seq_no '; $orderby_clause = "ORDER BY $this->log_table.log_id, $this->msg_table.log_msg_seq_no ";
if (isset($orderby)) if (isset($orderby))
{ {
$orderby_clause = 'ORDER BY ' . implode(', ',$orderby); $orderby_clause = 'ORDER BY ' . implode(', ',$orderby);
@ -155,20 +158,11 @@
$rows = array(); $rows = array();
/* Do Select */ $select = 'SELECT ' . implode(',',array_keys($fields)) . ' ' . $from_clause . $where_clause . $orderby_clause;
@reset($fields);
while(list($key,$val) = @each($fields))
{
$fkeys .= $key . ',';
}
$fkeys = substr($fkeys,0,-1);
$select = 'SELECT ' . $fkeys . ' ' . $from_clause . $where_clause . $orderby_clause;
$this->db->query($select,__LINE__,__FILE__); $this->db->query($select,__LINE__,__FILE__);
while($this->db->next_record()) while($this->db->next_record())
{ {
reset($fields); foreach($fields as $fname => $fopt)
while(list($fname,$fopt) = each($fields))
{ {
$this_row[$fname]['value'] = $this->db->f($fname); $this_row[$fname]['value'] = $this->db->f($fname);
} }

View File

@ -26,7 +26,7 @@ if($GLOBALS['egw_info']['flags']['currentapp'] != 'home' &&
{ {
$_returnhtml = array(); $_returnhtml = array();
$app_name = $GLOBALS['egw_info']['flags']['currentapp']; $app_name = $GLOBALS['egw_info']['flags']['currentapp'];
$GLOBALS['egw']->db->query("SELECT app_name,app_version FROM phpgw_applications WHERE app_name='$app_name' OR app_name='phpgwapi'",__LINE__,__FILE__); $GLOBALS['egw']->db->query("SELECT app_name,app_version FROM egw_applications WHERE app_name='$app_name' OR app_name='phpgwapi'",__LINE__,__FILE__);
while($GLOBALS['egw']->db->next_record()) while($GLOBALS['egw']->db->next_record())
{ {
$_db_version = $GLOBALS['egw']->db->f('app_version'); $_db_version = $GLOBALS['egw']->db->f('app_version');

View File

@ -15,9 +15,5 @@
if((int)$GLOBALS['hook_values']['account_id'] > 0) if((int)$GLOBALS['hook_values']['account_id'] > 0)
{ {
$GLOBALS['egw']->accounts->delete((int)$GLOBALS['hook_values']['account_id']); $GLOBALS['egw']->accounts->delete((int)$GLOBALS['hook_values']['account_id']);
$GLOBALS['egw']->db->lock(Array('phpgw_acl')); $GLOBALS['egw']->acl->delete_account((int)$GLOBALS['hook_values']['account_id']);
$GLOBALS['egw']->db->query("DELETE FROM phpgw_acl WHERE acl_location='" . (int)$GLOBALS['hook_values']['account_id']
. "' OR acl_account=".(int)$GLOBALS['hook_values']['account_id'],__LINE__,__FILE__);
$GLOBALS['egw']->db->unlock();
} }
?>

View File

@ -42,10 +42,8 @@ class updates {
function showUpdates() { function showUpdates() {
$updates = array(); $updates = array();
if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) && if (isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'] &&
$GLOBALS['egw_info']['user']['apps']['admin']) && isset($GLOBALS['egw_info']['server']['checkfornewversion']) && $GLOBALS['egw_info']['server']['checkfornewversion'])
(isset($GLOBALS['egw_info']['server']['checkfornewversion']) &&
$GLOBALS['egw_info']['server']['checkfornewversion']))
{ {
$GLOBALS['egw']->network =& CreateObject('phpgwapi.network'); $GLOBALS['egw']->network =& CreateObject('phpgwapi.network');
@ -62,16 +60,14 @@ class updates {
if($GLOBALS['egw']->common->cmp_version_long($GLOBALS['egw_info']['server']['versions']['phpgwapi'],$line_found[1])) if($GLOBALS['egw']->common->cmp_version_long($GLOBALS['egw_info']['server']['versions']['phpgwapi'],$line_found[1]))
{ {
$updates['egroupware'] = '<p>There is a new version of eGroupWare available. <a href="' $updates['egroupware'] = '<p>'.lang('There is a new version of eGroupWare available').
. 'http://www.egroupware.org">http://www.egroupware.org</a></p>'; ' <a href="http://www.egroupware.org">www.egroupware.org</a></p>';
} }
$_found = False; $_found = False;
$GLOBALS['egw']->db->query("select app_name,app_version from phpgw_applications",__LINE__,__FILE__); foreach($GLOBALS['egw_info']['apps'] as $_app_name => $data)
while($GLOBALS['egw']->db->next_record())
{ {
$_db_version = $GLOBALS['egw']->db->f('app_version'); $_db_version = $data['version'];
$_app_name = $GLOBALS['egw']->db->f('app_name');
$_app_dir = $GLOBALS['egw']->common->get_app_dir($_app_name); $_app_dir = $GLOBALS['egw']->common->get_app_dir($_app_name);
$_versionfile = $_app_dir . '/setup/setup.inc.php'; $_versionfile = $_app_dir . '/setup/setup.inc.php';
if($_app_dir && file_exists($_versionfile)) if($_app_dir && file_exists($_versionfile))
@ -102,7 +98,4 @@ class updates {
} }
return $updates; return $updates;
} }
} }
?>

View File

@ -40,10 +40,10 @@
include_once(EGW_API_INC . '/class.accounts_' . $GLOBALS['egw_info']['server']['account_repository'] . '.inc.php'); include_once(EGW_API_INC . '/class.accounts_' . $GLOBALS['egw_info']['server']['account_repository'] . '.inc.php');
/* /*
Dont know where to put this (seek3r) Dont know where to put this (seek3r)
This is where it belongs (jengo) This is where it belongs (jengo)
This is where it ended up (milosch) This is where it ended up (milosch)
Moved again at least temporarily since sql and ldap use it. Moved again at least temporarily since sql and ldap use it.
*/ */
$GLOBALS['egw_info']['server']['global_denied_users'] = array( $GLOBALS['egw_info']['server']['global_denied_users'] = array(
'root' => True, 'bin' => True, 'daemon' => True, 'root' => True, 'bin' => True, 'daemon' => True,

View File

@ -1,27 +1,27 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Accounts manager for the contacts class * * eGroupWare API - Accounts manager for the contacts class *
* This file written by Miles Lott <milosch@groupwhere.org> * * This file written by Miles Lott <milosch@groupwhere.org> *
* View and manipulate account records using the contacts class * * View and manipulate account records using the contacts class *
* Copyright (C) 2000, 2001 Miles Lott * * Copyright (C) 2000, 2001 Miles Lott *
* -------------------------------------------------------------------------* * -------------------------------------------------------------------------*
* This library is part of the eGroupWare API * * This library is part of the eGroupWare API *
* http://www.egroupware.org/api * * http://www.egroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
/* /*
@ -291,47 +291,55 @@
$expiredate = time() + ( ( 60 * 60 ) * (30 * 24) ); $expiredate = time() + ( ( 60 * 60 ) * (30 * 24) );
} }
$default_group_id = $this->name2id($GLOBALS['egw_info']['server']['default_group_lid']);
if (!$default_group_id)
{
$default_group_id = (int) $this->name2id('Default');
}
$primary_group = $GLOBALS['auto_create_acct']['primary_group'] &&
$this->get_type((int)$GLOBALS['auto_create_acct']['primary_group']) == 'g' ?
(int) $GLOBALS['auto_create_acct']['primary_group'] : $default_group_id;
$acct_info = array( $acct_info = array(
'account_lid' => $accountname, 'account_lid' => $accountname,
'account_type' => 'u', 'account_type' => 'u',
'account_passwd' => $passwd, 'account_passwd' => $passwd,
'account_firstname' => '', 'account_firstname' => $GLOBALS['auto_create_acct']['firstname'] ? $GLOBALS['auto_create_acct']['firstname'] : 'New',
'account_lastname' => '', 'account_lastname' => $GLOBALS['auto_create_acct']['lastname'] ? $GLOBALS['auto_create_acct']['lastname'] : 'User',
'account_status' => $account_status, 'account_status' => $account_status,
'account_expires' => mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)) 'account_expires' => mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)),
'account_primary_group' => $primary_group,
); );
if (isset($GLOBALS['auto_create_acct']['email']) == True && $GLOBALS['auto_create_acct']['email'] != '')
{
$acct_info['account_email'] = $GLOBALS['auto_create_acct']['email'];
}
elseif(isset($GLOBALS['egw_info']['server']['mail_suffix']) == True && $GLOBALS['egw_info']['server']['mail_suffix'] != '')
{
$acct_info['account_email'] = $accountname . '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
}
$this->create($acct_info); $this->create($acct_info);
$accountid = $this->name2id($accountname); $accountid = $this->name2id($accountname);
$this->db->transaction_begin(); if ($accountid)
if (!$default_prefs)
{ {
$default_prefs = 'a:5:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";N;s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";N;s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}:s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}'; /* If we have a primary_group, add it as "regular" eGW group (via ACL) too. */
// $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; if ($primary_group)
$this->db->query("insert into phpgw_preferences (preference_owner, preference_value) values ('".$accountid."', '$default_prefs')",__LINE__,__FILE__);
}
if (!$default_acls)
{
$apps = Array(
'addressbook',
'calendar',
'email',
'notes',
'todo',
'phpwebhosting',
'manual'
);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)values('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', '1', ".$accountid.", 1)",__LINE__,__FILE__);
@reset($apps);
while(list($key,$app) = each($apps))
{ {
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('".$app."', 'run', ".$accountid.", 1)",__LINE__,__FILE__); $GLOBALS['egw']->acl->add_repository('phpgw_group', $primary_group,$accountid,1);
} }
// call hook to notify other apps about the new account
$GLOBALS['hook_values']['account_lid'] = $acct_info['account_lid'];
$GLOBALS['hook_values']['account_id'] = $accountid;
$GLOBALS['hook_values']['new_passwd'] = $acct_info['account_passwd'];
$GLOBALS['hook_values']['account_status'] = $acct_info['account_status'];
$GLOBALS['hook_values']['account_firstname'] = $acct_info['account_firstname'];
$GLOBALS['hook_values']['account_lastname'] = $acct_info['account_lastname'];
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
'location' => 'addaccount'
),False,True); /* called for every app now, not only enabled ones */
} }
$this->db->transaction_commit();
return $accountid; return $accountid;
} }
} }

View File

@ -282,7 +282,7 @@
ldap_add($this->ds, $newDN, $newData); ldap_add($this->ds, $newDN, $newData);
} }
/* Normal behavior for save_repository /* Normal behavior for save_repository
update Account */ update Account */
else else
{ {
// add the list group members // add the list group members
@ -1007,15 +1007,10 @@
{ {
if($primary_group) if($primary_group)
{ {
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES('phpgw_group', " $GLOBALS['egw']->acl->add_repository('phpgw_group', $primary_group,$accountid,1);
. $primary_group . ", " . $accountid . ", 1)",__LINE__,__FILE__);
} }
/* FIXME - we are assuming the auth method is capable of password changing /* if we have an mail address set it in the users' email preference */
* $this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)VALUES('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
*/
/* if we have an mail address set it in the uesrs' email preference */
if (isset($GLOBALS['auto_create_acct']['email']) && $GLOBALS['auto_create_acct']['email'] != '') if (isset($GLOBALS['auto_create_acct']['email']) && $GLOBALS['auto_create_acct']['email'] != '')
{ {
$GLOBALS['egw']->acl->acl($accountid); /* needed als preferences::save_repository calls acl */ $GLOBALS['egw']->acl->acl($accountid); /* needed als preferences::save_repository calls acl */
@ -1037,7 +1032,7 @@
/* commit the new account transaction */ /* commit the new account transaction */
$this->db->transaction_commit(); $this->db->transaction_commit();
/* does anyone know what the heck this is required for? */ // call hook to notify interested apps about the new account
$GLOBALS['hook_values']['account_lid'] = $acct_info['account_lid']; $GLOBALS['hook_values']['account_lid'] = $acct_info['account_lid'];
$GLOBALS['hook_values']['account_id'] = $accountid; $GLOBALS['hook_values']['account_id'] = $accountid;
$GLOBALS['hook_values']['new_passwd'] = $acct_info['account_passwd']; $GLOBALS['hook_values']['new_passwd'] = $acct_info['account_passwd'];
@ -1101,4 +1096,25 @@
return $allValues[0]['dn']; return $allValues[0]['dn'];
} }
/**
* Update the last login timestamps and the IP
*
* @param int $account_id
* @param string $ip
* @return int lastlogin time
*/
function update_lastlogin($_account_id, $ip)
{
$entry['phpgwaccountlastlogin'] = time();
$entry['phpgwaccountlastloginfrom'] = $ip;
$sri = ldap_search($this->ds, $GLOBALS['egw_info']['server']['ldap_context'], 'uidnumber=' . (int)$_account_id);
$allValues = ldap_get_entries($ds, $sri);
$dn = $allValues[0]['dn'];
@ldap_modify($ds, $dn, $entry);
return $allValues[0]['phpgwaccountlastlogin'][0];
}
} }

View File

@ -26,9 +26,7 @@
/* $Id$ */ /* $Id$ */
/** /**
* @class_start accounts * Class for handling user and group accounts
* Class for handling user and group accounts
*
*/ */
class accounts_ class accounts_
{ {
@ -40,7 +38,7 @@
function accounts_() function accounts_()
{ {
$this->db = clone($GLOBALS['egw']->db); $this->db = clone($GLOBALS['egw']->db);
$this->table = 'phpgw_accounts'; $this->table = 'egw_accounts';
$this->db->set_app('phpgwapi'); // to load the right table-definitions for insert, select, update, ... $this->db->set_app('phpgwapi'); // to load the right table-definitions for insert, select, update, ...
} }
@ -224,8 +222,7 @@
); );
} }
$this->db->query("SELECT count(*) FROM $this->table $whereclause"); $this->db->query("SELECT count(*) FROM $this->table $whereclause");
$this->db->next_record(); $this->total = $this->db->next_record() ? $this->db->f(0) : 0;
$this->total = $this->db->f(0);
return $accounts; return $accounts;
} }
@ -392,11 +389,10 @@
/* If we have a primary_group, add it as "regular" eGW group (via ACL) too. */ /* If we have a primary_group, add it as "regular" eGW group (via ACL) too. */
if ($primary_group) if ($primary_group)
{ {
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', " $GLOBALS['egw']->acl->add_repository('phpgw_group', $primary_group,$accountid,1);
. $primary_group . ', ' . $accountid . ', 1)',__LINE__,__FILE__);
} }
/* if we have an mail address set it in the uesrs' email preference */ /* if we have an mail address set it in the users' email preference */
if (isset($GLOBALS['auto_create_acct']['email']) && $GLOBALS['auto_create_acct']['email'] != '') if (isset($GLOBALS['auto_create_acct']['email']) && $GLOBALS['auto_create_acct']['email'] != '')
{ {
$GLOBALS['egw']->acl->acl($accountid); /* needed als preferences::save_repository calls acl */ $GLOBALS['egw']->acl->acl($accountid); /* needed als preferences::save_repository calls acl */
@ -418,7 +414,7 @@
/* commit the new account transaction */ /* commit the new account transaction */
$this->db->transaction_commit(); $this->db->transaction_commit();
/* does anyone know what the heck this is required for? */ // call hook to notify interested apps about the new account
$GLOBALS['hook_values']['account_lid'] = $acct_info['account_lid']; $GLOBALS['hook_values']['account_lid'] = $acct_info['account_lid'];
$GLOBALS['hook_values']['account_id'] = $accountid; $GLOBALS['hook_values']['account_id'] = $accountid;
$GLOBALS['hook_values']['new_passwd'] = $acct_info['account_passwd']; $GLOBALS['hook_values']['new_passwd'] = $acct_info['account_passwd'];
@ -456,7 +452,26 @@
return True; return True;
} }
/**
* Update the last login timestamps and the IP
*
* @param int $account_id
* @param string $ip
* @return int lastlogin time
*/
function update_lastlogin($account_id, $ip)
{
$this->db->select($this->table,'account_lastlogin',array('account_id'=>$account_id),__LINE__,__FILE__);
$previous_login = $this->db->next_record() ? $this->db->f('account_lastlogin') : false;
$this->db->update($this->table,array(
'account_lastloginfrom' => $ip,
'account_lastlogin' => time(),
),array(
'account_id' => $account_id,
),__LINE__,__FILE__);
return $previous_login;
}
} }
/**
* @class_end accounts
*/

View File

@ -59,7 +59,7 @@
/** /**
* @var string $table_name name of the acl_table * @var string $table_name name of the acl_table
*/ */
var $table_name = 'phpgw_acl'; var $table_name = 'egw_acl';
/** /**
* ACL constructor for setting account id * ACL constructor for setting account id
@ -317,7 +317,8 @@
* get specific rights for this->account_id for an app location * get specific rights for this->account_id for an app location
* *
* @param string $location app location * @param string $location app location
* @param string $appname optional defaults to currentapp * @param string $appname='' optional defaults to currentapp
* @param int $account_id=0 optional defaults to $this->account_id
* @return int $rights * @return int $rights
*/ */
function get_specific_rights($location, $appname = '') function get_specific_rights($location, $appname = '')
@ -428,6 +429,84 @@
return $this->db->affected_rows(); return $this->db->affected_rows();
} }
/**
* Get rights for a given account, location and application
*
* @param int $account_id
* @param string $location
* @param string $appname='' defaults to current app
* @return int/boolean rights or false if none exist
*/
function get_specific_rights_for_account($account_id,$location,$appname='')
{
if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
$this->db->select($this->table_name,'acl_rights',array(
'acl_location' => $location,
'acl_account' => $account_id,
'acl_appname' => $appname,
),__LINE__,__FILE__);
return $this->db->next_record() ? $this->db->f('acl_rights') : false;
}
/**
* Get all rights for a given location and application
*
* @param string $location
* @param string $appname='' defaults to current app
* @return array with account => rights pairs
*/
function get_all_rights($location,$appname='')
{
if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
$this->db->select($this->table_name,'acl_account,acl_rights',array(
'acl_location' => $location,
'acl_appname' => $appname,
),__LINE__,__FILE__);
$rights = array();
while($this->db->next_record())
{
$rights[$this->db->f('acl_account')] = $this->db->f('acl_rights');
}
return $rights;
}
/**
* Get the rights for all locations
*
* @param int $account_id
* @param string $appname='' defaults to current app
* @param boolean $use_memberships=true
* @return array with location => rights pairs
*/
function get_all_location_rights($account_id,$appname='',$use_memberships=true)
{
if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
$acounts = array($account_id);
if ($use_memberships)
{
foreach((array)$GLOBALS['egw']->accounts->membership($account_id) as $group)
{
$accounts[] = $group['account_id'];
}
}
$this->db->select($this->table_name,'acl_location,acl_rights',array(
'acl_account' => $accounts,
'acl_appname' => $appname,
),__LINE__,__FILE__);
$rights = array();
while($this->db->next_record())
{
$rights[$this->db->f('acl_location')] |= $this->db->f('acl_rights');
}
return $rights;
}
/** /**
* get application list for an account id * get application list for an account id
* *

View File

@ -22,16 +22,17 @@
/* $Id$ */ /* $Id$ */
/*! /**
@class applications * functions for managing and installing apps
@abstract functions for managing and installing apps *
@discussion Author: skeeter * Author: skeeter
*/ */
class applications class applications
{ {
var $account_id; var $account_id;
var $data = Array(); var $data = Array();
var $db; var $db;
var $table_name = 'egw_applications';
var $public_functions = array( var $public_functions = array(
'list_methods' => True, 'list_methods' => True,
'read' => True 'read' => True
@ -42,14 +43,16 @@
* Standard constructor for setting $this->account_id * * Standard constructor for setting $this->account_id *
\**************************************************************************/ \**************************************************************************/
/*! /**
@function applications * standard constructor for setting $this->account_id
@abstract standard constructor for setting $this->account_id *
@param $account_id account id * @param $account_id account id
*/ */
function applications($account_id = '') function applications($account_id = '')
{ {
$this->db = $GLOBALS['phpgw']->db; $this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('phpgwapi');
$this->account_id = get_account_id($account_id); $this->account_id = get_account_id($account_id);
$this->xmlrpc_methods[] = array( $this->xmlrpc_methods[] = array(
@ -61,9 +64,9 @@
function NOT_list_methods($_type='xmlrpc') function NOT_list_methods($_type='xmlrpc')
{ {
/* /*
This handles introspection or discovery by the logged in client, This handles introspection or discovery by the logged in client,
in which case the input might be an array. The server always calls in which case the input might be an array. The server always calls
this function to fill the server dispatch map using a string. this function to fill the server dispatch map using a string.
*/ */
if (is_array($_type)) if (is_array($_type))
{ {
@ -99,15 +102,14 @@
* These are the standard $this->account_id specific functions * * These are the standard $this->account_id specific functions *
\**************************************************************************/ \**************************************************************************/
/*! /**
@function read_repository * read from repository
@abstract read from repository *
@discussion private should only be called from withing this class * private should only be called from withing this class
*/ */
function read_repository() function read_repository()
{ {
if (!isset($GLOBALS['phpgw_info']['apps']) || if (!isset($GLOBALS['egw_info']['apps']) || !is_array($GLOBALS['egw_info']['apps']))
!is_array($GLOBALS['phpgw_info']['apps']))
{ {
$this->read_installed_apps(); $this->read_installed_apps();
} }
@ -116,28 +118,28 @@
{ {
return False; return False;
} }
$apps = $GLOBALS['phpgw']->acl->get_user_applications($this->account_id); $apps = $GLOBALS['egw']->acl->get_user_applications($this->account_id);
foreach($GLOBALS['phpgw_info']['apps'] as $app => $data) foreach($GLOBALS['egw_info']['apps'] as $app => $data)
{ {
if (isset($apps[$app]) && $apps[$app]) if (isset($apps[$app]) && $apps[$app])
{ {
$this->data[$app] = array( $this->data[$app] = array(
'title' => $GLOBALS['phpgw_info']['apps'][$app]['title'], 'title' => $GLOBALS['egw_info']['apps'][$app]['title'],
'name' => $app, 'name' => $app,
'enabled' => True, 'enabled' => True,
'status' => $GLOBALS['phpgw_info']['apps'][$app]['status'], 'status' => $GLOBALS['egw_info']['apps'][$app]['status'],
'id' => $GLOBALS['phpgw_info']['apps'][$app]['id'] 'id' => $GLOBALS['egw_info']['apps'][$app]['id']
); );
} }
} }
return $this->data; return $this->data;
} }
/*! /**
@function read() * read from the repository
@abstract read from the repository *
@discussion pubic function that is used to determine what apps a user has rights to * pubic function that is used to determine what apps a user has rights to
*/ */
function read() function read()
{ {
if (!count($this->data)) if (!count($this->data))
@ -146,12 +148,12 @@
} }
return $this->data; return $this->data;
} }
/*! /**
@function add * add an app to a user profile
@abstract add an app to a user profile *
@discussion * @discussion
@param $apps array containing apps to add for a user * @param $apps array containing apps to add for a user
*/ */
function add($apps) function add($apps)
{ {
if(is_array($apps)) if(is_array($apps))
@ -159,32 +161,32 @@
foreach($apps as $app) foreach($apps as $app)
{ {
$this->data[$app] = array( $this->data[$app] = array(
'title' => $GLOBALS['phpgw_info']['apps'][$app]['title'], 'title' => $GLOBALS['egw_info']['apps'][$app]['title'],
'name' => $app, 'name' => $app,
'enabled' => True, 'enabled' => True,
'status' => $GLOBALS['phpgw_info']['apps'][$app]['status'], 'status' => $GLOBALS['egw_info']['apps'][$app]['status'],
'id' => $GLOBALS['phpgw_info']['apps'][$app]['id'] 'id' => $GLOBALS['egw_info']['apps'][$app]['id']
); );
} }
} }
elseif(gettype($apps)) elseif(gettype($apps))
{ {
$this->data[$apps] = array( $this->data[$apps] = array(
'title' => $GLOBALS['phpgw_info']['apps'][$apps]['title'], 'title' => $GLOBALS['egw_info']['apps'][$apps]['title'],
'name' => $apps, 'name' => $apps,
'enabled' => True, 'enabled' => True,
'status' => $GLOBALS['phpgw_info']['apps'][$apps]['status'], 'status' => $GLOBALS['egw_info']['apps'][$apps]['status'],
'id' => $GLOBALS['phpgw_info']['apps'][$apps]['id'] 'id' => $GLOBALS['egw_info']['apps'][$apps]['id']
); );
} }
return $this->data; return $this->data;
} }
/*! /**
@function delete * delete an app from a user profile
@abstract delete an app from a user profile *
@discussion * @discussion
@param $appname appname to remove * @param $appname appname to remove
*/ */
function delete($appname) function delete($appname)
{ {
if($this->data[$appname]) if($this->data[$appname])
@ -193,32 +195,32 @@
} }
return $this->data; return $this->data;
} }
/*! /**
@function update_data * update the array(?)
@abstract update the array(?) *
@discussion * @discussion
@param $data update the repository array(?) * @param $data update the repository array(?)
*/ */
function update_data($data) function update_data($data)
{ {
$this->data = $data; $this->data = $data;
return $this->data; return $this->data;
} }
/*! /**
@function save_repository() * save the repository
@abstract save the repository *
@discussion * @discussion
*/ */
function save_repository() function save_repository()
{ {
$num_rows = $GLOBALS['phpgw']->acl->delete_repository("%%", 'run', $this->account_id); $num_rows = $GLOBALS['egw']->acl->delete_repository("%%", 'run', $this->account_id);
foreach($this->data as $app => $data) foreach($this->data as $app => $data)
{ {
if(!$this->is_system_enabled($app)) if(!$this->is_system_enabled($app))
{ {
continue; continue;
} }
$GLOBALS['phpgw']->acl->add_repository($app,'run',$this->account_id,1); $GLOBALS['egw']->acl->add_repository($app,'run',$this->account_id,1);
} }
return $this->data; return $this->data;
} }
@ -242,22 +244,22 @@
function read_account_specific() function read_account_specific()
{ {
if (!is_array($GLOBALS['phpgw_info']['apps'])) if (!is_array($GLOBALS['egw_info']['apps']))
{ {
$this->read_installed_apps(); $this->read_installed_apps();
} }
if ($app_list = $GLOBALS['phpgw']->acl->get_app_list_for_id('run',1,$this->account_id)) if ($app_list = $GLOBALS['egw']->acl->get_app_list_for_id('run',1,$this->account_id))
{ {
foreach($app_list as $app) foreach($app_list as $app)
{ {
if ($this->is_system_enabled($app)) if ($this->is_system_enabled($app))
{ {
$this->data[$app] = array( $this->data[$app] = array(
'title' => $GLOBALS['phpgw_info']['apps'][$app]['title'], 'title' => $GLOBALS['egw_info']['apps'][$app]['title'],
'name' => $app, 'name' => $app,
'enabled' => True, 'enabled' => True,
'status' => $GLOBALS['phpgw_info']['apps'][$app]['status'], 'status' => $GLOBALS['egw_info']['apps'][$app]['status'],
'id' => $GLOBALS['phpgw_info']['apps'][$app]['id'] 'id' => $GLOBALS['egw_info']['apps'][$app]['id']
); );
} }
} }
@ -269,48 +271,45 @@
* These are the generic functions. Not specific to $this->account_id * * These are the generic functions. Not specific to $this->account_id *
\**************************************************************************/ \**************************************************************************/
/*! /**
@function read_installed_apps() * populate array with a list of installed apps
@abstract populate array with a list of installed apps *
*/ */
function read_installed_apps() function read_installed_apps()
{ {
$this->db->query('select * from phpgw_applications where app_enabled != 0 order by app_order asc',__LINE__,__FILE__); $this->db->select($this->table_name,'*','app_enabled != 0',__LINE__,__FILE__,false,'ORDER BY app_order ASC');
if($this->db->num_rows()) while ($this->db->next_record())
{ {
while ($this->db->next_record()) $title = $app_name = $this->db->f('app_name');
{
$title = $app_name = $this->db->f('app_name');
if (@is_array($GLOBALS['phpgw_info']['user']['preferences']) && if (@is_array($GLOBALS['egw_info']['user']['preferences']) && ($t = lang($app_name)) != $app_name.'*')
($t = lang($app_name)) != $app_name.'*') {
{ $title = $t;
$title = $t;
}
$GLOBALS['phpgw_info']['apps'][$this->db->f('app_name')] = Array(
'title' => $title,
'name' => $this->db->f('app_name'),
'enabled' => True,
'status' => $this->db->f('app_enabled'),
'id' => (int)$this->db->f('app_id'),
'order' => (int)$this->db->f('app_order'),
'version' => $this->db->f('app_version')
);
} }
$GLOBALS['egw_info']['apps'][$this->db->f('app_name')] = Array(
'title' => $title,
'name' => $this->db->f('app_name'),
'enabled' => True,
'status' => $this->db->f('app_enabled'),
'id' => (int)$this->db->f('app_id'),
'order' => (int)$this->db->f('app_order'),
'version' => $this->db->f('app_version')
);
} }
} }
/*!
@function is_system_enabled /**
@abstract check if an app is enabled * check if an app is enabled
@param $appname name of the app to check for *
*/ * @param $appname name of the app to check for
*/
function is_system_enabled($appname) function is_system_enabled($appname)
{ {
if(!is_array($GLOBALS['phpgw_info']['apps'])) if(!is_array($GLOBALS['egw_info']['apps']))
{ {
$this->read_installed_apps(); $this->read_installed_apps();
} }
if ($GLOBALS['phpgw_info']['apps'][$appname]['enabled']) if ($GLOBALS['egw_info']['apps'][$appname]['enabled'])
{ {
return True; return True;
} }
@ -322,7 +321,7 @@
function id2name($id) function id2name($id)
{ {
foreach($GLOBALS['phpgw_info']['apps'] as $appname => $app) foreach($GLOBALS['egw_info']['apps'] as $appname => $app)
{ {
if((int)$app['id'] == (int)$id) if((int)$app['id'] == (int)$id)
{ {
@ -334,11 +333,10 @@
function name2id($appname) function name2id($appname)
{ {
if(is_array($GLOBALS['phpgw_info']['apps'][$appname])) if(is_array($GLOBALS['egw_info']['apps'][$appname]))
{ {
return $GLOBALS['phpgw_info']['apps'][$appname]['id']; return $GLOBALS['egw_info']['apps'][$appname]['id'];
} }
return 0; return 0;
} }
} }
?>

View File

@ -1,24 +1,24 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Password auth and crypt functions * * eGroupWare API - Password auth and crypt functions *
* This file written by Miles Lott <milos@groupwhere.org> * * This file written by Miles Lott <milos@groupwhere.org> *
* Copyright (C) 2004 Miles Lott * * Copyright (C) 2004 Miles Lott *
* Many functions based on code from Frank Thomas <frank@thomas-alfeld.de> * * Many functions based on code from Frank Thomas <frank@thomas-alfeld.de> *
* which can be seen at http://www.thomas-alfeld.de/frank/ * * which can be seen at http://www.thomas-alfeld.de/frank/ *
* Other functions from class.common.inc.php originally from phpGroupWare * * Other functions from class.common.inc.php originally from phpGroupWare *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
@ -33,11 +33,11 @@
var $seeded = False; var $seeded = False;
var $error = ''; var $error = '';
/*! /**
@function randomstring * return a random string of size $size
@abstract return a random string of size $size *
@param $size int-size of random string to return * @param $size int-size of random string to return
*/ */
function randomstring($size) function randomstring($size)
{ {
$s = ''; $s = '';
@ -62,12 +62,13 @@
return $s; return $s;
} }
/*! /**
@function encrypt_password * encrypt password
@abstract encrypt password *
@abstract uses the encryption type set in setup and calls the appropriate encryption functions * uses the encryption type set in setup and calls the appropriate encryption functions
@param $password password to encrypt *
*/ * @param $password password to encrypt
*/
function encrypt_password($password,$sql=False) function encrypt_password($password,$sql=False)
{ {
if($sql) if($sql)
@ -77,15 +78,16 @@
return $this->encrypt_ldap($password); return $this->encrypt_ldap($password);
} }
/*! /**
@function compare_password * compagres an encrypted password
@abstract compagres an encrypted password *
@abstract encryption type set in setup and calls the appropriate encryption functions * encryption type set in setup and calls the appropriate encryption functions
@param $cleartext cleartext password *
@param $encrypted encrypted password * @param $cleartext cleartext password
@param $type type of encryption * @param $encrypted encrypted password
@param $username used as optional key of encryption for md5_hmac * @param $type type of encryption
*/ * @param $username used as optional key of encryption for md5_hmac
*/
function compare_password($cleartext,$encrypted,$type,$username='') function compare_password($cleartext,$encrypted,$type,$username='')
{ {
switch($type) switch($type)
@ -109,15 +111,16 @@
} }
} }
/*! /**
@function encrypt_ldap * encrypt password for ldap
@abstract encrypt password for ldap *
@abstract uses the encryption type set in setup and calls the appropriate encryption functions * uses the encryption type set in setup and calls the appropriate encryption functions
@param $password password to encrypt *
*/ * @param $password password to encrypt
*/
function encrypt_ldap($password) function encrypt_ldap($password)
{ {
$type = strtolower($GLOBALS['phpgw_info']['server']['ldap_encryption_type']); $type = strtolower($GLOBALS['egw_info']['server']['ldap_encryption_type']);
$salt = ''; $salt = '';
switch($type) switch($type)
{ {
@ -163,12 +166,12 @@
return $e_password; return $e_password;
} }
/* Create a password for storage in the phpgw_accounts table */ /* Create a password for storage in the accounts table */
function encrypt_sql($password) function encrypt_sql($password)
{ {
/* Grab configured type, or default to md5() (old method) */ /* Grab configured type, or default to md5() (old method) */
$type = @$GLOBALS['phpgw_info']['server']['sql_encryption_type'] $type = @$GLOBALS['egw_info']['server']['sql_encryption_type']
? strtolower($GLOBALS['phpgw_info']['server']['sql_encryption_type']) ? strtolower($GLOBALS['egw_info']['server']['sql_encryption_type'])
: 'md5'; : 'md5';
switch($type) switch($type)
{ {

View File

@ -81,7 +81,7 @@
} }
} }
$account = CreateObject('phpgwapi.accounts',$username,'u'); $account =& CreateObject('phpgwapi.accounts',$username,'u');
if ($account->account_id) if ($account->account_id)
{ {
return true; return true;
@ -110,14 +110,5 @@
{ {
return false; // Cant change passwd in ADS return false; // Cant change passwd in ADS
} }
function update_lastlogin($_account_id, $ip)
{
$account =& CreateObject('phpgwapi.accounts',$_account_id,'u');
$account->read_repository();
$account->data['lastlogin'] = time();
$account->data['lastloginfrom'] = $ip;
$account->save_repository();
}
} }
?> ?>

View File

@ -1,28 +1,28 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Auth from HTTP * * eGroupWare API - Auth from HTTP *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> * * This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> * * and Joseph Engo <jengo@phpgroupware.org> *
* Authentication based on HTTP auth * * Authentication based on HTTP auth *
* Copyright (C) 2000, 2001 Dan Kuykendall * * Copyright (C) 2000, 2001 Dan Kuykendall *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is part of the eGroupWare API * * This library is part of the eGroupWare API *
* http://www.egroupware.org/api * * http://www.egroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class auth_ class auth_
{ {
@ -44,17 +44,4 @@
{ {
return False; return False;
} }
// Since there account data will still be stored in SQL, this should be safe to do. (jengo)
function update_lastlogin($account_id, $ip)
{
$GLOBALS['egw']->db->query("SELECT account_lastlogin FROM phpgw_accounts WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
$GLOBALS['egw']->db->next_record();
$this->previous_login = $GLOBALS['egw']->db->f('account_lastlogin');
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
}
} }
?>

View File

@ -29,6 +29,13 @@
{ {
var $previous_login = -1; var $previous_login = -1;
/**
* authentication against LDAP
*
* @param string $username username of account to authenticate
* @param string $passwd corresponding password
* @return boolean true if successful authenticated, false otherwise
*/
function authenticate($username, $passwd) function authenticate($username, $passwd)
{ {
if (ereg('[()|&=*,<>!~]',$username)) if (ereg('[()|&=*,<>!~]',$username))
@ -91,7 +98,7 @@
{ {
if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap') if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap')
{ {
$account = CreateObject('phpgwapi.accounts',$username,'u'); $account =& CreateObject('phpgwapi.accounts',$username,'u');
if (!$account->account_id && $GLOBALS['egw_info']['server']['auto_create_acct']) if (!$account->account_id && $GLOBALS['egw_info']['server']['auto_create_acct'])
{ {
// create a global array with all availible info about that account // create a global array with all availible info about that account
@ -119,15 +126,23 @@
return False; return False;
} }
function change_password($old_passwd, $new_passwd, $_account_id='') /**
* changes password in LDAP
*
* @param string $old_passwd must be cleartext or empty to not to be checked
* @param string $new_passwd must be cleartext
* @param int $account_id account id of user whose passwd should be changed
* @return boolean true if password successful changed, false otherwise
*/
function change_password($old_passwd, $new_passwd, $account_id=0)
{ {
if ('' == $_account_id) if (!$_account_id)
{ {
$username = $GLOBALS['egw_info']['user']['account_lid']; $username = $GLOBALS['egw_info']['user']['account_lid'];
} }
else else
{ {
$username = $GLOBALS['egw']->accounts->id2name($_account_id); $username = $GLOBALS['egw']->accounts->id2name($account_id);
} }
$filter = $GLOBALS['egw_info']['server']['ldap_search_filter'] ? $GLOBALS['egw_info']['server']['ldap_search_filter'] : '(uid=%user)'; $filter = $GLOBALS['egw_info']['server']['ldap_search_filter'] ? $GLOBALS['egw_info']['server']['ldap_search_filter'] : '(uid=%user)';
$filter = str_replace(array('%user','%domain'),array($username,$GLOBALS['egw_info']['user']['domain']),$filter); $filter = str_replace(array('%user','%domain'),array($username,$GLOBALS['egw_info']['user']['domain']),$filter);
@ -139,41 +154,14 @@
$entry['userpassword'] = $this->encrypt_password($new_passwd); $entry['userpassword'] = $this->encrypt_password($new_passwd);
$dn = $allValues[0]['dn']; $dn = $allValues[0]['dn'];
if (!@ldap_modify($ds, $dn, $entry)) if ($old_passwd && $GLOBALS['egw']->auth->encrypt_password($old_passwd) != $allValues[0]['userpassword'] || !@ldap_modify($ds, $dn, $entry))
{ {
return false; return false;
} }
$GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd); if($old_passwd) // if old password given (not called by admin) update the password in the session
{
$GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd);
}
return $entry['userpassword']; return $entry['userpassword'];
} }
function update_lastlogin($_account_id, $ip)
{
if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap')
{
$entry['phpgwaccountlastlogin'] = time();
$entry['phpgwaccountlastloginfrom'] = $ip;
$ds = $GLOBALS['egw']->common->ldapConnect();
$sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], 'uidnumber=' . (int)$_account_id);
$allValues = ldap_get_entries($ds, $sri);
$dn = $allValues[0]['dn'];
$this->previous_login = $allValues[0]['phpgwaccountlastlogin'][0];
@ldap_modify($ds, $dn, $entry);
}
else
{
$GLOBALS['egw']->db->query("SELECT account_lastlogin FROM phpgw_accounts WHERE account_id=" . (int)$_account_id,__LINE__,__FILE__);
$GLOBALS['egw']->db->next_record();
$this->previous_login = $GLOBALS['egw']->db->f('account_lastlogin');
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' WHERE account_id=" . (int)$_account_id,__LINE__,__FILE__);
}
}
} }
?>

View File

@ -1,27 +1,27 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Auth from Mail server * * eGroupWare API - Auth from Mail server *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> * * This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* Authentication based on mail server * * Authentication based on mail server *
* Copyright (C) 2000, 2001 Dan Kuykendall * * Copyright (C) 2000, 2001 Dan Kuykendall *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is part of the eGroupWare API * * This library is part of the eGroupWare API *
* http://www.egroupware.org/api * * http://www.egroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class auth_ class auth_
{ {
@ -29,8 +29,6 @@
function authenticate($username, $passwd) function authenticate($username, $passwd)
{ {
error_reporting(error_reporting() - 2);
if ($GLOBALS['egw_info']['server']['mail_login_type'] == 'vmailmgr') if ($GLOBALS['egw_info']['server']['mail_login_type'] == 'vmailmgr')
{ {
$username = $username . '@' . $GLOBALS['egw_info']['server']['mail_suffix']; $username = $username . '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
@ -76,33 +74,17 @@
.':'.$GLOBALS['egw_info']['server']['mail_port'].'}INBOX', $username , $passwd); .':'.$GLOBALS['egw_info']['server']['mail_port'].'}INBOX', $username , $passwd);
} }
error_reporting(error_reporting() + 2);
if ($mailauth == False) if ($mailauth == False)
{ {
return False; return False;
} }
else imap_close($mailauth);
{
imap_close($mailauth); return True;
return True;
}
} }
function change_password($old_passwd, $new_passwd) function change_password($old_passwd, $new_passwd)
{ {
return False; return False;
} }
// Since there account data will still be stored in SQL, this should be safe to do. (jengo)
function update_lastlogin($account_id, $ip)
{
$GLOBALS['egw']->db->query("SELECT account_lastlogin FROM phpgw_accounts WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
$GLOBALS['egw']->db->next_record();
$this->previous_login = $GLOBALS['egw']->db->f('account_lastlogin');
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
}
} }
?>

View File

@ -57,14 +57,4 @@
// can't change passwords unless server runs as root (bad idea) // can't change passwords unless server runs as root (bad idea)
return( False ); return( False );
} }
function update_lastlogin($account_id, $ip)
{
$account_id = get_account_id($account_id);
$GLOBALS['egw']->db->query("update phpgw_accounts set account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' where account_id='$account_id'",__LINE__,__FILE__);
}
} }
?>

View File

@ -1,24 +1,24 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Auth from PAM * * eGroupWare API - Auth from PAM *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is part of the eGroupWare API * * This library is part of the eGroupWare API *
* http://www.egroupware.org/api * * http://www.egroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class auth_ class auth_
{ {
@ -28,25 +28,12 @@
{ {
return True; return True;
} }
else return False;
{
return False;
}
} }
function change_password($old_passwd, $new_passwd, $account_id='') function change_password($old_passwd, $new_passwd, $account_id='')
{ {
// deny password changes. // deny password changes.
return( False ); return False;
}
function update_lastlogin($account_id, $ip)
{
$account_id = get_account_id($account_id);
$GLOBALS['egw']->db->query('UPDATE phpgw_accounts SET account_lastloginfrom='
. $GLOBALS['egw']->db->quote($ip).', account_lastlogin=' . time()
. ' WHERE account_id='.(int)$account_id,__LINE__,__FILE__);
} }
} }
?>

View File

@ -1,31 +1,31 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Auth from SQL * * eGroupWare API - Auth from SQL *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> * * This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> * * and Joseph Engo <jengo@phpgroupware.org> *
* Encryption types other than md5() added by * * Encryption types other than md5() added by *
* Miles Lott <milos@groupwhere.org> based on code from * * Miles Lott <milos@groupwhere.org> based on code from *
* http://www.thomas-alfeld.de/frank/ * * http://www.thomas-alfeld.de/frank/ *
* massive code cleanup and * * massive code cleanup and *
* added password migration by * * added password migration by *
* Cornelius Weiss <egw@von-und-zu-weiss.de * * Cornelius Weiss <egw@von-und-zu-weiss.de *
* Authentication based on SQL table * * Authentication based on SQL table *
* Copyright (C) 2000, 2001 Dan Kuykendall * * Copyright (C) 2000, 2001 Dan Kuykendall *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class auth_ class auth_
{ {
@ -34,98 +34,90 @@
function auth_() function auth_()
{ {
copyobj($GLOBALS['egw']->db,$this->db); $this->db = clone($GLOBALS['egw']->db);
$this->type = @$GLOBALS['egw_info']['server']['sql_encryption_type'] $this->db->set_app('phpgwapi');
? strtolower($GLOBALS['egw_info']['server']['sql_encryption_type']) $this->table = 'egw_accounts';
: 'md5';
$this->type = @$GLOBALS['egw_info']['server']['sql_encryption_type'] ?
strtolower($GLOBALS['egw_info']['server']['sql_encryption_type']) : 'md5';
} }
/*! /**
@function authenticate * password authentication against password stored in sql datababse
@abstract password authentication against password stored in sql datababse *
@param $username username of account to authenticate * @param string $username username of account to authenticate
@param $passwd corresponding password * @param string $passwd corresponding password
@param $passwd_type 'text' for cleartext passwords * @param string $passwd_type='text' 'text' for cleartext passwords (default)
*/ * @return boolean true if successful authenticated, false otherwise
function authenticate($username, $passwd, $passwd_type) */
function authenticate($username, $passwd, $passwd_type='text')
{ {
/* normal web form login */ /* normal web form login */
if($passwd_type == 'text') if($passwd_type == 'text')
{ {
$this->db->query("SELECT account_lid,account_pwd,account_lastlogin FROM phpgw_accounts WHERE account_lid = '$username' AND " $this->db->select($this->table,'account_lid,account_pwd,account_lastlogin',array(
. " account_type='u' AND " 'account_lid' => $username,
. " account_status ='A'",__LINE__,__FILE__); 'account_type' => 'u',
$this->db->next_record(); 'account_status' => 'A'
),__LINE__,__FILE__);
if($GLOBALS['egw_info']['server']['case_sensitive_username'] == true) if(!$this->db->next_record() || !$this->db->f('account_pwd') ||
$GLOBALS['egw_info']['server']['case_sensitive_username'] && $this->db->f('account_lid') != $username)
{ {
if($this->db->f('account_lid') != $username) return false; return false;
} }
if(!$this->db->f('account_pwd')) return false;
if(!$this->compare_password($passwd,$this->db->f('account_pwd'),$this->type,strtolower($username))) if(!$this->compare_password($passwd,$this->db->f('account_pwd'),$this->type,strtolower($username)))
{ {
$match = false;
// do we have to migrate an old password ? // do we have to migrate an old password ?
if($GLOBALS['egw_info']['server']['pwd_migration_allowed']) if($GLOBALS['egw_info']['server']['pwd_migration_allowed'] && !emplty($GLOBALS['egw_info']['server']['pwd_migration_types']))
{ {
if(!isset($GLOBALS['egw_info']['server']['pwd_migration_types'])) return false; foreach(explode(',', $GLOBALS['egw_info']['server']['pwd_migration_types']) as $type)
$allowed_types = explode(',', $GLOBALS['egw_info']['server']['pwd_migration_types']);
foreach($allowed_types as $num => $type)
{ {
if($this->compare_password($passwd,$this->db->f('account_pwd'),$type,strtolower($username))) if($this->compare_password($passwd,$this->db->f('account_pwd'),$type,strtolower($username)))
{ {
$account_id = $GLOBALS['egw_info']['user']['account_id']; $account_id = $GLOBALS['egw_info']['user']['account_id'];
$encrypted_passwd = $this->encrypt_sql($passwd); $encrypted_passwd = $this->encrypt_sql($passwd);
$this->_update_passwd($encrypted_passwd,$passwd,$account_id,false,__FILE__); $this->_update_passwd($encrypted_passwd,$passwd,$account_id);
$match = true;
break; break;
} }
return false;
} }
} }
else if (!$match) return false;
{
return false;
}
} }
/* if this point is reached, auth was successfull */
$this->previous_login = $this->db->f('account_lastlogin');
return true;
} }
/* Auth via crypted password. NOTE: mail needs cleartext password to authenticate against mailserver! */ /* Auth via crypted password. NOTE: mail needs cleartext password to authenticate against mailserver! */
else else
{ {
$this->db->query("SELECT * FROM phpgw_accounts WHERE account_lid = '$username' AND " $this->db->select($this->table,'account_lid,account_lastlogin',array(
. "account_pwd='" . $passwd . "' AND account_status ='A'",__LINE__,__FILE__); 'account_lid' => $username,
$this->db->next_record(); 'account_type' => 'u',
'account_status' => 'A',
'account_pwd' => $passwd,
),__LINE__,__FILE__);
if($GLOBALS['egw_info']['server']['case_sensitive_username'] == true) if(!$this->db->next_record() ||
$GLOBALS['egw_info']['server']['case_sensitive_username'] && $this->db->f('account_lid') != $username)
{ {
if($this->db->f('account_lid') != $username) return false;
{
return false;
}
}
if($this->db->f('account_lid'))
{
$this->previous_login = $this->db->f('account_lastlogin');
return True;
}
else
{
return False;
} }
} }
// if this point is reached, auth was successfull
$this->previous_login = $this->db->f('account_lastlogin');
return true;
} }
/*! /**
@function change_password * changes password in sql datababse
@abstract changes password in sql datababse *
@param $old_passwd must be cleartext * @param string $old_passwd must be cleartext
@param $new_passwd must be cleartext * @param string $new_passwd must be cleartext
@param $account_id account id of user whose passwd should be changed * @param int $account_id account id of user whose passwd should be changed
*/ * @return boolean true if password successful changed, false otherwise
function change_password($old_passwd, $new_passwd, $account_id = '') */
function change_password($old_passwd, $new_passwd, $account_id=0)
{ {
$admin = True; $admin = True;
// Don't allow password changes for other accounts when using XML-RPC // Don't allow password changes for other accounts when using XML-RPC
@ -135,56 +127,49 @@
$account_id = $GLOBALS['egw_info']['user']['account_id']; $account_id = $GLOBALS['egw_info']['user']['account_id'];
} }
$this->db->query("SELECT account_pwd FROM phpgw_accounts WHERE account_id = " . (int)$account_id $this->db->select($this->table,'account_pwd',array(
. " AND " // . " account_type='u' AND " 'account_id' => $account_id,
. " account_status ='A'",__LINE__,__FILE__); 'account_type' => 'u',
$this->db->next_record(); 'account_status' => 'A',
if(!$this->db->f('account_pwd')) return false; ),__LINE__,__FILE__);
if(!$this->db->next_record()) return false; // account not found
/* Check the old_passwd to make sure this is legal */ /* Check the old_passwd to make sure this is legal */
if(!$admin) if(!$admin && !$this->compare_password($old_passwd,$this->db->f('account_pwd'),$this->type,strtolower($username)))
{ {
if(!$this->compare_password($old_passwd,$this->db->f('account_pwd'),$this->type,strtolower($username))) return false;
{
return false;
}
} }
/* old password ok, or admin called the function from the admin application (no old passwd available).*/ /* old password ok, or admin called the function from the admin application (no old passwd available).*/
$encrypted_passwd = $this->encrypt_sql($new_passwd); return $this->_update_passwd($this->encrypt_sql($new_passwd),$new_passwd,$account_id,$admin);
return $this->_update_passwd($encrypted_passwd,$new_passwd,$account_id,$admin,__FILE__);
} }
function _update_passwd($encrypted_passwd,$new_passwd,$account_id,$admin=False,$file='') /**
* changes password in sql datababse
*
* @internal
* @param string $encrypted_passwd
* @param string $new_passwd cleartext
* @param int $account_id account id of user whose passwd should be changed
* @param boolean $admin=false called by admin, if not update password in the session
* @return boolean true if password successful changed, false otherwise
*/
function _update_passwd($encrypted_passwd,$new_passwd,$account_id,$admin=false)
{ {
/* This should only be called from this file */ $this->db->update($this->table,array(
if($file != EGW_API_INC . SEP . 'class.auth_sql.inc.php') 'account_pwd' => $encrypted_passwd,
{ 'account_lastpwd_change' => time(),
return False; ),array(
} 'account_id' => $account_id,
$this->db->query("UPDATE phpgw_accounts SET account_pwd='" . $encrypted_passwd . "'," ),__LINE__,__FILE__);
. "account_lastpwd_change='" . time()
. "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
$this->db->next_record();
if($this->db->affected_rows())
{
if(!$admin)
{
$GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd);
}
return $encrypted_passwd;
}
else
{
return False;
}
}
function update_lastlogin($account_id, $ip) if(!$this->db->affected_rows()) return false;
{
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_lastloginfrom='" if(!$admin)
. "$ip', account_lastlogin='" . time() {
. "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__); $GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd);
}
return $encrypted_passwd;
} }
} }
?>

View File

@ -31,6 +31,8 @@
function auth_() function auth_()
{ {
$this->db = clone($GLOBALS['egw']->db); $this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('phpgwapi');
$this->table = 'egw_accounts';
} }
function authenticate($username, $passwd) function authenticate($username, $passwd)
@ -41,6 +43,16 @@
{ {
echo "<b>Debug SQL: uid - $username passwd - $passwd</b>"; echo "<b>Debug SQL: uid - $username passwd - $passwd</b>";
} }
$this->db->select($this->table,'account_lid,account_pwd',array(
'account_lid' => $username,
'account_status' => 'A',
'account_type' => 'u',
),__LINE__,__FILE__);
if (!$this->db->next_record() || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $db->f('account_lid') != $username)
{
return false;
}
# Apache + mod_ssl provide the data in the environment # Apache + mod_ssl provide the data in the environment
# Certificate (chain) verification occurs inside mod_ssl # Certificate (chain) verification occurs inside mod_ssl
@ -48,32 +60,9 @@
if(!isset($_SERVER['SSL_CLIENT_S_DN'])) if(!isset($_SERVER['SSL_CLIENT_S_DN']))
{ {
# if we're not doing SSL authentication, behave like auth_sql # if we're not doing SSL authentication, behave like auth_sql
$this->db->query("SELECT * FROM phpgw_accounts WHERE account_lid = '$username' AND " return $this->compare_password($passwd,$this->db->f('account_pwd'),$this->type,strtolower($username));
. "account_pwd='" . md5($passwd) . "' AND account_status ='A'",__LINE__,__FILE__);
$this->db->next_record();
}
else
{
# use username only for authentication, ignore X.509 subject in $passwd for now
$this->db->query("SELECT * FROM phpgw_accounts WHERE account_lid = '$username' AND account_status ='A'",__LINE__,__FILE__);
$this->db->next_record();
}
if($GLOBALS['egw_info']['server']['case_sensitive_username'] == true)
{
if($db->f('account_lid') != $username)
{
return false;
}
}
if($this->db->f('account_lid'))
{
return True;
}
else
{
return False;
} }
return True;
} }
function change_password($old_passwd, $new_passwd, $account_id = '') function change_password($old_passwd, $new_passwd, $account_id = '')
@ -83,25 +72,17 @@
$account_id = $GLOBALS['egw_info']['user']['account_id']; $account_id = $GLOBALS['egw_info']['user']['account_id'];
} }
$encrypted_passwd = md5($new_passwd); $encrypted_passwd = $this->encrypt_sql($new_passwd);
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_pwd='" . md5($new_passwd) . "'," $GLOBALS['egw']->db->update($this->table,array(
. "account_lastpwd_change='" . time() . "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__); 'account_pwd' => $encrypted_passwd,
'account_lastpwd_change' => time(),
),array(
'account_id' => $account_id,
),__LINE__,__FILE__);
$GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd); $GLOBALS['egw']->session->appsession('password','phpgwapi',$new_passwd);
return $encrypted_passwd; return $encrypted_passwd;
} }
function update_lastlogin($account_id, $ip)
{
$GLOBALS['egw']->db->query("SELECT account_lastlogin FROM phpgw_accounts WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
$GLOBALS['egw']->db->next_record();
$this->previous_login = $GLOBALS['egw']->db->f('account_lastlogin');
$GLOBALS['egw']->db->query("UPDATE phpgw_accounts SET account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' WHERE account_id=" . (int)$account_id,__LINE__,__FILE__);
}
} }
?>

View File

@ -1,31 +1,31 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* eGroupWare API - Commononly used functions * * eGroupWare API - Commononly used functions *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> * * This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> * * and Joseph Engo <jengo@phpgroupware.org> *
* and Mark Peters <skeeter@phpgroupware.org> * * and Mark Peters <skeeter@phpgroupware.org> *
* and Lars Kneschke <lkneschke@linux-at-work.de> * * and Lars Kneschke <lkneschke@linux-at-work.de> *
* Functions commonly used by eGroupWare developers * * Functions commonly used by eGroupWare developers *
* Copyright (C) 2000, 2001 Dan Kuykendall * * Copyright (C) 2000, 2001 Dan Kuykendall *
* Copyright (C) 2003 Lars Kneschke * * Copyright (C) 2003 Lars Kneschke *
* -------------------------------------------------------------------------* * -------------------------------------------------------------------------*
* This library is part of the eGroupWare API * * This library is part of the eGroupWare API *
* http://www.egroupware.org * * http://www.egroupware.org *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
$d1 = strtolower(@substr(EGW_API_INC,0,3)); $d1 = strtolower(@substr(EGW_API_INC,0,3));
$d2 = strtolower(@substr(EGW_SERVER_ROOT,0,3)); $d2 = strtolower(@substr(EGW_SERVER_ROOT,0,3));
@ -37,22 +37,22 @@
} }
unset($d1);unset($d2);unset($d3); unset($d1);unset($d2);unset($d3);
/*! /**
@class common * common class that contains commonly used functions
@abstract common class that contains commonly used functions *
*/ */
class common class common
{ {
var $debug_info; // An array with debugging info from the API var $debug_info; // An array with debugging info from the API
var $found_files; var $found_files;
/*! /**
@function cmp_version * Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1 *
@discussion This function checks for major version only. * This function checks for major version only.
@param $str1 * @param $str1
@param $str2 * @param $str2
*/ */
function cmp_version($str1,$str2,$debug=False) function cmp_version($str1,$str2,$debug=False)
{ {
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str1,$regs); ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str1,$regs);
@ -77,13 +77,13 @@
} }
} }
/*! /**
@function cmp_version_long * Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1 *
@discussion This function checks all fields. cmp_version() checks release version only. * This function checks all fields. cmp_version() checks release version only.
@param $str1 * @param $str1
@param $str2 * @param $str2
*/ */
function cmp_version_long($str1,$str2,$debug=False) function cmp_version_long($str1,$str2,$debug=False)
{ {
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)\.([0-9]*)",$str1,$regs); ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)\.([0-9]*)",$str1,$regs);
@ -114,12 +114,12 @@
} }
// Convert an array into the format needed for the access column. // Convert an array into the format needed for the access column.
/*! /**
@function array_to_string * Convert an array into the format needed for the access column
@abstract Convert an array into the format needed for the access column *
@param $access * @param $access
@param $array * @param $array
*/ */
function array_to_string($access,$array) function array_to_string($access,$array)
{ {
$this->debug_info[] = 'array_to_string() is a depreciated function - use ACL instead'; $this->debug_info[] = 'array_to_string() is a depreciated function - use ACL instead';
@ -175,12 +175,12 @@
} }
// This is used for searching the access fields // This is used for searching the access fields
/*! /**
@function sql_search * this function is used for searching the access fields
@abstract this function is used for searching the access fields *
@param $table * @param $table
@param $owner * @param $owner
*/ */
function sql_search($table,$owner=0) function sql_search($table,$owner=0)
{ {
$this->debug_info[] = 'sql_search() is a deprecated function - use ACL instead'; $this->debug_info[] = 'sql_search() is a deprecated function - use ACL instead';
@ -201,11 +201,11 @@
} }
// return a array of installed languages // return a array of installed languages
/*! /**
@function getInstalledLanguages * return an array of installed languages
@abstract return an array of installed languages *
@result $installedLanguages; an array containing the installed languages * @return $installedLanguages; an array containing the installed languages
*/ */
function getInstalledLanguages() function getInstalledLanguages()
{ {
$GLOBALS['egw']->db->query('SELECT DISTINCT lang FROM phpgw_lang'); $GLOBALS['egw']->db->query('SELECT DISTINCT lang FROM phpgw_lang');
@ -220,12 +220,12 @@
// return the preferred language of the users // return the preferred language of the users
// it's using HTTP_ACCEPT_LANGUAGE (send from the users browser) // it's using HTTP_ACCEPT_LANGUAGE (send from the users browser)
// and ...(to find out which languages are installed) // and ...(to find out which languages are installed)
/*! /**
@function getPreferredLanguage * return the preferred langugae of the users
@abstract return the preferred langugae of the users *
@discussion it uses HTTP_ACCEPT_LANGUAGE (from the users browser) <br> * it uses HTTP_ACCEPT_LANGUAGE (from the users browser) <br>
and .... to find out which languages are installed * and .... to find out which languages are installed
*/ */
function getPreferredLanguage() function getPreferredLanguage()
{ {
// create a array of languages the user is accepting // create a array of languages the user is accepting
@ -257,27 +257,27 @@
return $retValue; return $retValue;
} }
/*! /**
@function ldap_addslashes * escapes a string for use in searchfilters meant for ldap_search.
@abstract escapes a string for use in searchfilters meant for ldap_search. *
Escaped Characters are: '*', '(', ')', ' ', '\', NUL * Escaped Characters are: '*', '(', ')', ' ', '\', NUL
It's actually a PHP-Bug, that we have to escape space. * It's actually a PHP-Bug, that we have to escape space.
For all other Characters, refer to RFC2254. * For all other Characters, refer to RFC2254.
@param $string either a string to be escaped, or an array of values to be escaped * @param $string either a string to be escaped, or an array of values to be escaped
*/ */
function ldap_addslashes($string='') function ldap_addslashes($string='')
{ {
return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string); return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string);
} }
// connect to the ldap server and return a handle // connect to the ldap server and return a handle
/*! /**
@function ldapConnect * connect to the ldap server and return a handle
@abstract connect to the ldap server and return a handle *
@param $host ldap host * @param $host ldap host
@param $dn ldap_root_dn * @param $dn ldap_root_dn
@param $passwd ldap_root_pw * @param $passwd ldap_root_pw
*/ */
function ldapConnect($host='', $dn='', $passwd='') function ldapConnect($host='', $dn='', $passwd='')
{ {
if(!function_exists('ldap_connect')) if(!function_exists('ldap_connect'))
@ -319,6 +319,7 @@
} }
printf("<b>Error: Can't connect to LDAP server %s!</b><br>",$host); printf("<b>Error: Can't connect to LDAP server %s!</b><br>",$host);
echo function_backtrace(1);
return False; return False;
} }
@ -340,19 +341,20 @@
} }
printf("<b>Error: Can't bind to LDAP server: %s!</b><br>",$dn); printf("<b>Error: Can't bind to LDAP server: %s!</b><br>",$dn);
echo function_backtrace(1);
return False; return False;
} }
return $ds; return $ds;
} }
/*! /**
@function egw_exit * function to stop running an app
@abstract function to stop running an app *
@discussion used to stop running an app in the middle of execution <br> * used to stop running an app in the middle of execution <br>
There may need to be some cleanup before hand * There may need to be some cleanup before hand
@param $call_footer boolean value to if true then call footer else exit * @param $call_footer boolean value to if true then call footer else exit
*/ */
function egw_exit($call_footer = False) function egw_exit($call_footer = False)
{ {
if (!defined('EGW_EXIT')) if (!defined('EGW_EXIT'))
@ -393,11 +395,11 @@
} }
} }
/*! /**
@function randomstring * return a random string of size $size
@abstract return a random string of size $size *
@param $size int-size of random string to return * @param $size int-size of random string to return
*/ */
function randomstring($size) function randomstring($size)
{ {
$s = ''; $s = '';
@ -422,11 +424,11 @@
return filesystem_separator(); return filesystem_separator();
} }
/*! /**
@function error_list * This is used for reporting errors in a nice format.
@abstract This is used for reporting errors in a nice format. *
@param $error - array of errors * @param $error - array of errors
*/ */
function error_list($errors,$text='Error') function error_list($errors,$text='Error')
{ {
if (! is_array($errors)) if (! is_array($errors))
@ -443,14 +445,14 @@
return $html_error . '</table>'; return $html_error . '</table>';
} }
/*! /**
@function check_owner * none yet
@abstract none yet *
@param $record ? * @param $record ?
@param $link ? * @param $link ?
@param $label ? * @param $label ?
@param $extravars * @param $extravars
*/ */
// This is a depreciated function - use ACL instead (jengo) // This is a depreciated function - use ACL instead (jengo)
function check_owner($record,$link,$label,$extravars = '') function check_owner($record,$link,$label,$extravars = '')
{ {
@ -476,13 +478,13 @@
*/ */
} }
/*! /**
@function display_fullname * return the fullname of a user
@abstract return the fullname of a user *
@param $lid account loginid * @param $lid account loginid
@param $firstname firstname * @param $firstname firstname
@param $lastname lastname * @param $lastname lastname
*/ */
function display_fullname($lid = '', $firstname = '', $lastname = '') function display_fullname($lid = '', $firstname = '', $lastname = '')
{ {
if (! $lid && ! $firstname && ! $lastname) if (! $lid && ! $firstname && ! $lastname)
@ -529,30 +531,30 @@
return $name; return $name;
} }
/*! /**
@function grab_owner_name * grab the owner name
@abstract grab the owner name *
@param $id account id * @param $id account id
*/ */
function grab_owner_name($accountid = '') function grab_owner_name($accountid = '')
{ {
$GLOBALS['egw']->accounts->get_account_name($accountid,$lid,$fname,$lname); $GLOBALS['egw']->accounts->get_account_name($accountid,$lid,$fname,$lname);
return $this->display_fullname($lid,$fname,$lname); return $this->display_fullname($lid,$fname,$lname);
} }
/*! /**
@function create_tabs * create tabs
@abstract create tabs *
@param array $tabs an array repersenting the tabs you wish to display, each element * @param array $tabs an array repersenting the tabs you wish to display, each element
in the array is an array of 3 elements, 'label' which is the * * * in the array is an array of 3 elements, 'label' which is the
text displaed on the tab (you should pass translated string, * * * text displaed on the tab (you should pass translated string,
create_tabs will not do <code>lang()</code> for you), 'link' * * * create_tabs will not do <code>lang()</code> for you), 'link'
which is the uri, 'target', the frame name or '_blank' to show * * * which is the uri, 'target', the frame name or '_blank' to show
page in a new browser window. * * * page in a new browser window.
@param mixed $selected the tab whos key is $selected will be displayed as current tab * @param mixed $selected the tab whos key is $selected will be displayed as current tab
@param $fontsize optional * @param $fontsize optional
@return string return html that displays the tabs * @return string return html that displays the tabs
*/ */
function create_tabs($tabs, $selected, $fontsize = '') function create_tabs($tabs, $selected, $fontsize = '')
{ {
$output_text = '<table border="0" cellspacing="0" cellpadding="0"><tr>'; $output_text = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
@ -638,12 +640,12 @@
return $output_text; return $output_text;
} }
/*! /**
@function get_app_dir * get directory of application
@abstract get directory of application *
@discussion $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp']; * $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp'];
@param $appname name of application * @param $appname name of application
*/ */
function get_app_dir($appname = '') function get_app_dir($appname = '')
{ {
if ($appname == '') if ($appname == '')
@ -672,12 +674,12 @@
} }
} }
/*! /**
@function get_inc_dir * get inc (include dir) of application
@abstract get inc (include dir) of application *
@discussion $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp']; * $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp'];
@param $appname name of application * @param $appname name of application
*/ */
function get_inc_dir($appname = '') function get_inc_dir($appname = '')
{ {
if (! $appname) if (! $appname)
@ -706,12 +708,12 @@
} }
} }
/*! /**
@function list_themes * list themes available
@abstract list themes available *
@note themes can either be css file like in HEAD (if the template has a css-dir and has css-files in is) \ * themes can either be css file like in HEAD (if the template has a css-dir and has css-files in is) \
or ordinary .14 themes-files * or ordinary .14 themes-files
*/ */
function list_themes() function list_themes()
{ {
$tpl_dir = $this->get_tpl_dir('phpgwapi'); $tpl_dir = $this->get_tpl_dir('phpgwapi');
@ -752,7 +754,7 @@
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates'); $d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
while ($entry=$d->read()) while ($entry=$d->read())
{ {
if ($entry != '..' && is_file(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/setup/setup.inc.php') if ($entry != '..' && is_file(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/setup/setup.inc.php')
) )
{ {
$list[$entry]['name'] = $entry; $list[$entry]['name'] = $entry;
@ -776,11 +778,11 @@
return $list; return $list;
} }
/*! /**
@function get_tpl_dir * get template dir of an application
@abstract get template dir of an application *
@param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp']; * @param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp'];
*/ */
function get_tpl_dir($appname = '') function get_tpl_dir($appname = '')
{ {
if (! $appname) if (! $appname)
@ -832,12 +834,12 @@
} }
} }
/*! /**
@function is_image_dir * checks if image_dir exists and has more than just a navbar-icon
@abstract checks if image_dir exists and has more than just a navbar-icon *
@note this is just a workaround for idots, better to use find_image, which has a fallback \ * this is just a workaround for idots, better to use find_image, which has a fallback \
on a per image basis to the default dir * on a per image basis to the default dir
*/ */
function is_image_dir($dir) function is_image_dir($dir)
{ {
if (!@is_dir($dir)) if (!@is_dir($dir))
@ -858,11 +860,11 @@
return False; return False;
} }
/*! /**
@function get_image_dir * get image dir of an application
@abstract get image dir of an application *
@param $appname application name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp']; * @param $appname application name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp'];
*/ */
function get_image_dir($appname = '') function get_image_dir($appname = '')
{ {
if ($appname == '') if ($appname == '')
@ -897,11 +899,11 @@
} }
} }
/*! /**
@function get_image_path * get image path of an application
@abstract get image path of an application *
@param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp']; * @param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp'];
*/ */
function get_image_path($appname = '') function get_image_path($appname = '')
{ {
if ($appname == '') if ($appname == '')
@ -1109,11 +1111,11 @@
} }
} }
/*! /**
@function navbar * none yet
@abstract none yet *
@discussion *someone wanna add some detail here* * *someone wanna add some detail here*
*/ */
function navbar() function navbar()
{ {
@ -1205,10 +1207,10 @@
$GLOBALS['egw_info']['navbar']['logout']['icon_hover'] = $this->image_on('phpgwapi',Array('logout','nonav'),'-over'); $GLOBALS['egw_info']['navbar']['logout']['icon_hover'] = $this->image_on('phpgwapi',Array('logout','nonav'),'-over');
} }
/*! /**
@function app_header * load header.inc.php for an application
@abstract load header.inc.php for an application *
*/ */
function app_header() function app_header()
{ {
if (file_exists(EGW_APP_INC . '/header.inc.php')) if (file_exists(EGW_APP_INC . '/header.inc.php'))
@ -1217,10 +1219,10 @@
} }
} }
/*! /**
@function egw_header * load the phpgw header
@abstract load the phpgw header *
*/ */
function egw_header() function egw_header()
{ {
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
@ -1261,7 +1263,7 @@
*/ */
function get_css() function get_css()
{ {
$tpl = createObject('phpgwapi.Template', $this->get_tpl_dir('phpgwapi')); $tpl =& CreateObject('phpgwapi.Template', $this->get_tpl_dir('phpgwapi'));
$tpl->set_file('css', 'css.tpl'); $tpl->set_file('css', 'css.tpl');
$tpl->set_var($GLOBALS['egw_info']['theme']); $tpl->set_var($GLOBALS['egw_info']['theme']);
$app_css = ''; $app_css = '';
@ -1350,7 +1352,7 @@
if ($GLOBALS['egw_info']['flags']['include_xajax']) if ($GLOBALS['egw_info']['flags']['include_xajax'])
{ {
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/xajax.inc.php'); require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/xajax.inc.php');
$xajax = new xajax($GLOBALS['egw']->link('/xajax.php')); $xajax =& new xajax($GLOBALS['egw']->link('/xajax.php'));
$xajax->registerFunction("doXMLHTTP"); $xajax->registerFunction("doXMLHTTP");
$java_script .= $xajax->getJavascript(); $java_script .= $xajax->getJavascript();
@ -1408,47 +1410,48 @@
return @pack('H' . $len, $data); return @pack('H' . $len, $data);
} }
/*! /**
@function encrypt * encrypt data passed to the function
@abstract encrypt data passed to the function *
@param $data data (string?) to be encrypted * @param $data data (string?) to be encrypted
*/ */
function encrypt($data) function encrypt($data)
{ {
return $GLOBALS['egw']->crypto->encrypt($data); return $GLOBALS['egw']->crypto->encrypt($data);
} }
/*! /**
@function decrypt * decrypt $data
@abstract decrypt $data *
@param $data data to be decrypted * @param $data data to be decrypted
*/ */
function decrypt($data) function decrypt($data)
{ {
return $GLOBALS['egw']->crypto->decrypt($data); return $GLOBALS['egw']->crypto->decrypt($data);
} }
/*! /**
@function encrypt_password * legacy wrapper for newer auth class function, encrypt_password
@abstract legacy wrapper for newer auth class function, encrypt_password *
@abstract uses the encryption type set in setup and calls the appropriate encryption functions * uses the encryption type set in setup and calls the appropriate encryption functions
@param $password password to encrypt *
*/ * @param $password password to encrypt
*/
function encrypt_password($password,$sql=False) function encrypt_password($password,$sql=False)
{ {
if(!@is_object($GLOBALS['egw']->auth)) if(!@is_object($GLOBALS['egw']->auth))
{ {
$GLOBALS['egw']->auth = CreateObject('phpgwapi.auth'); $GLOBALS['egw']->auth =& CreateObject('phpgwapi.auth');
} }
return $GLOBALS['egw']->auth->encrypt_password($password,$sql); return $GLOBALS['egw']->auth->encrypt_password($password,$sql);
} }
/*! /**
@function find_portal_order * find the current position of the app is the users portal_order preference
@abstract find the current position of the app is the users portal_order preference *
@param $app application id to find current position - required * @param $app application id to find current position - required
@discussion No discussion * No discussion
*/ */
function find_portal_order($app) function find_portal_order($app)
{ {
if(!is_array($GLOBALS['egw_info']['user']['preferences']['portal_order'])) if(!is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']))
@ -1468,20 +1471,20 @@
return -1; return -1;
} }
/*! /**
@function hook * temp wrapper to new hooks class
@abstract temp wrapper to new hooks class *
*/ */
function hook($location, $appname = '', $no_permission_check = False) function hook($location, $appname = '', $no_permission_check = False)
{ {
echo '$'."GLOBALS['phpgw']common->hook()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->process()".'. For now this will act as a wrapper<br>'; echo '$'."GLOBALS['phpgw']common->hook()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->process()".'. For now this will act as a wrapper<br>';
return $GLOBALS['egw']->hooks->process($location, $order, $no_permission_check); return $GLOBALS['egw']->hooks->process($location, $order, $no_permission_check);
} }
/*! /**
@function hook_single * temp wrapper to new hooks class
@abstract temp wrapper to new hooks class *
*/ */
// Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo) // Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo)
function hook_single($location, $appname = '', $no_permission_check = False) function hook_single($location, $appname = '', $no_permission_check = False)
{ {
@ -1489,10 +1492,10 @@
return $GLOBALS['egw']->hooks->single($location, $order, $no_permission_check); return $GLOBALS['egw']->hooks->single($location, $order, $no_permission_check);
} }
/*! /**
@function hook_count * temp wrapper to new hooks class
@abstract temp wrapper to new hooks class *
*/ */
function hook_count($location) function hook_count($location)
{ {
echo '$'."GLOBALS['phpgw']common->hook_count()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->count()".'. For now this will act as a wrapper<br>'; echo '$'."GLOBALS['phpgw']common->hook_count()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->count()".'. For now this will act as a wrapper<br>';
@ -1502,23 +1505,23 @@
/* Wrapper to the session->appsession() */ /* Wrapper to the session->appsession() */
function appsession($data = '##NOTHING##') function appsession($data = '##NOTHING##')
{ {
$this->debug_info[] = '$phpgw->common->appsession() is a depreciated function' $this->debug_info[] = "\$GLOBALS['egw']->common->appsession() is a depreciated function"
. ' - use $phpgw->session->appsession() instead'; . " - use \$GLOBALS['egw']->session->appsession() instead";
return $GLOBALS['egw']->session->appsession('default','',$data); return $GLOBALS['egw']->session->appsession('default','',$data);
} }
/*! /**
@function show_date * show current date
@abstract show current date *
@param $t time - optional can be pulled from user preferences * @param $t time - optional can be pulled from user preferences
@param $format - optional can be pulled from user prefernces * @param $format - optional can be pulled from user prefernces
*/ */
function show_date($t = '', $format = '') function show_date($t = '', $format = '')
{ {
if(!is_object($GLOBALS['egw']->datetime)) if(!is_object($GLOBALS['egw']->datetime))
{ {
$GLOBALS['egw']->datetime = createobject('phpgwapi.datetime'); $GLOBALS['egw']->datetime =& CreateObject('phpgwapi.datetime');
} }
if (!$t) if (!$t)
@ -1544,14 +1547,13 @@
return adodb_date($format,$t); return adodb_date($format,$t);
} }
/*! /**
@function dateformatorder * @abstract
@abstract * @param $yearstr year - string
@param $yearstr year - string * @param $monthstr month - string
@param $monthstr month - string * @param $day day - string
@param $day day - string * @param $add_seperator boolean defaults to false
@param $add_seperator boolean defaults to false */
*/
function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False) function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False)
{ {
$dateformat = strtolower($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']); $dateformat = strtolower($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']);
@ -1572,13 +1574,13 @@
} }
} }
/*! /**
@function formattime * format the time takes settings from user preferences
@abstract format the time takes settings from user preferences *
@param $hour hour * @param $hour hour
@param $min minutes * @param $min minutes
@param $sec defaults to '' * @param $sec defaults to ''
*/ */
function formattime($hour,$min,$sec='') function formattime($hour,$min,$sec='')
{ {
$h12 = $hour; $h12 = $hour;
@ -1618,11 +1620,11 @@
} }
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM // This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
/*! /**
@function get_email_passwd_ex * uses code in /email class msg to obtain the appropriate password for email
@abstract uses code in /email class msg to obtain the appropriate password for email *
@param (none - it will abtain the info it needs on its own) * @param (none - it will abtain the info it needs on its own)
*/ */
/* /*
function get_email_passwd_ex() function get_email_passwd_ex()
{ {
@ -1633,7 +1635,7 @@
} }
else else
{ {
$GLOBALS['egw']->msg = CreateObject('email.mail_msg'); $GLOBALS['egw']->msg =& CreateObject('email.mail_msg');
$do_free_me = True; $do_free_me = True;
} }
// use the Msg class to obtain the appropriate password // use the Msg class to obtain the appropriate password
@ -1656,13 +1658,13 @@
*/ */
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM // This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
/*! /**
@function create_emailpreferences * create email preferences
@abstract create email preferences *
@discussion This is not the best place for it, but it needs to be shared between Aeromail and SM * This is not the best place for it, but it needs to be shared between Aeromail and SM
@param $prefs * @param $prefs
@param $account_id -optional defaults to : phpgw_info['user']['account_id'] * @param $account_id -optional defaults to : phpgw_info['user']['account_id']
*/ */
function create_emailpreferences($prefs='',$accountid='') function create_emailpreferences($prefs='',$accountid='')
{ {
return $GLOBALS['egw']->preferences->create_email_preferences($accountid); return $GLOBALS['egw']->preferences->create_email_preferences($accountid);
@ -1673,7 +1675,7 @@
} }
else else
{ {
$GLOBALS['egw']->msg = CreateObject('email.mail_msg'); $GLOBALS['egw']->msg =& CreateObject('email.mail_msg');
$do_free_me = True; $do_free_me = True;
} }
@ -1772,11 +1774,11 @@
*/ */
// This will be moved into the applications area. // This will be moved into the applications area.
/*! /**
@function check_code * ?
@abstract ? *
@discussion This will be moved into the applications area * This will be moved into the applications area
*/ */
function check_code($code) function check_code($code)
{ {
$s = '<br>'; $s = '<br>';
@ -1863,13 +1865,13 @@
} }
return $s; return $s;
} }
/*! /**
@function phpgw_error * process error message
@abstract process error message *
@param $error error * @param $error error
@param $line line * @param $line line
@param $file file * @param $file file
*/ */
function phpgw_error($error,$line = '', $file = '') function phpgw_error($error,$line = '', $file = '')
{ {
echo '<p><b>eGroupWare internal error:</b><p>'.$error; echo '<p><b>eGroupWare internal error:</b><p>'.$error;
@ -1885,11 +1887,11 @@
exit; exit;
} }
/*! /**
@function create_phpcode_from_array * create phpcode from array
@abstract create phpcode from array *
@param $array - array * @param $array - array
*/ */
function create_phpcode_from_array($array) function create_phpcode_from_array($array)
{ {
while (list($key, $val) = each($array)) while (list($key, $val) = each($array))
@ -1934,11 +1936,11 @@
} }
// This will return the full phpgw_info array, used for debugging // This will return the full phpgw_info array, used for debugging
/*! /**
@function debug_list_array_contents * return the full phpgw_info array for debugging
@abstract return the full phpgw_info array for debugging *
@param array - array * @param array - array
*/ */
function debug_list_array_contents($array) function debug_list_array_contents($array)
{ {
while (list($key, $val) = each($array)) while (list($key, $val) = each($array))
@ -1978,10 +1980,10 @@
} }
// This will return a list of functions in the API // This will return a list of functions in the API
/*! /**
@function debug_list_core_functions * return a list of functionsin the API
@abstract return a list of functionsin the API *
*/ */
function debug_list_core_functions() function debug_list_core_functions()
{ {
echo '<br><b>core functions</b><br>'; echo '<br><b>core functions</b><br>';
@ -1992,10 +1994,10 @@
} }
// This will return a value for the next id an app/class may need to insert values into ldap. // This will return a value for the next id an app/class may need to insert values into ldap.
/*! /**
@function next_id * return the next higher value for an integer, and increment it in the db.
@abstract return the next higher value for an integer, and increment it in the db. *
*/ */
function next_id($appname,$min=0,$max=0) function next_id($appname,$min=0,$max=0)
{ {
if (!$appname) if (!$appname)
@ -2034,10 +2036,10 @@
// This will return a value for the last id entered, which an app may need to check // This will return a value for the last id entered, which an app may need to check
// values for ldap. // values for ldap.
/*! /**
@function last_id * return the current id in the next_id table for a particular app/class.
@abstract return the current id in the next_id table for a particular app/class. *
*/ */
function last_id($appname,$min=0,$max=0) function last_id($appname,$min=0,$max=0)
{ {
if (!$appname) if (!$appname)

View File

@ -28,6 +28,7 @@
var $appname; var $appname;
var $config_data; // actual config-data var $config_data; // actual config-data
var $read_data; // config-data as read from db var $read_data; // config-data as read from db
var $table = 'egw_config';
function config($appname = '') function config($appname = '')
{ {
@ -44,7 +45,6 @@
$this->db = clone($GLOBALS['egw_setup']->db); $this->db = clone($GLOBALS['egw_setup']->db);
} }
$this->db->set_app('phpgwapi'); $this->db->set_app('phpgwapi');
$this->table = 'phpgw_config';
$this->appname = $appname; $this->appname = $appname;
} }
@ -75,13 +75,12 @@
/** /**
* updates the whole repository for $this->appname, you have to call read_repository() before (!) * updates the whole repository for $this->appname, you have to call read_repository() before (!)
*
*/ */
function save_repository() function save_repository()
{ {
if (is_array($this->config_data)) if (is_array($this->config_data))
{ {
$this->db->lock(array('phpgw_config')); $this->db->lock(array($this->table));
foreach($this->config_data as $name => $value) foreach($this->config_data as $name => $value)
{ {
$this->save_value($name,$value); $this->save_value($name,$value);
@ -137,7 +136,7 @@
*/ */
function delete_repository() function delete_repository()
{ {
$this->db->delete("delete from phpgw_config where config_app='" . $this->appname . "'",__LINE__,__FILE__); $this->db->delete($this->table,array('config_app' => $this->appname),__LINE__,__FILE__);
} }
/** /**
@ -149,6 +148,7 @@
{ {
unset($this->config_data[$variable_name]); unset($this->config_data[$variable_name]);
} }
/** /**
* sets a single value in the repositry, you need to call save_repository after * sets a single value in the repositry, you need to call save_repository after
* *
@ -160,4 +160,3 @@
$this->config_data[$variable_name] = $variable_data; $this->config_data[$variable_name] = $variable_data;
} }
} }
?>

View File

@ -39,9 +39,9 @@
*/ */
function db_backup() function db_backup()
{ {
if (is_object($GLOBALS['phpgw_setup']->oProc)) // schema_proc already instanciated, use it if (is_object($GLOBALS['egw_setup']->oProc)) // schema_proc already instanciated, use it
{ {
$this->schema_proc = $GLOBALS['phpgw_setup']->oProc; $this->schema_proc = $GLOBALS['egw_setup']->oProc;
} }
else else
{ {
@ -50,25 +50,24 @@
$this->db = $this->schema_proc->m_odb; $this->db = $this->schema_proc->m_odb;
$this->adodb = &$GLOBALS['egw']->ADOdb; $this->adodb = &$GLOBALS['egw']->ADOdb;
if (is_object($GLOBALS['phpgw_setup'])) // called from setup if (is_object($GLOBALS['egw_setup'])) // called from setup
{ {
$tables = $this->adodb->MetaTables('TABLES'); if ($GLOBALS['egw_setup']->config_table)
if (in_array('phpgw_config',$tables))
{ {
$this->db->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='backup_dir'",__LINE__,__FILE__); $this->db->query("SELECT config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_app='phpgwapi' AND config_name='backup_dir'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
if (!($this->backup_dir = $this->db->f(0))) if (!($this->backup_dir = $this->db->f(0)))
{ {
$this->db->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='files_dir'",__LINE__,__FILE__); $this->db->query("SELECT config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_app='phpgwapi' AND config_name='files_dir'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$this->backup_dir = $this->db->f(0).'/db_backup'; $this->backup_dir = $this->db->f(0).'/db_backup';
} }
$this->db->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__); $this->db->query("SELECT config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$this->charset = $this->db->f(0); $this->charset = $this->db->f(0);
if (!$this->charset) if (!$this->charset)
{ {
$this->db->query("SELECT content FROM phpgw_lang WHERE message_id='charset' AND app_name='common' AND lang!='en'",__LINE__,__FILE__); $this->db->query("SELECT content FROM {$GLOBALS['egw_setup']->lang_table} WHERE message_id='charset' AND app_name='common' AND lang!='en'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$this->charset = $this->db->f(0); $this->charset = $this->db->f(0);
} }

View File

@ -40,7 +40,7 @@
* @var egw_db-object $db instance of the db-object * @var egw_db-object $db instance of the db-object
*/ */
var $db; var $db;
var $config_table = 'phpgw_config'; var $config_table = 'egw_config';
/** /**
* Constructor: Instantiates the sub-classes * Constructor: Instantiates the sub-classes

View File

@ -27,6 +27,8 @@
'clearstack', 'clearstack',
'astable' 'astable'
); );
var $log_table = 'egw_log';
var $msg_table = 'egw_log_msg';
function message($parms) function message($parms)
{ {
@ -104,19 +106,19 @@
function commit() function commit()
{ {
$db = $GLOBALS['phpgw']->db; $db = clone($GLOBALS['egw']->db);
// $db->lock('phpgw_log'); // $db->lock($this->log_table);
$db->query("insert into phpgw_log (log_date, log_user, log_app, log_severity) values " $db->query("insert into $this->log_table (log_date, log_user, log_app, log_severity) values "
."('". $GLOBALS['phpgw']->db->to_timestamp(time()) ."('". $GLOBALS['egw']->db->to_timestamp(time())
."','".(int)$GLOBALS['phpgw']->session->account_id ."','".(int)$GLOBALS['egw']->session->account_id
."','".$GLOBALS['phpgw_info']['flags']['currentapp']."'" ."','".$GLOBALS['egw_info']['flags']['currentapp']."'"
.",'".$this->severity()."'" .",'".$this->severity()."'"
.")" .")"
,__LINE__,__FILE__ ,__LINE__,__FILE__
); );
$log_id = $db->get_last_insert_id('phpgw_log','log_id'); $log_id = $db->get_last_insert_id($this->log_table,'log_id');
// $db->query('select max(log_id) as lid from phpgw_log'); // $db->query('select max(log_id) as lid from $this->log_table');
// $db->next_record(); // $db->next_record();
// $log_id = $db->f('lid'); // $log_id = $db->f('lid');
// $db->unlock(); // $db->unlock();
@ -125,12 +127,12 @@
for ($i = 0; $i < count($errorstack); $i++) for ($i = 0; $i < count($errorstack); $i++)
{ {
$err = $errorstack[$i]; $err = $errorstack[$i];
$db->query("insert into phpgw_log_msg " $db->query("insert into $this->msg_table "
."(Log_msg_log_id, log_msg_seq_no, log_msg_date, log_msg_severity, " ."(Log_msg_log_id, log_msg_seq_no, log_msg_date, log_msg_severity, "
."log_msg_code, log_msg_msg, log_msg_parms, log_msg_file, log_msg_line) values " ."log_msg_code, log_msg_msg, log_msg_parms, log_msg_file, log_msg_line) values "
."(" . $log_id ."(" . $log_id
."," . $i ."," . $i
.", '" . $GLOBALS['phpgw']->db->to_timestamp($err->timestamp) .", '" . $GLOBALS['egw']->db->to_timestamp($err->timestamp)
."', '". $err->severity . "'" ."', '". $err->severity . "'"
.", '". $err->code . "'" .", '". $err->code . "'"
.", '". $db->db_addslashes($err->msg) . "'" .", '". $db->db_addslashes($err->msg) . "'"
@ -194,7 +196,7 @@
$html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n"; $html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n";
$html .= "\t\t<td align=center>".$i."</td>\n"; $html .= "\t\t<td align=center>".$i."</td>\n";
$html .= "\t\t<td>".$GLOBALS['phpgw']->common->show_date($err->timestamp)."</td>\n"; $html .= "\t\t<td>".$GLOBALS['egw']->common->show_date($err->timestamp)."</td>\n";
$html .= "\t\t<td>".$err->app."&nbsp </td>\n"; $html .= "\t\t<td>".$err->app."&nbsp </td>\n";
$html .= "\t\t<td align=center>".$err->severity."</td>\n"; $html .= "\t\t<td align=center>".$err->severity."</td>\n";
$html .= "\t\t<td>".$err->code."</td>\n"; $html .= "\t\t<td>".$err->code."</td>\n";

View File

@ -27,6 +27,8 @@
'clearstack', 'clearstack',
'astable' 'astable'
); );
var $log_table = 'egw_log';
var $msg_table = 'egw_log_msg';
function message($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') function message($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='')
{ {
@ -82,11 +84,11 @@
function commit() function commit()
{ {
$db = $GLOBALS['phpgw']->db; $db = clone($GLOBALS['egw']->db);
$db->query("insert into phpgw_log (log_date, log_user, log_app, log_severity) values " $db->query("insert into $this->log_table (log_date, log_user, log_app, log_severity) values "
."('". $GLOBALS['phpgw']->db->to_timestamp(time()) ."('". $GLOBALS['egw']->db->to_timestamp(time())
."','".$GLOBALS['phpgw']->session->account_id ."','".$GLOBALS['egw']->session->account_id
."','".$GLOBALS['phpgw_info']['flags']['currentapp']."'" ."','".$GLOBALS['egw_info']['flags']['currentapp']."'"
.",'".$this->severity()."'" .",'".$this->severity()."'"
.")" .")"
,__LINE__,__FILE__); ,__LINE__,__FILE__);
@ -95,11 +97,11 @@
for ($i = 0; $i < count($errorstack); $i++) for ($i = 0; $i < count($errorstack); $i++)
{ {
$err = $errorstack[$i]; $err = $errorstack[$i];
$db->query("insert into phpgw_log_msg " $db->query("insert into $this->msg_table "
. "(log_msg_seq_no, log_msg_date, " . "(log_msg_seq_no, log_msg_date, "
. "log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values " . "log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values "
. "(" . $i . "(" . $i
. ", '" . $GLOBALS['phpgw']->db->to_timestamp($err->timestamp) . ", '" . $GLOBALS['egw']->db->to_timestamp($err->timestamp)
. "', '". $err->severity . "'" . "', '". $err->severity . "'"
. ", '". $err->code . "'" . ", '". $err->code . "'"
. ", '". $err->msg . "'" . ", '". $err->msg . "'"
@ -162,8 +164,8 @@
$html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n"; $html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n";
$html .= "\t\t<td align=center>".$i."</td>\n"; $html .= "\t\t<td align=center>".$i."</td>\n";
$html .= "\t\t<td>".$GLOBALS['phpgw']->common->show_date($err->timestamp)."</td>\n"; $html .= "\t\t<td>".$GLOBALS['egw']->common->show_date($err->timestamp)."</td>\n";
$html .= "\t\t<td>".$GLOBALS['phpgw_info']['flags']['currentapp']."&nbsp </td>\n"; $html .= "\t\t<td>".$GLOBALS['egw_info']['flags']['currentapp']."&nbsp </td>\n";
$html .= "\t\t<td align=center>".$err->severity."</td>\n"; $html .= "\t\t<td align=center>".$err->severity."</td>\n";
$html .= "\t\t<td>".$err->code."</td>\n"; $html .= "\t\t<td>".$err->code."</td>\n";
$html .= "\t\t<td>".$err->langmsg()."</td>\n"; $html .= "\t\t<td>".$err->langmsg()."</td>\n";

View File

@ -580,7 +580,7 @@
$this->log_access($this->sessionid,$login,$user_ip,$this->account_id); $this->log_access($this->sessionid,$login,$user_ip,$this->account_id);
} }
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['egw']->auth->previous_login); $this->appsession('account_previous_login','phpgwapi',$GLOBALS['egw']->auth->previous_login);
$GLOBALS['egw']->auth->update_lastlogin($this->account_id,$user_ip); $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip);
$GLOBALS['egw']->db->transaction_commit(); $GLOBALS['egw']->db->transaction_commit();
//if (!$this->sessionid) echo "<p>session::create(login='$login') = '$this->sessionid': lid='$this->account_lid', domain='$this->account_domain'</p>\n"; //if (!$this->sessionid) echo "<p>session::create(login='$login') = '$this->sessionid': lid='$this->account_lid', domain='$this->account_domain'</p>\n";
@ -873,7 +873,7 @@
$this->log_access($this->sessionid,$login,$user_ip,$this->account_id); $this->log_access($this->sessionid,$login,$user_ip,$this->account_id);
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['egw']->auth->previous_login); $this->appsession('account_previous_login','phpgwapi',$GLOBALS['egw']->auth->previous_login);
$GLOBALS['egw']->auth->update_lastlogin($this->account_id,$user_ip); $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip);
$GLOBALS['egw']->db->transaction_commit(); $GLOBALS['egw']->db->transaction_commit();
return array($this->sessionid,$this->kp3); return array($this->sessionid,$this->kp3);

View File

@ -53,7 +53,7 @@
} }
else else
{ {
$GLOBALS['phpgw']->db->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__); $GLOBALS['phpgw']->db->query("SELECT config_value FROM egw_config WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__);
if($GLOBALS['phpgw']->db->next_record()) if($GLOBALS['phpgw']->db->next_record())
{ {
$this->system_charset = $GLOBALS['phpgw']->db->f(0); $this->system_charset = $GLOBALS['phpgw']->db->f(0);

View File

@ -60,7 +60,7 @@
$this->db->set_app('phpgwapi'); $this->db->set_app('phpgwapi');
$this->lang_table = 'phpgw_lang'; $this->lang_table = 'phpgw_lang';
$this->languages_table = 'phpgw_languages'; $this->languages_table = 'phpgw_languages';
$this->config_table = 'phpgw_config'; $this->config_table = 'egw_config';
if (!isset($GLOBALS['egw_setup'])) if (!isset($GLOBALS['egw_setup']))
{ {

View File

@ -131,7 +131,7 @@
/* /*
function system_listApps() function system_listApps()
{ {
$GLOBALS['phpgw']->db->query("SELECT * FROM phpgw_applications WHERE app_enabled<3",__LINE__,__FILE__); $GLOBALS['phpgw']->db->query("SELECT * FROM egw_applications WHERE app_enabled<3",__LINE__,__FILE__);
$apps = array(); $apps = array();
if($GLOBALS['phpgw']->db->num_rows()) if($GLOBALS['phpgw']->db->num_rows())
{ {

View File

@ -904,7 +904,7 @@
function _xmlrpcs_listApps($server,$m) function _xmlrpcs_listApps($server,$m)
{ {
$m->getParam(0); $m->getParam(0);
$GLOBALS['egw']->db->query("SELECT * FROM phpgw_applications WHERE app_enabled<3",__LINE__,__FILE__); $GLOBALS['egw']->db->query("SELECT * FROM egw_applications WHERE app_enabled<3",__LINE__,__FILE__);
if($GLOBALS['egw']->db->num_rows()) if($GLOBALS['egw']->db->num_rows())
{ {
while($GLOBALS['egw']->db->next_record()) while($GLOBALS['egw']->db->next_record())

View File

@ -150,9 +150,20 @@
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zt','Chinese(Taiwan)')"); $oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zt','Chinese(Taiwan)')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zu','Zulu')"); $oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zu','Zulu')");
$oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('phpgwapi','sessions_checkip','True')");
$oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('phpgwapi','image_type','1')"); foreach(array(
$oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('phpgwapi','asyncservice','fallback')"); 'sessions_checkip' => 'True',
'image_type' => '1',
'asyncservice' => 'fallback',
) as $name => $value)
{
$oProc->insert($GLOBALS['egw_setup']->config_table,array(
'config_value' => $value,
),array(
'config_app' => 'phpgwapi',
'config_name' => $name,
),__FILE__,__LINE__);
}
$oProc->query("INSERT INTO phpgw_interserv(server_name,server_host,server_url,trust_level,trust_rel,server_mode) VALUES ('eGW demo',NULL,'http://www.egroupware.org/egroupware/xmlrpc.php',99,0,'xmlrpc')"); $oProc->query("INSERT INTO phpgw_interserv(server_name,server_host,server_url,trust_level,trust_rel,server_mode) VALUES ('eGW demo',NULL,'http://www.egroupware.org/egroupware/xmlrpc.php',99,0,'xmlrpc')");

View File

@ -13,17 +13,17 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi'; $setup_info['phpgwapi']['title'] = 'API';
$setup_info['phpgwapi']['version'] = '1.0.1.012'; $setup_info['phpgwapi']['version'] = '1.0.1.014';
$setup_info['phpgwapi']['versions']['current_header'] = '1.28'; $setup_info['phpgwapi']['versions']['current_header'] = '1.28';
$setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1; $setup_info['phpgwapi']['app_order'] = 1;
/* The tables this app creates */ /* The tables this app creates */
$setup_info['phpgwapi']['tables'][] = 'phpgw_config'; $setup_info['phpgwapi']['tables'][] = 'egw_config';
$setup_info['phpgwapi']['tables'][] = 'phpgw_applications'; $setup_info['phpgwapi']['tables'][] = 'egw_applications';
$setup_info['phpgwapi']['tables'][] = 'phpgw_acl'; $setup_info['phpgwapi']['tables'][] = 'egw_acl';
$setup_info['phpgwapi']['tables'][] = 'phpgw_accounts'; $setup_info['phpgwapi']['tables'][] = 'egw_accounts';
$setup_info['phpgwapi']['tables'][] = 'phpgw_preferences'; $setup_info['phpgwapi']['tables'][] = 'phpgw_preferences';
$setup_info['phpgwapi']['tables'][] = 'phpgw_sessions'; $setup_info['phpgwapi']['tables'][] = 'phpgw_sessions';
$setup_info['phpgwapi']['tables'][] = 'phpgw_app_sessions'; $setup_info['phpgwapi']['tables'][] = 'phpgw_app_sessions';
@ -35,8 +35,8 @@
$setup_info['phpgwapi']['tables'][] = 'phpgw_categories'; $setup_info['phpgwapi']['tables'][] = 'phpgw_categories';
$setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook'; $setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook';
$setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook_extra'; $setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook_extra';
$setup_info['phpgwapi']['tables'][] = 'phpgw_log'; $setup_info['phpgwapi']['tables'][] = 'egw_log';
$setup_info['phpgwapi']['tables'][] = 'phpgw_log_msg'; $setup_info['phpgwapi']['tables'][] = 'egw_log_msg';
$setup_info['phpgwapi']['tables'][] = 'phpgw_interserv'; $setup_info['phpgwapi']['tables'][] = 'phpgw_interserv';
$setup_info['phpgwapi']['tables'][] = 'egw_vfs'; $setup_info['phpgwapi']['tables'][] = 'egw_vfs';
$setup_info['phpgwapi']['tables'][] = 'phpgw_history_log'; $setup_info['phpgwapi']['tables'][] = 'phpgw_history_log';

View File

@ -13,7 +13,7 @@
// $Source$ // $Source$
$phpgw_baseline = array( $phpgw_baseline = array(
'phpgw_config' => array( 'egw_config' => array(
'fd' => array( 'fd' => array(
'config_app' => array('type' => 'varchar','precision' => '50','nullable' => False), 'config_app' => array('type' => 'varchar','precision' => '50','nullable' => False),
'config_name' => array('type' => 'varchar','precision' => '255','nullable' => False), 'config_name' => array('type' => 'varchar','precision' => '255','nullable' => False),
@ -24,7 +24,7 @@
'ix' => array(), 'ix' => array(),
'uc' => array() 'uc' => array()
), ),
'phpgw_applications' => array( 'egw_applications' => array(
'fd' => array( 'fd' => array(
'app_id' => array('type' => 'auto','precision' => '4','nullable' => False), 'app_id' => array('type' => 'auto','precision' => '4','nullable' => False),
'app_name' => array('type' => 'varchar','precision' => '25','nullable' => False), 'app_name' => array('type' => 'varchar','precision' => '25','nullable' => False),
@ -38,7 +38,7 @@
'ix' => array(array('app_enabled','app_order')), 'ix' => array(array('app_enabled','app_order')),
'uc' => array('app_name') 'uc' => array('app_name')
), ),
'phpgw_acl' => array( 'egw_acl' => array(
'fd' => array( 'fd' => array(
'acl_appname' => array('type' => 'varchar','precision' => '50','nullable' => False), 'acl_appname' => array('type' => 'varchar','precision' => '50','nullable' => False),
'acl_location' => array('type' => 'varchar','precision' => '255','nullable' => False), 'acl_location' => array('type' => 'varchar','precision' => '255','nullable' => False),
@ -50,7 +50,7 @@
'ix' => array('acl_account',array('acl_location','acl_account'),array('acl_appname','acl_account')), 'ix' => array('acl_account',array('acl_location','acl_account'),array('acl_appname','acl_account')),
'uc' => array() 'uc' => array()
), ),
'phpgw_accounts' => array( 'egw_accounts' => array(
'fd' => array( 'fd' => array(
'account_id' => array('type' => 'auto','nullable' => False), 'account_id' => array('type' => 'auto','nullable' => False),
'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False), 'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False),
@ -262,7 +262,7 @@
'ix' => array(), 'ix' => array(),
'uc' => array() 'uc' => array()
), ),
'phpgw_log' => array( 'egw_log' => array(
'fd' => array( 'fd' => array(
'log_id' => array('type' => 'auto','precision' => '4','nullable' => False), 'log_id' => array('type' => 'auto','precision' => '4','nullable' => False),
'log_date' => array('type' => 'timestamp','nullable' => False), 'log_date' => array('type' => 'timestamp','nullable' => False),
@ -275,7 +275,7 @@
'ix' => array(), 'ix' => array(),
'uc' => array() 'uc' => array()
), ),
'phpgw_log_msg' => array( 'egw_log_msg' => array(
'fd' => array( 'fd' => array(
'log_msg_log_id' => array('type' => 'int','precision' => '4','nullable' => False), 'log_msg_log_id' => array('type' => 'int','precision' => '4','nullable' => False),
'log_msg_seq_no' => array('type' => 'int','precision' => '4','nullable' => False), 'log_msg_seq_no' => array('type' => 'int','precision' => '4','nullable' => False),
@ -448,7 +448,7 @@
'quota' => array('type' => 'int','precision' => '4','nullable' => False) 'quota' => array('type' => 'int','precision' => '4','nullable' => False)
), ),
'pk' => array('account_id'), 'pk' => array('account_id'),
'fk' => array('account_id' => array('phpgw_accounts' => 'account_id')), 'fk' => array('account_id' => array('egw_accounts' => 'account_id')),
'ix' => array(), 'ix' => array(),
'uc' => array() 'uc' => array()
), ),
@ -459,7 +459,7 @@
'acl_rights' => array('type' => 'int','precision' => '4','nullable' => False) 'acl_rights' => array('type' => 'int','precision' => '4','nullable' => False)
), ),
'pk' => array('account_id','file_id'), 'pk' => array('account_id','file_id'),
'fk' => array('account_id' => array('phpgw_accounts' => 'account_id'),'file_id' => array('phpgw_vfs2_files' => 'file_id')), 'fk' => array('account_id' => array('egw_accounts' => 'account_id'),'file_id' => array('phpgw_vfs2_files' => 'file_id')),
'ix' => array(), 'ix' => array(),
'uc' => array() 'uc' => array()
), ),

View File

@ -43,12 +43,12 @@
$test[] = '1.0.0.004'; $test[] = '1.0.0.004';
function phpgwapi_upgrade1_0_0_004() function phpgwapi_upgrade1_0_0_004()
{ {
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','id','async_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','id','async_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','next','async_next'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','next','async_next');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','times','async_times'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','times','async_times');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','method','async_method'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','method','async_method');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','data','async_data'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','data','async_data');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_async','account_id','async_account_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_async','account_id','async_account_id');
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.001'; $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.001';
return $GLOBALS['setup_info']['phpgwapi']['currentver']; return $GLOBALS['setup_info']['phpgwapi']['currentver'];
@ -93,12 +93,12 @@
function phpgwapi_upgrade1_0_1_001() function phpgwapi_upgrade1_0_1_001()
{ {
// removing the ACL entries of deleted accounts // removing the ACL entries of deleted accounts
$GLOBALS['phpgw_setup']->setup_account_object(); $GLOBALS['egw_setup']->setup_account_object();
if (($all_accounts = $GLOBALS['phpgw']->accounts->search(array('type'=>'both')))) if (($all_accounts = $GLOBALS['phpgw']->accounts->search(array('type'=>'both'))))
{ {
$all_accounts = array_keys($all_accounts); $all_accounts = array_keys($all_accounts);
$GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE acl_account NOT IN (".implode(',',$all_accounts).")",__LINE__,__FILE__); $GLOBALS['egw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE acl_account NOT IN (".implode(',',$all_accounts).")",__LINE__,__FILE__);
$GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$all_accounts)."')",__LINE__,__FILE__); $GLOBALS['egw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$all_accounts)."')",__LINE__,__FILE__);
} }
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.002'; $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.002';
return $GLOBALS['setup_info']['phpgwapi']['currentver']; return $GLOBALS['setup_info']['phpgwapi']['currentver'];
@ -108,26 +108,26 @@
$test[] = '1.0.1.002'; $test[] = '1.0.1.002';
function phpgwapi_upgrade1_0_1_002() function phpgwapi_upgrade1_0_1_002()
{ {
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','file_id','vfs_file_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','file_id','vfs_file_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','owner_id','vfs_owner_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','owner_id','vfs_owner_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','createdby_id','vfs_createdby_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','createdby_id','vfs_createdby_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','modifiedby_id','vfs_modifiedby_id'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','modifiedby_id','vfs_modifiedby_id');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','created','vfs_created'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','created','vfs_created');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','modified','vfs_modified'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','modified','vfs_modified');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','size','vfs_size'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','size','vfs_size');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','mime_type','vfs_mime_type'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','mime_type','vfs_mime_type');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','deleteable','vfs_deleteable'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','deleteable','vfs_deleteable');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','comment','vfs_comment'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','comment','vfs_comment');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','app','vfs_app'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','app','vfs_app');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','directory','vfs_directory'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','directory','vfs_directory');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','name','vfs_name'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','name','vfs_name');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','link_directory','vfs_link_directory'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','link_directory','vfs_link_directory');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','link_name','vfs_link_name'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','link_name','vfs_link_name');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','version','vfs_version'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','version','vfs_version');
$GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_vfs','content','vfs_content'); $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_vfs','content','vfs_content');
$GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_vfs','egw_vfs'); $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_vfs','egw_vfs');
$GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_vfs',array( $GLOBALS['egw_setup']->oProc->RefreshTable('egw_vfs',array(
'fd' => array( 'fd' => array(
'vfs_file_id' => array('type' => 'auto','nullable' => False), 'vfs_file_id' => array('type' => 'auto','nullable' => False),
'vfs_owner_id' => array('type' => 'int','precision' => '4','nullable' => False), 'vfs_owner_id' => array('type' => 'int','precision' => '4','nullable' => False),
@ -160,7 +160,7 @@
$test[] = '1.0.1.003'; $test[] = '1.0.1.003';
function phpgwapi_upgrade1_0_1_003() function phpgwapi_upgrade1_0_1_003()
{ {
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'egw_api_content_history', array( 'egw_api_content_history', array(
'fd' => array( 'fd' => array(
'sync_appname' => array('type' => 'varchar','precision' => '60','nullable' => False), 'sync_appname' => array('type' => 'varchar','precision' => '60','nullable' => False),
@ -186,13 +186,13 @@
$test[] = '1.0.1.004'; $test[] = '1.0.1.004';
function phpgwapi_upgrade1_0_1_004() function phpgwapi_upgrade1_0_1_004()
{ {
$GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_api_content_history','sync_added',array( $GLOBALS['egw_setup']->oProc->AlterColumn('egw_api_content_history','sync_added',array(
'type' => 'timestamp' 'type' => 'timestamp'
)); ));
$GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_api_content_history','sync_modified',array( $GLOBALS['egw_setup']->oProc->AlterColumn('egw_api_content_history','sync_modified',array(
'type' => 'timestamp' 'type' => 'timestamp'
)); ));
$GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_api_content_history','sync_deleted',array( $GLOBALS['egw_setup']->oProc->AlterColumn('egw_api_content_history','sync_deleted',array(
'type' => 'timestamp' 'type' => 'timestamp'
)); ));
@ -207,7 +207,7 @@
* VFS version 2 * * VFS version 2 *
\*********************************************************************/ \*********************************************************************/
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_mimetypes', array( 'phpgw_vfs2_mimetypes', array(
'fd' => array( 'fd' => array(
'mime_id' => array('type' => 'auto','nullable' => False), 'mime_id' => array('type' => 'auto','nullable' => False),
@ -225,7 +225,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_files' , array( 'phpgw_vfs2_files' , array(
'fd' => array( 'fd' => array(
'file_id' => array('type' => 'auto','nullable' => False), 'file_id' => array('type' => 'auto','nullable' => False),
@ -254,7 +254,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_customfields' , array( 'phpgw_vfs2_customfields' , array(
'fd' => array( 'fd' => array(
'customfield_id' => array('type' => 'auto','nullable' => False), 'customfield_id' => array('type' => 'auto','nullable' => False),
@ -271,7 +271,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_quota' , array( 'phpgw_vfs2_quota' , array(
'fd' => array( 'fd' => array(
'account_id' => array('type' => 'int','precision' => 4,'nullable' => false), 'account_id' => array('type' => 'int','precision' => 4,'nullable' => false),
@ -284,7 +284,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_shares' , array( 'phpgw_vfs2_shares' , array(
'fd' => array( 'fd' => array(
'account_id' => array('type' => 'int','precision' => 4,'nullable' => false), 'account_id' => array('type' => 'int','precision' => 4,'nullable' => false),
@ -298,7 +298,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_versioning' , array( 'phpgw_vfs2_versioning' , array(
'fd' => array( 'fd' => array(
'version_id' => array('type' => 'auto', 'nullable' => false), 'version_id' => array('type' => 'auto', 'nullable' => false),
@ -320,7 +320,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_customfields_data' , array( 'phpgw_vfs2_customfields_data' , array(
'fd' => array( 'fd' => array(
'file_id' => array('type' => 'int','precision' => 4,'nullable' => false), 'file_id' => array('type' => 'int','precision' => 4,'nullable' => false),
@ -334,7 +334,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'phpgw_vfs2_prefixes' , array( 'phpgw_vfs2_prefixes' , array(
'fd' => array( 'fd' => array(
'prefix_id' => array('type' => 'auto','nullable' => false), 'prefix_id' => array('type' => 'auto','nullable' => false),
@ -360,7 +360,7 @@
include PHPGW_INCLUDE_ROOT.'/phpgwapi/setup/default_records_mime.inc.php'; include PHPGW_INCLUDE_ROOT.'/phpgwapi/setup/default_records_mime.inc.php';
$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_vfs2_files (mime_id,owner_id,createdby_id,size,directory,name) $GLOBALS['egw_setup']->oProc->query("INSERT INTO phpgw_vfs2_files (mime_id,owner_id,createdby_id,size,directory,name)
SELECT mime_id,0,0,4096,'/','' FROM phpgw_vfs2_mimetypes WHERE mime='Directory'"); SELECT mime_id,0,0,4096,'/','' FROM phpgw_vfs2_mimetypes WHERE mime='Directory'");
if ($GLOBALS['DEBUG']) if ($GLOBALS['DEBUG'])
@ -377,7 +377,7 @@
$test[] = '1.0.1.006'; $test[] = '1.0.1.006';
function phpgwapi_upgrade1_0_1_006() function phpgwapi_upgrade1_0_1_006()
{ {
$GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_async','egw_async'); $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_async','egw_async');
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.007'; $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.007';
return $GLOBALS['setup_info']['phpgwapi']['currentver']; return $GLOBALS['setup_info']['phpgwapi']['currentver'];
@ -387,23 +387,23 @@
function phpgwapi_upgrade1_0_1_007() function phpgwapi_upgrade1_0_1_007()
{ {
//Creating cached values for modified and modifiedby_id //Creating cached values for modified and modifiedby_id
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_vfs2_files', 'modifiedby_id', array('type' => 'int','precision' => 4)); $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_vfs2_files', 'modifiedby_id', array('type' => 'int','precision' => 4));
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_vfs2_files', 'modified', array('type' => 'timestamp', 'nullable' => true)); $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_vfs2_files', 'modified', array('type' => 'timestamp', 'nullable' => true));
//Updating existing values //Updating existing values
$sql = "SELECT max(modified) as mod, file_id, modifiedby_id from phpgw_vfs2_versioning group by file_id"; $sql = "SELECT max(modified) as mod, file_id, modifiedby_id from phpgw_vfs2_versioning group by file_id";
$GLOBALS['phpgw_setup']->oProc->m_odb->query($sql,__LINE__,__FILE__); $GLOBALS['egw_setup']->oProc->m_odb->query($sql,__LINE__,__FILE__);
$files_to_change = array(); $files_to_change = array();
while ($GLOBALS['phpgw_setup']->oProc->m_odb->next_record()) while ($GLOBALS['egw_setup']->oProc->m_odb->next_record())
{ {
$files_to_change[] = $GLOBALS['phpgw_setup']->oProc->m_odb->Record; $files_to_change[] = $GLOBALS['egw_setup']->oProc->m_odb->Record;
} }
foreach ($files_to_change as $key => $val) foreach ($files_to_change as $key => $val)
{ {
$GLOBALS['phpgw_setup']->oProc->m_odb->update('phpgw_vfs2_files', $GLOBALS['egw_setup']->oProc->m_odb->update('phpgw_vfs2_files',
array( array(
'modified' => $val['mod'], 'modified' => $val['mod'],
'modifiedby_id' => $val['modifiedby_id'] 'modifiedby_id' => $val['modifiedby_id']
@ -419,7 +419,7 @@
$test[] = '1.0.1.008'; $test[] = '1.0.1.008';
function phpgwapi_upgrade1_0_1_008() function phpgwapi_upgrade1_0_1_008()
{ {
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'egw_contentmap', array( 'egw_contentmap', array(
'fd' => array( 'fd' => array(
'map_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), 'map_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
@ -435,7 +435,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'egw_syncmldevinfo', array( 'egw_syncmldevinfo', array(
'fd' => array( 'fd' => array(
'dev_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), 'dev_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
@ -457,7 +457,7 @@
) )
); );
$GLOBALS['phpgw_setup']->oProc->CreateTable( $GLOBALS['egw_setup']->oProc->CreateTable(
'egw_syncmlsummary', array( 'egw_syncmlsummary', array(
'fd' => array( 'fd' => array(
'dev_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), 'dev_id' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
@ -485,7 +485,7 @@
include(EGW_SERVER_ROOT . '/home/setup/setup.inc.php'); include(EGW_SERVER_ROOT . '/home/setup/setup.inc.php');
$home_version = $setup_info['home']['version']; $home_version = $setup_info['home']['version'];
$GLOBALS['phpgw_setup']->db->insert('phpgw_applications',array( $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->applications_table,array(
'app_enabled' => $setup_info['home']['enable'], 'app_enabled' => $setup_info['home']['enable'],
'app_order' => $setup_info['home']['app_order'], 'app_order' => $setup_info['home']['app_order'],
'app_version' => $setup_info['home']['version'], 'app_version' => $setup_info['home']['version'],
@ -495,19 +495,19 @@
),__LINE__,__FILE__); ),__LINE__,__FILE__);
// give all users and groups with preferences rights, rights for the home app. // give all users and groups with preferences rights, rights for the home app.
$GLOBALS['phpgw_setup']->db->select('phpgw_acl','acl_account',array( $GLOBALS['egw_setup']->db->select('phpgw_acl','acl_account',array(
'acl_appname' => 'preferences', 'acl_appname' => 'preferences',
'acl_location' => 'run', 'acl_location' => 'run',
'acl_rights' => 1, 'acl_rights' => 1,
),__LINE__,__FILE__); ),__LINE__,__FILE__);
$accounts_with_preference_rights = array(); $accounts_with_preference_rights = array();
while (($row = $GLOBALS['phpgw_setup']->db->row(true))) while (($row = $GLOBALS['egw_setup']->db->row(true)))
{ {
$accounts_with_preference_rights[] = $row['acl_account']; $accounts_with_preference_rights[] = $row['acl_account'];
} }
foreach($accounts_with_preference_rights as $account) foreach($accounts_with_preference_rights as $account)
{ {
$GLOBALS['phpgw_setup']->db->insert('phpgw_acl',array( $GLOBALS['egw_setup']->db->insert('phpgw_acl',array(
'acl_rights' => 1, 'acl_rights' => 1,
),array( ),array(
'acl_appname' => 'home', 'acl_appname' => 'home',
@ -524,18 +524,18 @@
$test[] = '1.0.1.010'; $test[] = '1.0.1.010';
function phpgwapi_upgrade1_0_1_010() function phpgwapi_upgrade1_0_1_010()
{ {
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_sessions','session_ip',array( $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_sessions','session_ip',array(
'type' => 'varchar', 'type' => 'varchar',
'precision' => '40' 'precision' => '40'
)); ));
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_access_log','ip',array( $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_access_log','ip',array(
'type' => 'varchar', 'type' => 'varchar',
'precision' => '40', 'precision' => '40',
'nullable' => False 'nullable' => False
)); ));
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_access_log','loginid',array( $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_access_log','loginid',array(
'type' => 'varchar', 'type' => 'varchar',
'precision' => '128' 'precision' => '128'
)); ));
@ -548,15 +548,15 @@
function phpgwapi_upgrade1_0_1_011() function phpgwapi_upgrade1_0_1_011()
{ {
// moving the egw_links table into the API // moving the egw_links table into the API
if ($GLOBALS['phpgw_setup']->oProc->GetTableDefinition('phpgw_links')) if ($GLOBALS['egw_setup']->oProc->GetTableDefinition('phpgw_links'))
{ {
// table exists with old name ==> rename it to new one // table exists with old name ==> rename it to new one
$GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_links','egw_links'); $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_links','egw_links');
} }
elseif (!$GLOBALS['phpgw_setup']->oProc->GetTableDefinition('egw_links')) elseif (!$GLOBALS['egw_setup']->oProc->GetTableDefinition('egw_links'))
{ {
// table does not exist at all (infolog not installed) ==> create it // table does not exist at all (infolog not installed) ==> create it
$GLOBALS['phpgw_setup']->oProc->CreateTable('egw_links',array( $GLOBALS['egw_setup']->oProc->CreateTable('egw_links',array(
'fd' => array( 'fd' => array(
'link_id' => array('type' => 'auto','nullable' => False), 'link_id' => array('type' => 'auto','nullable' => False),
'link_app1' => array('type' => 'varchar','precision' => '25','nullable' => False), 'link_app1' => array('type' => 'varchar','precision' => '25','nullable' => False),
@ -574,9 +574,34 @@
)); ));
} }
// move the link-configuration to the api // move the link-configuration to the api
$GLOBALS['phpgw_setup']->oProc->query('UPDATE '.$GLOBALS['phpgw_setup']->config_table." SET config_app='phpgwapi' WHERE config_app='infolog' AND config_name IN ('link_pathes','send_file_ips')",__LINE__,__FILE__); $GLOBALS['egw_setup']->oProc->query('UPDATE '.$GLOBALS['egw_setup']->config_table." SET config_app='phpgwapi' WHERE config_app='infolog' AND config_name IN ('link_pathes','send_file_ips')",__LINE__,__FILE__);
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.012'; $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.012';
return $GLOBALS['setup_info']['phpgwapi']['currentver']; return $GLOBALS['setup_info']['phpgwapi']['currentver'];
} }
?>
$test[] = '1.0.1.012';
function phpgwapi_upgrade1_0_1_012()
{
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_accounts','egw_accounts');
$GLOBALS['egw_setup']->accounts_table = 'egw_accounts';
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_acl','egw_acl');
$GLOBALS['egw_setup']->acl_table = 'egw_acl';
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_log','egw_log');
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_log_msg','egw_log_msg');
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.013';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.013';
function phpgwapi_upgrade1_0_1_013()
{
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_config','egw_config');
$GLOBALS['egw_setup']->config_table = 'egw_config';
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_applications','egw_applications');
$GLOBALS['egw_setup']->applications_table = 'egw_applications';
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.014';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}

View File

@ -16,7 +16,7 @@
{ {
$file['Change your Password'] = $GLOBALS['egw']->link('/index.php','menuaction=preferences.uipassword.change'); $file['Change your Password'] = $GLOBALS['egw']->link('/index.php','menuaction=preferences.uipassword.change');
} }
$file['change your settings'] = $GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname=preferences'); $file['common preferences'] = $GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname=preferences');
display_section('preferences',$file); display_section('preferences',$file);
?> ?>

View File

@ -14,64 +14,18 @@
class so_acl class so_acl
{ {
var $db;
function so_acl()
{
$this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('resources');
}
function get_rights($location) function get_rights($location)
{ {
$result = array(); return $GLOBALS['egw']->acl->get_all_rights($location,'news_admin');
$sql = "SELECT acl_account, acl_rights from phpgw_acl WHERE acl_appname = 'resources' AND acl_location = '$location'";
$this->db->query($sql,__LINE__,__FILE__);
while($this->db->next_record())
{
$result[$this->db->f('acl_account')] = $this->db->f('acl_rights');
}
return $result;
} }
function remove_location($location) function remove_location($location)
{ {
$sql = "delete from phpgw_acl where acl_appname='resources' and acl_location='$location'"; $GLOBALS['egw']->acl->delete_repository('news_admin',$location,false);
$this->db->query($sql,__LINE__,__FILE__);
} }
/**
* gets permissions for resources of user
*
* This function is needed, cause eGW api dosn't provide a usefull function for that topic!
* Using api-functions for that, would resault bad performace :-(
* autor of news_admin ?
*
* @param int $user user_id we want to get perms for
* @param bool $inc_groups get rights due to groupmembership of user
*
*/
function get_permissions($user, $inc_groups) function get_permissions($user, $inc_groups)
{ {
$groups = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $user); return $GLOBALS['egw']->acl->get_all_location_rights($user,'sitemgr',$inc_groups);
$result = array();
$sql = 'SELECT acl_location, acl_rights FROM phpgw_acl ';
$sql .= "WHERE acl_appname = 'resources' ";
if($inc_groups)
{
$sql .= 'AND acl_account IN('. (int)$user;
$sql .= ($groups ? ',' . implode(',', $groups) : '');
$sql .= ')';
}
else
{
$sql .= 'AND acl_account ='. (int)$user;
}
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$result[$this->db->f('acl_location')] |= $this->db->f('acl_rights');
}
return $result;
} }
} }

View File

@ -160,7 +160,7 @@
// delete all application categories and ACL // delete all application categories and ACL
$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_categories WHERE cat_appname='$appname'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_categories WHERE cat_appname='$appname'",__LINE__,__FILE__);
$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_acl WHERE acl_appname='$appname'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->query("DELETE FROM {$GLOBALS['egw_setup']->acl_table} WHERE acl_appname='$appname'",__LINE__,__FILE__);
} }
} }

View File

@ -49,15 +49,6 @@
/* Check api version, use correct table */ /* Check api version, use correct table */
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions(); $setup_info = $GLOBALS['egw_setup']->detection->get_db_versions();
if($GLOBALS['egw_setup']->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.10pre7'))
{
$configtbl = 'config';
}
else
{
$configtbl = 'phpgw_config';
}
$newsettings = $_POST['newsettings']; $newsettings = $_POST['newsettings'];
if(@get_var('submit',Array('POST')) && @$newsettings) if(@get_var('submit',Array('POST')) && @$newsettings)
@ -83,11 +74,7 @@
print_debug('TZ_OFFSET',$newsettings['tz_offset']); print_debug('TZ_OFFSET',$newsettings['tz_offset']);
$GLOBALS['egw_setup']->db->transaction_begin(); $GLOBALS['egw_setup']->db->transaction_begin();
/* This is only temp: */ foreach($newsettings as $setting => $value)
$GLOBALS['egw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='useframes'");
$GLOBALS['egw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) values ('phpgwapi','useframes','never')");
while(list($setting,$value) = @each($newsettings))
{ {
if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting)) if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting))
{ {
@ -99,55 +86,32 @@
/* Bail out, stop writing config data */ /* Bail out, stop writing config data */
break; break;
} }
else
{
/* echo '<br />Updating: ' . $setting . '=' . $value; */
/* Don't erase passwords, since we also do not print them below */
if($value || (!stristr($setting,'passwd') && !stristr($setting,'password') && !stristr($setting,'root_pw')))
{
@$GLOBALS['egw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='" . $setting . "'");
}
if($value)
{
$GLOBALS['egw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) VALUES ('phpgwapi','" . $GLOBALS['egw_setup']->db->db_addslashes($setting)
. "','" . $GLOBALS['egw_setup']->db->db_addslashes($value) . "')");
}
}
} }
else /* Don't erase passwords, since we also do not print them below */
if(empty($value) && !(stristr($setting,'passwd') || stristr($setting,'password') || stristr($setting,'root_pw')))
{ {
if($value || (!stristr($setting,'passwd') && !stristr($setting,'password') && !stristr($setting,'root_pw'))) $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->config_table,array(
{ 'config_name' => $setting,
@$GLOBALS['egw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='" . $setting . "'"); 'config_app' => 'phpgwapi',
} ),__LINE__,__FILE__);
if($value) }
{ elseif($value)
$GLOBALS['egw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) VALUES ('phpgwapi','" . $GLOBALS['egw_setup']->db->db_addslashes($setting) {
. "','" . $GLOBALS['egw_setup']->db->db_addslashes($value) . "')"); $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
} 'config_value' => $value,
),array(
'config_name' => $setting,
'config_app' => 'phpgwapi',
),__LINE__,__FILE__);
} }
} }
if(!$GLOBALS['error']) if(!$GLOBALS['error'])
{ {
$GLOBALS['egw_setup']->db->transaction_commit(); $GLOBALS['egw_setup']->db->transaction_commit();
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
$tablenames = $GLOBALS['egw_setup']->db->table_names();
while(list($key,$val) = @each($tablenames))
{
$tables[] = $val['table_name'];
}
if(in_array('phpgw_app_sessions',$tables))
{
$GLOBALS['egw_setup']->db->lock(array('phpgw_app_sessions'));
@$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'",__LINE__,__FILE__);
@$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE app = 'phpgwapi' and location = 'phpgw_info_cache'",__LINE__,__FILE__);
$GLOBALS['egw_setup']->db->unlock();
}
if($newsettings['auth_type'] == 'ldap') if($newsettings['auth_type'] == 'ldap')
{ {
Header('Location: '.$newsettings['webserver_url'].'/setup/ldap.php'); Header('Location: ldap.php');
exit; exit;
} }
else else
@ -160,8 +124,8 @@
$GLOBALS['egw_setup']->html->show_header(lang('Configuration'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); $GLOBALS['egw_setup']->html->show_header(lang('Configuration'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
@$GLOBALS['egw_setup']->db->query("SELECT * FROM $configtbl"); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'*',false,__LINES__,__FILES__);
while(@$GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$GLOBALS['current_config'][$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value'); $GLOBALS['current_config'][$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
} }
@ -177,8 +141,8 @@
var $db; var $db;
} }
$GLOBALS['egw'] = new phpgw; $GLOBALS['egw'] = new phpgw;
$GLOBALS['egw']->common = CreateObject('phpgwapi.common'); $GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
$GLOBALS['egw']->db = $GLOBALS['egw_setup']->db; $GLOBALS['egw']->db =& $GLOBALS['egw_setup']->db;
$t = CreateObject('setup.Template',$GLOBALS['egw']->common->get_tpl_dir('setup')); $t = CreateObject('setup.Template',$GLOBALS['egw']->common->get_tpl_dir('setup'));

View File

@ -27,8 +27,15 @@
class setup class setup
{ {
var $db; var $db;
var $config_table = 'phpgw_config'; var $config_table = 'egw_config';
var $applications_table = 'phpgw_applications'; var $applications_table = 'egw_applications';
var $acl_table = 'egw_acl';
var $accounts_table = 'egw_accounts';
var $prefs_table = 'phpgw_preferences';
var $lang_table = 'phpgw_lang';
var $languages_table = 'phpgw_languages';
var $hooks_table = 'phpgw_hooks';
var $cats_table = 'phpgw_categories';
var $oProc; var $oProc;
var $detection = ''; var $detection = '';
@ -49,10 +56,6 @@
/* The setup application needs these */ /* The setup application needs these */
$this->html = $html ? CreateObject('setup.setup_html') : ''; $this->html = $html ? CreateObject('setup.setup_html') : '';
$this->translation = $translation ? CreateObject('setup.setup_translation') : ''; $this->translation = $translation ? CreateObject('setup.setup_translation') : '';
// $this->tbl_apps = $this->get_apps_table_name();
// $this->tbl_config = $this->get_config_table_name();
$this->tbl_hooks = $this->get_hooks_table_name();
} }
/** /**
@ -85,8 +88,13 @@
{ {
$this->db->Halt_On_Error = 'no'; // table might not be created at that stage $this->db->Halt_On_Error = 'no'; // table might not be created at that stage
$this->set_table_names(); // sets/checks config- and applications-table-name
// Set the DB's client charset if a system-charset is set // Set the DB's client charset if a system-charset is set
$this->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='system_charset'",__LINE__,__FILE__); $this->db->select($this->config_table,'config_value',array(
'config_app' => 'phpgwapi',
'config_name' => 'system_charset',
),__LINE__,__FILE__);
if ($this->db->next_record() && $this->db->f(0)) if ($this->db->next_record() && $this->db->f(0))
{ {
$this->db->Link_ID->SetCharSet($this->db->f(0)); $this->db->Link_ID->SetCharSet($this->db->f(0));
@ -426,15 +434,6 @@
} }
$enable = (int)$enable; $enable = (int)$enable;
/*
Use old applications table if the currentver is less than 0.9.10pre8,
but not if the currentver = '', which probably means new install.
*/
if($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
{
$this->applications_table = 'applications';
}
if($GLOBALS['DEBUG']) if($GLOBALS['DEBUG'])
{ {
echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', table: ' . $appstbl . '<br>'; echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', table: ' . $appstbl . '<br>';
@ -861,17 +860,6 @@
} }
} }
function get_hooks_table_name()
{
if(@$this->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'],'0.9.8pre5') &&
@$GLOBALS['setup_info']['phpgwapi']['currentver'] != '')
{
/* No phpgw_hooks table yet. */
return False;
}
return 'phpgw_hooks';
}
function setup_account_object() function setup_account_object()
{ {
if (!is_object($GLOBALS['egw']->accounts)) if (!is_object($GLOBALS['egw']->accounts))
@ -881,7 +869,7 @@
$this->loaddb(); $this->loaddb();
} }
/* Load up some configured values */ /* Load up some configured values */
$this->db->query("SELECT config_name,config_value FROM phpgw_config " $this->db->query("SELECT config_name,config_value FROM $this->config_table "
. "WHERE config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%'",__LINE__,__FILE__); . "WHERE config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%'",__LINE__,__FILE__);
while($this->db->next_record()) while($this->db->next_record())
{ {
@ -1005,12 +993,54 @@
} }
foreach($apps as $app) foreach($apps as $app)
{ {
$this->db->query("DELETE FROM phpgw_acl WHERE acl_appname='$app' AND acl_location='$location' AND acl_account=$account"); $this->db->query("DELETE FROM $this->acl_table WHERE acl_appname='$app' AND acl_location='$location' AND acl_account=$account");
if ($rights) if ($rights)
{ {
$this->db->query("INSERT INTO phpgw_acl(acl_appname,acl_location,acl_account,acl_rights) VALUES('$app','$location',$account,$rights)"); $this->db->query("INSERT INTO $this->acl_table (acl_appname,acl_location,acl_account,acl_rights) VALUES('$app','$location',$account,$rights)");
} }
} }
} }
/**
* checks if one of the given tables exist, returns the first match
*
* @param array $tables array with possible table-names
* @return string/boolean tablename or false
*/
function table_exist($tables)
{
static $table_names;
if (!$table_names) $table_names = $this->db->table_names();
if (!$table_names) return false;
foreach($table_names as $data)
{
if (($key = array_search($data['table_name'],$tables)) !== false)
{
return $tables[$key];
}
}
return false;
}
/**
* Checks and set the names of the tables, which get accessed before an update: eg. config- and applications-table
*
* Other tables can always use the most up to date name
*/
function set_table_names()
{
foreach(array(
'config_table' => array('egw_config','phpgw_config','config'),
'applications_table' => array('egw_applications','phpgw_applications','applications'),
'lang_table' => array('egw_lang','phpgw_lang','lang'),
'languages_table' => array('egw_languages','phpgw_languages','languages'),
) as $name => $tables)
{
$this->$name = $this->table_exist($tables);
//echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n";
}
}
} }
?>

View File

@ -42,20 +42,15 @@
{ {
$tname = Array(); $tname = Array();
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no'; $GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
$tables = $GLOBALS['egw_setup']->db->table_names();
foreach($tables as $key => $val)
{
$tname[] = $val['table_name'];
}
$newapps = in_array('phpgw_applications',$tname);
$oldapps = in_array('applications',$tname);
if((count($tables) > 0) && (is_array($tables)) && ($newapps || $oldapps)) $GLOBALS['egw_setup']->set_table_names();
if($GLOBALS['egw_setup']->applications_table)
{ {
/* one of these tables exists. checking for post/pre beta version */ /* one of these tables exists. checking for post/pre beta version */
if($newapps) if($GLOBALS['egw_setup']->applications_table != 'applications')
{ {
$GLOBALS['egw_setup']->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__);
while(@$GLOBALS['egw_setup']->db->next_record()) while(@$GLOBALS['egw_setup']->db->next_record())
{ {
$setup_info[$GLOBALS['egw_setup']->db->f('app_name')]['currentver'] = $GLOBALS['egw_setup']->db->f('app_version'); $setup_info[$GLOBALS['egw_setup']->db->f('app_name')]['currentver'] = $GLOBALS['egw_setup']->db->f('app_version');
@ -80,7 +75,7 @@
} }
$setup_info['phpgwapi']['version'] = $tmp; /* restore the file version */ $setup_info['phpgwapi']['version'] = $tmp; /* restore the file version */
} }
elseif($oldapps) else
{ {
$GLOBALS['egw_setup']->db->query('select * from applications'); $GLOBALS['egw_setup']->db->query('select * from applications');
while(@$GLOBALS['egw_setup']->db->next_record()) while(@$GLOBALS['egw_setup']->db->next_record())
@ -267,6 +262,8 @@
$GLOBALS['egw_setup']->db->connect(); $GLOBALS['egw_setup']->db->connect();
error_reporting($old); error_reporting($old);
} }
$GLOBALS['egw_setup']->set_table_names();
if (!$GLOBALS['egw_setup']->db->Link_ID) if (!$GLOBALS['egw_setup']->db->Link_ID)
{ {
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)'; $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
@ -276,7 +273,7 @@
{ {
$setup_info = $this->get_db_versions($setup_info); $setup_info = $this->get_db_versions($setup_info);
} }
// _debug_array($setup_info); //_debug_array($setup_info);
if (isset($setup_info['phpgwapi']['currentver'])) if (isset($setup_info['phpgwapi']['currentver']))
{ {
if(@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version']) if(@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version'])
@ -293,10 +290,10 @@
else else
{ {
/* no tables, so checking if we can create them */ /* no tables, so checking if we can create them */
$GLOBALS['egw_setup']->db->query('CREATE TABLE phpgw_testrights ( testfield varchar(5) NOT NULL )'); $GLOBALS['egw_setup']->db->query('CREATE TABLE egw_testrights ( testfield varchar(5) NOT NULL )');
if(!$GLOBALS['egw_setup']->db->Errno) if(!$GLOBALS['egw_setup']->db->Errno)
{ {
$GLOBALS['egw_setup']->db->query('DROP TABLE phpgw_testrights'); $GLOBALS['egw_setup']->db->query('DROP TABLE egw_testrights');
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (Install Applications)'; $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (Install Applications)';
return 3; return 3;
} }
@ -316,19 +313,7 @@
return ''; return '';
} }
/* Since 0.9.10pre6 config table is named as phpgw_config */ $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_value',array('config_name'=>'freshinstall'),__LINE__,__FILE__);
$ver = explode('.',@$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
$config_table = $ver[0] > 0 || (int)$ver[2] > 10 ? 'phpgw_config' : 'config';
if(ereg("([0-9]+)(pre)([0-9]+)",$ver[2],$regs))
{
if(($regs[1] == '10') && ($regs[3] >= '6'))
{
$config_table = 'phpgw_config';
}
}
@$GLOBALS['egw_setup']->db->query("select config_value from $config_table where config_name='freshinstall'");
$configured = $GLOBALS['egw_setup']->db->next_record() ? $GLOBALS['egw_setup']->db->f('config_value') : False; $configured = $GLOBALS['egw_setup']->db->next_record() ? $GLOBALS['egw_setup']->db->f('config_value') : False;
if($configed) if($configed)
{ {
@ -353,18 +338,7 @@
{ {
$GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']); $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']);
} }
if($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.14.501') || $GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}",__LINE__,__FILE__);
ereg('0\.9\.15\.00[01]{1,1}',$GLOBALS['setup_info']['phpgwapi']['currentver']))
{
$langtbl = 'lang';
$languagestbl = 'languages';
}
else
{
$langtbl = 'phpgw_lang';
$languagestbl = 'phpgw_languages';
}
$GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM $langtbl",__LINE__,__FILE__);
if($GLOBALS['egw_setup']->db->num_rows() == 0) if($GLOBALS['egw_setup']->db->num_rows() == 0)
{ {
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)'; $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)';
@ -378,7 +352,7 @@
} }
foreach($GLOBALS['egw_info']['setup']['installed_langs'] as $key => $value) foreach($GLOBALS['egw_info']['setup']['installed_langs'] as $key => $value)
{ {
$sql = "SELECT lang_name FROM $languagestbl WHERE lang_id = '".$value."'"; $sql = "SELECT lang_name FROM {$GLOBALS['egw_setup']->languages_table} WHERE lang_id = '".$value."'";
$GLOBALS['egw_setup']->db->query($sql); $GLOBALS['egw_setup']->db->query($sql);
if ($GLOBALS['egw_setup']->db->next_record()) if ($GLOBALS['egw_setup']->db->next_record())
{ {

View File

@ -231,12 +231,14 @@
} }
} }
foreach($GLOBALS['current_config'] as $setting => $value) foreach($GLOBALS['current_config'] as $name => $value)
{ {
$setting = $GLOBALS['egw_setup']->db->db_addslashes($setting); $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
$value = $GLOBALS['egw_setup']->db->db_addslashes($value); 'config_value' => $value,
@$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='$setting'",__LINE__,__FILE__); ),array(
$GLOBALS['egw_setup']->db->query("INSERT INTO phpgw_config (config_app,config_name, config_value) VALUES ('phpgwapi','$setting','$value')"); 'config_app' => 'phpgwapi',
'config_name' => $name,
),__FILE__,__LINE__);
} }
} }

View File

@ -440,7 +440,7 @@ function check_dir($dir,&$msg,$check_in_docroot=false)
$setup_tpl->set_var('ldap_table_data','&nbsp;'); $setup_tpl->set_var('ldap_table_data','&nbsp;');
break; break;
case 10: case 10:
$GLOBALS['egw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_app='phpgwapi'"); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$config[$GLOBALS['egw_setup']->db->f(0)] = $GLOBALS['egw_setup']->db->f(1); $config[$GLOBALS['egw_setup']->db->f(0)] = $GLOBALS['egw_setup']->db->f(1);
@ -451,7 +451,12 @@ function check_dir($dir,&$msg,$check_in_docroot=false)
$config['backup_dir'] = $config['files_dir'].'/db_backup'; $config['backup_dir'] = $config['files_dir'].'/db_backup';
if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir'])) if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir']))
{ {
$GLOBALS['egw_setup']->db->query("INSERT INTO phpgw_config (config_app,config_name,config_value) VALUES ('phpgwapi','backup_dir',".$GLOBALS['egw_setup']->db->quote($config['backup_dir']).')',__LINE__,__FILE__); $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
'config_value' => $config['backup_dir'],
),array(
'config_app' => 'phpgwapi',
'config_name' => 'backup_dir',
),__LINE__,__FILE__);
} }
} }
$config_msg = ''; $config_msg = '';

View File

@ -51,12 +51,14 @@
'T_alert_msg' => 'msg_alert_msg.tpl' 'T_alert_msg' => 'msg_alert_msg.tpl'
)); ));
$GLOBALS['egw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array(
"config_name LIKE 'ldap%'",
),__LINE__,__FILE__);
while ($GLOBALS['egw_setup']->db->next_record()) while ($GLOBALS['egw_setup']->db->next_record())
{ {
$config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value'); $config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
} }
$phpgw_info['server']['ldap_host'] = $config['ldap_host']; $phpgw_info['server']['ldap_host'] = $config['ldap_host'];
$phpgw_info['server']['ldap_context'] = $config['ldap_context']; $phpgw_info['server']['ldap_context'] = $config['ldap_context'];
$phpgw_info['server']['ldap_group_context'] = $config['ldap_group_context']; $phpgw_info['server']['ldap_group_context'] = $config['ldap_group_context'];
$phpgw_info['server']['ldap_root_dn'] = $config['ldap_root_dn']; $phpgw_info['server']['ldap_root_dn'] = $config['ldap_root_dn'];
@ -69,7 +71,7 @@
$phpgw_info['server']['account_repository'] = 'ldap'; $phpgw_info['server']['account_repository'] = 'ldap';
$egw->accounts = CreateObject('phpgwapi.accounts'); $egw->accounts = CreateObject('phpgwapi.accounts');
$acct = $egw->accounts; $acct = $egw->accounts;
// First, see if we can connect to the LDAP server, if not send `em back to config.php with an // First, see if we can connect to the LDAP server, if not send `em back to config.php with an
// error message. // error message.
@ -86,7 +88,7 @@
exit; exit;
} }
$sql = "SELECT * FROM phpgw_accounts WHERE account_type='u'"; $sql = "SELECT * FROM ".$GLOBALS['egw_setup']->accounts_table." WHERE account_type='u'";
$GLOBALS['egw_setup']->db->query($sql,__LINE__,__FILE__); $GLOBALS['egw_setup']->db->query($sql,__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
@ -100,7 +102,7 @@
$account_info[$i]['account_primary_group'] = $GLOBALS['egw_setup']->db->f('account_primary_group'); $account_info[$i]['account_primary_group'] = $GLOBALS['egw_setup']->db->f('account_primary_group');
} }
$sql = "SELECT * FROM phpgw_accounts WHERE account_type='g'"; $sql = "SELECT * FROM ".$GLOBALS['egw_setup']->accounts_table." WHERE account_type='g'";
$GLOBALS['egw_setup']->db->query($sql,__LINE__,__FILE__); $GLOBALS['egw_setup']->db->query($sql,__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {

View File

@ -56,7 +56,9 @@
$phpgw->applications = CreateObject('phpgwapi.applications'); $phpgw->applications = CreateObject('phpgwapi.applications');
$applications = $phpgw->applications; $applications = $phpgw->applications;
$GLOBALS['egw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array(
"config_name LIKE 'ldap%' OR config_name='account_repository'",
),__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value'); $config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
@ -129,7 +131,7 @@
$group_info = array(); $group_info = array();
} }
$GLOBALS['egw_setup']->db->query("SELECT app_name FROM phpgw_applications WHERE app_enabled!='0' AND app_enabled!='3' ORDER BY app_name",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'app_name','app_enabled != 0 AND app_enabled != 3',__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$apps[$GLOBALS['egw_setup']->db->f('app_name')] = lang($GLOBALS['egw_setup']->db->f('app_name')); $apps[$GLOBALS['egw_setup']->db->f('app_name')] = lang($GLOBALS['egw_setup']->db->f('app_name'));

View File

@ -51,7 +51,9 @@
'T_alert_msg' => 'msg_alert_msg.tpl' 'T_alert_msg' => 'msg_alert_msg.tpl'
)); ));
$GLOBALS['egw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array(
"config_name LIKE 'ldap%' OR config_name='account_repository'",
),__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value'); $config[$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
@ -111,7 +113,7 @@
$group_info = array(); $group_info = array();
} }
$GLOBALS['egw_setup']->db->query("SELECT app_name FROM phpgw_applications WHERE app_enabled!='0' AND app_enabled!='3' ORDER BY app_name",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'app_name','app_enabled != 0 AND app_enabled != 3',__LINE__,__FILE__);
while($GLOBALS['egw_setup']->db->next_record()) while($GLOBALS['egw_setup']->db->next_record())
{ {
$apps[$GLOBALS['egw_setup']->db->f('app_name')] = lang($GLOBALS['egw_setup']->db->f('app_name')); $apps[$GLOBALS['egw_setup']->db->f('app_name')] = lang($GLOBALS['egw_setup']->db->f('app_name'));

View File

@ -91,9 +91,10 @@
if($_POST['delete_all']) if($_POST['delete_all'])
{ {
/* Now, clear out existing tables */ /* Now, clear out existing tables */
$GLOBALS['egw_setup']->db->query('DELETE FROM phpgw_accounts'); foreach(array($GLOBALS['egw_setup']->accounts_table,$GLOBALS['egw_setup']->prefs_table,$GLOBALS['egw_setup']->acl_table) as $table)
$GLOBALS['egw_setup']->db->query('DELETE FROM phpgw_preferences'); {
$GLOBALS['egw_setup']->db->query('DELETE FROM phpgw_acl'); $GLOBALS['egw_setup']->db->delete($table,'1=1');
}
} }
/* Create the demo groups */ /* Create the demo groups */
$defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); $defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
@ -112,7 +113,7 @@
// give admin access to all apps, to save us some support requests // give admin access to all apps, to save us some support requests
$all_apps = array(); $all_apps = array();
$GLOBALS['egw_setup']->db->query('SELECT app_name FROM phpgw_applications WHERE app_enabled<3'); $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'app_name','app_enabled < 3',__LINE__,__FILE__);
while ($GLOBALS['egw_setup']->db->next_record()) while ($GLOBALS['egw_setup']->db->next_record())
{ {
$all_apps[] = $GLOBALS['egw_setup']->db->f('app_name'); $all_apps[] = $GLOBALS['egw_setup']->db->f('app_name');

View File

@ -144,8 +144,12 @@
} }
} }
} }
@$GLOBALS['egw_setup']->db->query("DELETE FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='system_charset'",__LINE__,__FILE__); $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
$GLOBALS['egw_setup']->db->query("INSERT INTO phpgw_config (config_app,config_name,config_value) VALUES ('phpgwapi','system_charset','$to')",__LINE__,__FILE__); 'config_value' => $to,
),array(
'config_app' => 'phpgwapi',
'config_name' => 'systemcharset',
),__LINE__,__FILE__);
} }
$setup_tpl->set_var('stage_title',$stage_title); $setup_tpl->set_var('stage_title',$stage_title);