public function actionIndex() { $this->needAuthenticate(); $galleryId = Param::post('gallery-id')->asInteger(true, 'Недопустимое значние номера галереи.'); $galleryItemId = Param::post('gallery-item-edit-id', false)->asInteger(false); $name = Param::post('gallery-item-edit-name')->noEmpty('Поле "Название" должно быть заполнено.')->asString(); $description = Param::post('gallery-item-edit-description')->asString(); $path = Param::post('gallery-item-edit-path')->noEmpty('Недопустимое значение пути к изображению.')->asString(); $position = Param::post('gallery-item-edit-position')->noEmpty('Недопустимое значение позиции элемента.')->asInteger(); /** @var Gallery $oGallery */ $oGallery = DataSource::factory(Gallery::cls(), $galleryId); if ($oGallery->isNew()) { SCMSNotificationLog::instance()->pushError("Попытка добавить элемент в несуществующую галерею."); } if (!SCMSNotificationLog::instance()->hasProblems()) { /** @var GalleryItem $oGalleryItem */ $oGalleryItem = DataSource::factory(GalleryItem::cls(), $galleryItemId == 0 ? null : $galleryItemId); $oGalleryItem->name = $name; $oGalleryItem->description = $description; $oGalleryItem->path = $path; $oGalleryItem->gallery_id = $oGallery->id; $oGalleryItem->position = $position; $oGalleryItem->commit(); SCMSNotificationLog::instance()->pushMessage("Элемент \"{$oGalleryItem->name}\" успешно " . ($galleryItemId == 0 ? "добавлен в галерею \"{$oGalleryItem->getGallery()->name}\"" : 'отредактирован') . '.'); $redirect = ''; if (Param::post('gallery-item-edit-accept', false)->exists()) { $redirect = "/admin/modules/gallery/item/?gallery_id={$oGalleryItem->gallery_id}"; } elseif ($galleryItemId == 0) { $redirect = "/admin/modules/gallery/item/edit/?id={$oGalleryItem->getPrimaryKey()}"; } $this->Response->send($redirect); } else { $this->Response->send(); } }
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(); }
public function actionIndex() { $this->needAuthenticate(); $pageId = Param::post('page-edit-id', false)->asInteger(false); $name = Param::post('page-edit-name')->noEmpty('Поле "Наименование" должно быть заполнено.')->asString(); $description = Param::post('page-edit-description')->asString(); $content = Param::post('page-edit-content')->asString(); $active = (bool) Param::post('page-edit-active')->exists(); if (!SCMSNotificationLog::instance()->hasProblems()) { /** @var Page $oPage */ $oPage = DataSource::factory(Page::cls(), $pageId == 0 ? null : $pageId); $oPage->name = $name; $oPage->description = $description; $oPage->content = $content; $oPage->active = $active; if (!$oPage->getPrimaryKey()) { $oPage->deleted = false; } $oPage->commit(); SCMSNotificationLog::instance()->pushMessage("Страница \"{$oPage->name}\" успешно " . ($pageId == 0 ? 'добавлена' : 'отредактирована') . '.'); $redirect = ''; if (Param::post('page-edit-accept', false)->exists()) { $redirect = '/admin/modules/pages/'; } elseif ($pageId == 1) { $redirect = "/admin/modules/pages/edit/?id={$oPage->getPrimaryKey()}"; } $this->Response->send($redirect); } else { $this->Response->send(); } }
public function actionIndex() { $this->needAuthenticate(); $galleryId = Param::post('gallery-edit-id', false)->asInteger(false); $name = Param::post('gallery-edit-name')->noEmpty('Поле "Название" должно быть заполнено.')->asString(); $description = Param::post('gallery-edit-description')->asString(); if (!SCMSNotificationLog::instance()->hasProblems()) { /** @var Gallery $oGallery */ $oGallery = DataSource::factory(Gallery::cls(), $galleryId == 0 ? null : $galleryId); $oGallery->name = $name; $oGallery->description = $description; $oGallery->deleted = false; $oGallery->commit(); SCMSNotificationLog::instance()->pushMessage("Галерея \"{$oGallery->name}\" успешно " . ($galleryId == 0 ? 'добавлена' : 'отредактирована') . '.'); $redirect = ''; if (Param::post('gallery-edit-accept', false)->exists()) { $redirect = '/admin/modules/gallery/'; } elseif ($galleryId == 0) { $redirect = "/admin/modules/gallery/edit/?id={$oGallery->getPrimaryKey()}"; } $this->Response->send($redirect); } else { $this->Response->send(); } }
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(); } }
public function actionItem() { if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) { SCMSNotificationLog::instance()->pushError('Нет доступа!'); $this->Response->send(); return; } $this->needAuthenticate(); $categoryId = Param::post('catalogue-item-id', false)->asInteger(false); $name = Param::post('catalogue-item-name')->noEmpty('Заполните поле "Наименование"')->asString(); $description = Param::post('catalogue-item-description')->asString(); $parentCategoryId = Param::post('catalogue-item-parent_id')->asInteger(true, 'Поле "Родительская категория" заполнено неверно.'); $price = Param::post('catalogue-item-price', true)->asNumber(true, "Поле \"Цена\" заполнено неверно."); $count = Param::post('catalogue-item-count', true)->asInteger(true, "Поле \"Количество\" заполнено неверно."); $thumbnail = Param::post('catalogue-item-thumbnail', false)->asString(); $priority = Param::post('catalogue-item-priority', false)->asString(); $active = (int) Param::post('catalogue-item-active', false)->exists(); $accept = Param::post('catalogue-item-accept', false); if (CoreFunctions::isAJAX() && SCMSNotificationLog::instance()->hasProblems()) { $this->Response->send(); return; } /** @var Item $oItem */ $oItem = DataSource::factory(Item::cls(), $categoryId == 0 ? null : $categoryId); $oItem->name = $name; $oItem->description = $description; $oItem->category_id = $parentCategoryId; $oItem->price = $price; $oItem->count = $count; $oItem->thumbnail = $thumbnail; $oItem->priority = $priority; $oItem->active = $active; if ($oItem->isNew()) { $oItem->deleted = false; } $oItem->commit(); if (!SCMSNotificationLog::instance()->hasProblems()) { SCMSNotificationLog::instance()->pushMessage("Позиция \"{$oItem->name}\" успешно " . ($categoryId == 0 ? 'добавлена' : 'отредактирована') . "."); } $redirect = "/admin/modules/catalogue/edit/?id={$oItem->getPrimaryKey()}"; if ($accept->exists()) { $redirect = '/admin/modules/catalogue/' . ($oItem->category_id == 0 ? '' : "?parent_pk={$oItem->category_id}"); } elseif ($categoryId != 0) { $redirect = ''; } $this->Response->send($redirect); }
public function actionIndex() { if (!Param::post('employee-authorization-form-sign-in', false)->exists()) { SCMSNotificationLog::instance()->pushError('Форма авторизации заполнена неверно'); $this->Response->send(); exit; } $email = Param::post('employee-authorization-form-email')->noEmpty('Заполните Email.')->asEmail(true, 'Недопустимый Email.'); $password = Param::post('employee-authorization-form-password')->noEmpty('Заполните пароль.')->asString(true, 'Недопустимый пароль.'); $redirect = ''; if ($this->EmployeeAuthentication->signIn($email, $password)) { $redirect = '/admin'; } else { SCMSNotificationLog::instance()->pushError('Неверно указан email или пароль.'); } $this->Response->send($redirect); }
public function actionIndex() { if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) { SCMSNotificationLog::instance()->pushError('Нет доступа!'); $this->Response->send(); return; } $this->needAuthenticate(); $frameName = Param::post('frame-name')->asString(); $frameContent = Param::post('frame-content')->asString(); $FrameFile = new File(SFW_MODULES_FRAMES . $frameName); $isNew = !$FrameFile->exists(); $FrameFile->setContent($frameContent); if (Param::post('frame-accept', false)->exists()) { $redirect = '/admin/modules/frames/'; } else { $redirect = $isNew ? "/admin/modules/frames/edit/?name={$frameName}" : ''; } SCMSNotificationLog::instance()->pushMessage("Фрейм \"{$frameName}\" успешно " . ($isNew ? 'создан' : 'отредактирован') . '!'); $this->Response->send($redirect); }
protected function saveStructureSettings(Structure $oStructure) { /** @var Module $oModule */ $oModule = $oStructure->getModule(); /** @var ModuleSetting[] $aModuleSettings */ $aModuleSettings = $oModule->getModuleSettings(); foreach ($aModuleSettings as $oModuleSetting) { /** @var StructureSetting $oStructureSettings */ $oStructureSettings = DataSource::factory(StructureSetting::cls()); $oStructureSettings->builder()->where("module_setting_id={$oModuleSetting->id}")->whereAnd()->where("structure_id={$oStructure->id}"); /** @var StructureSetting[] $aStructureSettings */ $aStructureSettings = $oStructureSettings->findAll(); if (!empty($aStructureSettings)) { $oStructureSetting = $aStructureSettings[0]; $oStructureSetting->value = is_null($oModuleSetting->entity) ? (string) Param::post($oModuleSetting->parameter, false)->asString() : (string) Param::post($oModuleSetting->parameter, false)->asInteger(); $oStructureSetting->commit(); } else { /** @var StructureSetting $oNewStructureSetting */ $oNewStructureSetting = DataSource::factory(StructureSetting::cls()); $oNewStructureSetting->structure_id = $oStructure->id; $oNewStructureSetting->module_setting_id = $oModuleSetting->id; $oNewStructureSetting->value = is_null($oModuleSetting->entity) ? Param::post($oModuleSetting->parameter)->asString() : Param::post($oModuleSetting->parameter)->asInteger(); $oNewStructureSetting->commit(); } } }
public function actionIndex() { if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) { SCMSNotificationLog::instance()->pushError('Нет доступа!'); $this->Response->send(); return; } $this->needAuthenticate(); $siteuserAuthorizator = new Authorizator(); $siteuserId = Param::post('siteuser-edit-id', false)->asInteger(false); $name = Param::post('siteuser-edit-name')->noEmpty('Заполните поле "Имя"')->asString(); $surname = Param::post('siteuser-edit-surname')->noEmpty('Заполните поле "Фамилия"')->asString(); $patronymic = Param::post('siteuser-edit-patronymic')->noEmpty('Заполните поле "Отчество"')->asString(); $email = Param::post('siteuser-edit-email')->noEmpty('Заполните поле "E-mail"')->asEmail(true, 'Вы ввели некорректный email.'); $phone = Param::post('siteuser-edit-phone')->noEmpty('Заполните поле "Телефон"')->asString(); $postcode = Param::post('siteuser-edit-postcode')->noEmpty('Заполните поле "Индекс"')->asString(); $address = Param::post('siteuser-edit-address', false)->noEmpty('Заполните поле "Адрес"')->asString(); $type = Param::post('siteuser-edit-type', false)->noEmpty('Необходимо указать тип пользователя')->asInteger(true, 'Недопустимое значение поля "Тип"'); $status = Param::post('siteuser-edit-status', false)->noEmpty('Необходимо указать статус пользователя')->asInteger(true, 'Недопустимое значение поля "Статус"'); $active = (bool) Param::post('siteuser-edit-active')->exists(); $accept = Param::post('siteuser-edit-accept', false); if (!in_array($type, [Siteuser::TYPE_USER, Siteuser::TYPE_CONTRACTOR])) { SCMSNotificationLog::instance()->pushError('Недопустимое значение поля "Тип".'); } if (!in_array($status, [Siteuser::STATUS_UNCONFIRMED, Siteuser::STATUS_CONFIRMED, Siteuser::STATUS_DENIED])) { SCMSNotificationLog::instance()->pushError('Недопустимое значение поля "Статус".'); } $oSiteusers = DataSource::factory(Siteuser::cls()); $oSiteusers->builder()->where("deleted=0")->whereAnd()->whereBracketOpen()->where("email='{$email}'")->whereOr()->where("phone='{$phone}'")->whereBracketClose(); /** @var Siteuser[] $aSiteusers */ $aSiteusers = $oSiteusers->findAll(); if (!empty($aSiteusers)) { $oSiteuser = $aSiteusers[0]; if ($oSiteuser->email == $email) { SCMSNotificationLog::instance()->pushError('Пользователь с таким Email уже зарегистрирован в системе.'); } if ($oSiteuser->phone == $phone) { SCMSNotificationLog::instance()->pushError('Пользователь с таким телефоном уже зарегистрирован в системе.'); } } if (CoreFunctions::isAJAX() && SCMSNotificationLog::instance()->hasProblems()) { $this->Response->send(); return; } /** @var Siteuser $oSiteuser */ $oSiteuser = DataSource::factory(Siteuser::cls(), $siteuserId); $oSiteuser->name = $name; $oSiteuser->surname = $surname; $oSiteuser->patronymic = $patronymic; $oSiteuser->email = $email; $oSiteuser->phone = $phone; $oSiteuser->postcode = $postcode; $oSiteuser->mail_address = $address; $oSiteuser->password = $siteuserAuthorizator->defaultPassword(); $oSiteuser->type = $type; $oSiteuser->status = $status; $oSiteuser->active = $active; if ($oSiteuser->isNew()) { $oSiteuser->deleted = false; } try { $oSiteuser->commit(); } catch (Exception $e) { SCMSNotificationLog::instance()->pushError($e->getMessage()); } $redirect = ''; if (!SCMSNotificationLog::instance()->hasProblems()) { SCMSNotificationLog::instance()->pushMessage("Пользователь \"{$oSiteuser->email}\" успешно " . ($siteuserId == 0 ? 'добавлен' : 'отредактирован') . "."); $redirect = "/admin/modules/siteusers/edit/?id={$oSiteuser->getPrimaryKey()}"; if ($accept->exists()) { $redirect = '/admin/modules/siteusers/'; } } $this->Response->send($redirect); }