public function actionSignup()
 {
     $this->needAuthenticate();
     if (Param::post('employee-registration-form-sign-up', false)->exists()) {
         $name = Param::post('employee-registration-form-name', false)->noEmpty("Запоните поле \"Имя\".")->asString(true, "Недопустимое значение поля \"Имя\".");
         $email = Param::post('employee-registration-form-email', false)->noEmpty("Заполните поле \"Email\"!")->asEmail(true, "Недопустимое значение поля \"Email\".");
         $password = Param::post('employee-registration-form-password', false)->noEmpty("Заполните поле \"Пароль\".")->asString(true, "Недопустимое значение поля \"Пароль\".");
         $passwordRepeat = Param::post('employee-registration-form-password-repeat', false)->noEmpty("Заполните поле \"Повтор пароля\".")->asString(true, "Недопустимое значение поля \"Повтор пароля\".");
         if ($password != $passwordRepeat) {
             SCMSNotificationLog::instance()->pushError("\"Пароль\" и \"Повтор пароля\" должны быть одинаковы.");
         }
         if (SCMSNotificationLog::instance()->hasProblems()) {
             $this->Response->send();
             exit;
         }
         /** @var Employee $oEmployee */
         $oEmployee = DataSource::factory(Employee::cls());
         $oEmployee->name = $name;
         $oEmployee->email = $email;
         $oEmployee->password = $this->EmployeeAuthentication->encodePassword($password, Employee::SALT);
         $oEmployee->active = true;
         $oEmployee->deleted = false;
         $oEmployee->commit();
         SCMSNotificationLog::instance()->pushMessage("Успешно зарегистрирован!");
         $this->Response->send('/admin/modules/employees');
         exit;
     } else {
         SCMSNotificationLog::instance()->pushError("Форма регистрации сотрудника заполнена неверно!");
     }
     $this->Response->send();
 }
Exemple #2
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $pk = Param::get('id', true)->asInteger(true, 'Не указан обязательный параметр.');
     /** @var Employee $oEmployee */
     $oEmployee = DataSource::factory(Employee::cls(), $pk);
     $view = new ViewEmployeeEdit();
     $view->employee = $oEmployee;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Сотрудники', '/modules/employees'), new Breadcrumb("Редактирование \"{$oEmployee->email}\"", '')];
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }
Exemple #3
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $employeeId = Param::get('id')->noEmpty('Параметр обязателен для заполнения.')->asInteger(true, "Неверно задан параметр.");
     /** @var Employee $oEmployee */
     $oEmployee = DataSource::factory(Employee::cls(), $employeeId);
     if ($oEmployee->id) {
         SCMSNotificationLog::instance()->pushMessage("Сотрудник \"{$oEmployee->name}\" успешно удалён.");
         $oEmployee->deleted = true;
         $oEmployee->commit();
     } else {
         SCMSNotificationLog::instance()->pushError("Сотрутник с ID {$employeeId} не найден");
     }
     $this->Response->send();
 }
Exemple #4
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $employeeId = Param::post('employee-id')->asInteger(true, 'Не указан обязательный параметр.');
     $name = Param::post('employee-name')->noEmpty('Поле "Имя" должно быть заполнено.')->asString();
     $email = Param::post('employee-email')->noEmpty('Поле "Email" должно быть заполнено.')->asString();
     $currentEmployeePassword = Param::post('employee-current-password')->asString();
     $newPassword = Param::post('employee-new-password')->asString();
     $newPasswordRepeat = Param::post('employee-new-password-repeat')->asString();
     if (!empty($newPassword)) {
         if (!$this->EmployeeAuthentication->verifyPassword($currentEmployeePassword, $this->EmployeeAuthentication->getCurrentUser()->password)) {
             SCMSNotificationLog::instance()->pushError('Вы указали неверный пароль.');
         }
         if ($newPassword != $newPasswordRepeat) {
             SCMSNotificationLog::instance()->pushError('"Новый пароль" и "Повтор нового пароля" должны быть заполены одинаково.');
         }
     }
     /** @var Employee $oEmployee */
     $oEmployee = DataSource::factory(Employee::cls(), $employeeId);
     if (!$oEmployee->getPrimaryKey()) {
         SCMSNotificationLog::instance()->pushError('Редактируемый сотрудник не определён.');
     }
     /** @var Employee $aEmployee */
     $aEmployee = DataSource::factory(Employee::cls());
     $aEmployee->builder()->where("{$aEmployee->getPrimaryKeyName()}<>{$employeeId}")->whereAnd()->where('deleted=0')->whereAnd()->where('active=1')->whereAnd()->where("email='{$email}'")->limit(1);
     $aEmployees = $aEmployee->findAll();
     if (sizeof($aEmployees) > 0) {
         SCMSNotificationLog::instance()->pushError('Данный Email уже используется другим сотрудником.');
     }
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         $oEmployee->name = $name;
         $oEmployee->email = $email;
         $oEmployee->password = $this->EmployeeAuthentication->encodePassword($newPassword, Employee::SALT);
         $oEmployee->commit();
         SCMSNotificationLog::instance()->pushMessage("Сотрудник \"{$oEmployee->email}\" успешно отредактирован");
         $redirect = '';
         if (Param::post('employee-accept', false)->exists()) {
             $redirect = '/admin/modules/employees/';
         } else {
             if ($employeeId == 1) {
                 $redirect = "/admin/modules/employees/edit/?pk={$oEmployee->getPrimaryKey()}";
             }
         }
         $this->Response->send($redirect);
     } else {
         $this->Response->send();
     }
 }
