Example #1
0
 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \AppBundle\Entity\User $user
  * @return bool
  */
 public function createUser(Form $form, User $user) : bool
 {
     $return = false;
     if (!$this->checkUsername($user->getUsername())) {
         $return = true;
         $form->get('username')->addError(new FormError($this->translator->trans('users.registration.username_already_taken')));
     }
     if (!$this->checkEmail($user->getEmail())) {
         $return = true;
         $form->get('email')->addError(new FormError($this->translator->trans('users.registration.email_already_taken')));
     }
     if ($return) {
         return false;
     }
     $user->setSalt(uniqid('', true));
     $password = $this->encoder->encodePassword($user, $user->getPlainPassword());
     $user->setPassword($password);
     $user->addRole('ROLE_USER');
     $user->enable(false);
     $this->em->persist($user);
     $this->em->flush();
     $this->activationLinkManager->createActivationLink($user);
     $this->activationLinkManager->sendValidationMail($user);
     return true;
 }
Example #2
0
 /**
  * Get the expiration time of the ban based on the fields of the form
  *
  * @param  Form          $form The form
  * @return TimeDate|null
  */
 private function getExpiration($form)
 {
     if ($form->get('automatic_expiration')->getData()) {
         return $form->get('expiration')->getData();
     } else {
         return null;
     }
 }
Example #3
0
 /**
  */
 public function testFormOptions()
 {
     $this->object->set('test', 'existing');
     $this->assertFalse($this->object->get('nonExisting'));
     $this->assertEquals('existing', $this->object->get('test'));
     $this->assertEquals('default', $this->object->get('nonExists', 'default'));
     $this->assertTrue(is_array($this->object->getAll()));
     $this->assertEquals(1, count($this->object->getAll()));
     $this->object->setAll(array('test' => 'merged', 'second' => 'test'));
     $this->assertEquals(2, count($this->object->getAll()));
     $this->assertEquals('merged', $this->object->get('test'));
 }
 public function testFormInitialState()
 {
     // check the form properties
     foreach ($this->_formProperties as $propertyName => $propertyValue) {
         $this->assertEquals(true, $this->_form->hasAttribute($propertyName), "Form has no property {$propertyName} element");
         $this->assertEquals($propertyValue, $this->_form->getAttribute($propertyName), "Form property {$propertyName} doesn't match {$propertyValue}");
     }
     foreach ($this->_formFields as $fieldName => $properties) {
         $this->assertEquals(true, $this->_form->has($fieldName), "Form missing element '{$fieldName}'");
         foreach ($properties as $propertyName => $propertyValue) {
             switch ($propertyName) {
                 case 'type':
                     $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getAttribute('type'), "field {$fieldName} should have been of type: " . $this->_form->get($fieldName)->getAttribute('type'));
                     break;
                 case 'value':
                     $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getValue(), "field {$fieldName} should have value: " . $this->_form->get($fieldName)->getValue());
                     break;
                 case 'label':
                     $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getLabel(), "field {$fieldName} should have label matching: " . $this->_form->get($fieldName)->getLabel());
                     break;
                 case 'placeholder':
                     $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getAttribute('placeholder'), "field {$fieldName} should placeholder matching: {$propertyValue}");
                     break;
             }
         }
     }
 }
Example #5
0
 function newApplication()
 {
     $AppName = Form::get("AppName");
     if ($AppName) {
         // klasörleri oluştursun
     }
 }
 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \AppBundle\Entity\User $user
  * @return boolean
  */
 public function createUser(Form $form, User $user) : bool
 {
     if ($user->getUsername() === 'Toto') {
         $form->get('username')->addError(new FormError('users.registration.username_already_taken'));
         return false;
     }
     return true;
 }
Example #7
0
 public static function verify($key = null, $debug = false)
 {
     global $global;
     $result = Session::get('_token.' . $global['name']) === ($key == null ? Form::get('token', 'no') : $key);
     if (!$debug) {
         Session::remove('_token.' . $global['name']);
     }
     return $result;
 }
