Beispiel #1
0
 public function create()
 {
     $this->assertLoggedIn();
     $this->setTitle('Create a New Queue');
     if ($this->args('submit')) {
         //did we get a name?
         if (!$this->args('name')) {
             $errors['name'] = "You need to provide a name.";
             $errorfields['name'] = 'error';
         }
         //okay, we good?
         if (empty($errors)) {
             //woot!
             $q = new Queue();
             $q->set('name', $this->args('name'));
             $q->set('user_id', User::$me->id);
             $q->save();
             //todo: send a confirmation email.
             Activity::log("created a new queue named " . $q->getLink() . ".");
             $this->forwardToUrl($q->getUrl());
         } else {
             $this->set('errors', $errors);
             $this->set('errorfields', $errorfields);
             $this->setArg('name');
         }
     }
 }
Beispiel #2
0
 public function register()
 {
     $registerForm = $this->_createRegisterForm();
     $this->set('register_form', $registerForm);
     if ($registerForm->checkSubmitAndValidate($this->args())) {
         $username = $this->args('username');
         if (!Verify::username($username, $reason)) {
             /** @var FormField $field */
             $field = $registerForm->get('username');
             $field->error($reason);
         }
         $email = $this->args('email');
         $testUser = User::byEmail($email);
         if ($testUser->isHydrated()) {
             /** @var FormField $emailField */
             $emailField = $registerForm->get('email');
             $emailField->error("That email is already being used");
         }
         if ($this->args('pass1') != $this->args('pass2')) {
             /** @var FormField $field */
             $field = $registerForm->get('pass2');
             $field->error("Your passwords do not match");
         }
         if (!$registerForm->hasError()) {
             //woot!
             $user = new User();
             $user->set('username', $username);
             $user->set('email', $email);
             $user->set('pass_hash', User::hashPass($this->args('pass1')));
             $user->set('registered_on', date("Y-m-d H:i:s"));
             $user->save();
             //create a default queue for them
             $q = new Queue();
             $q->set("name", 'Default');
             $q->set("user_id", $user->id);
             $q->save();
             Activity::log("registered a new account on BotQueue.", $user);
             $text = Controller::byName('email')->renderView('new_user', array('user' => $user));
             $html = Controller::byName('email')->renderView('new_user_html', array('user' => $user));
             Email::queue($user, "Welcome to " . RR_PROJECT_NAME . "!", $text, $html);
             //automatically log them in.
             $token = $user->createToken();
             $token->setCookie();
             $this->forwardToURL("/");
         }
     }
 }
Beispiel #3
0
 public function register()
 {
     if ($this->args('submit') && $this->args('action') == 'register') {
         //validate username
         $username = $this->args('username');
         if (!Verify::username($username, $reason)) {
             $errors['username'] = $reason;
             $errorfields['username'] = '******';
         }
         //validate email
         $email = $this->args('email');
         if (!Verify::email($email)) {
             $errors['email'] = "You must supply a valid email.";
             $errorfields['email'] = 'error';
         } else {
             $testUser = User::byEmail($email);
             if ($testUser->isHydrated()) {
                 $errors['email'] = "That email is already being used.";
                 $errorfields['email'] = 'error';
             }
         }
         //check passwords
         if ($this->args('pass1') != $this->args('pass2')) {
             $errors['password'] = "******";
             $errorfields['password'] = '******';
         } else {
             if (!strlen($this->args('pass1'))) {
                 $errors['password'] = "******";
                 $errorfields['password'] = '******';
             }
         }
         //okay, we good?
         if (empty($errors)) {
             //woot!
             $user = new User();
             $user->set('username', $username);
             $user->set('email', $email);
             $user->set('pass_hash', User::hashPass($this->args('pass1')));
             $user->set('registered_on', date("Y-m-d H:i:s"));
             $user->save();
             //create them a default queue.
             $q = new Queue();
             $q->set("name", 'Default');
             $q->set("user_id", $user->id);
             $q->save();
             //todo: send a confirmation email.
             Activity::log("registered a new account on BotQueue.", $user);
             //automatically log them in.
             $token = $user->createToken();
             $token->setCookie();
             $this->forwardToUrl('/');
         } else {
             $this->set('errors', $errors);
             $this->set('errorfields', $errorfields);
             $this->setArg('username');
             $this->setArg('email');
             $this->setArg('pass1');
             $this->setArg('pass2');
         }
     }
 }
Beispiel #4
0
 public function api_createqueue()
 {
     if (!$this->args('name')) {
         throw new Exception('Queue name is a required parameter.');
     }
     $q = new Queue();
     $q->set('name', $this->args('name'));
     $q->set('user_id', User::$me->id);
     $q->save();
     Activity::log("created a queue named " . $q->getLink() . " via the API.");
     return $q->getAPIData();
 }
Beispiel #5
0
}
if (isset($_POST['testbed'])) {
    $_POST['testbed'] = preg_replace("/\\s*\\(\\w+\\)\\s*\$/", "", $_POST['testbed']);
}
$objEditItem = new Queue();
if ($_REQUEST['id']) {
    $objEditItem->setUid($_REQUEST['id']);
    $objEditItem->load();
    if ($_REQUEST['mode'] && $_REQUEST['mode'] != 'save' && $_REQUEST['mode'] != 'save_reg') {
        switch ($_REQUEST['mode']) {
            case 'delete':
                $objEditItem->delete();
                $pMessage = $arrLanguageMessage['done_deleted'];
                break;
            default:
                $objEditItem->set('status', $_REQUEST['mode']);
                $objEditItem->update('status');
                $pMessage = $arrLanguageMessage['done_status'];
        }
        $objEditItem = new Queue();
    }
}
######################################################################
// --- NEW / UPDATE Regression-MiniReg Queue ----------------------------------------
if ($_REQUEST['mode'] == 'save_reg') {
    $suiteStrArr = array();
    $tbArr = array();
    if (is_array($_POST[module])) {
        foreach ($_POST[module] as $componentID) {
            array_push($suiteStrArr, $componentID);
        }