update to version 0.9.99.002:

- new columns for accounts-table: contact_id and primary group
- fixed error from 0.9.10 update with groups and permissions columns only half deleted
- update function for phpGW 0.9.14.508/9 and 0.9.15.013/4
This commit is contained in:
Ralf Becker 2003-09-13 18:19:03 +00:00
parent ac487777b7
commit 36b40204e3
5 changed files with 184 additions and 35 deletions

View File

@ -95,6 +95,8 @@
$this->data['lastpasswd_change'] = $this->db->f('account_lastpwd_change');
$this->data['status'] = $this->db->f('account_status');
$this->data['expires'] = $this->db->f('account_expires');
$this->data['person_id'] = $this->db->f('person_id');
$this->data['account_primary_group'] = $this->db->f('account_primary_group');
return $this->data;
}
@ -105,11 +107,15 @@
*/
function save_repository()
{
$this->db->query("UPDATE phpgw_accounts SET account_firstname='" . $this->data['firstname']
. "', account_lastname='" . $this->data['lastname'] . "', account_status='"
. $this->data['status'] . "', account_expires=" . $this->data['expires']
. ($this->data['account_lid']?", account_lid='".$this->data['account_lid']."'":'')
. ' WHERE account_id=' . intval($this->account_id),__LINE__,__FILE__);
$this->db->query('UPDATE phpgw_accounts SET'.
" account_firstname='" . $this->db->db_addslashes($this->data['firstname']).
"', account_lastname='" . $this->db->db_addslashes($this->data['lastname']).
"', account_status='". $this->db->db_addslashes($this->data['status']).
"', account_expires=" . intval($this->data['expires']).
($this->data['account_lid']?", account_lid='".$this->db->db_addslashes($this->data['account_lid'])."'":'').
', person_id='.intval($this->data['person_id']).
', account_primary_group='.intval($this->data['account_primary_group']).
' WHERE account_id=' . intval($this->account_id),__LINE__,__FILE__);
}
function delete($accountid = '')
@ -172,7 +178,7 @@
{
$whereclause = ' WHERE ( ';
}
$query = $this->db->db_addslashes($query);
$whereclause .= " account_firstname LIKE '%$query%' OR account_lastname LIKE "
. "'%$query%' OR account_lid LIKE '%$query%' )";
}
@ -200,7 +206,9 @@
'account_firstname' => $this->db->f('account_firstname'),
'account_lastname' => $this->db->f('account_lastname'),
'account_status' => $this->db->f('account_status'),
'account_expires' => $this->db->f('account_expires')
'account_expires' => $this->db->f('account_expires'),
'person_id' => $this->db->f('person_id'),
'account_primary_group' => $this->db->f('account_primary_group')
);
}
$this->db->query("SELECT count(*) FROM phpgw_accounts $whereclause");
@ -224,7 +232,7 @@
return $name_list[$account_lid];
}
$this->db->query("SELECT account_id FROM phpgw_accounts WHERE account_lid='".$account_lid."'",__LINE__,__FILE__);
$this->db->query("SELECT account_id FROM phpgw_accounts WHERE account_lid='".$this->db->db_addslashes($account_lid)."'",__LINE__,__FILE__);
if($this->db->num_rows())
{
$this->db->next_record();
@ -302,7 +310,7 @@
static $by_id, $by_lid;
$sql = 'SELECT count(account_id) FROM phpgw_accounts WHERE ';
if(is_integer($account_lid))
if(is_numeric($account_lid))
{
if(@isset($by_id[$account_lid]) && $by_id[$account_lid] != '')
{
@ -316,13 +324,13 @@
{
return $by_lid[$account_lid];
}
$sql .= "account_lid = '".$account_lid."'";
$sql .= "account_lid = '".$this->db->db_addslashes($account_lid)."'";
}
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$ret_val = $this->db->f(0) > 0;
if(gettype($account_lid) == 'integer')
if(is_numeric($account_lid))
{
$by_id[$account_lid] = $ret_val;
$by_lid[$this->id2name($account_lid)] = $ret_val;
@ -337,18 +345,26 @@
function create($account_info,$default_prefs=True)
{
$this->db->query('insert into phpgw_accounts (account_lid, account_type, account_pwd, '
. "account_firstname, account_lastname, account_status, account_expires) values ('"
. $account_info['account_lid'] . "','" . $account_info['account_type'] . "','"
. md5($account_info['account_passwd']) . "', '" . $account_info['account_firstname']
. "','" . $account_info['account_lastname'] . "','" . $account_info['account_status']
. "'," . $account_info['account_expires'] . ')',__LINE__,__FILE__);
$this->db->query('INSERT INTO phpgw_accounts (account_lid,account_type,account_pwd,'
. 'account_firstname,account_lastname,account_status,account_expires,person_id,'
. "account_primary_group) VALUES ('".$this->db->db_addslashes($account_info['account_lid'])
. "','" . $this->db->db_addslashes($account_info['account_type'])
. "','" . md5($account_info['account_passwd'])
. "', '" . $this->db->db_addslashes($account_info['account_firstname'])
. "','" . $this->db->db_addslashes($account_info['account_lastname'])
. "','" . $this->db->db_addslashes($account_info['account_status'])
. "'," . intval($account_info['account_expires'])
. ',' . intval($account_info['person_id'])
. ',' . intval($account_info['account_primary_group']) . ')',__LINE__,__FILE__);
$accountid = $this->db->get_last_insert_id('phpgw_accounts','account_id');
/* default prefs dont need to be set anymore
if($accountid && is_object($GLOBALS['phpgw']->preferences) && $default_prefs)
{
$GLOBALS['phpgw']->preferences->create_defaults($accountid);
}
*/
return $accountid;
}
@ -411,7 +427,7 @@
// This generally doesn't / shouldn't happen, but will (jengo)
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('preferences', 'changepassword', " . $accountid . ', 1)',__LINE__,__FILE__);
$apps = Array(
foreach(Array(
'addressbook',
'calendar',
'email',
@ -419,10 +435,7 @@
'todo',
'phpwebhosting',
'manual'
);
@reset($apps);
while(list($key,$app) = each($apps))
) as $app)
{
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('" . $app . "', 'run', " . $accountid . ', 1)',__LINE__,__FILE__);
}
@ -445,7 +458,7 @@
return;
}
$db = $GLOBALS['phpgw']->db;
$db->query('select account_lid,account_firstname,account_lastname from phpgw_accounts where account_id=' . $account_id,__LINE__,__FILE__);
$db->query('SELECT account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_id=' . intval($account_id),__LINE__,__FILE__);
$db->next_record();
$account_name[$account_id]['lid'] = $db->f('account_lid');
$account_name[$account_id]['fname'] = $db->f('account_firstname');

View File

@ -155,7 +155,12 @@
foreach($depvalue['versions'] as $depskey => $depsvalue)
{
$major = $GLOBALS['phpgw_setup']->get_major($setup_info[$depvalue['appname']]['currentver']);
$currentver = $setup_info[$depvalue['appname']]['currentver'];
if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99')
{
$currentver = '0.9.14.508';
}
$major = $GLOBALS['phpgw_setup']->get_major($currentver);
if ($major == $depsvalue)
{
$setup_info['depends'][$depkey]['status'] = True;
@ -164,7 +169,7 @@
{
$major_depsvalue = $GLOBALS['phpgw_setup']->get_major($depsvalue);
list(,,,$minor_depsvalue) = explode('.',$depsvalue);
list(,,,$minor) = explode('.',$setup_info[$depsvalue['appname']]['currentver']);
list(,,,$minor) = explode('.',$currentver);
if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
{
$setup_info['depends'][$depkey]['status'] = True;

View File

@ -15,7 +15,7 @@
/* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi';
$setup_info['phpgwapi']['version'] = '0.9.14.508';
$setup_info['phpgwapi']['version'] = '0.9.99.002';
$setup_info['phpgwapi']['versions']['current_header'] = '1.23';
$setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1;
@ -56,3 +56,4 @@

View File

@ -55,16 +55,16 @@
'account_id' => array('type' => 'auto','nullable' => False),
'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False),
'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False),
'account_firstname' => array('type' => 'varchar','precision' => '50'),
'account_lastname' => array('type' => 'varchar','precision' => '50'),
'account_permissions' => array('type' => 'text'),
'account_groups' => array('type' => 'varchar','precision' => '30'),
'account_lastlogin' => array('type' => 'int','precision' => '4'),
'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'),
'account_lastpwd_change' => array('type' => 'int','precision' => '4'),
'account_firstname' => array('type' => 'varchar','precision' => '50','nullable' => False),
'account_lastname' => array('type' => 'varchar','precision' => '50','nullable' => False),
'account_lastlogin' => array('type' => 'int','precision' => '4','nullable' => False),
'account_lastloginfrom' => array('type' => 'varchar','precision' => '255','nullable' => False),
'account_lastpwd_change' => array('type' => 'int','precision' => '4','nullable' => False),
'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'),
'account_expires' => array('type' => 'int','precision' => '4'),
'account_type' => array('type' => 'char','precision' => '1','nullable' => True)
'account_expires' => array('type' => 'int','precision' => '4','nullable' => False),
'account_type' => array('type' => 'char','precision' => '1','nullable' => True),
'person_id' => array('type' => 'int','precision' => '4','nullable' => True),
'account_primary_group' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
),
'pk' => array('account_id'),
'fk' => array(),

View File

@ -743,4 +743,134 @@
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '0.9.14.508';
function phpgwapi_upgrade0_9_14_508()
{
// update to 0.9.10pre3 droped the columns account_permissions and account_groups
// unfortunally they are still in the tables_current of 0.9.14.508
// so it depends on having a new or an updated install, if one have them or not
// we now check if they are there and drop them if thats the case
//echo "<pre>"; print_r(debug_backtrace()); echo "</pre>\n";
//echo "<pre>"; print_r($GLOBALS['phpgw_setup']->oProc); echo "</pre>\n";
$GLOBALS['phpgw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['phpgw_setup']->oProc,'phpgw_accounts',$columns);
$columns = explode(',',$columns);
if (in_array('account_permissions',$columns))
{
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_accounts',array(
'fd' => array(
'account_id' => array('type' => 'auto','nullable' => False),
'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False),
'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False),
'account_firstname' => array('type' => 'varchar','precision' => '50'),
'account_lastname' => array('type' => 'varchar','precision' => '50'),
'account_groups' => array('type' => 'varchar','precision' => '30'),
'account_lastlogin' => array('type' => 'int','precision' => '4'),
'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'),
'account_lastpwd_change' => array('type' => 'int','precision' => '4'),
'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'),
'account_expires' => array('type' => 'int','precision' => '4'),
'account_type' => array('type' => 'char','precision' => '1','nullable' => True)
),
'pk' => array('account_id'),
'fk' => array(),
'ix' => array(),
'uc' => array('account_lid')
),'account_permissions');
}
if (in_array('account_groups',$columns))
{
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_accounts',array(
'fd' => array(
'account_id' => array('type' => 'auto','nullable' => False),
'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False),
'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False),
'account_firstname' => array('type' => 'varchar','precision' => '50'),
'account_lastname' => array('type' => 'varchar','precision' => '50'),
'account_lastlogin' => array('type' => 'int','precision' => '4'),
'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'),
'account_lastpwd_change' => array('type' => 'int','precision' => '4'),
'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'),
'account_expires' => array('type' => 'int','precision' => '4'),
'account_type' => array('type' => 'char','precision' => '1','nullable' => True)
),
'pk' => array('account_id'),
'fk' => array(),
'ix' => array(),
'uc' => array('account_lid')
),'account_groups');
}
// we add the person_id from the .16RC1, if its not already there
if (!in_array('person_id',$columns))
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','person_id',array(
'type' => 'int',
'precision' => '4',
'nullable' => True
));
}
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','account_primary_group',array(
'type' => 'int',
'precision' => '4',
'nullable' => False,
'default' => '0'
));
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.002';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
/*
* Updates from phpGroupWare .16 branch
*/
$test[] = '0.9.14.509';
function phpgwapi_upgrade0_9_14_509()
{
// this is the phpGW .16RC1 with the new contacts tables
// we need to drop them here to not run into problems later on, if we install them
foreach(array(
'phpgw_contact',
'phpgw_contact_person',
'phpgw_contact_org',
'phpgw_contact_org_person',
'phpgw_contact_addr',
'phpgw_contact_note',
'phpgw_contact_others',
'phpgw_contact_comm',
'phpgw_contact_comm_descr',
'phpgw_contact_comm_type',
'phpgw_contact_types',
'phpgw_contact_addr_type',
'phpgw_contact_note_type'
) as $table)
{
$GLOBALS['phpgw_setup']->oProc->DropTable($table);
}
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
/*
* Updates / downgrades from phpGroupWare HEAD branch
*/
$test[] = '0.9.15.013';
function phpgwapi_upgrade0_9_15_013()
{
// is db-compatible to 0.9.14.507
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.507';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '0.9.15.014';
function phpgwapi_upgrade0_9_15_014()
{
// is db-compatible to 0.9.14.508
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
?>