Пример #1
0
 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();
     }
 }
Пример #2
0
 public function getCurrentUser()
 {
     if (isset($_SESSION['siteuser']) && is_null($this->currentUser)) {
         $this->currentUser = DataSource::factory(Siteuser::cls(), $_SESSION['siteuser']);
     }
     return $this->currentUser;
 }
Пример #3
0
 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();
 }
Пример #4
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::get('gallery_id')->asInteger(true, 'Недопустимое значение номера галереи.');
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if (!$oGallery) {
         SCMSNotificationLog::instance()->pushError("Запрошенная галерея с номером \"{$galleryId}\" не существует.");
         $this->Frame->render();
         return;
     }
     $pageNumber = Param::get('gallery-item-page', false)->asInteger(false);
     $itemsPerPage = Param::get('gallery-item-items-per-page', false)->asInteger(false);
     $manifest = $this->ModuleInstaller->getManifest($this->ModuleDirectory);
     $dataGridView = new ViewDataGrid();
     $retriever = new GalleryRetriever();
     $dataGrid = new DataGrid('item', '', 'id', $manifest['meta']['alias'], $pageNumber, $itemsPerPage, $manifest['meta']['description']);
     $dataGrid->getMenu()->addElement(new Item('Добавить элемент', "/admin/modules/gallery/item/edit/?gallery_id={$oGallery->id}"));
     $dataGrid->addAction(new Action('id', "/admin/modules/gallery/item/edit/?gallery_id={$oGallery->id}", 'edit', '', [], ['class' => 'glyphicon glyphicon-pencil'], 'Редактировать'))->addAction(new Action('id', '/admin/modules/gallery/item/delete/', 'delete', '', [], ['class' => 'glyphicon glyphicon-trash'], 'Удалить', true));
     $dataGrid->addHeader(new Header('id', '№', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('item-filter-id', false)->asString(false)))->addHeader(new Header('name', 'Название', null, ['class' => 'text-center', 'style' => 'width: 250px;'], [], true, Param::get('item-filter-name', false)->asString(false)))->addHeader(new Header('description', 'Описание', new ViewCutString(20, true, ['class' => 'content-to-modal', 'style' => 'cursor: pointer;'], ['style' => 'display: none;']), ['class' => 'text-center'], ['class' => 'modal-display-field'], true, Param::get('item-filter-description', false)->asString(false)))->addHeader(new Header('path', 'Миниатюра', new ViewCondition(new ViewImageLink(true, ['class' => 'fancybox'], ['class' => 'img-rounded', 'style' => 'height: 20px;']), [['field' => 'path', 'value' => '/public/assets/images/system/no-image.svg', 'view' => new ViewStub('<span class="glyphicon glyphicon-picture"></span>')]]), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center']))->addHeader(new Header('position', 'Позиция', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('item-filter-position', false)->asString(false)));
     $galleries = $retriever->getGalleryItems($oGallery, $dataGrid->getFilterConditions(), $dataGrid->Pagination->getLimit(), $dataGrid->Pagination->getOffset());
     $dataSet = new ArrayDataSet($galleries);
     $dataGrid->addDataSet($dataSet);
     $dataGridView->dataGrid = $dataGrid;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Галереи', '/modules/gallery'), new Breadcrumb("Элементы галереи \"{$oGallery->name}\"", '')];
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $dataGridView);
     $this->Frame->render();
 }
Пример #5
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryItemId = Param::get('id', false)->asInteger(false);
     $galleryId = Param::get('gallery_id')->asInteger(true, 'Недопустимое значение номера галереи.');
     /** @var GalleryItem $oGalleryItem */
     $oGalleryItem = DataSource::factory(GalleryItem::cls(), $galleryItemId);
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if ($oGalleryItem->isNew() && $oGallery->isNew()) {
         SCMSNotificationLog::instance()->pushError('Недопустимое значение параметра!');
         $this->Frame->render();
         return;
     }
     $view = new ViewEditForm();
     $view->GalleryItem = $oGalleryItem;
     $view->Gallery = $oGallery;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Галереи', '/modules/gallery'), new Breadcrumb("Галерея \"{$oGallery->name}\"", "/item/?gallery_id={$oGallery->id}")];
     if ($oGalleryItem->id !== null) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oGalleryItem->name}\"", '');
     } else {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb('Добавление нового элемента галереи', '');
     }
     $view->backUrl = CoreFunctions::buildUrlByBreadcrumbs($viewBreadcrumbs->Breadcrumbs, 1);
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }
Пример #6
0
 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();
     }
 }