Example #8
0
 /**
  * Returns array of models model_name => Model used in this form.
  *
  * @return array
  */
 public function getFields()
 {
     $models = array();
     /**
      * @var Form_Field $form_field
      * @var Field $model_field
      */
     foreach ($this->field_associations as $form_field => $model_field) {
         $v = $this->form->get($form_field);
         $model_field->set($v);
         if (!isset($models[$model_field->owner->name])) {
             $models[$model_field->owner->name] = $model_field->owner;
         }
     }
     return $models;
 }
 public function saveAction()
 {
     $this->_model = Model::get($this->_controller);
     $form = Form::get($this->_controller);
     if ($form->isValid($_POST)) {
         try {
             $array = array();
             $values = $form->getValues();
             foreach ($values as $id => $value) {
                 if (isset($value) && $value != '') {
                     $array[$id] = addslashes($value);
                 }
             }
             //$array['chave'] = Chave::get($nome);
             $id = $form->getValue('id');
             $nome = $form->getValue('nome');
             if ($id) {
                 //die($id);
                 $this->_model->update($array, 'id = ' . $id);
             } else {
                 unset($array['id']);
                 $this->_model->insert($array);
                 $id = $this->_model->getAdapter()->lastInsertId($this->_controller);
             }
             $this->addMessage('Dados salvos com sucesso.');
         } catch (Exception $e) {
             die($e->getMessage());
             $this->addMessage($e->getMessage());
         }
     } else {
         $this->addMessage('Campos obrigatórios devem ser preenchidos.');
     }
     $url = '/admin/message';
     if ($this->getRequest()->isXmlHttpRequest() || $this->getRequest()->getParam('ajax') == true) {
         $url .= '/index/ajax/true';
     }
     $this->_redirect($url);
 }
Example #10
0
            $disable->show_errors();
            $disable->HTML('<img class="qrcode" src="includes/qrcode.php?sec=1&code=otpauth://totp/Backstage2?secret=' . $key . '" />');
            $disable->textInput('token', 'Enter token', true);
            $disable->submitButton('submit', 'Disable 2FA');
            $disable->display();
        }
    }
}
if ($show_form) {
    Messages::display();
    $CFG->form_legend = 'My User Info.';
    $edit = new Form('users_form', false, false, false, 'admin_users', true);
    $edit->verify();
    $edit->show_errors();
    $edit->save();
    $edit->get(User::$info['id']);
    $edit->textInput('user', $CFG->user_username, true, false, false, false, false, false, false, false, 1, $CFG->user_unique_error);
    $edit->passwordInput('pass', $CFG->user_password, true);
    $edit->passwordInput('pass1', $CFG->user_password, true, false, false, false, false, false, 'pass');
    $edit->textInput('first_name', $CFG->user_first_name, true);
    $edit->textInput('last_name', $CFG->user_last_name, true);
    $edit->textInput('phone', $CFG->user_phone);
    $edit->textInput('email', $CFG->user_email);
    $edit->submitButton('submit', $CFG->save_caption);
    $edit->cancelButton($CFG->cancel_button);
    if ($edit->info['verified_authy'] == 'Y') {
        $edit->button('my-account', 'Disable Google 2FA', array('action' => 'disable'));
    } else {
        $edit->button('my-account', 'Enable Google 2FA', array('action' => 'enable'));
    }
    $edit->display();
Example #11
0
 public static function onClick($userFormId)
 {
     $userForm = Form::get($userFormId);
     return "popUpForm({$userForm->id},'{$userForm->name}');";
 }
Example #12
0
         $sql = "ALTER TABLE admin_tabs ADD admin_tabs.is_ctrl_panel ENUM( 'Y', 'N' ) NOT NULL";
         db_query($sql);
     }
     if (!in_array('for_group', $table_fields)) {
         $sql = "ALTER TABLE admin_tabs ADD admin_tabs.for_group INT( 10 ) UNSIGNED NOT NULL";
         db_query($sql);
     }
 }
 if (!in_array('one_record', $table_fields)) {
     $sql = "ALTER TABLE admin_tabs ADD {$_REQUEST['table']}.one_record ENUM( 'Y', 'N' ) NOT NULL";
     db_query($sql);
 }
 $form = new Form('tabs_form', false, false, false, $_REQUEST['table']);
 $form->verify();
 $form->save();
 $form->get($_REQUEST['id']);
 $form->show_errors();
 $form->show_messages();
 $form->textInput('name', 'Name', true);
 $form->textInput('url', 'Url');
 $form->textInput('order', 'Order', false, '0');
 $form->checkBox('one_record', 'Auto First Record?');
 if ($_REQUEST['table'] == 'admin_tabs') {
     $form->checkBox('hidden', 'Hidden?');
     $form->checkBox('is_ctrl_panel', 'Is Control Panel?');
     $form->selectInput('for_group', 'For Group' . false, false, false, false, 'admin_groups', array('name'));
 } elseif ($_REQUEST['table'] == 'admin_pages') {
     if (in_array('icon', $table_fields)) {
         $form->textInput('icon', 'Icon');
     }
 }
