moved infolog links to addressbook,projects and calendar to new link-class and its table phpgw_links

This commit is contained in:
Ralf Becker 2002-09-01 20:41:36 +00:00
parent bd8aba2246
commit 78320c0525
4 changed files with 156 additions and 10 deletions

View File

@ -29,6 +29,8 @@
$this->grants = $GLOBALS['phpgw']->acl->get_grants('infolog');
$this->user = $GLOBALS['phpgw_info']['user']['account_id'];
$this->links = CreateObject('infolog.solink');
$this->read( $info_id );
}
@ -173,6 +175,16 @@
{
$this->data[$key] = stripslashes($this->data[$key]);
}
$links = $this->links->get_links('infolog',$this->data['info_id']);
while (list($nul,$link) = each($links))
{
if ($link['app'] == 'addressbook')
$this->data['info_addr_id'] = $link['id'];
if ($link['app'] == 'projects')
$this->data['info_proj_id'] = $link['id'];
if ($link['app'] == 'calendar')
$this->data['info_event_id'] = $link['id'];
}
}
return $this->data;
}
@ -183,6 +195,8 @@
. "$info_id' AND ((info_access='public' and info_owner != '$this->user')"
. " or (info_owner='$this->user'))" ,__LINE__,__FILE__);
$this->links->unlink(0,'infolog',$info_id);
if ($this->data['info_id'] == $info_id)
{
$this->init( );
@ -199,6 +213,9 @@
$this->data[$key] = $val; // update internal data
if ($key == 'info_addr_id' || $key == 'info_proj_id' || $key == 'info_event_id')
continue; // not longer in infolog-table
if ($this->maybe_slashes[$key])
{
$val = addslashes($val);
@ -208,11 +225,12 @@
$query .= ($query ? ',' : '')."$key='$val'";
}
}
if ($values['info_id'])
if (($this->data['info_id'] = $values['info_id']) > 0)
{
$query = "UPDATE phpgw_infolog SET $query where info_id='".$values['info_id']."'";
$this->db->query($query,__LINE__,__FILE__);
$this->data['info_id'] = $values['info_id'];
$this->db->query($query,__LINE__,__FILE__);
$this->links->unlink(0,'infolog',$values['info_id']);
}
else
{
@ -220,6 +238,14 @@
$this->db->query($query,__LINE__,__FILE__);
$this->data['info_id']=$this->db->get_last_insert_id('phpgw_infolog','info_id');
}
// echo "<p>soinfolog.write values= "; _debug_array($values);
// echo "<p>soinfolog.write this->data= "; _debug_array($this->data);
if ($this->data['info_addr_id'])
$this->links->link('infolog',$this->data['info_id'],'addressbook',$this->data['info_addr_id']);
if ($this->data['info_proj_id'])
$this->links->link('infolog',$this->data['info_id'],'projects',$this->data['info_proj_id']);
if ($this->data['info_event_id'])
$this->links->link('infolog',$this->data['info_id'],'calendar',$this->data['info_event_id']);
}
function anzSubs( $info_id )
@ -235,6 +261,23 @@
function readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
$ordermethod,&$start,&$total)
{
//echo "<p>soinfolog.readIdArray(action='$action',action_id='$action_id')</p>\n";
$action2app = array(
'addr' => 'addressbook',
'proj' => 'projects',
'event' => 'calendar'
);
if ($action != '' && $action2app[$action] != '')
{
$links = $this->links->get_links($action2app[$action],$action_id);
$ids = array();
while (list($nul,$link) = each($links))
{
$ids[''.$link['id']] = 0;
}
//echo "<p>soinfolog.readIdArray($action,$action_id) ids ="; _debug_array($ids);
return $ids;
}
if ($order)
{
$ordermethod = 'order by ' . $order . ' ' . $sort;
@ -250,7 +293,7 @@
if ($cat_id)
{
$filtermethod .= " AND info_cat='$cat_id' ";
$filtermethod .= " AND info_cat='$cat_id' ";
}
switch ($action)
{

View File

@ -13,9 +13,9 @@
$setup_info['infolog']['name'] = 'infolog';
$setup_info['infolog']['title'] = 'Info Log';
$setup_info['infolog']['version'] = '0.9.15.001';
$setup_info['infolog']['version'] = '0.9.15.003';
$setup_info['infolog']['app_order'] = 20;
$setup_info['infolog']['tables'] = array('phpgw_infolog');
$setup_info['infolog']['tables'] = array('phpgw_infolog','phpgw_links');
$setup_info['infolog']['enable'] = 1;
$setup_info['infolog']['author'] = 'Ralf Becker';

View File

@ -16,8 +16,6 @@
'fd' => array(
'info_id' => array('type' => 'auto','nullable' => False),
'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
'info_addr_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_proj_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
@ -34,8 +32,7 @@
'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not'),
'info_event_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False)
'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not')
),
'pk' => array('info_id'),
'fk' => array(),

View File

@ -52,4 +52,110 @@
$GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.002';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '0.9.15.002';
function infolog_upgrade0_9_15_002()
{
echo "<p>infolog_upgrade0_9_15_002</p>\n";
$insert = 'INSERT INTO phpgw_links (link_app1,link_id1,link_app2,link_id2,link_remark,link_lastmod,link_owner) ';
$select = "SELECT 'infolog',info_id,'addressbook',info_addr_id,info_from,info_datemodified,info_owner FROM phpgw_infolog WHERE info_addr_id != 0";
echo "<p>copying address-links: $insert.$select</p>\n";
$GLOBALS['phpgw_setup']->oProc->query($insert.$select);
$select = "SELECT 'infolog',info_id,'projects',info_proj_id,'',info_datemodified,info_owner FROM phpgw_infolog WHERE info_proj_id != 0";
echo "<p>copying projects-links: $insert.$select</p>\n";
$GLOBALS['phpgw_setup']->oProc->query($insert.$select);
$select = "SELECT 'infolog',info_id,'calendar',info_event_id,'',info_datemodified,info_owner FROM phpgw_infolog WHERE info_event_id != 0";
echo "<p>copying calendar-links: $insert.$select</p>\n";
$GLOBALS['phpgw_setup']->oProc->query($insert.$select);
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
'fd' => array(
'info_id' => array('type' => 'auto','nullable' => False),
'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
'info_proj_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_des' => array('type' => 'text','nullable' => True),
'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not'),
'info_event_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False)
),
'pk' => array('info_id'),
'fk' => array(),
'ix' => array(),
'uc' => array()
),'info_addr_id');
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
'fd' => array(
'info_id' => array('type' => 'auto','nullable' => False),
'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_des' => array('type' => 'text','nullable' => True),
'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not'),
'info_event_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False)
),
'pk' => array('info_id'),
'fk' => array(),
'ix' => array(),
'uc' => array()
),'info_proj_id');
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
'fd' => array(
'info_id' => array('type' => 'auto','nullable' => False),
'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
'info_des' => array('type' => 'text','nullable' => True),
'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not')
),
'pk' => array('info_id'),
'fk' => array(),
'ix' => array(),
'uc' => array()
),'info_event_id');
$GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.003';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
?>