[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: infolog/inc class.bolink.inc.php,1.7,1.8 class.s
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: infolog/inc class.bolink.inc.php,1.7,1.8 class.solink.inc.php,1.4,1.5 |
Date: |
Tue, 08 Oct 2002 20:37:03 -0400 |
Update of /cvsroot/phpgroupware/infolog/inc
In directory subversions:/tmp/cvs-serv22082
Modified Files:
class.bolink.inc.php class.solink.inc.php
Log Message:
nearly finished port of infolog.edit
improved handling of linkage with not yet written entries
Index: class.bolink.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.bolink.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.bolink.inc.php 8 Oct 2002 00:10:02 -0000 1.7
--- class.bolink.inc.php 9 Oct 2002 00:37:00 -0000 1.8
***************
*** 92,100 ****
@result if $id1==0 or already an array: $id1 is array with links
*/
! function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0 )
{
if ($this->debug)
{
! echo
"<p>bolink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
}
if (!$app1 || !$app2 || !$id1 && is_array($id2) ||
$app1 == $app2 && $id1 == $id2)
--- 92,100 ----
@result if $id1==0 or already an array: $id1 is array with links
*/
! function link(
$app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0 )
{
if ($this->debug)
{
! echo
"<p>bolink.link('$app1',$id1,'$app2',$id2,'$remark',$owner,$lastmod)</p>\n";
}
if (!$app1 || !$app2 || !$id1 && is_array($id2) ||
$app1 == $app2 && $id1 == $id2)
***************
*** 113,117 ****
'remark' => $remark,
'owner' => $owner,
! 'link_id' => "$app2:$id2"
);
return 0;
--- 113,118 ----
'remark' => $remark,
'owner' => $owner,
! 'link_id' => "$app2:$id2",
! 'lastmod' => time()
);
return 0;
***************
*** 123,127 ****
while (!$err && list(,$link) = each($app2))
{
! $err =
solink::link($app1,$id1,$link['app'],$link['id'],$link['remark'],$link['owner']);
}
return $err;
--- 124,128 ----
while (!$err && list(,$link) = each($app2))
{
! $err =
solink::link($app1,$id1,$link['app'],$link['id'],$link['remark'],$link['owner'],$link['lastmod']);
}
return $err;
***************
*** 151,156 ****
$only_app = substr(1,$only_app);
}
! reset($id);
! while (list($key,$link) = each($id))
{
if ($only_app && $not_only ==
($link['app'] == $only_app))
--- 152,157 ----
$only_app = substr(1,$only_app);
}
! end($id);
! while ($link = current($id))
{
if ($only_app && $not_only ==
($link['app'] == $only_app))
***************
*** 158,162 ****
continue;
}
! $ids[$key] = $link;
}
}
--- 159,164 ----
continue;
}
! $ids[$link['link_id']] = $link;
! prev($id);
}
}
***************
*** 168,185 ****
/*!
@function unlink
! @syntax unlink( $link_id,$app='',$id='',$owner='' )
@author ralfbecker
@abstract Remove link with $link_id or all links matching given
$app,$id
@param $link_id link-id to remove if > 0
! @param $app,$id,$owner if $link_id <= 0: removes all links
matching the non-empty params
@discussion Note: if $link_id != '' and $id is an array: unlink
removes links from that array only
@discussion unlink has to be called with &$id so see the
result !!!
@result the number of links deleted
*/
! function unlink($link_id,$app='',$id='',$owner='')
{
if ($link_id > 0 || !is_array($id))
{
! return solink::unlink($link_id,$app,$id,$owner);
}
$result = isset($id[$link_id]);
--- 170,187 ----
/*!
@function unlink
! @syntax unlink( $link_id,$app='',$id='',$owner='',$app2='',$id2='' )
@author ralfbecker
@abstract Remove link with $link_id or all links matching given
$app,$id
@param $link_id link-id to remove if > 0
! @param $app,$id,$owner,$app2,$id2 if $link_id <= 0: removes all
links matching the non-empty params
@discussion Note: if $link_id != '' and $id is an array: unlink
removes links from that array only
@discussion unlink has to be called with &$id so see the
result !!!
@result the number of links deleted
*/
! function
unlink($link_id,$app='',$id='',$owner='',$app2='',$id2='')
{
if ($link_id > 0 || !is_array($id))
{
! return
solink::unlink($link_id,$app,$id,$owner,$app2,$id2);
}
$result = isset($id[$link_id]);
***************
*** 194,198 ****
@syntax app_list( )
@author ralfbecker
! @abstrac get list/array of link-aware apps
@result array( $app => lang($app), ... )
*/
--- 196,200 ----
@syntax app_list( )
@author ralfbecker
! @abstrac get list/array of link-aware apps the user has rights
to use
@result array( $app => lang($app), ... )
*/
***************
*** 203,207 ****
while (list($app,$reg) = each($this->app_register))
{
! $apps[$app] = lang($app);
}
return $apps;
--- 205,212 ----
while (list($app,$reg) = each($this->app_register))
{
! if
($GLOBALS['phpgw_info']['user']['apps'][$app])
! {
! $apps[$app] = lang($app);
! }
}
return $apps;
***************
*** 400,404 ****
{
if
(!file_exists(PHPGW_SERVER_ROOT.'/projects')) // check if projects
installed
! return '';
$this->boprojects =
createobject('projects.boprojects');
}
--- 405,409 ----
{
if
(!file_exists(PHPGW_SERVER_ROOT.'/projects')) // check if projects
installed
! return '';
$this->boprojects =
createobject('projects.boprojects');
}
Index: class.solink.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.solink.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.solink.inc.php 3 Sep 2002 23:08:00 -0000 1.4
--- class.solink.inc.php 9 Oct 2002 00:37:00 -0000 1.5
***************
*** 1,220 ****
! <?php
!
/**************************************************************************\
! * phpGroupWare - InfoLog Links
*
! * http://www.phpgroupware.org
*
! * Written by Ralf Becker <address@hidden> *
! * --------------------------------------------
*
! * This program is free software; you can redistribute it and/or modify
it *
! * under the terms of the GNU General Public License as published by
the *
! * Free Software Foundation; either version 2 of the License, or (at
your *
! * option) any later version.
*
!
\**************************************************************************/
!
! /* $Id$ */
!
! /*!
! @class solink
! @author ralfbecker
! @abstract generalized linking between entries of phpGroupware apps - DB
layer
! @discussion This class is to access the links in the DB
! @discussion Links have to ends each pointing to an entry, an entry is a
double:
! @discussion app app-name or directory-name of an phpgw application,
eg. 'infolog'
! @discussion id this is the id, eg. an integer or a tupple like
'0:INBOX:1234'
! */
! class solink // DB-Layer
! {
! var $public_functions = array
! (
! 'link' => True,
! 'get_links' => True,
! 'unlink' => True,
! 'chown' => True
! );
! var $db;
! var $user;
! var $db_name = 'phpgw_links';
! var $debug = 0;
!
! /*!
! @function solink
! @syntax solink( )
! @author ralfbecker
! @abstract constructor
! */
! function solink( )
! {
! $this->db = $GLOBALS['phpgw']->db;
! $this->user =
$GLOBALS['phpgw_info']['user']['account_id'];
! }
!
! /*!
! @function link
! @syntax link( $app1,$id1,$app2,$id2,$remark='',$user=0 )
! @author ralfbecker
! @abstract creats a link between $app1,$id1 and $app2,$id2
! @param $remark Remark to be saved with the link (defaults to '')
! @param $owner Owner of the link (defaults to user)
! @discussion Does NOT check if link already exists
! @result db-errno or -1 (for param-error) or 0 for success
! */
! function link( $app1,$id1,$app2,$id2,$remark='',$owner=0 )
! {
! if ($this->debug)
! {
! echo
"<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
! }
! if ($app1 == $app2 && $id1 == $id2 ||
! $id1 == '' || $id2 == '' || $app1 == '' || $app2 ==
'')
! {
! return -1; // dont link to self or other
nosense
! }
! if (!$owner)
! {
! $owner = $this->user;
! }
! $remark = $this->db->db_addslashes($remark);
! $lastmod = time();
!
! $sql = "INSERT INTO $this->db_name
(link_app1,link_id1,link_app2,link_id2,link_remark,link_lastmod,link_owner) ".
! " VALUES
('$app1','$id1','$app2','$id2','$remark',$lastmod,$owner)";
!
! if ($this->debug)
! {
! echo
"<p>solink.link($app1,$id1,$app2,$id2,'$remark',$owner) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! return $this->db->errno;
! }
!
! /*!
! @function get_links
! @syntax get_links(
$app,$id,$only_app='',$only_name='',$order='link_lastmod DESC' )
! @author ralfbecker
! @abstract returns array of links to $app,$id
! @param $only_app if set return only links from $only_app (eg.
only addressbook-entries) or NOT from if $only_app[0]=='!'
! @param $order defaults to newest links first
! @result array of links or empty array if no matching links found
! */
! function get_links( $app,$id,$only_app='',$order='link_lastmod
DESC' )
! {
! $links = array();
!
! $sql = "SELECT * FROM $this->db_name".
! " WHERE (link_app1 = '$app' AND
link_id1 = '$id')".
! " OR (link_app2 = '$app' AND link_id2
= '$id')".
! ($order != '' ? " ORDER BY $order" :
'');
!
! if ($this->debug)
! {
! echo
"<p>solink.get_links($app,$id,$only_app,$order) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! if ($not_only = $only_app[0] == '!')
! {
! $only_app = substr($only_app,1);
! }
! while ($this->db->next_record())
! {
! $row = $this->db->Record;
!
! if ($row['link_app1'] == $app AND $row['link_id1'] == $id)
! {
! $link = array(
! 'app' => $row['link_app2'],
! 'id' =>
stripslashes($row['link_id2'])
! );
! }
! else
! {
! $link = array(
! 'app' => $row['link_app1'],
! 'id' =>
stripslashes($row['link_id1'])
! );
! }
! if ($only_app && $not_only == ($link['app'] ==
$only_app))
! {
! continue;
! }
! $link['remark'] =
stripslashes($row['link_remark']);
! $link['owner'] = $row['link_owner'];
! $link['lastmod'] = $row['link_lastmod'];
! $link['link_id'] = $row['link_id'];
!
! $links[] = $link;
! }
! return $links;
! }
!
! /*!
! @function unlink
! @syntax unlink( $link_id,$app='',$id='',$owner='' )
! @author ralfbecker
! @abstract Remove link with $link_id or all links matching given
params
! @param $link_id link-id to remove if > 0
! @param $app,$id,$owner if $link_id <= 0: removes all links
matching the non-empty params
! @result the number of links deleted
! */
! function unlink($link_id,$app='',$id='',$owner='')
! {
! $sql = "DELETE FROM $this->db_name WHERE ";
! if ($link_id > 0)
! {
! $sql .= "link_id=$link_id";
! }
! elseif ($app == '' AND $owner == '')
! {
! return 0;
! }
! else
! {
! if ($app != '')
! {
! $sql .= "((link_app1='$app'";
! $sql2 = '';
! if ($id != '')
! {
! $sql .= " AND link_id1='$id'";
! $sql2 .= " AND link_id2='$id'";
! }
! $sql .= ") OR (link_app2='$app'$sql2))";
! }
! if ($owner != '')
! {
! $sql .= ($app != '' ? ' AND ' : '') .
"link_owner='$owner'";
! }
! }
! if ($this->debug)
! {
! echo
"<p>solink.unlink($link_id,$app,$id,$owner) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! return $this->db->affected_rows();
! }
!
! /*!
! @function chown
! @syntax chown( $owner,$new_owner )
! @author ralfbecker
! @abstract Changes ownership of all links from $owner to
$new_owner
! @discussion This is needed when a user/account gets deleted
! @discussion Does NOT change the modification-time
! @result the number of links changed
! */
! function chown($owner,$new_owner)
! {
! if ($owner <= 0 || $new_owner <= 0)
! {
! return 0;
! }
! $this->db->query("UPDATE $this->db_name SET
owner=$new_owner WHERE owner=$owner");
!
! return $this->db->affected_rows();
! }
! }
!
!
!
!
--- 1,229 ----
! <?php
!
/**************************************************************************\
! * phpGroupWare - InfoLog Links
*
! * http://www.phpgroupware.org
*
! * Written by Ralf Becker <address@hidden> *
! * --------------------------------------------
*
! * This program is free software; you can redistribute it and/or modify
it *
! * under the terms of the GNU General Public License as published by
the *
! * Free Software Foundation; either version 2 of the License, or (at
your *
! * option) any later version.
*
!
\**************************************************************************/
!
! /* $Id$ */
!
! /*!
! @class solink
! @author ralfbecker
! @abstract generalized linking between entries of phpGroupware apps - DB
layer
! @discussion This class is to access the links in the DB
! @discussion Links have to ends each pointing to an entry, an entry is a
double:
! @discussion app app-name or directory-name of an phpgw application,
eg. 'infolog'
! @discussion id this is the id, eg. an integer or a tupple like
'0:INBOX:1234'
! */
! class solink // DB-Layer
! {
! var $public_functions = array
! (
! 'link' => True,
! 'get_links' => True,
! 'unlink' => True,
! 'chown' => True
! );
! var $db;
! var $user;
! var $db_name = 'phpgw_links';
! var $debug = 0;
!
! /*!
! @function solink
! @syntax solink( )
! @author ralfbecker
! @abstract constructor
! */
! function solink( )
! {
! $this->db = $GLOBALS['phpgw']->db;
! $this->user =
$GLOBALS['phpgw_info']['user']['account_id'];
! }
!
! /*!
! @function link
! @syntax link( $app1,$id1,$app2,$id2,$remark='',$user=0 )
! @author ralfbecker
! @abstract creats a link between $app1,$id1 and $app2,$id2
! @param $remark Remark to be saved with the link (defaults to '')
! @param $owner Owner of the link (defaults to user)
! @discussion Does NOT check if link already exists
! @result db-errno or -1 (for param-error) or 0 for success
! */
! function link(
$app1,$id1,$app2,$id2,$remark='',$owner=0,$lastmod=0 )
! {
! if ($this->debug)
! {
! echo
"<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
! }
! if ($app1 == $app2 && $id1 == $id2 ||
! $id1 == '' || $id2 == '' || $app1 == '' || $app2 ==
'')
! {
! return -1; // dont link to self or other
nosense
! }
! if (!$owner)
! {
! $owner = $this->user;
! }
! $remark = $this->db->db_addslashes($remark);
! if (!$lastmod)
! {
! $lastmod = time();
! }
! $this->unlink(0,$app1,$id1,'',$app2,$id2); //
remove link if one exists
!
! $sql = "INSERT INTO $this->db_name
(link_app1,link_id1,link_app2,link_id2,link_remark,link_lastmod,link_owner) ".
! " VALUES
('$app1','$id1','$app2','$id2','$remark',$lastmod,$owner)";
!
! if ($this->debug)
! {
! echo
"<p>solink.link($app1,$id1,$app2,$id2,'$remark',$owner) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! return $this->db->errno;
! }
!
! /*!
! @function get_links
! @syntax get_links(
$app,$id,$only_app='',$only_name='',$order='link_lastmod DESC' )
! @author ralfbecker
! @abstract returns array of links to $app,$id
! @param $only_app if set return only links from $only_app (eg.
only addressbook-entries) or NOT from if $only_app[0]=='!'
! @param $order defaults to newest links first
! @result array of links or empty array if no matching links found
! */
! function get_links( $app,$id,$only_app='',$order='link_lastmod
DESC' )
! {
! $links = array();
!
! $sql = "SELECT * FROM $this->db_name".
! " WHERE (link_app1 = '$app' AND
link_id1 = '$id')".
! " OR (link_app2 = '$app' AND link_id2
= '$id')".
! ($order != '' ? " ORDER BY $order" :
'');
!
! if ($this->debug)
! {
! echo
"<p>solink.get_links($app,$id,$only_app,$order) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! if ($not_only = $only_app[0] == '!')
! {
! $only_app = substr($only_app,1);
! }
! while ($this->db->next_record())
! {
! $row = $this->db->Record;
!
! if ($row['link_app1'] == $app AND $row['link_id1'] == $id)
! {
! $link = array(
! 'app' => $row['link_app2'],
! 'id' =>
stripslashes($row['link_id2'])
! );
! }
! else
! {
! $link = array(
! 'app' => $row['link_app1'],
! 'id' =>
stripslashes($row['link_id1'])
! );
! }
! if ($only_app && $not_only == ($link['app'] ==
$only_app) ||
!
!$GLOBALS['phpgw_info']['user']['apps'][$link['app']])
! {
! continue;
! }
! $link['remark'] =
stripslashes($row['link_remark']);
! $link['owner'] = $row['link_owner'];
! $link['lastmod'] = $row['link_lastmod'];
! $link['link_id'] = $row['link_id'];
!
! $links[] = $link;
! }
! return $links;
! }
!
! /*!
! @function unlink
! @syntax unlink( $link_id,$app='',$id='',$owner='',$app2='',$id2='' )
! @author ralfbecker
! @abstract Remove link with $link_id or all links matching given
params
! @param $link_id link-id to remove if > 0
! @param $app,$id,$owner,$app2,$id2 if $link_id <= 0: removes all
links matching the non-empty params
! @result the number of links deleted
! */
! function
unlink($link_id,$app='',$id='',$owner='',$app2='',$id2='')
! {
! $sql = "DELETE FROM $this->db_name WHERE ";
! if ($link_id > 0)
! {
! $sql .= "link_id=$link_id";
! }
! elseif ($app == '' AND $owner == '')
! {
! return 0;
! }
! else
! {
! if ($app != '' && $app2 == '')
! {
! $sql .= "((link_app1='$app'";
! $sql2 = '';
! if ($id != '')
! {
! $sql .= " AND link_id1='$id'";
! $sql2 .= " AND link_id2='$id'";
! }
! $sql .= ") OR (link_app2='$app'$sql2))";
! }
! elseif ($app != '' && $app2 != '')
! {
! $sql .= "((link_app1='$app' AND
link_id1='$id' AND link_app2='$app2' AND link_id2='$id2') OR";
! $sql .= " (link_app1='$app2' AND
link_id1='$id2' AND link_app2='$app' AND link_id2='$id'))";
! }
! if ($owner != '')
! {
! $sql .= ($app != '' ? ' AND ' : '') .
"link_owner='$owner'";
! }
! }
! if ($this->debug)
! {
! echo
"<p>solink.unlink($link_id,$app,$id,$owner,$app2,$id2) sql='$sql'</p>\n";
! }
! $this->db->query($sql);
!
! return $this->db->affected_rows();
! }
!
! /*!
! @function chown
! @syntax chown( $owner,$new_owner )
! @author ralfbecker
! @abstract Changes ownership of all links from $owner to
$new_owner
! @discussion This is needed when a user/account gets deleted
! @discussion Does NOT change the modification-time
! @result the number of links changed
! */
! function chown($owner,$new_owner)
! {
! if ($owner <= 0 || $new_owner <= 0)
! {
! return 0;
! }
! $this->db->query("UPDATE $this->db_name SET
owner=$new_owner WHERE owner=$owner");
!
! return $this->db->affected_rows();
! }
! }
!
!
!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: infolog/inc class.bolink.inc.php,1.7,1.8 class.solink.inc.php,1.4,1.5,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: etemplate/templates/default/images delete.gif,NONE,1.1 delete.png,NONE,1.1 view.gif,NONE,1.1 view.png,NONE,1.1
- Next by Date:
[Phpgroupware-cvs] CVS: infolog/inc class.linklist_widget.inc.php,1.2,NONE class.linkto_widget.inc.php,1.4,NONE
- Previous by thread:
[Phpgroupware-cvs] CVS: etemplate/templates/default/images delete.gif,NONE,1.1 delete.png,NONE,1.1 view.gif,NONE,1.1 view.png,NONE,1.1
- Next by thread:
[Phpgroupware-cvs] CVS: infolog/inc class.linklist_widget.inc.php,1.2,NONE class.linkto_widget.inc.php,1.4,NONE
- Index(es):