コード例 #1
0
 function subscribeAction()
 {
     $user = new User($_REQUEST['user']);
     $group = new Group($this->args[1]);
     if ($user->add_to_group($group->id)) {
         $this->flash($user->name . ' was successfuly added to ' . $group->name);
         redirect_to(ADMIN_URL . '/groups/show/' . $group->id);
     } else {
         $this->flash('There was an error adding the user.  Please try again or contact an administrator.');
         redirect_to(ADMIN_URL . '/groups/show/' . $group->id);
     }
 }
コード例 #2
0
function addUserToGroup()
{
    global $tool, $propertyForm;
    $users = $_POST['list'];
    if (isset($_POST['groups'])) {
        $groupID = $_POST['groups'];
    } else {
        if (isset($_POST['groups2'])) {
            $groupID = $_POST['groups2'];
        }
    }
    $addSuccess;
    if (isset($users)) {
        foreach ($users as $id => $value) {
            $curUser = new User($value);
            if ($curUser->add_to_group($groupID)) {
                $addSuccess = true;
            } else {
                $addSuccess = false;
                $error = $curUser->get_error();
                break;
            }
        }
        if ($addSuccess) {
            $status = "success";
            if (isset($_POST['groups'])) {
                echo "<script language='javascript'>LoadPage(\"configurations.php?action=userManage&mode=edit&add=" . $status . "\", 'settingsInfo');</script>";
            } else {
                if (isset($_POST['groups2'])) {
                    echo "<script language='javascript'>LoadPage(\"configurations.php?action=groupManage&mode=edit&add=" . $status . "\", 'settingsInfo');</script>";
                }
            }
        } else {
            $propertyForm->error("Warning: Failed to add user to group " . $groupID . ". Reason: " . $error, $_GET['ID']);
        }
    } else {
        $propertyForm->error("Warning: You did not pick any users. Reason: " . $error, $_GET['ID']);
    }
}