Example #13
0
                                    continue;
                                }
                            }
                        }
                        if ($method['method'] == 'emailNotify') {
                            if (Email::send($CFG->form_email, $row1[$email_field], $message['title'], $CFG->form_email_from, false, $message['content'], $row1)) {
                                Messages::add($CFG->email_sent_message);
                            } else {
                                Errors::add($CFG->email_send_error);
                            }
                        } elseif ($method['method'] == 'createRecord') {
                            $CFG->save_called = 1;
                            $form = new Form('cron', false, false, false, $control_args['table'], false, 1);
                            $form->get($row1['id']);
                            $form->createRecord($method_args['table'], $method_args['insert_array'], $method_args['trigger_field'], $method_args['trigger_value'], $method_args['day'], $method_args['month'], $method_args['year'], $method_args['send_condition'], $method_args['any_modification'], $method_args['register_changes'], $method_args['on_new_record_only'], $method_args['store_row'], $method_args['if_not_exists'], $method_args['run_in_cron']);
                            unset($form);
                        } elseif ($method['method'] == 'editRecord') {
                            $CFG->save_called = 1;
                            $form = new Form('cron', false, false, false, $control_args['table'], false, 1);
                            $form->get($row1['id']);
                            $form->editRecord($method_args['table'], $method_args['insert_array'], $method_args['trigger_field'], $method_args['trigger_value'], $method_args['day'], $method_args['month'], $method_args['year'], $method_args['send_condition'], $method_args['any_modification'], $method_args['register_changes'], $method_args['on_new_record_only'], $method_args['store_row'], $method_args['edit_record_field_id'], $method_args['run_in_cron']);
                            unset($form);
                        }
                    }
                }
            }
        }
    }
}
Messages::display();
Errors::display();
Example #14
0
        $view->field('phone', $CFG->user_phone);
        $view->field('email', $CFG->user_email);
        $view->field('f_id', $CFG->user_group, 'admin_groups', array('name'));
        $view->field('is_admin', $CFG->user_is_admin);
    }
    $view->display();
    if ($_REQUEST['table'] == 'admin_groups') {
        $pe = new PermissionEditor('admin', $_REQUEST['id']);
    }
    $form = new Form('dummy');
    //$form->button(false,$CFG->ok_button,false,false,false,false,'onclick="closePopup(this);"');
    $form->cancelButton($CFG->ok_button);
    $form->display();
} elseif ($CFG->action == 'form') {
    $edit = new Form('users_form', false, false, false, $_REQUEST['table']);
    $edit->get($_REQUEST['id']);
    if ($_REQUEST['table'] == 'admin_groups') {
        $edit->textInput('name', 'Name');
        if ($_REQUEST['id']) {
            $edit->permissionEditor('admin', $_REQUEST['id']);
        }
    } else {
        $edit->passiveField('id', 'ID');
        $edit->textInput('user', $CFG->user_username, true, false, false, false, false, false, false, false, 1, $CFG->user_unique_error);
        $edit->passwordInput('pass', $CFG->user_password, true);
        $edit->passwordInput('pass1', $CFG->user_password, true, false, false, false, false, false, 'pass');
        $edit->textInput('first_name', $CFG->user_first_name, true);
        $edit->textInput('last_name', $CFG->user_last_name, true);
        $edit->textInput('phone', $CFG->user_phone);
        $edit->textInput('country_code', 'Country Code');
        $edit->textInput('email', $CFG->user_email);
Example #15
0
if (!$authcode1 || !$authcode_valid) {
    User::logOut(true);
    Link::redirect('login.php');
    exit;
}
// check if form submitted and process
if (!empty($_REQUEST['settings'])) {
    $match = preg_match_all($CFG->pass_regex, $_REQUEST['settings']['pass'], $matches);
    $_REQUEST['settings']['pass'] = preg_replace($CFG->pass_regex, "", $_REQUEST['settings']['pass']);
    $too_few_chars = mb_strlen($_REQUEST['settings']['pass'], 'utf-8') < $CFG->pass_min_chars;
}
API::add('User', 'getInfo', array($_SESSION['session_id']));
$query = API::send();
$personal = new Form('settings', false, false, 'form1', 'site_users');
$personal->verify();
$personal->get($query['User']['getInfo']['results'][0]);
if (!empty($_REQUEST['settings']) && $_SESSION['cp_uniq'] != $uniq1) {
    $personal->errors[] = 'Page expired.';
}
if (!empty($match)) {
    $personal->errors[] = htmlentities(str_replace('[characters]', implode(',', array_unique($matches[0])), Lang::string('login-pass-chars-error')));
}
if (!empty($too_few_chars)) {
    $personal->errors[] = Lang::string('login-password-error');
}
// check if we should request 2fa
/*
if (!empty($_REQUEST['settings']) && !$token1 && !is_array($personal->errors) && !is_array(Errors::$errors)) {
	if (!empty($_REQUEST['request_2fa'])) {
		if (!($token1 > 0)) {
			$no_token = true;
 /**
  *  Test to detect the incorrect input.
  *
  * @param Form     $form     form to control
  * @param Dropzone $dropzone dropzone to update
  *
  * @return form
  */
 public function handleFormErrors($form, Dropzone $dropzone)
 {
     if (!$dropzone->getAllowWorkspaceResource() && !$dropzone->getAllowUpload() && !$dropzone->getAllowUrl() && !$dropzone->getAllowRichText()) {
         $form->get('allowWorkspaceResource')->addError(new FormError('Choose at least one type of document'));
         $form->get('allowUpload')->addError(new FormError('Choose at least one type of document'));
         $form->get('allowUrl')->addError(new FormError('Choose at least one type of document'));
         $form->get('allowRichText')->addError(new FormError('Choose at least one type of document'));
     }
     if (!$dropzone->getManualPlanning()) {
         if ($dropzone->getStartAllowDrop() === null) {
             $form->get('startAllowDrop')->addError(new FormError('Choose a date'));
         }
         if ($dropzone->getEndAllowDrop() === null) {
             $form->get('endAllowDrop')->addError(new FormError('Choose a date'));
         }
         if ($dropzone->getStartAllowDrop() !== null && $dropzone->getEndAllowDrop() !== null) {
             if ($dropzone->getStartAllowDrop()->getTimestamp() > $dropzone->getEndAllowDrop()->getTimestamp()) {
                 $form->get('startAllowDrop')->addError(new FormError('Must be before end allow drop'));
                 $form->get('endAllowDrop')->addError(new FormError('Must be after start allow drop'));
             }
         }
     }
     return $form;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $forms = $this->former->get();
     return View::make('forms.index', compact('forms'));
 }