X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fgroup.php;h=fd1c97dfde47d1af8c665b03eac51370428a7940;hb=9d4d29ad9eb6302fb02eda0ba5f6bcd128a86f49;hp=fe29d39f1a810ae86eb6ec5ef66d630c7538831e;hpb=a867e3a7524e067bdf5da515d85fa2581a6fe49c;p=friendica.git diff --git a/include/group.php b/include/group.php index fe29d39f1a..fd1c97dfde 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'), )); @@ -326,3 +340,30 @@ function groups_containing($uid,$c) { return $ret; } +/** + * @brief count unread group items + * + * Count unread items of each groups + * + * @return array + * 'id' => group id + * 'name' => group name + * 'count' => counted unseen group items + * + */ +function groups_count_unseen() { + + $r = q("SELECT `group`.`id`, `group`.`name`, COUNT(`item`.`id`) AS `count` FROM `group`, `group_member`, `item` + WHERE `group`.`uid` = %d + AND `item`.`uid` = %d + AND `item`.`unseen` AND `item`.`visible` + AND NOT `item`.`deleted` + AND `item`.`contact-id` = `group_member`.`contact-id` + AND `group_member`.`gid` = `group`.`id` + GROUP BY `group`.`id` ", + intval(local_user()), + intval(local_user()) + ); + + return $r; +} \ No newline at end of file