Пример #7
0
 public function actionIndex()
 {
     if (CoreFunctions::isAJAX()) {
         if (!$this->EmployeeAuthentication->authenticated()) {
             SCMSNotificationLog::instance()->pushError('Нет доступа.');
             $this->Response->send();
             return;
         }
     } else {
         $this->needAuthenticate();
     }
     $siteuserId = Param::get('id')->noEmpty('Параметр обязателен для заполнения.')->asInteger(true, "Неверно задан параметр.");
     /** @var Siteuser $oSiteuser */
     $oSiteuser = DataSource::factory(Siteuser::cls(), $siteuserId);
     if ($oSiteuser->id) {
         $oSiteuser->deleted = true;
         try {
             $oSiteuser->commit();
             SCMSNotificationLog::instance()->pushMessage("Пользователь \"{$oSiteuser->name}\" успешно удалён.");
         } catch (Exception $e) {
             SCMSNotificationLog::instance()->pushError($e->getMessage());
         }
     } else {
         SCMSNotificationLog::instance()->pushError("Пользователь с ID {$siteuserId} не найден");
     }
     $this->Response->send();
 }
Пример #8
0
 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();
     }
 }
Пример #9
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $isCategory = Param::get('is_category')->asInteger(true, "Недопустимое значение параметра.");
     $id = Param::get('id', false)->asInteger(false);
     $parentId = Param::get('parent_pk', false)->asInteger(false);
     /** @var Category $oCategories */
     $oCategories = DataSource::factory(Category::cls());
     $oCategories->builder()->where('deleted=0');
     /** @var Category[] $aCategories */
     $aCategories = $oCategories->findAll();
     if ($isCategory == 1) {
         $viewCatalogueEdit = new ViewCategoryEdit();
         /** @var Category $oCategory */
         $oCategory = DataSource::factory(Category::cls(), $id);
         $viewCatalogueEdit->oCategory = $oCategory;
         $viewCatalogueEdit->aCategories = $aCategories;
         $viewCatalogueEdit->parentId = $oCategory->isNew() ? $parentId : $oCategory->category_id;
     } else {
         $viewCatalogueEdit = new ViewItemEdit();
         /** @var Item $oItem */
         $oItem = DataSource::factory(Item::cls(), $id);
         $viewCatalogueEdit->oItem = $oItem;
         $viewCatalogueEdit->aCategories = $aCategories;
         $viewCatalogueEdit->parentId = $oItem->isNew() ? $parentId : $oItem->category_id;
     }
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Каталог', '/modules/catalogue')];
     if ($parentId) {
         $breadcrumbsParentPK = $parentId;
     } elseif ($isCategory == 1 && isset($oCategory)) {
         $breadcrumbsParentPK = $oCategory->category_id;
     } elseif (!$isCategory && isset($oItem)) {
         $breadcrumbsParentPK = $oItem->category_id;
     } else {
         $breadcrumbsParentPK = 0;
     }
     $catalogueEditBreadcrumbs = [];
     while ($breadcrumbsParentPK) {
         /** @var Category $oParentCategory */
         $oParentCategory = DataSource::factory(Category::cls(), $breadcrumbsParentPK);
         $catalogueEditBreadcrumbs[] = new Breadcrumb($oParentCategory->name, "?parent_pk={$oParentCategory->getPrimaryKey()}", true);
         $breadcrumbsParentPK = $oParentCategory->category_id;
     }
     $viewBreadcrumbs->Breadcrumbs = array_merge($viewBreadcrumbs->Breadcrumbs, array_reverse($catalogueEditBreadcrumbs));
     if ($id && isset($oCategory)) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oCategory->name}\"", '');
     } elseif ($id && isset($oItem)) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oItem->name}\"", '');
     } else {
         $lastBreadcrumb = 'Добавление новой ' . ($isCategory == 1 ? 'категории' : 'позиции');
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb($lastBreadcrumb, '');
     }
     $viewCatalogueEdit->backUrl = CoreFunctions::buildUrlByBreadcrumbs($viewBreadcrumbs->Breadcrumbs, 1);
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $viewCatalogueEdit);
     $this->Frame->render();
 }
Пример #10
0
 public function setItemCount($catalogueItemId, $count)
 {
     /** @var Item $oCatalogueItem */
     $oCatalogueItem = DataSource::factory(Item::cls(), $catalogueItemId);
     if ($oCatalogueItem) {
         $_SESSION[self::SESSION_SECTION_NAME][$oCatalogueItem->getPrimaryKey()] = $count;
     }
 }
Пример #11
0
 /**
  * @param int $parentStructureId
  *
  * @return Structure[]
  */
 protected function getStructuresByParentId($parentStructureId = 0)
 {
     $oStructures = DataSource::factory(Structure::cls());
     $oStructures->builder()->where("structure_id={$parentStructureId}")->whereAnd()->where("active=1")->order('priority');
     /** @var Structure[] $aStructures */
     $aStructures = $oStructures->findAll();
     return $aStructures;
 }
