Author: ralfbecker
New Revision: 55288
URL: http://svn.stylite.de/viewvc/egroupware?rev=55288&view=rev
Log:
move egw_link to Api\Link
Added:
trunk/egroupware/api/src/Link/
trunk/egroupware/api/src/Link.php
- copied, changed from r55263, trunk/phpgwapi/inc/class.egw_link.inc.php
trunk/egroupware/api/src/Link/Storage.php
- copied, changed from r55263, trunk/phpgwapi/inc/class.solink.inc.php
trunk/phpgwapi/inc/class.solink.inc.php
- copied, changed from r55263, trunk/phpgwapi/inc/class.solink.inc.php
Modified:
trunk/egroupware/api/src/Contacts.php
trunk/egroupware/api/src/Storage/Customfields.php
trunk/egroupware/api/src/Storage/Tracking.php
trunk/egroupware/api/src/Vfs/Links/StreamWrapper.php
trunk/phpgwapi/inc/class.egw_link.inc.php
— trunk/egroupware/api/src/Contacts.php (original)
+++ trunk/egroupware/api/src/Contacts.php Mon Mar 7 09:46:32 2016
@@ -18,7 +18,6 @@
// explicitly reference classes still in phpgwapi
use categories;
-use egw_link;
use calendar_bo; // to_do: do NOT require it, just use if there
@@ -813,11 +812,11 @@
$delete[‘tid’] = self::DELETED_TYPE;
if ($check_etag) $delete[‘etag’] = $check_etag;
if (($ok = $this->save($delete))) $ok = true; // we have to return true or false
-
egw_link::unlink(0,'addressbook',$id,'','','',true);
-
Link::unlink(0,'addressbook',$id,'','','',true);
}
elseif (($ok = parent::delete($id,$check_etag)))
{
@@ -996,12 +995,12 @@
$GLOBALS[‘egw’]->hooks->process($to_write,False,True); // called for every app now, not only enabled ones));
}
// Notify linked apps about changes in the contact data
-
Link::notify_update('addressbook', $contact['id'], $contact);
// Check for restore of deleted contact, restore held links
if($old && $old['tid'] == self::DELETED_TYPE && $contact['tid'] != self::DELETED_TYPE)
{
@@ -1805,11 +1804,11 @@
{
continue;
}
-
foreach(Link::get_links('addressbook',$contact['id']) as $data)
{
//_debug_array(array('function'=>__METHOD__,'line'=>__LINE__,'app'=>'addressbook','id'=>$contact['id'],'data:'=>$data,'target'=>$target['id']));
// info_from and info_link_id (main link)
-
$newlinkID = egw_link::link('addressbook',$target['id'],$data['app'],$data['id'],$data['remark'],$target['owner']);
-
$newlinkID = Link::link('addressbook',$target['id'],$data['app'],$data['id'],$data['remark'],$target['owner']);
//_debug_array(array('newLinkID'=>$newlinkID));
if ($newlinkID)
{
— trunk/phpgwapi/inc/class.egw_link.inc.php (original)
+++ trunk/egroupware/api/src/Link.php Mon Mar 7 09:46:32 2016
@@ -1,6 +1,6 @@
<?php
/**
- * API - Interapplicaton links BO layer
+ * EGroupware API - Interapplicaton links
*
* Links have two ends each pointing to an entry, each entry is a double:
* - app app-name or directory-name of an egw application, eg. 'infolog'
@@ -8,12 +8,19 @@
*
* @link http://www.egroupware.org
* @author Ralf Becker
- * @copyright 2001-2014 by RalfBecker@outdoor-training.de
+ * @copyright 2001-2016 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage link
* @version $Id$
*/
+
+namespace EGroupware\Api;
+
+// explicitly reference classes still in phpgwapi
+use html;
+use egw; // on_shutdown
+use egw_json_response;
/**
* Generalized linking between entries of EGroupware apps
@@ -60,9 +67,9 @@
* 'file_access' => 'app.class.method', // method to be called to check file access rights of a given user, see links_stream_wrapper class
* // boolean file_access(string $id,int $check,string $rel_path=null,int $user=null)
* 'file_access_user' => false, // true if file_access method supports 4th parameter $user, if app is NOT supporting it
- * // egw_link::file_access() returns false for $user != current user!
+ * // Link::file_access() returns false for $user != current user!
* 'file_dir' => 'app/sub', // sub file dir for uploaded files/links
- * 'find_extra' => array('name_preg' => '/^(?!.picture.jpg)$/') // extra options to egw_vfs::find, to eg. remove some files from the list of attachments
+ * 'find_extra' => array('name_preg' => '/^(?!.picture.jpg)$/') // extra options to Vfs::find, to eg. remove some files from the list of attachments
* 'edit' => array(
* 'menuaction' => 'app.class.method',
* ),
@@ -75,7 +82,7 @@
* 'mime' => array( // Optional register mime-types application can open
* 'text/something' => array(
* 'mime_url' => $attr, // either mime_url or mime_data is required for server-side processing!
- * 'mime_data' => $attr, // md5-hash returned from egw_link::set_data() to retrive content (only server-side)
+ * 'mime_data' => $attr, // md5-hash returned from Link::set_data() to retrive content (only server-side)
* 'menuaction' => 'app.class.method', // method to call
* 'mime_popup' => '400x300', // optional size of popup
* 'mime_target' => '_self', // optional target, default _blank
@@ -106,7 +113,7 @@
* Modification times in links (and deleted timestamp) are always in server-time!
* (We dont convert them here, as most apps ignore them anyway)
*/
-class egw_link extends solink
+class Link extends Link\Storage
{
/**
* appname used for returned attached files (!= 'filemanager'!)
@@ -114,7 +121,7 @@
const VFS_APPNAME = 'file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app
/**
- * Appname used of files stored via egw_link::set_data()
+ * Appname used of files stored via Link::set_data()
*/
const DATA_APPNAME = 'egw-data';
@@ -202,10 +209,10 @@
// other apps can participate in the linking by implementing a search_link hook, which
// has to return an array in the format of an app_register entry
// for performance reasons, we do it only once / cache it in the session
- if (!($search_link_hooks = $GLOBALS['egw']->session->appsession('search_link_hooks','phpgwapi')))
+ if (!($search_link_hooks = Cache::getSession(__CLASS__, 'search_link_hooks')))
{
$search_link_hooks = $GLOBALS['egw']->hooks->process('search_link',array(), (bool)$GLOBALS['egw_info']['flags']['async-service']);
- $GLOBALS['egw']->session->appsession('search_link_hooks','phpgwapi',$search_link_hooks);
+ Cache::setSession(__CLASS__, 'search_link_hooks', $search_link_hooks);
}
if (is_array($search_link_hooks))
{
@@ -242,11 +249,11 @@
{
unset(self::$app_register['home-accounts']);
}
- if (!(self::$title_cache = $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi')))
+ if (!(self::$title_cache = Cache::getSession(__CLASS__, 'link_title_cache')))
{
self::$title_cache = array();
}
- if (!(self::$file_access_cache = $GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi')))
+ if (!(self::$file_access_cache = Cache::getSession(__CLASS__, 'link_file_access_cache')))
{
self::$file_access_cache = array();
}
@@ -298,8 +305,8 @@
if (isset($GLOBALS['egw']->session)) // eg. cron-jobs use it too, without any session
{
//error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache));
- $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi',self::$title_cache);
- $GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi',self::$file_access_cache);
+ Cache::setSession(__CLASS__, 'link_title_cache', self::$title_cache);
+ Cache::setSession(__CLASS__, 'link_file_access_cache', self::$file_access_cache);
}
}
@@ -319,7 +326,7 @@
* $file['name'] name of the file (no directory)
* $file['type'] mime-type of the file
* $file['tmp_name'] name of the uploaded file (incl. directory) for self::VFS_APPNAME or
- * $file['egw_data'] id of egw_link::set_data() call for self::DATA_APPNAME
+ * $file['egw_data'] id of Link::set_data() call for self::DATA_APPNAME
* @param string $remark ='' Remark to be saved with the link (defaults to '')
* @param int $owner =0 Owner of the link (defaults to user)
* @param int $lastmod =0 timestamp of last modification (defaults to now=time())
@@ -330,7 +337,7 @@
{
if (self::DEBUG)
{
- echo "
egw_link::link('$app1',$id1,'".print_r($app2,true)."',".print_r($id2,true).",'$remark',$owner,$lastmod)
\n";
+ echo "
Link::link('$app1',$id1,'".print_r($app2,true)."',".print_r($id2,true).",'$remark',$owner,$lastmod)
\n";
}
if (!$app1 || !$app2 || $app1 == $app2 && $id1 == $id2)
{
@@ -370,7 +377,7 @@
break;
default:
- $link_id = solink::link($app1,$id1,$link['app'],$link['id'],
+ $link_id = Link\Storage::link($app1,$id1,$link['app'],$link['id'],
$link['remark'],$link['owner'],$link['lastmod']);
// notify both sides
if (!($no_notify&2)) self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id);
@@ -418,7 +425,7 @@
{
return self::attach_file($app1,$id1,$id2,$remark);
}
- $link_id = solink::link($app1,$id1,$app2,$id2,$remark,$owner);
+ $link_id = Link\Storage::link($app1,$id1,$app2,$id2,$remark,$owner);
if (!($no_notify&2)) self::notify('link',$app2,$id2,$app1,$id1,$link_id);
if (!($no_notify&1)) self::notify('link',$app1,$id1,$app2,$id2,$link_id);
@@ -453,7 +460,7 @@
*/
static function get_links($app, $id, $only_app='', $order='link_lastmod DESC',$cache_titles=false, $deleted=false, $limit=null)
{
- if (self::DEBUG) echo "
egw_link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')
\n";
+ if (self::DEBUG) echo "
Link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')
\n";
if (is_array($id) || !$id)
{
@@ -475,7 +482,7 @@
}
return $ids;
}
- $ids = solink::get_links($app, $id, $only_app, $order, $deleted, $limit);
+ $ids = Link\Storage::get_links($app, $id, $only_app, $order, $deleted, $limit);
if (empty($only_app) || $only_app == self::VFS_APPNAME ||
($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME))
{
@@ -530,7 +537,7 @@
{
return array(); // no ids are linked to nothing
}
- $links = solink::get_links($app,$ids,$only_app,$order,$deleted);
+ $links = Link\Storage::get_links($app,$ids,$only_app,$order,$deleted);
if (empty($only_app) || $only_app == self::VFS_APPNAME ||
($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME))
@@ -606,7 +613,7 @@
}
return self::info_attached($app_link_id,$id,$id2);
}
- return solink::get_link($app_link_id,$id,$app2,$id2);
+ return Link\Storage::get_link($app_link_id,$id,$app2,$id2);
}
/**
@@ -645,7 +652,7 @@
{
if (self::DEBUG)
{
- echo "
egw_link::unlink('$link_id','$app',".array2string($id).",'$owner','$app2','$id2', $hold_for_purge)
\n";
+ echo "
Link::unlink('$link_id','$app',".array2string($id).",'$owner','$app2','$id2', $hold_for_purge)
\n";
}
if ($link_id < 0) // vfs-link?
{
@@ -679,10 +686,10 @@
}
if ($app && $app2)
{
- historylog::static_add($app,$id,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app2.':'.$id2);
- historylog::static_add($app2,$id2,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app.':'.$id);
- }
- $deleted =& solink::unlink($link_id,$app,$id,$owner,$app2 != '!'.self::VFS_APPNAME ? $app2 : '',$id2,$hold_for_purge);
+ Storage\History::static_add($app,$id,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app2.':'.$id2);
+ Storage\History::static_add($app2,$id2,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app.':'.$id);
+ }
+ $deleted =& Link\Storage::unlink($link_id,$app,$id,$owner,$app2 != '!'.self::VFS_APPNAME ? $app2 : '',$id2,$hold_for_purge);
// only notify on real links, not the one cached for writing or fileattachments
self::notify_unlink($deleted);
@@ -744,7 +751,7 @@
if (self::DEBUG)
{
- echo "
egw_link::query('$app','$pattern') => '$method'
\n";
+ echo "
Link::query('$app','$pattern') => '$method'
\n";
echo "Options: "; _debug_array($options);
}
@@ -823,7 +830,7 @@
if (is_array($id) && $link)
{
$link = $id;
- $title = egw_vfs::decodePath($link['name']);
+ $title = Vfs::decodePath($link['name']);
}
else
{
@@ -833,7 +840,7 @@
and users dont need it most of the time. These details can allways be views in filemanager.
if (is_array($link))
{
- $title .= ': '.$link['type'] . ' '.egw_vfs::hsize($link['size']);
+ $title .= ': '.$link['type'] . ' '.Vfs::hsize($link['size']);
}*/
if (self::DEBUG) echo '
'.__METHOD__."('$app','$id')='$title' (file)
\n";
return $title;
@@ -926,7 +933,7 @@
*/
static function add($app,$to_app='',$to_id='')
{
- //echo "
egw_link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]);
+ //echo "
Link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]);
if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['add']))
{
return false;
@@ -951,7 +958,7 @@
*/
static function edit($app,$id,&$popup=null)
{
- //echo "
egw_link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]);
+ //echo "
Link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]);
if (empty($app) || empty($id) || !is_array($reg = self::$app_register[$app]) || !isset($reg['edit']))
{
if ($reg && isset($reg['view']))
@@ -981,7 +988,7 @@
{
if ($app == self::VFS_APPNAME && !empty($id) && is_array($link))
{
- //return egw_vfs::download_url(self::vfs_path($link['app2'],$link['id2'],$link['id'],true));
+ //return Vfs::download_url(self::vfs_path($link['app2'],$link['id2'],$link['id'],true));
return self::mime_open(self::vfs_path($link['app2'],$link['id2'],$link['id'],true), $link['type']);
}
if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
@@ -1041,19 +1048,19 @@
* Get handler (link-data) for given path and mime-type
*
* @param string $path vfs path
- * @param string $type =null default to egw_vfs::mime_content_type($path)
+ * @param string $type =null default to Vfs::mime_content_type($path)
* @param string &$popup=null on return popup size or null
* @return string|array string with EGw relative link, array with get-parameters for '/index.php' or null (directory and not filemanager access)
*/
static function mime_open($path, $type=null, &$popup=null)
{
- if (is_null($type)) $type = egw_vfs::mime_content_type($path);
+ if (is_null($type)) $type = Vfs::mime_content_type($path);
if (($data = self::get_mime_info($type)))
{
if (isset($data['mime_url']))
{
- $data[$data['mime_url']] = egw_vfs::PREFIX.$path;
+ $data[$data['mime_url']] = Vfs::PREFIX.$path;
unset($data['mime_url']);
}
elseif (isset($data['mime_id']))
@@ -1073,7 +1080,7 @@
}
else
{
- $data = egw_vfs::download_url($path);
+ $data = Vfs::download_url($path);
}
return $data;
}
@@ -1184,7 +1191,7 @@
}
else
{
- $path = egw_vfs::resolve_url($path);
+ $path = Vfs::resolve_url($path);
}
//error_log(__METHOD__."($app,$id,$file,$just_the_path)=$path");
return $path;
@@ -1213,8 +1220,8 @@
}
if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir,0,true)))
{
- $Ok = egw_vfs::copy_uploaded($file, $p=self::vfs_path($app,$id,'',true), $comment, false); // no is_uploaded_file() check!
- if (!$Ok) error_log(__METHOD__."('$app', '$id', ".array2string($file).", '$comment') called egw_vfs::copy_uploaded('$file[tmp_name]', '$p', '$comment', false)=".array2string($Ok));
+ $Ok = Vfs::copy_uploaded($file, $p=self::vfs_path($app,$id,'',true), $comment, false); // no is_uploaded_file() check!
+ if (!$Ok) error_log(__METHOD__."('$app', '$id', ".array2string($file).", '$comment') called Vfs::copy_uploaded('$file[tmp_name]', '$p', '$comment', false)=".array2string($Ok));
}
else
{
@@ -1238,17 +1245,17 @@
$app_path = self::vfs_path($app,$id);
$ok = true;
- if (egw_vfs::file_exists($app_path) || ($ok = egw_vfs::mkdir($app_path,0,true)))
- {
- if (!egw_vfs::stat($file))
- {
- error_log(__METHOD__. ' (Link target ' . egw_vfs::decodePath($file) . ' not found!');
+ if (Vfs::file_exists($app_path) || ($ok = Vfs::mkdir($app_path,0,true)))
+ {
+ if (!Vfs::stat($file))
+ {
+ error_log(__METHOD__. ' (Link target ' . Vfs::decodePath($file) . ' not found!');
return false;
}
}
- $link = egw_vfs::concat($app_path,egw_vfs::basename($file));
- return egw_vfs::symlink($file,$link);
+ $link = Vfs::concat($app_path,Vfs::basename($file));
+ return Vfs::symlink($file,$link);
}
/**
* deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!)
@@ -1262,7 +1269,7 @@
{
if ((int)$app > 0) // is file_id
{
- $url = egw_vfs::resolve_url(sqlfs_stream_wrapper::id2path($app));
+ $url = Vfs::resolve_url(Vfs\Sqlfs\StreamWrapper::id2path($app));
}
else
{
@@ -1274,8 +1281,8 @@
if (!$fname || !$id) // we delete the whole entry (or all entries), which probably not exist anymore
{
- $current_is_root = egw_vfs::$is_root;
- egw_vfs::$is_root = true;
+ $current_is_root = Vfs::$is_root;
+ Vfs::$is_root = true;
}
}
if (self::DEBUG)
@@ -1288,17 +1295,17 @@
$link = self::get_link(-$app);
if($link['app2'] && $link['id2'])
{
- historylog::static_add($link['app2'],$link['id2'],$GLOBALS['egw_info']['user']['account_id'],'~file~','', basename($url));
- }
- }
- if (($Ok = !file_exists($url) || egw_vfs::remove($url,true)) && ((int)$app > 0 || $fname))
+ Storage\History::static_add($link['app2'],$link['id2'],$GLOBALS['egw_info']['user']['account_id'],'~file~','', basename($url));
+ }
+ }
+ if (($Ok = !file_exists($url) || Vfs::remove($url,true)) && ((int)$app > 0 || $fname))
{
// try removing the dir, in case it's empty
- @egw_vfs::rmdir(egw_vfs::dirname($url));
+ @Vfs::rmdir(Vfs::dirname($url));
}
if (!is_null($current_is_root))
{
- egw_vfs::$is_root = $current_is_root;
+ Vfs::$is_root = $current_is_root;
}
return $Ok;
}
@@ -1314,7 +1321,7 @@
static function info_attached($app,$id,$filename)
{
$path = self::vfs_path($app,$id,$filename,true);
- if (!($stat = egw_vfs::stat($path,STREAM_URL_STAT_QUIET)))
+ if (!($stat = Vfs::stat($path,STREAM_URL_STAT_QUIET)))
{
return false;
}
@@ -1331,8 +1338,8 @@
{
if (!is_array($fileinfo))
{
- $url = sqlfs_stream_wrapper::id2path($fileinfo);
- if (!($fileinfo = egw_vfs::url_stat($url,STREAM_URL_STAT_QUIET)))
+ $url = Vfs\Sqlfs\StreamWrapper::id2path($fileinfo);
+ if (!($fileinfo = Vfs::url_stat($url,STREAM_URL_STAT_QUIET)))
{
return false;
}
@@ -1411,9 +1418,9 @@
if (substr($path,0,13) == 'stylite.links') $path = substr($path,8);
$attached = array();
- if (($url2stats = egw_vfs::find($path,array('need_mime'=>true,'type'=>'F','url'=>true)+$extra,true)))
- {
- $props = egw_vfs::propfind(array_keys($url2stats)); // get the comments
+ if (($url2stats = Vfs::find($path,array('need_mime'=>true,'type'=>'F','url'=>true)+$extra,true)))
+ {
+ $props = Vfs::propfind(array_keys($url2stats)); // get the comments
foreach($url2stats as $url => &$fileinfo)
{
$link = self::fileinfo2link($fileinfo,$url);
@@ -1421,7 +1428,7 @@
{
foreach($props[$url] as $prop)
{
- if ($prop['ns'] == egw_vfs::DEFAULT_PROP_NAMESPACE && $prop['name'] == 'comment')
+ if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'] == 'comment')
{
$link['remark'] = $prop['val'];
}
@@ -1445,7 +1452,7 @@
}
/**
- * Key for old link title in $data param to egw_link::notify
+ * Key for old link title in $data param to Link::notify
*/
const OLD_LINK_TITLE = 'old_link_title';
@@ -1453,7 +1460,7 @@
* notify other apps about changed content in $app,$id
*
* To give other apps the possebility to update a title, you can also specify
- * a changed old link-title in $data[egw_link::OLD_LINK_TITLE].
+ * a changed old link-title in $data[Link::OLD_LINK_TITLE].
*
* @param string $app name of app in which the updated happend
* @param string $id id in $app of the updated entry
@@ -1467,7 +1474,7 @@
{
self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data);
}
- if($data[egw_link::OLD_LINK_TITLE] && egw_json_response::isJSONResponse())
+ if($data[Link::OLD_LINK_TITLE] && egw_json_response::isJSONResponse())
{
// Update client side with new title
egw_json_response::get()->apply('egw.link_title_callback',array(array($app => array($id => self::title($app, $id)))));
@@ -1564,7 +1571,7 @@
case 'file_access':
return self::$file_access_cache[$app.':'.$id];
default:
- throw new egw_exception_wrong_parameter("Unknown type '$type'!");
+ throw new Exception\WrongParameter("Unknown type '$type'!");
}
}
@@ -1623,7 +1630,7 @@
array_unshift($params, $method);
$id = md5(serialize($params));
//error_log(__METHOD__."('$mime_type', '$method', ...) params=".array2string($params)." --> json=".array2string(serialize($params)).' --> id='.array2string($id));
- egw_cache::setSession(__CLASS__, $id, $params);
+ Cache::setSession(__CLASS__, $id, $params);
return $id;
}
@@ -1633,15 +1640,15 @@
* @param string $id
* @param boolean $return_resource =false false: return string, true: return resource
* @return mixed null if id is not found or invalid
- * @throws egw_exception_wrong_parameter
+ * @throws Exception\WrongParameter
*/
public static function get_data($id, $return_resource=false)
{
- $data = egw_cache::getSession(__CLASS__, $id);
+ $data = Cache::getSession(__CLASS__, $id);
if (!isset($data) || empty($data[0]))
{
- throw new egw_exception_wrong_parameter(__METHOD__."('$id')");
+ throw new Exception\WrongParameter(__METHOD__."('$id')");
}
$ret = call_user_func_array('ExecMethod2', $data);
@@ -1722,4 +1729,4 @@
return !!($cache & $required);
}
}
-egw_link::init_static();
+Link::init_static();
Copied: trunk/egroupware/api/src/Link/Storage.php (from r55263, trunk/phpgwapi/inc/class.solink.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Link/Storage.php?p2=trunk/egroupware/api/src/Link/Storage.php&p1=trunk/phpgwapi/inc/class.solink.inc.php&r1=55263&r2=55288&rev=55288&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.solink.inc.php (original)
+++ trunk/egroupware/api/src/Link/Storage.php Mon Mar 7 09:46:32 2016
@@ -1,6 +1,6 @@
<?php
/**
- * API - Interapplicaton links BO layer
+ * EGroupware API - Interapplicaton links storage
*
* Links have two ends each pointing to an entry, each entry is a double:
* - app app-name or directory-name of an egw application, eg. 'infolog'
@@ -8,12 +8,16 @@
*
* @link http://www.egroupware.org
* @author Ralf Becker
- * @copyright 2001-2015 by RalfBecker@outdoor-training.de
+ * @copyright 2001-2016 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage link
* @version $Id$
*/
+
+namespace EGroupware\Api\Link;
+
+use EGroupware\Api;
/**
* generalized linking between entries of eGroupware apps - SO layer
@@ -22,7 +26,7 @@
*
* All methods are now static!
*/
-class solink
+class Storage
{
/**
* Name of the links table
@@ -166,7 +170,7 @@
}
// catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267)
// caused by non-ascii chars compared with ascii field uid
- catch(egw_exception_db $e) {
+ catch(Api\Db\Exception $e) {
_egw_log_exception($e);
}
return is_array($id) ? $links : ($links[$id] ? $links[$id] : array());
@@ -237,7 +241,7 @@
}
// catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267)
// caused by non-ascii chars compared with ascii field uid
- catch(egw_exception_db $e) {
+ catch(Api\Db\Exception $e) {
_egw_log_exception($e);
}
return false;
@@ -322,7 +326,7 @@
}
// catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267)
// caused by non-ascii chars compared with ascii field uid
- catch(egw_exception_db $e) {
+ catch(Api\Db\Exception $e) {
_egw_log_exception($e);
}
@@ -389,7 +393,7 @@
* ^ ^
* +---------------------------c-----------------------------------------+
*
- * egw_link::get_3links('timesheet','projectmanager',$pm_id) returns the links (c) between the timesheet and the project,
+ * Api\Link::get_3links('timesheet','projectmanager',$pm_id) returns the links (c) between the timesheet and the project,
* plus the other app/id in the keys 'app3' and 'id3'
*
* @param string $app app the returned links are linked on one side (atm. this must be link_app1!)
@@ -459,7 +463,7 @@
}
else
{
- $links[] = egw_db::strip_array_keys($row,'link_');
+ $links[] = Api\Db::strip_array_keys($row,'link_');
}
}
// if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded
@@ -476,4 +480,4 @@
self::$db = $GLOBALS['egw']->db;
}
}
-solink::init_static();
+Storage::init_static();
Modified: trunk/egroupware/api/src/Storage/Customfields.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Storage/Customfields.php?rev=55288&r1=55287&r2=55288&view=diff
==============================================================================
--- trunk/egroupware/api/src/Storage/Customfields.php (original)
+++ trunk/egroupware/api/src/Storage/Customfields.php Mon Mar 7 09:46:32 2016
@@ -14,9 +14,6 @@
use EGroupware\Api;
-// explicitly reference classes still in phpgwapi
-use egw_link;
-
/**
* Managing custom-field definitions
*/
@@ -248,7 +245,7 @@
{
$app = $field['type'];
}
- if ($value) $value = egw_link::title($app, $value);
+ if ($value) $value = Api\Link::title($app, $value);
}
break;
}
@@ -301,7 +298,7 @@
if (is_null($link_types))
{
- $link_types = array_keys(array_intersect(egw_link::app_list('query'),egw_link::app_list('title')));
+ $link_types = array_keys(array_intersect(Api\Link::app_list('query'),Api\Link::app_list('title')));
$link_types[] = 'link-entry';
}
return $link_types;
@@ -338,7 +335,7 @@
$app = $data['type'];
$id = $old['#'.$name];
}
- egw_link::unlink(false,$own_app,$values[$id_name],'',$app,$id);
+ Api\Link::unlink(false,$own_app,$values[$id_name],'',$app,$id);
}
if ($data['type'] == 'link-entry')
{
@@ -351,7 +348,7 @@
}
if ($id) // create new link, does nothing for already existing links
{
- egw_link::link($own_app,$values[$id_name],$app,$id);
+ Api\Link::link($own_app,$values[$id_name],$app,$id);
}
}
}
Modified: trunk/egroupware/api/src/Storage/Tracking.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Storage/Tracking.php?rev=55288&r1=55287&r2=55288&view=diff
==============================================================================
--- trunk/egroupware/api/src/Storage/Tracking.php (original)
+++ trunk/egroupware/api/src/Storage/Tracking.php Mon Mar 7 09:46:32 2016
@@ -16,7 +16,6 @@
use EGroupware\Api;
// explicitly reference classes still in phpgwapi
-use egw_link;
use html;
/**
@@ -195,7 +194,7 @@
{
if ($cf_app)
{
- $linkable_cf_types = array('link-entry')+array_keys(egw_link::app_list());
+ $linkable_cf_types = array('link-entry')+array_keys(Api\Link::app_list());
foreach(Customfields::get($cf_app, true) as $cf_name => $cf_data)
{
$this->field2history['#'.$cf_name] = '#'.$cf_name;
@@ -357,9 +356,9 @@
}
$source_id = $data[$this->id_field];
//error_log(__METHOD__.__LINE__.array2string($source_id));
- if ($source_id) egw_link::link($this->app,$source_id,$app,$id);
- //error_log(__METHOD__.__LINE__."egw_link::link('$this->app',".array2string($source_id).",'$app',$id);");
- //echo "
egw_link::link('$this->app',{$data[$this->id_field]},'$app',$id);
\n";
+ if ($source_id) Api\Link::link($this->app,$source_id,$app,$id);
+ //error_log(__METHOD__.__LINE__."Api\Link::link('$this->app',".array2string($source_id).",'$app',$id);");
+ //echo "
Api\Link::link('$this->app',{$data[$this->id_field]},'$app',$id);
\n";
}
// unlink removed application entries
@@ -372,8 +371,8 @@
if (!$id) continue;
}
$source_id = $data[$this->id_field];
- if ($source_id) egw_link::unlink(null,$this->app,$source_id,0,$app,$id);
- //echo "
egw_link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);
\n";
+ if ($source_id) Api\Link::unlink(null,$this->app,$source_id,0,$app,$id);
+ //echo "
Api\Link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);
\n";
}
}
@@ -869,7 +868,7 @@
{
unset($old); // not used, but required by function signature
- return egw_link::title($this->app,$data[$this->id_field]);
+ return Api\Link::title($this->app,$data[$this->id_field]);
}
/**
@@ -887,7 +886,7 @@
{
unset($old, $deleted, $receiver); // not used, but required by function signature
- return egw_link::title($this->app,$data[$this->id_field]);
+ return Api\Link::title($this->app,$data[$this->id_field]);
}
/**
@@ -932,10 +931,10 @@
}
else
{
- if (($view = egw_link::view($this->app,$data[$this->id_field])))
+ if (($view = Api\Link::view($this->app,$data[$this->id_field])))
{
$link = $GLOBALS['egw']->link('/index.php',$view);
- $popup = egw_link::is_popup($this->app,'view');
+ $popup = Api\Link::is_popup($this->app,'view');
}
}
if ($link[0] == '/')
@@ -966,14 +965,14 @@
{
unset($receiver); // not used, but required by function signature
- if (($view = egw_link::view($this->app,$data[$this->id_field])))
+ if (($view = Api\Link::view($this->app,$data[$this->id_field])))
{
return array(
'text' => $this->get_title($data,$old),
'app' => $this->app,
'id' => $data[$this->id_field],
'view' => $view,
- 'popup' => egw_link::is_popup($this->app,'view'),
+ 'popup' => Api\Link::is_popup($this->app,'view'),
);
}
return false;
Modified: trunk/egroupware/api/src/Vfs/Links/StreamWrapper.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Vfs/Links/StreamWrapper.php?rev=55288&r1=55287&r2=55288&view=diff
==============================================================================
--- trunk/egroupware/api/src/Vfs/Links/StreamWrapper.php (original)
+++ trunk/egroupware/api/src/Vfs/Links/StreamWrapper.php Mon Mar 7 09:46:32 2016
@@ -14,9 +14,9 @@
namespace EGroupware\Api\Vfs\Links;
use EGroupware\Api\Vfs;
+use EGroupware\Api;
// explicitly import old phpgwapi classes used:
-use egw_link;
use addressbook_vcal;
/**
@@ -111,10 +111,10 @@
// which gives him then read AND write access to the file store of the entry
else
{
- // vfs & stream-wrapper use posix rights, egw_link::file_access uses EGW_ACL_{EDIT|READ}!
+ // vfs & stream-wrapper use posix rights, Api\Link::file_access uses EGW_ACL_{EDIT|READ}!
$required = $check & Vfs::WRITABLE ? EGW_ACL_EDIT : EGW_ACL_READ;
- $access = egw_link::file_access($app,$id,$required,$rel_path,Vfs::$user);
- $what = "from egw_link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")";
+ $access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user);
+ $what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")";
}
if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!'));
return $access;
Modified: trunk/phpgwapi/inc/class.egw_link.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/inc/class.egw_link.inc.php?rev=55288&r1=55287&r2=55288&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_link.inc.php (original)
+++ trunk/phpgwapi/inc/class.egw_link.inc.php Mon Mar 7 09:46:32 2016
@@ -1,6 +1,6 @@
<?php
/**
- * API - Interapplicaton links BO layer
+ * EGroupware API - Interapplicaton links BO layer
*
* Links have two ends each pointing to an entry, each entry is a double:
* - app app-name or directory-name of an egw application, eg. 'infolog'
@@ -8,1718 +8,18 @@
*
* @link http://www.egroupware.org
* @author Ralf Becker
- * @copyright 2001-2014 by RalfBecker@outdoor-training.de
+ * @copyright 2001-2016 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage link
* @version $Id$
*/
+use EGroupware\Api;
+
/**
* Generalized linking between entries of EGroupware apps
- *
- * Please note: this class can NOT and does not need to be initialised, all methods are static
- *
- * To participate in the linking an applications has to implement the following hooks:
- *
- * /**
- * * Hook called by link-class to include app in the appregistry of the linkage
- * *
- * * @param array|string $location location and other parameters (not used)
- * * @return array with method-names
- * *%
- * function search_link($location)
- * {
- * return array(
- * 'query' => 'app.class.link_query', // method to search app for a pattern: array link_query(string $pattern, array $options)
- * 'title' => 'app.class.link_title', // method to return title of an entry of app: string/false/null link_title(int/string $id)
- * 'titles' => 'app.class.link_titles', // method to return multiple titles: array link_title(array $ids)
- * 'view' => array( // get parameters to view an entry of app
- * 'menuaction' => 'app.class.method',
- * ),
- * 'types' => array( // Optional list of sub-types to filter (eg organisations), app to handle different queries
- * 'type_key' => array(
- * 'name' => 'Human Reference',
- * 'icon' => 'app/icon' // Optional icon to use for that sub-type
- * )
- * ),
- * 'view_id' => 'app_id', // name of get parameter of the id
- * 'view_popup' => '400x300', // size of popup (XxY), if view is in popup
- * 'view_list' => 'app.class.method' // deprecated use 'list' instead
- * 'list' => array( // Method to be called to display a list of links, method should check $_GET['search'] to filter
- * 'menuaction' => 'app.class.method',
- * ),
- * 'list_popup' => '400x300'
- * 'add' => array( // get parameter to add an empty entry to app
- * 'menuaction' => 'app.class.method',
- * ),
- * 'add_app' => 'link_app', // name of get parameter to add links to other app
- * 'add_id' => 'link_id', // --------------------- " ------------------- id
- * 'add_popup' => '400x300', // size of popup (XxY), if add is in popup
- * 'notify' => 'app.class.method', // method to be called if an other applications liks or unlinks with app: notify(array $data)
- * 'file_access' => 'app.class.method', // method to be called to check file access rights of a given user, see links_stream_wrapper class
- * // boolean file_access(string $id,int $check,string $rel_path=null,int $user=null)
- * 'file_access_user' => false, // true if file_access method supports 4th parameter $user, if app is NOT supporting it
- * // egw_link::file_access() returns false for $user != current user!
- * 'file_dir' => 'app/sub', // sub file dir for uploaded files/links
- * 'find_extra' => array('name_preg' => '/^(?!.picture.jpg)$/') // extra options to egw_vfs::find, to eg. remove some files from the list of attachments
- * 'edit' => array(
- * 'menuaction' => 'app.class.method',
- * ),
- * 'edit_id' => 'app_id',
- * 'edit_popup' => '400x300',
- * 'name' => 'Some name', // Name to use instead of app-name
- * 'icon' => 'app/icon', // Optional icon to use instead of app-icon
- * 'entry' => 'Contact', // Optional name for single entry of app, eg. "contact" used instead of appname
- * 'entries' => 'Contacts', // Optional name for multiple entries of app, eg. "contacts" used instead of appname
- * 'mime' => array( // Optional register mime-types application can open
- * 'text/something' => array(
- * 'mime_url' => $attr, // either mime_url or mime_data is required for server-side processing!
- * 'mime_data' => $attr, // md5-hash returned from egw_link::set_data() to retrive content (only server-side)
- * 'menuaction' => 'app.class.method', // method to call
- * 'mime_popup' => '400x300', // optional size of popup
- * 'mime_target' => '_self', // optional target, default _blank
- * // other get-parameters to set in url
- * ),
- * // further mime types supported ...
- * ),
- * 'fetch' => 'app.class.method', // method to return entry data for a given id. the method called should support id, and expected mime-type
- * // basically you should return something like array(id, title, mimetype, body, linked-files)
- * 'additional' => array( // allow one app to register sub-types,
- * 'app-sub' => array( // different from 'types' approach above
- * // every value defined above
- * )
- * )
- * }
- * All entries are optional, thought you only get conected functionality, if you implement them ...
- *
- * The BO-layer implementes some extra features on top of the so-layer:
- * 1) It handles links to not already existing entries. This is used by the eTemplate link-widget, which allows to
- * setup links even for new / not already existing entries, before they get saved.
- * In that case you have to set the first id to 0 for the link-static function and pass the array returned in that id
- * (not the return-value) after saveing your new entry again to the link static function.
- * 2) Attaching files: they are saved in the vfs and not the link-table (!).
- * Attached files are stored under $vfs_basedir='/infolog' in the vfs!
- * 3) It manages the link-registry, in which apps can register themselfs by implementing some hooks
- * 4) It notifies apps, who registered for that service, about changes in the links their entries
- *
- * Modification times in links (and deleted timestamp) are always in server-time!
- * (We dont convert them here, as most apps ignore them anyway)
+ * *
+ * @deprecated use Api\Link
*/
-class egw_link extends solink
-{
- /**
- * appname used for returned attached files (!= 'filemanager'!)
- */
- const VFS_APPNAME = 'file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app
-
- /**
- * Appname used of files stored via egw_link::set_data()
- */
- const DATA_APPNAME = 'egw-data';
-
- /**
- * appname used for linking existing files to VFS
- */
- const VFS_LINK = 'link';
-
- /**
- * Baseurl for the attachments in the vfs
- */
- const VFS_BASEURL = 'vfs://default/apps';
- /**
- * Turns on debug-messages
- */
- const DEBUG = false;
- /**
- * other apps can participate in the linking by implementing a 'search_link' hook, which
- * has to return an array in the format of an app_register entry below
- *
- * @var array
- */
- static $app_register = array(
- 'home-accounts' => array( // user need run-rights for home
- 'app' => 'home',
- 'name' => 'Accounts',
- 'icon' => 'addressbook/accounts',
- 'query' => 'accounts::link_query',
- 'title' => 'common::grab_owner_name',
- 'view' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'),
- 'view_id' => 'account_id'
- ),
- 'home' => array(
- // handling of text or pdf files by browser in a popup window
- 'mime' => array(
- 'application/pdf' => array(
- 'mime_popup' => '640x480',
- 'mime_target' => '_blank',
- ),
- '/^text\\/(plain|html|diff)/' => array( // text/(mimetypes which can be opened as recognised popups)
- 'mime_popup' => '640x480',
- 'mime_target' => '_blank',
- ),
- '/^image\\//' => array( // image
- 'mime_popup' => '640x480',
- 'mime_target' => '_blank',
- ),
- ),
- ),
- );
- /**
- * Caches link titles for a better performance
- *
- * @var array
- */
- private static $title_cache = array();
-
- /**
- * Cache file access permissions
- *
- * @var array
- */
- private static $file_access_cache = array();
-
- /**
- * Private constructor to forbid instanciated use
- *
- */
- private function __construct()
- {
-
- }
-
- /**
- * initialize our static vars
- */
- static function init_static( )
- {
- // FireFox 36 can not display pdf with it's internal viewer in an iframe used by mobile theme/template for popups
- // same is true for all mobile devices
- if (html::$user_agent == 'firefox' && $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile' || html::$ua_mobile)
- {
- unset(self::$app_register['home']['mime']['application/pdf']);
- }
- // other apps can participate in the linking by implementing a search_link hook, which
- // has to return an array in the format of an app_register entry
- // for performance reasons, we do it only once / cache it in the session
- if (!($search_link_hooks = $GLOBALS['egw']->session->appsession('search_link_hooks','phpgwapi')))
- {
- $search_link_hooks = $GLOBALS['egw']->hooks->process('search_link',array(), (bool)$GLOBALS['egw_info']['flags']['async-service']);
- $GLOBALS['egw']->session->appsession('search_link_hooks','phpgwapi',$search_link_hooks);
- }
- if (is_array($search_link_hooks))
- {
- foreach($search_link_hooks as $app => $data)
- {
- // allow apps to register additional types
- if (isset($data['additional']))
- {
- foreach($data['additional'] as $name => $values)
- {
- $values['app'] = $app; // store name of registring app, to be able to check access
- self::$app_register[$name] = $values;
- }
- unset($data['additional']);
- }
- // support deprecated view_list attribute instead of new index attribute
- if (isset($data['view_list']) && !isset($data['list']))
- {
- $data['list'] = array('menuaction' => $data['view_list']);
- }
- elseif(isset($data['list']) && !isset($data['view_list']))
- {
- $data['view_list'] = $data['list']['menuaction'];
- }
- if (is_array($data))
- {
- self::$app_register[$app] = $data;
- }
- }
- }
- // disable ability to link to accounts for non-admins, if account-selection is disabled
- if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'none' &&
- !isset($GLOBALS['egw_info']['user']['apps']['admin']))
- {
- unset(self::$app_register['home-accounts']);
- }
- if (!(self::$title_cache = $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi')))
- {
- self::$title_cache = array();
- }
- if (!(self::$file_access_cache = $GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi')))
- {
- self::$file_access_cache = array();
- }
-
- // register self::save_session_cache to run on shutdown
- egw::on_shutdown(array(__CLASS__, 'save_session_cache'));
-
- //error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache));
- }
-
- /**
- * Get clientside relevant attributes from app registry in json format
- *
- * Only transfering relevant information cuts approx. half of the size.
- * Also only transfering information relevant to apps user has access too.
- * Important eg. for mime-registry, to not use calendar for opening iCal files, if user has no calendar!
- * A