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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user