aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-08-02 22:39:35 -0700
committerFriendika <info@friendika.com>2011-08-02 22:39:35 -0700
commite22e823e93756fbfbb175f4f9f182aee64c1f5b1 (patch)
tree04aba82a020894da4e9ea8bd0e933cd96a0d25e3 /include
parent6bf800c6c8ea90d86cadb58b862ecddcf40e7b2a (diff)
downloadvolse-hubzilla-e22e823e93756fbfbb175f4f9f182aee64c1f5b1.tar.gz
volse-hubzilla-e22e823e93756fbfbb175f4f9f182aee64c1f5b1.tar.bz2
volse-hubzilla-e22e823e93756fbfbb175f4f9f182aee64c1f5b1.zip
allow group selection from contact edit page
Diffstat (limited to 'include')
-rw-r--r--include/group.php28
-rw-r--r--include/main.js8
2 files changed, 34 insertions, 2 deletions
diff --git a/include/group.php b/include/group.php
index e16c900d9..8ee7face6 100644
--- a/include/group.php
+++ b/include/group.php
@@ -136,7 +136,7 @@ function group_public_members($gid) {
-function group_side($every="contacts",$each="group",$edit = false, $group_id = 0) {
+function group_side($every="contacts",$each="group",$edit = false, $group_id = 0, $cid = 0) {
$o = '';
@@ -160,10 +160,19 @@ EOT;
$r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC",
intval($_SESSION['uid'])
);
+ if($cid) {
+ $member_of = groups_containing(local_user(),$cid);
+ }
+
if(count($r)) {
foreach($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : '');
- $o .= ' <li class="sidebar-group-li">' . (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit') . "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "") . "<a href=\"$each/{$rr['id']}\" $selected >{$rr['name']}</a></li>\r\n";
+ $o .= ' <li class="sidebar-group-li">'
+ . (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit')
+ . "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "")
+ . (($cid) ? '<input type="checkbox" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" '
+ . ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '')
+ . "<a href=\"$each/{$rr['id']}\" $selected >{$rr['name']}</a></li>\r\n";
}
}
$o .= " </ul>\r\n </div>";
@@ -204,3 +213,18 @@ function member_of($c) {
}
+function groups_containing($uid,$c) {
+
+ $r = q("SELECT `gid` FROM `group_member` WHERE `uid` = %d AND `group_member`.`contact-id` = %d ",
+ intval($uid),
+ intval($c)
+ );
+
+ $ret = array();
+ if(count($r)) {
+ foreach($r as $rr)
+ $ret[] = $rr['gid'];
+ }
+
+ return $ret;
+} \ No newline at end of file
diff --git a/include/main.js b/include/main.js
index d17d923e4..e5c78a065 100644
--- a/include/main.js
+++ b/include/main.js
@@ -341,6 +341,14 @@
});
}
+ function contactgroupChangeMember(gid,cid) {
+ $('body').css('cursor', 'wait');
+ $.get('contactgroup/' + gid + '/' + cid, function(data) {
+ $('body').css('cursor', 'auto');
+ });
+ }
+
+
function checkboxhighlight(box) {
if($(box).is(':checked')) {
$(box).addClass('checkeditem');