Exemple #5
0
 /**
  * Аутентификация
  *
  * @param string $login
  * @param string $password
  * @return bool
  */
 public function signIn($login, $password)
 {
     /** @var Employee $oEmployees */
     $oEmployees = DataSource::factory(Employee::cls());
     $oEmployees->builder()->where("email='{$login}'")->whereAnd()->where('active=1');
     /** @var Employee[] $aEmployees */
     $aEmployees = $oEmployees->findAll();
     if (empty($aEmployees)) {
         return false;
     }
     $oEmployee = $aEmployees[0];
     if (!$this->verifyPassword($password . Employee::SALT, $oEmployee->password)) {
         return false;
     }
     $this->oCurrentEmployee = $oEmployee;
     return true;
 }
Exemple #6
0
    public function currentRender()
    {
        ?>
        <form action="/admin/modules/employees/save/" method="post" id="employee-form">
            <fieldset>
                <legend>Редактирование сотрудника</legend>
                <input type="hidden" id="employee-id" name="employee-id" value="<?php 
        echo $this->employee->getPrimaryKey();
        ?>
" />

                <div class="row">
                    <div class="col-lg-6">
                        <div class="row">
                            <div class="col-lg-1">
                                <div class="form-group">
                                    <label for="employee-number">№</label>
                                    <input class="form-control input-sm" name="employee-number" id="employee-number" disabled="disabled" type="number" placeholder="№" value="<?php 
        echo $this->employee->getPrimaryKey();
        ?>
">
                                    <span class="help-block">Номер</span>
                                </div>
                            </div>
                            <div class="col-lg-11">
                                <div class="form-group">
                                    <label for="employee-name">Имя</label>
                                    <input class="form-control input-sm" name="employee-name" id="employee-name" type="text" placeholder="Имя" value="<?php 
        echo $this->employee->name;
        ?>
">
                                    <span class="help-block">ФИО сотрудника</span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="form-group">
                                    <label for="employee-email">Email</label>
                                    <input class="form-control input-sm" name="employee-email" id="employee-email" type="email" placeholder="Email" value="<?php 
        echo $this->employee->email;
        ?>
">
                                    <span class="help-block">Адрес электронной почты, используется при авторизации сотрудника в панели управления.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="form-group">
                                    <label for="employee-current-password">Ваш пароль</label>
                                    <input class="form-control input-sm" name="employee-current-password" id="employee-current-password" type="password" placeholder="Пароль текущего пользователя">
                                    <span class="help-block">Для изменения пароля сотрудника нужно указать пароль активного пользователя.</span>
                                </div>
                                <div class="form-group">
                                    <label for="employee-new-password">Новый пароль</label>
                                    <input class="form-control input-sm" name="employee-new-password" id="employee-new-password" type="password" placeholder="Новый пароль">
                                    <span class="help-block">Новый пароль сотрудника.</span>
                                </div>
                                <div class="form-group">
                                    <label for="employee-new-password-repeat">Повтор нового пароля</label>
                                    <input class="form-control input-sm" name="employee-new-password-repeat" id="employee-new-password-repeat" type="password" placeholder="Повтор нового пароля">
                                    <span class="help-block">Повтор нового пароля сотрудника.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <hr/>
                <button name="employee-save" id="employee-save" type="submit" class="btn btn-primary">Сохранить</button>
                <button name="employee-accept" id="employee-accept" type="submit" class="btn btn-success">Применить</button>
            </fieldset>
        </form>
        <?php 
    }