diff --git a/include/group.php b/include/group.php index fe29d39f1..862d06818 100644 --- a/include/group.php +++ b/include/group.php @@ -213,9 +213,20 @@ function mini_group_select($uid,$gid = 0) { } - - -function group_side($every="contacts",$each="group",$edit = false, $group_id = 0, $cid = 0) { +/** + * @brief Create group sidebar widget + * + * @param string $every + * @param string $each + * @param string $editmode + * 'standard' => include link 'Edit groups' + * 'extended' => include link 'Create new group' + * 'full' => include link 'Create new group' and provide for each group a link to edit this group + * @param int $group_id + * @param int $cid + * @return string + */ +function group_side($every="contacts",$each="group",$editmode = "standard", $group_id = 0, $cid = 0) { $o = ''; @@ -239,13 +250,13 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0 $member_of = array(); if($cid) { $member_of = groups_containing(local_user(),$cid); - } + } if(count($r)) { foreach($r as $rr) { $selected = (($group_id == $rr['id']) ? ' group-selected' : ''); - if ($edit) { + if ($editmode == "full") { $groupedit = array( 'href' => "group/".$rr['id'], 'title' => t('edit'), @@ -269,14 +280,17 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0 $tpl = get_markup_template("group_side.tpl"); $o = replace_macros($tpl, array( - '$title' => t('Groups'), + '$title' => t('Groups'), + 'newgroup' => (($editmode == "extended") || ($editmode == "full") ? 1 : ''), + '$editgroupstext' => t('Edit groups'), + 'grouppage' => "group/", '$edittext' => t('Edit group'), '$createtext' => t('Create a new group'), - '$creategroup' => t('Group Name: '), - '$form_security_token' => get_form_security_token("group_edit"), + '$creategroup' => t('Group Name: '), + '$form_security_token' => get_form_security_token("group_edit"), '$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''), - '$groups' => $groups, - '$add' => t('add'), + '$groups' => $groups, + '$add' => t('add'), )); diff --git a/mod/contacts.php b/mod/contacts.php index 017b1d643..1dc886363 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -55,7 +55,7 @@ function contacts_init(&$a) { $findpeople_widget .= findpeople_widget(); } - $groups_widget .= group_side('contacts','group',false,0,$contact_id); + $groups_widget .= group_side('contacts','group','full',0,$contact_id); $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array( '$vcard_widget' => $vcard_widget, diff --git a/mod/group.php b/mod/group.php index 263586e2e..e9f9561f4 100644 --- a/mod/group.php +++ b/mod/group.php @@ -7,7 +7,7 @@ function validate_members(&$item) { function group_init(&$a) { if(local_user()) { require_once('include/group.php'); - $a->page['aside'] = group_side('contacts','group',false,(($a->argc > 1) ? intval($a->argv[1]) : 0)); + $a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0)); } } diff --git a/mod/network.php b/mod/network.php index 903ee4154..fd22f3e19 100644 --- a/mod/network.php +++ b/mod/network.php @@ -145,7 +145,7 @@ function network_init(&$a) { )); } - $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network',true,$group_id) : ''); + $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network','standard',$group_id) : ''); $a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? widget_forumlist($a) : ''); $a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network',local_user(),false); $a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : '')); diff --git a/mod/nogroup.php b/mod/nogroup.php index 06fa730e0..9f6e97843 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -15,7 +15,7 @@ function nogroup_init(&$a) { if(! x($a->page,'aside')) $a->page['aside'] = ''; - $a->page['aside'] .= group_side('contacts','group',false,0,$contact_id); + $a->page['aside'] .= group_side('contacts','group','extended',0,$contact_id); } diff --git a/view/templates/group_side.tpl b/view/templates/group_side.tpl index 4905c2fa1..466882370 100644 --- a/view/templates/group_side.tpl +++ b/view/templates/group_side.tpl @@ -1,38 +1,42 @@