/** * @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 = ''; if (!local_user()) { return ''; } $groups = array(); $groups[] = array('text' => t('Everybody'), 'id' => 0, 'selected' => $group_id == 0 ? 'group-selected' : '', 'href' => $every); $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", intval($_SESSION['uid'])); $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 ($editmode == "full") { $groupedit = array('href' => "group/" . $rr['id'], 'title' => t('edit')); } else { $groupedit = null; } $groups[] = array('id' => $rr['id'], 'cid' => $cid, 'text' => $rr['name'], 'selected' => $selected, 'href' => $each . "/" . $rr['id'], 'edit' => $groupedit, 'ismember' => in_array($rr['id'], $member_of)); } } $tpl = get_markup_template("group_side.tpl"); $o = replace_macros($tpl, array('$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"), '$ungrouped' => $every === 'contacts' ? t('Contacts not in any group') : '', '$groups' => $groups, '$add' => t('add'))); return $o; }
function group_side($every = "connections", $each = "group", $edit = false, $group_id = 0, $cid = '', $mode = 1) { $o = ''; if (!(local_channel() && feature_enabled(local_channel(), 'groups'))) { return ''; } $groups = array(); $groups[] = array('text' => t('All Channels'), 'id' => 0, 'selected' => $group_id == 0 ? 'group-selected' : '', 'href' => $every . ($every === 'network' ? '?f=&gid=0' : '')); $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", intval($_SESSION['uid'])); $member_of = array(); if ($cid) { $member_of = groups_containing(local_channel(), $cid); } if (count($r)) { foreach ($r as $rr) { $selected = $group_id == $rr['id'] ? ' group-selected' : ''; if ($edit) { $groupedit = array('href' => "group/" . $rr['id'], 'title' => t('edit')); } else { $groupedit = null; } $groups[] = array('id' => $rr['id'], 'enc_cid' => base64url_encode($cid), 'cid' => $cid, 'text' => $rr['name'], 'selected' => $selected, 'href' => ($mode == 0 ? $each . '?f=&gid=' . $rr['id'] : $each . "/" . $rr['id']) . (x($_GET, 'new') ? '&new=' . $_GET['new'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : ''), 'edit' => $groupedit, 'ismember' => in_array($rr['id'], $member_of)); } } $tpl = get_markup_template("group_side.tpl"); $o = replace_macros($tpl, array('$title' => t('Privacy Groups'), '$edittext' => t('Edit group'), '$createtext' => t('Add privacy group'), '$ungrouped' => $every === 'contacts' ? t('Channels not in any privacy group') : '', '$groups' => $groups, '$add' => t('add'))); return $o; }