Пример #12
0
 public function actionIndex()
 {
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $this->gallery_id);
     $view = new MainView();
     $view->displayType = $this->gallery_display_type;
     $view->oGallery = $oGallery;
     $view->oStructure = $this->oStructure;
     $view->render();
 }
Пример #13
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $structureId = Param::get('id')->asInteger();
     /** @var Structure $oStructure */
     $oStructure = DataSource::factory(Structure::cls(), $structureId);
     $name = $oStructure->name;
     $this->deepDelete($oStructure);
     SCMSNotificationLog::instance()->pushMessage("Структура \"{$name}\" успешно удалена.");
     $this->Response->send();
 }
Пример #14
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  *
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     /** @var NotificationLog $oSCMSNotificationLog */
     $oSCMSNotificationLog = DataSource::factory(NotificationLog::cls());
     $oSCMSNotificationLog->code = 0;
     $oSCMSNotificationLog->type = $level;
     $oSCMSNotificationLog->message = addslashes(trim(strtr($message, $context)));
     $oSCMSNotificationLog->ip = $_SERVER["REMOTE_ADDR"];
     $oSCMSNotificationLog->date = date('Y-m-d H:i:s');
     $oSCMSNotificationLog->commit();
 }
Пример #15
0
 public function actionIndex()
 {
     $view = new ViewPage();
     if ($this->page_id != 0) {
         /** @var Page $oPage */
         $oPage = DataSource::factory(Page::cls(), $this->page_id);
         $view->page = $oPage;
         $view->render();
     } else {
         echo 'Страница не назначена.';
     }
 }
Пример #16
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $this->Frame->addCss('\\public\\assets\\css\\edit-form.css');
     $this->Frame->addCss('\\public\\assets\\css\\main-menu.css');
     $moduleId = Param::get('pk')->asInteger();
     $view = new ViewModuleShow();
     $module = DataSource::factory(Module::cls(), $moduleId);
     $view->module = $module;
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }
Пример #17
0
 public function getPath(Structure $oStructure)
 {
     $path = [];
     /** @var Structure $oCurrentStructure */
     $oCurrentStructure = $oStructure;
     $path[] = ucfirst($oCurrentStructure->path);
     while ($oCurrentStructure->structure_id != 0) {
         $oCurrentStructure = DataSource::factory(Structure::cls(), $oCurrentStructure->structure_id);
         $path[] = ucfirst($oCurrentStructure->path);
     }
     return implode('\\', array_reverse($path));
 }
Пример #18
0
 public function getSiteusers($conditions = '', $limit = null, $offset = null)
 {
     $driver = DataSource::getCurrent();
     $sql = 'SELECT
       SQL_CALC_FOUND_ROWS
       *
     FROM
       siteuser
     WHERE
       deleted = 0' . (!empty($conditions) ? " and {$conditions}" : '') . (is_null($limit) ? '' : " limit {$limit}") . (is_null($offset) ? '' : " offset {$offset}");
     $driver->query($sql);
     return $driver->fetchAssoc();
 }
Пример #19
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryItemId = Param::get('id')->noEmpty('Не задан обязательный параметр.')->asInteger(true, 'Параметр должен быть числом.');
     /** @var GalleryItem $oGalleryItem */
     $oGalleryItem = DataSource::factory(GalleryItem::cls(), $galleryItemId);
     if (is_null($oGalleryItem) || !$oGalleryItem->getPrimaryKey()) {
         SCMSNotificationLog::instance()->pushError('Элемент галереи не найден.');
     } else {
         SCMSNotificationLog::instance()->pushMessage("Элемент \"{$oGalleryItem->name}\" галереи {$oGalleryItem->getGallery()->name} успешно удален.");
         $oGalleryItem->delete();
     }
     $this->Response->send();
 }
Пример #20
0
 public function getModules()
 {
     /** @var Module[] $aModules */
     $aModules = $this->findRelationCache($this->getPrimaryKeyName(), Module::cls());
     if (empty($aModules)) {
         $oModules = DataSource::factory(Module::cls());
         $oModules->builder()->where("module_id={$this->getPrimaryKey()}");
         $aModules = $oModules->findAll();
         foreach ($aModules as $oModule) {
             $this->addRelationCache($this->getPrimaryKeyName(), $oModule);
             $oModule->addRelationCache('module_id', $this);
         }
     }
 }
