You are here

function _spaces_dashboard_user_batch in Spaces 5.2

Same name and namespace in other branches
  1. 5 spaces_dashboard/spaces_dashboard.module \_spaces_dashboard_user_batch()
1 call to _spaces_dashboard_user_batch()
spaces_dashboard_users_submit in spaces_dashboard/spaces_dashboard.module

File

spaces_dashboard/spaces_dashboard.module, line 262

Code

function _spaces_dashboard_user_batch($op = 'active', $users, $gid = null) {
  switch ($op) {
    case 'active':
    case 'block':
      $status = $op == 'active' ? 1 : 0;
      foreach ($users as $uid) {
        $account = user_load(array(
          'uid' => $uid,
        ));
        user_save($account, array(
          'status' => $status,
        ));
      }
      return true;
    case 'join':

      // check gid for validity
      if (is_numeric($gid) && ($node = node_load($gid))) {
        if (og_is_group_type($node->type)) {
          foreach ($users as $uid) {
            $account = user_load(array(
              'uid' => $uid,
            ));
            if (!isset($account->og_groups[$gid])) {
              og_save_subscription($gid, $uid, array(
                'is_active' => 1,
              ));
            }
          }
          return true;
        }
      }
      return false;
    case 'yank':

      // check gid for validity
      if (is_numeric($gid) && ($node = node_load($gid))) {
        if (og_is_group_type($node->type)) {
          foreach ($users as $uid) {
            $account = user_load(array(
              'uid' => $uid,
            ));
            if (isset($account->og_groups[$gid])) {
              og_delete_subscription($gid, $uid);
            }
          }
          return true;
        }
      }
      return false;
  }
}