Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

49 rindas
1.1KB

  1. <?php
  2. require_once('include/group.php');
  3. function contactgroup_content(App $a) {
  4. if (! local_user()) {
  5. killme();
  6. }
  7. if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
  8. $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
  9. intval($a->argv[2]),
  10. intval(local_user())
  11. );
  12. if (dbm::is_result($r))
  13. $change = intval($a->argv[2]);
  14. }
  15. if(($a->argc > 1) && (intval($a->argv[1]))) {
  16. $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
  17. intval($a->argv[1]),
  18. intval(local_user())
  19. );
  20. if (! dbm::is_result($r)) {
  21. killme();
  22. }
  23. $group = $r[0];
  24. $members = group_get_members($group['id']);
  25. $preselected = array();
  26. if(count($members)) {
  27. foreach($members as $member)
  28. $preselected[] = $member['id'];
  29. }
  30. if($change) {
  31. if(in_array($change,$preselected)) {
  32. group_rmv_member(local_user(),$group['name'],$change);
  33. }
  34. else {
  35. group_add_member(local_user(),$group['name'],$change);
  36. }
  37. }
  38. }
  39. killme();
  40. }