/** * Cancels invite(s) * * @return void */ public function uninviteTask() { // Check for request forgeries Request::checkToken(['get', 'post']); $gid = Request::getVar('gid', ''); // Load the group page $this->group = new Group(); $this->group->read($gid); $authorized = $this->authorized; $users = array(); $useremails = array(); // Get all the group's invitees $invitees = $this->group->get('invitees'); // Incoming array of users to demote $mbrs = Request::getVar('id', array()); $mbrs = !is_array($mbrs) ? array($mbrs) : $mbrs; foreach ($mbrs as $mbr) { //check to see if we are uninviting email if (filter_var($mbr, FILTER_VALIDATE_EMAIL)) { $useremails[] = $mbr; } else { // Retrieve user's account info $targetuser = User::getInstance($mbr); // Ensure we found an account if (is_object($targetuser)) { $uid = $targetuser->get('id'); if (in_array($uid, $invitees)) { $users[] = $uid; } } else { $this->setError(Lang::txt('COM_GROUPS_USER_NOTFOUND') . ' ' . $mbr); } } } // Remove users from members list $this->group->remove('invitees', $users); //remove any invite emails if (count($useremails) > 0) { $hubzeroGroupInviteEmail = new \Hubzero\User\Group\InviteEmail($this->database); $hubzeroGroupInviteEmail->removeInvites($this->group->get('gidNumber'), $useremails); } // Save changes $this->group->update(); // log Log::log(array('gidNumber' => $this->group->get('gidNumber'), 'action' => 'group_members_uninvited', 'comments' => array_merge($users, $useremails))); if (!Request::getInt('no_html', 0)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->group->get('cn'), false), Lang::txt('COM_GROUPS_MEMBER_UNINVITED')); } }