mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
* API/Calendar: allow to link to accounts and allow to select accounts as participants by searching them like contacts
This commit is contained in:
parent
8d28765f76
commit
b633044a46
@ -237,6 +237,10 @@ class calendar_bo
|
||||
'info' => __CLASS__.'::email_info',
|
||||
'app' => 'email',
|
||||
);
|
||||
$this->resources[''] = array(
|
||||
'type' => '',
|
||||
'app' => 'home-accounts',
|
||||
);
|
||||
$GLOBALS['egw']->session->appsession('resources','calendar',$this->resources);
|
||||
}
|
||||
//echo "registered resources="; _debug_array($this->resources);
|
||||
|
@ -237,7 +237,8 @@ class calendar_hooks
|
||||
'resources_conflict' => lang('resources with conflict detection'),
|
||||
'resources_without_conflict' => lang('resources except conflicting ones'),
|
||||
'resources' => lang('resources'),
|
||||
'addressbook' => lang('addressbook')
|
||||
'addressbook' => lang('addressbook'),
|
||||
'home-accounts' => lang('Accounts'),
|
||||
);
|
||||
$reset_stati_on_shifts = array(
|
||||
'no' => lang('Never'),
|
||||
|
@ -320,8 +320,12 @@ class calendar_uiforms extends calendar_ui
|
||||
}
|
||||
foreach($this->bo->resources as $type => $data) if ($data['app'] == $app) break;
|
||||
$uid = $this->bo->resources[$type]['app'] == $app ? $type.$id : false;
|
||||
if ($app == 'home-accounts')
|
||||
{
|
||||
$data = $id;
|
||||
}
|
||||
// check if new entry is no account (or contact entry of an account)
|
||||
if ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id,'person_id')) || !$this->bo->check_acl_invite($data))
|
||||
elseif ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id,'person_id')) || !$this->bo->check_acl_invite($data))
|
||||
{
|
||||
if ($uid && $id)
|
||||
{
|
||||
|
@ -321,7 +321,7 @@ class link_widget
|
||||
}
|
||||
else
|
||||
{
|
||||
$value[$row]['icon'] = 'egw/'.$value[$row]['app'];
|
||||
$value[$row]['icon'] = egw_link::get_registry($value[$row]['app'], 'icon');
|
||||
$value[$row]['label'] = 'Unlink';
|
||||
$value[$row]['help'] = lang('Remove this link (not the entry itself)');
|
||||
}
|
||||
|
@ -309,10 +309,10 @@ class vfs_widget
|
||||
$cell['label'] = mime_magic::mime2label($mime);
|
||||
|
||||
list($mime_main,$mime_sub) = explode('/',$mime);
|
||||
if ($mime_main == 'egw')
|
||||
if ($mime_main == 'egw' || isset($GLOBALS['egw_info']['apps'][$mime_main]))
|
||||
{
|
||||
$value = $mime_sub.'/navbar'; // egw-applications for link-widget
|
||||
$cell['label'] = lang($mime_sub);
|
||||
$value = $mime_main == 'egw' ? $mime_sub.'/navbar' : $mime; // egw-applications for link-widget
|
||||
$cell['label'] = lang($mime_main == 'egw' ? $mime_sub : $mime_main);
|
||||
list($span,$class) = explode(',',$cell['span'],2);
|
||||
$class .= ($class ? ' ' : '') . 'vfsMimeIcon';
|
||||
$cell['span'] = $span.','.$class;
|
||||
|
@ -339,6 +339,32 @@ class accounts
|
||||
return $account_search[$serial]['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Query for accounts
|
||||
*
|
||||
* @param string|array $pattern
|
||||
* @param array $options
|
||||
* @return array with id - title pairs of the matching entries
|
||||
*/
|
||||
public static function link_query($pattern, array &$options = array())
|
||||
{
|
||||
if (isset($options['filter']) && !is_array($options['filter']))
|
||||
{
|
||||
$options['filter'] = (array)$options['filter'];
|
||||
}
|
||||
$accounts = array();
|
||||
foreach(self::getInstance()->search(array(
|
||||
'type' => 'both',
|
||||
'query' => $pattern,
|
||||
'query_type' => 'all',
|
||||
)) as $account)
|
||||
{
|
||||
$accounts[$account['account_id']] = common::display_fullname($account['account_lid'],
|
||||
$account['account_firstname'],$account['account_lastname'],$account['account_id']);
|
||||
}
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the data of one account
|
||||
*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright 2001-2008 by RalfBecker@outdoor-training.de
|
||||
* @copyright 2001-2011 by RalfBecker@outdoor-training.de
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage link
|
||||
@ -67,6 +67,8 @@
|
||||
* ),
|
||||
* '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
|
||||
* 'additional' => array( // allow one app to register sub-types,
|
||||
* 'app-sub' => array( // different from 'types' approach above
|
||||
* // every value defined above
|
||||
@ -112,6 +114,12 @@ class egw_link extends solink
|
||||
),
|
||||
'add_popup' => '700x750',
|
||||
),
|
||||
'home-accounts' => array( // user need run-rights for home
|
||||
'name' => 'Accounts',
|
||||
'icon' => 'addressbook/accounts',
|
||||
'query' => 'accounts::link_query',
|
||||
'title' => 'common::grab_owner_name',
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Caches link titles for a better performance
|
||||
@ -205,6 +213,7 @@ class egw_link extends solink
|
||||
'add','add_app','add_id','add_popup',
|
||||
'edit','edit_id','edit_popup',
|
||||
'list','list_popup',
|
||||
'name','icon','query',
|
||||
)));
|
||||
}
|
||||
return json_encode($to_json);
|
||||
@ -587,13 +596,14 @@ class egw_link extends solink
|
||||
static function app_list($must_support='')
|
||||
{
|
||||
$apps = array();
|
||||
foreach(self::$app_register as $app => $reg)
|
||||
foreach(self::$app_register as $type => $reg)
|
||||
{
|
||||
if ($must_support && !isset($reg[$must_support])) continue;
|
||||
|
||||
list($app) = explode('-', $type);
|
||||
if ($GLOBALS['egw_info']['user']['apps'][$app])
|
||||
{
|
||||
$apps[$app] = $GLOBALS['egw_info']['apps'][$app]['title'];
|
||||
$apps[$type] = lang(self::get_registry($type, 'name'));
|
||||
}
|
||||
}
|
||||
return $apps;
|
||||
@ -894,6 +904,29 @@ class egw_link extends solink
|
||||
{
|
||||
$reg = self::$app_register[$app];
|
||||
|
||||
if (!isset($reg)) return false;
|
||||
|
||||
if (!isset($reg[$name])) // some defaults
|
||||
{
|
||||
switch($name)
|
||||
{
|
||||
case 'name':
|
||||
$reg[$name] = $app;
|
||||
break;
|
||||
case 'icon':
|
||||
if (isset($GLOBALS['egw_info']['apps'][$app]['icon']))
|
||||
{
|
||||
$reg[$name] = ($GLOBALS['egw_info']['apps'][$app]['icon_app'] ? $GLOBALS['egw_info']['apps'][$app]['icon_app'] : $app).
|
||||
'/'.$GLOBALS['egw_info']['apps'][$app]['icon'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$reg[$name] = $app.'/navbar';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isset($reg) ? $reg[$name] : false;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* generalized linking between entries of eGroupware apps - SO layer
|
||||
*
|
||||
* All vars passed to this class get correct escaped to prevent query insertion.
|
||||
*
|
||||
*
|
||||
* All methods are now static!
|
||||
*/
|
||||
class solink
|
||||
@ -89,7 +89,7 @@ class solink
|
||||
'link_owner' => $owner,
|
||||
),False,__LINE__,__FILE__) ? self::$db->get_last_insert_id(self::TABLE,'link_id') : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update the remark of a link
|
||||
*
|
||||
@ -110,7 +110,7 @@ class solink
|
||||
/**
|
||||
* returns array of links to $app,$id
|
||||
*
|
||||
* @param string $app appname
|
||||
* @param string $app appname
|
||||
* @param string/array $id id(s) in $app
|
||||
* @param string $only_app if set return only links from $only_app (eg. only addressbook-entries) or NOT from if $only_app[0]=='!'
|
||||
* @param string $order defaults to newest links first
|
||||
@ -158,7 +158,8 @@ class solink
|
||||
$linked_app = $left ? $row['link_app2'] : $row['link_app1'];
|
||||
$linked_id = $left ? $row['link_id2'] : $row['link_id1'];
|
||||
$app_id = $left ? $row['link_id1'] : $row['link_id2'];
|
||||
if ($only_app && $not_only == ($linked_app == $only_app) || !$GLOBALS['egw_info']['user']['apps'][$linked_app])
|
||||
list($app) = explode('-',$linked_app);
|
||||
if ($only_app && $not_only == ($linked_app == $only_app) || !$GLOBALS['egw_info']['user']['apps'][$app])
|
||||
{
|
||||
#echo "$linked_app == $only_app, ";var_dump($linked_app == $only_app);echo " ->dont return a link<br>";
|
||||
return;
|
||||
@ -173,7 +174,7 @@ class solink
|
||||
'link_id' => $row['link_id'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns data of a link
|
||||
*
|
||||
@ -346,21 +347,21 @@ class solink
|
||||
|
||||
return self::$db->affected_rows();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all links from a given app's entries to an other app's entries, which both link to the same 3. app and id
|
||||
*
|
||||
* Example:
|
||||
* I search all timesheet's linked to a given project and id(s), who are also linked to other entries,
|
||||
* which link to the same project:
|
||||
*
|
||||
*
|
||||
* ($app='timesheet'/some id) <--a--> (other app/other id) <--b--> ($t_app='projectmanager'/$t_id=$pm_id)
|
||||
* ^ ^
|
||||
* ^ ^
|
||||
* +---------------------------c-----------------------------------------+
|
||||
*
|
||||
* bolink::get_3links('timesheet','projectmanager',$pm_id) returns the links (c) between the timesheet and the project,
|
||||
*
|
||||
* bolink::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!)
|
||||
* @param string $target_app app the returned links other side link also to
|
||||
* @param string/array $target_id=null id(s) the returned links other side link also to
|
||||
@ -385,7 +386,7 @@ class solink
|
||||
'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3',
|
||||
'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app).
|
||||
(!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))),
|
||||
'join'=>" a
|
||||
'join'=>" a
|
||||
JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2
|
||||
JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1",
|
||||
),
|
||||
@ -394,7 +395,7 @@ class solink
|
||||
'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3',
|
||||
'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app).
|
||||
(!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))),
|
||||
'join'=>" a
|
||||
'join'=>" a
|
||||
JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2
|
||||
JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1",
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user