Пример #21
0
 public function getCategory()
 {
     /** @var Category[] $aCategories */
     $aCategories = $this->findRelationCache('category_id', Category::cls());
     if (empty($aCategories)) {
         $oCategories = DataSource::factory(Category::cls());
         $oCategories->builder()->where("{$oCategories->getPrimaryKeyName()}={$this->category_id}");
         $aCategories = $oCategories->findAll();
         foreach ($aCategories as $oCategory) {
             $this->addRelationCache('category_id', $oCategory);
             $oCategory->addRelationCache($oCategory->getPrimaryKeyName(), $this);
         }
     }
     return isset($aCategories[0]) ? $aCategories[0] : null;
 }
Пример #22
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();
 }
Пример #23
0
 public function getItems()
 {
     /** @var Item[] $aItems */
     $aItems = $this->findRelationCache($this->getPrimaryKeyName(), Item::cls());
     if (empty($aItems)) {
         $oItems = DataSource::factory(Item::cls());
         $oItems->builder()->where("category_id={$this->getPrimaryKey()}");
         $aItems = $oItems->findAll();
         foreach ($aItems as $oItem) {
             $this->addRelationCache($this->getPrimaryKeyName(), $oItem);
             $oItem->addRelationCache('category_id', $this);
         }
     }
     return $aItems;
 }
Пример #24
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();
 }
Пример #25
0
 public function getModuleSetting()
 {
     /** @var ModuleSetting[] $aModuleSettings */
     $aModuleSettings = $this->findRelationCache('module_setting_id', ModuleSetting::cls());
     if (empty($aModuleSettings)) {
         $oModuleSettings = DataSource::factory(ModuleSetting::cls());
         $oModuleSettings->builder()->where("{$oModuleSettings->getPrimaryKeyName()}={$this->module_setting_id}");
         $aModuleSettings = $oModuleSettings->findAll();
         foreach ($aModuleSettings as $oModuleSetting) {
             $this->addRelationCache('module_setting_id', $oModuleSetting);
             $oModuleSetting->addRelationCache($oModuleSetting->getPrimaryKeyName(), $this);
         }
     }
     return isset($aModuleSettings[0]) ? $aModuleSettings[0] : null;
 }
Пример #26
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $view = new ViewConfiguration();
     /** @var NotificationLog $oNotificationLogs */
     $oNotificationLogs = DataSource::factory(NotificationLog::cls());
     /** @var NotificationLog[] $aNotificationLogs */
     $aNotificationLogs = $oNotificationLogs->findAll();
     $DataGrid = new DataGrid();
     $DataGrid->setCaption('Список параметров')->setAttributes(['class' => 'table table-bordered table-hover table-striped'])->addColumn((new Column())->setDisplayName('#')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->switchOnCounter())->addColumn((new Column())->setDisplayName('Тип')->setValueName('type')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setCallback(function (NotificationLog $data) {
         echo $data->type;
     }))->addColumn((new Column())->setDisplayName('Сообщение')->setValueName('message')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['class' => 'text-justify']))->addColumn((new Column())->setDisplayName('IP-адрес')->setValueName('ip')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;']))->setDataSet($aNotificationLogs);
     $view->DataGrid = $DataGrid;
     $this->getFrame()->bindView('content', $view)->render();
 }
Пример #27
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $pageId = Param::get('id')->noEmpty('Не задан обязательный параметр.')->asInteger(true, 'Параметр должен быть числом.');
     /** @var Page $oPage */
     $oPage = DataSource::factory(Page::cls(), $pageId);
     if (is_null($oPage) || !$oPage->getPrimaryKey()) {
         SCMSNotificationLog::instance()->pushError('Статическая страница не найдена.');
     } else {
         SCMSNotificationLog::instance()->pushMessage("Страница \"{$oPage->name}\" успешно удалена.");
         $oPage->deleted = true;
         $oPage->commit();
     }
     $this->Response->send();
 }
Пример #28
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();
     }
 }
Пример #29
0
 public function getGalleryItems($orderFieldName = 'id', $order = 'asc')
 {
     /** @var GalleryItem[] $aGalleryItems */
     $aGalleryItems = $this->findRelationCache($this->getPrimaryKeyName(), GalleryItem::cls());
     if (empty($aGalleryItems)) {
         /** @var GalleryItem $oGalleryItems */
         $oGalleryItems = DataSource::factory(GalleryItem::cls());
         $oGalleryItems->builder()->where("gallery_id={$this->getPrimaryKey()}")->order($orderFieldName, $order);
         $aGalleryItems = $oGalleryItems->findAll();
         foreach ($aGalleryItems as $oGalleryItem) {
             $this->addRelationCache($this->getPrimaryKeyName(), $oGalleryItem);
             $oGalleryItem->addRelationCache('gallery_id', $this);
         }
     }
     return $aGalleryItems;
 }
Пример #30
0
 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);
 }