* Calendar: sort participants by there name

This commit is contained in:
Ralf Becker 2012-11-13 11:23:29 +00:00
parent 39e3d199fc
commit d6ce940eb0
2 changed files with 38 additions and 13 deletions

View File

@ -1550,6 +1550,8 @@ class calendar_bo
$names[$id] .= ' '.$role; $names[$id] .= ' '.$role;
} }
} }
natcasesort($names);
return $names; return $names;
} }

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @package calendar * @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2004-11 by RalfBecker-At-outdoor-training.de * @copyright (c) 2004-12 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -1101,6 +1101,36 @@ class calendar_uiforms extends calendar_ui
return "window.open('".egw::link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');"; return "window.open('".egw::link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');";
} }
/**
* Get title of a uid / calendar participant
*
* @param int|string $uid
* @return string
*/
public function get_title($uid)
{
if (is_numeric($uid))
{
return common::grab_owner_name($uid);
}
elseif (($info = $this->bo->resource_info($uid)))
{
return $info['name'] ? $info['name'] : $info['email'];
}
return '#'.$uid;
}
/**
* Compare two uid by there title
*
* @param int|string $uid1
* @param int|string $uid2
* @return int see strnatcasecmp
*/
public function uid_title_cmp($uid1, $uid2)
{
return strnatcasecmp($this->get_title($uid1), $this->get_title($uid2));
}
/** /**
* Edit a calendar event * Edit a calendar event
@ -1355,6 +1385,8 @@ function replace_eTemplate_onsubmit()
{ {
$name = $this->bo->resources[$type]['app']; $name = $this->bo->resources[$type]['app'];
} }
// sort participants (in there group/app) by title
uksort($participants, array($this, 'uid_title_cmp'));
foreach($participants as $id => $status) foreach($participants as $id => $status)
{ {
$uid = $type == 'u' ? $id : $type.$id; $uid = $type == 'u' ? $id : $type.$id;
@ -1386,23 +1418,14 @@ function replace_eTemplate_onsubmit()
$readonlys[$row.'[status]'] = !$this->bo->check_status_perms($uid,$event); $readonlys[$row.'[status]'] = !$this->bo->check_status_perms($uid,$event);
$readonlys["delete[$uid]"] = $preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event); $readonlys["delete[$uid]"] = $preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event);
// todo: make the participants available as links with email as title // todo: make the participants available as links with email as title
if ($name == 'accounts') $content['participants'][$row++]['title'] = $this->get_title($uid);
{
$content['participants'][$row++]['title'] = common::grab_owner_name($id);
}
elseif (($info = $this->bo->resource_info($uid)))
{
$content['participants'][$row++]['title'] = $info['name'] ? $info['name'] : $info['email'];
}
else
{
$content['participants'][$row++]['title'] = '#'.$uid;
}
// enumerate group-invitations, so people can accept/reject them // enumerate group-invitations, so people can accept/reject them
if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
($members = $GLOBALS['egw']->accounts->members($id,true))) ($members = $GLOBALS['egw']->accounts->members($id,true)))
{ {
$sel_options['status']['G'] = lang('Select one'); $sel_options['status']['G'] = lang('Select one');
// sort members by title
usort($members, array($this, 'uid_title_cmp'));
foreach($members as $member) foreach($members as $member)
{ {
if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member)) if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member))