Beispiel #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();
     }
 }
Beispiel #2
0
function dbg_last_error()
{
    $e = error_get_last();
    if ($e['type'] & E_COMPILE_ERROR || $e['type'] & E_ERROR || $e['type'] & E_CORE_ERROR || $e['type'] & E_RECOVERABLE_ERROR) {
        SCMSNotificationLog::instance()->DBLogger->critical("{$e['type']} | {$e['message']} | {$e['file']} | {$e['line']}");
    }
}
Beispiel #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();
 }
Beispiel #4
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();
 }
Beispiel #5
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();
     }
 }
Beispiel #6
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();
 }
Beispiel #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();
 }
Beispiel #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();
     }
 }
Beispiel #9
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();
 }
Beispiel #10
0
 public function getManifest(Directory $ModuleDirectory)
 {
     if (!$ModuleDirectory) {
         SCMSNotificationLog::instance()->pushError("Модуль \"{$ModuleDirectory->getName()}\" не найден.");
         return null;
     }
     $ManifestFile = $ModuleDirectory->getFile('manifest.php');
     if (!$ManifestFile || !$ManifestFile->exists()) {
         throw new Exception("Манифест модуля \"{$ModuleDirectory->getName()}\" не найден.");
     }
     return include $ManifestFile->getPath();
 }
Beispiel #11
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();
 }
Beispiel #12
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();
 }
Beispiel #13
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();
 }
Beispiel #14
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();
     }
 }
 public function __construct($ModuleDirectory = null)
 {
     $this->ModuleDirectory = $ModuleDirectory;
     $this->ModuleInstaller = new ModuleInstaller();
     $this->Response = new Response(SCMSNotificationLog::instance());
     $this->config = Registry::get('config');
     $this->Frame = Registry::frame('back');
     $this->Router = Registry::router();
     $this->EmployeeAuthentication = new Authentication();
     $this->HTTPEmployeeAuthentication = new HttpAuthentication();
     $this->Frame->addCss('/public/assets/js/fancybox2/source/jquery.fancybox.css');
     $this->Frame->bindView('menu', $this->buildMenu());
     $this->Frame->bindView('modal-notification', new ViewNotificationsModal());
     $this->Frame->bindView('modal-confirmation', new ViewConfirmationModal());
     $this->Frame->bindView('modal-information', new ViewInformationModal());
 }
Beispiel #16
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $parentCategoryId = Param::get('parent_pk', false);
     if ($parentCategoryId->exists()) {
         $parentCategoryId = $parentCategoryId->asInteger(true, 'Недопустимое значение параметра!');
         /** @var Category $oParentCategoryFact */
         $oParentCategoryFact = DataSource::factory(Category::cls(), $parentCategoryId);
         if ($oParentCategoryFact->isNew()) {
             SCMSNotificationLog::instance()->pushError('Недопустимое значение параметра!');
             $this->Frame->render();
             return;
         }
     } else {
         $parentCategoryId = 0;
     }
     $pageNumber = Param::get('catalogue-page', false)->asInteger(false);
     $itemsPerPage = Param::get('catalogue-items-per-page', false)->asInteger(false);
     $manifest = $this->ModuleInstaller->getManifest($this->ModuleDirectory);
     $dataGridView = new ViewDataGrid();
     $retriever = new CatalogueRetriever();
     $dataGrid = new DataGrid('catalogue', '/admin/modules/catalogue/', 'id', $manifest['meta']['alias'], $pageNumber, $itemsPerPage, $manifest['meta']['description']);
     $dataGrid->addHiddenField('parent_pk', $parentCategoryId);
     $dataGrid->getMenu()->addElement(new DataGrid\Menu\Item('Добавить категорию', '/admin/modules/catalogue/edit/?is_category=1' . ($parentCategoryId ? "&parent_pk={$parentCategoryId}" : '')))->addElement(new DataGrid\Menu\Item('Добавить позицию', '/admin/modules/catalogue/edit/?is_category=0' . ($parentCategoryId ? "&parent_pk={$parentCategoryId}" : '')));
     $dataGrid->addAction(new Action('id', '/admin/modules/catalogue/edit/', 'edit', '', ['is_category'], ['class' => 'glyphicon glyphicon-pencil'], 'Редактировать'))->addAction(new Action('id', '/admin/modules/catalogue/delete/', 'delete', '', ['is_category'], ['class' => 'glyphicon glyphicon-trash'], 'Удалить', true));
     $dataGrid->addHeader(new Header('id', '№', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('catalogue-filter-id', false)->asString(false)))->addHeader(new Header('is_category', 'Тип', new ViewChange('', [[0, '<span class="glyphicon glyphicon-file"></span>'], [1, '<span class="glyphicon glyphicon-folder-open"></span>']]), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('catalogue-filter-is_category', false)->asString(false)))->addHeader(new Header('name', 'Наименование', new ViewCondition(new ViewDefault(), [['field' => 'is_category', 'value' => 1, 'view' => new ViewLink('/admin/modules/catalogue/?parent_pk={label}', false, 'id')]]), ['class' => 'text-center'], [], true, Param::get('catalogue-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('catalogue-filter-description', false)->asString(false)))->addHeader(new Header('thumbnail', 'Миниатюра', new ViewCondition(new ViewImageLink(true, ['class' => 'fancybox'], ['class' => 'img-rounded', 'style' => 'height: 20px;']), [['field' => 'thumbnail', '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('price', '<span class="glyphicon glyphicon-ruble" title="Цена"></span>', new ViewMoney('<span class="glyphicon glyphicon-ruble"></span>'), ['class' => 'text-center'], ['class' => 'text-center'], true, Param::get('catalogue-filter-price', false)->asString(false)))->addHeader(new Header('count', '<span class="glyphicon glyphicon-inbox" title="Количество"></span>', null, ['class' => 'text-center'], ['class' => 'text-center'], true, Param::get('catalogue-filter-count', false)->asString(false)))->addHeader(new Header('priority', '<span class="glyphicon glyphicon-sort-by-attributes" title="Приоритет"></span>', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('catalogue-filter-priority', false)->asString(false)))->addHeader(new Header('active', '<span class="glyphicon glyphicon-asterisk" title="Активность"></span>', new ViewSwitch(), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('catalogue-filter-active', false)->asString(false)));
     $categoriesAndItems = $retriever->getCategoriesAndItems($parentCategoryId, $dataGrid->getFilterConditions('childs'), $dataGrid->Pagination->getLimit(), $dataGrid->Pagination->getOffset());
     $dataSet = new ArrayDataSet($categoriesAndItems);
     $dataGrid->addDataSet($dataSet);
     $dataGridView->dataGrid = $dataGrid;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Каталог', '/modules/catalogue')];
     $breadcrumbsParentPK = $parentCategoryId;
     $categoryBreadcrumbs = [];
     while ($breadcrumbsParentPK) {
         /** @var Category $oParentCategory */
         $oParentCategory = DataSource::factory(Category::cls(), $breadcrumbsParentPK);
         $categoryBreadcrumbs[] = new Breadcrumb($oParentCategory->name, "?parent_pk={$oParentCategory->getPrimaryKey()}", true);
         $breadcrumbsParentPK = $oParentCategory->category_id;
     }
     $viewBreadcrumbs->Breadcrumbs = array_merge($viewBreadcrumbs->Breadcrumbs, array_reverse($categoryBreadcrumbs));
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $dataGridView);
     $this->Frame->render();
 }
Beispiel #17
0
 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);
 }
Beispiel #18
0
 public function actionIndex()
 {
     if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) {
         SCMSNotificationLog::instance()->pushError('Нет доступа!');
         $this->Response->send();
         return;
     }
     $this->needAuthenticate();
     $frameName = Param::get('name', true)->asString(true, 'Недопустимое имя фрейма!');
     $FrameFile = new File(SFW_MODULES_FRAMES . $frameName);
     if (!$FrameFile->exists()) {
         SCMSNotificationLog::instance()->pushError("Фрейм с именем \"{$frameName}\" не найден!");
     }
     if (SCMSNotificationLog::instance()->hasProblems()) {
         $this->Response->send();
         return;
     }
     $oStructures = DataSource::factory(Structure::cls());
     $oStructures->builder()->where('deleted=0')->whereAnd()->where("frame='{$frameName}'");
     /** @var Structure[] $aStructures */
     $aStructures = $oStructures->findAll();
     if (sizeof($aStructures) > 0) {
         $structureNames = [];
         foreach ($aStructures as $oStructure) {
             $structureNames[] = $oStructure->name;
         }
         SCMSNotificationLog::instance()->pushError("Фрейм \"{$frameName}\" нельзя удалять, пока он используется в структуре сайта. На данный момент фрейм назначен разделам: \"" . implode('", "', $structureNames) . '"');
     }
     if (SCMSNotificationLog::instance()->hasProblems()) {
         $this->Response->send();
         return;
     }
     try {
         $FrameFile->delete();
     } catch (Exception $e) {
         SCMSNotificationLog::instance()->pushError('При удалении фрейма произошла ошибка.');
     }
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         SCMSNotificationLog::instance()->pushMessage("Фрейм \"{$frameName}\" успешно удалён.");
     }
     $this->Response->send();
 }
Beispiel #19
0
 public function actionAjaxModuleConfig()
 {
     $this->needAuthenticate();
     $structureId = Param::get('structure_id')->noEmpty('Пропущен обязательный параметр "structure_id".')->asInteger(true, '"structure_id" должен быть числом.');
     if ($structureId == 0) {
         SCMSNotificationLog::instance()->pushError("Не указана целевая структура.");
         $this->Response->send();
         exit;
     }
     $moduleId = Param::get('module_id')->noEmpty('Пропущен обязательный параметр "module_id".')->asInteger(true, '"structure_id" должен быть числом.');
     /** @var Structure $oStructure */
     $oStructure = DataSource::factory(Structure::cls(), $structureId);
     /** @var Module $oModule */
     $oModule = DataSource::factory(Module::cls(), $moduleId == 0 ? null : $moduleId);
     ob_start();
     $view = $this->getModuleConfigView($oStructure, $oModule);
     $view->render();
     $form = ob_get_clean();
     $this->Response->send('', ['form' => $form]);
 }
Beispiel #20
0
 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);
 }
Beispiel #21
0
 public function __construct(Frame $Frame, array $manifest, Structure $oStructure)
 {
     $this->Frame = $Frame;
     $this->oStructure = $oStructure;
     $this->Response = new Response(SCMSNotificationLog::instance());
     $this->BreadcrumbsView = new ViewBreadcrumbs();
     $this->BreadcrumbsView->Breadcrumbs = [];
     if (!$this->oStructure->is_main) {
         $this->BreadcrumbsView->Breadcrumbs = [new Breadcrumb('Главная', '/')];
         if (!$this->oStructure->anchor) {
             $this->BreadcrumbsView->Breadcrumbs[] = new Breadcrumb($this->oStructure->name, $this->oStructure->path);
         }
     }
     $this->cart = new Cart();
     $this->Frame->addCss('/public/assets/js/fancybox2/source/jquery.fancybox.css');
     $this->Frame->bindView('breadcrumbs', $this->BreadcrumbsView);
     $this->Frame->bindView('modal-notification', new ViewNotificationsModal());
     $this->Frame->bindView('modal-confirmation', new ViewConfirmationModal());
     $this->Frame->bindView('modal-information', new ViewInformationModal());
     $this->Frame->bindView('modal-catalogue-cart', new ViewCartModal());
     $this->Frame->bindData('catalogue-cart-total-count', $this->cart->getTotalCount());
 }
Beispiel #22
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);
 }
Beispiel #23
0
 public function actionGroup()
 {
     // TODO: Реализовать групповое удаление
     SCMSNotificationLog::instance()->pushMessage('Данная функция отключена в связи с техническими работами.');
     $this->Response->send();
 }
Beispiel #24
0
 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);
 }
Beispiel #25
0
    public function actionIndex()
    {
        $action = Param::request('action', false)->asString(false);
        $categoryId = 0;
        switch ($action) {
            case 'show-item':
                $itemId = Param::get('item_id', false)->asInteger(false);
                /** @var Item $oItem */
                $oItem = DataSource::factory(Item::cls(), $itemId);
                $view = new ViewItem();
                if (!$oItem->isNew()) {
                    $categoryId = $oItem->category_id;
                    $view->oItem = $oItem;
                } else {
                    SCMSNotificationLog::instance()->pushError("Товар не найден.");
                }
                break;
            case 'add-to-cart':
                $id = Param::get('id', true)->noEmpty('Товар не найден.')->asInteger(true, 'Неизвестный товар.');
                $count = Param::get('count', true)->noEmpty('Количество должно быть указано.')->asInteger(true, 'Не указано количество товара.');
                /** @var Item $oItem */
                $oItem = DataSource::factory(Item::cls(), $id);
                if (!$oItem) {
                    SCMSNotificationLog::instance()->pushError('Товар, который Вы пытаетесь добавить в корзину не существует.');
                }
                if (!$count) {
                    SCMSNotificationLog::instance()->pushError('Количество товара должно быть больше нуля.');
                }
                if (SCMSNotificationLog::instance()->hasProblems()) {
                    $this->Response->send();
                    return;
                }
                $this->cart->addItem($id, $count);
                SCMSNotificationLog::instance()->pushMessage("Товар \"{$oItem->name}\" в количестве {$count} (шт.) успешно добавлен в корзину. Теперь Вы можете перейти к оформлению заказа или продолжить покупки.");
                $this->Response->send('', ['totalCount' => $this->cart->getTotalCount()]);
                return;
                break;
            case 'show-cart':
                $view = new ViewCart();
                $cart = $this->cart;
                $DataGrid = new DataGrid();
                $aItemsInCart = $this->cart->getItems();
                $DataGrid->setCaption(empty($aItemsInCart) ? 'В Вашей корзине ещё нет ни одного товара' : 'Список товаров')->setAttributes(['class' => 'table table-condensed'])->addColumn((new Column())->setDisplayName('№')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['style' => 'text-align: center; vertical-align: middle;'])->switchOnCounter())->addColumn((new Column())->setDisplayName('Наименование')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setValueName('name'))->addColumn((new Column())->setDisplayName('Цена')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setFooterAttributes(['style' => 'text-align: center; vertical-align: middle;', 'class' => 'text-success'])->setCallback(function (Item $oItem) {
                    echo $oItem->price, '<span class="glyphicon glyphicon-ruble"></span>';
                })->setFooterCallback(function (array $aItems) {
                    ?>
Итого:<?php 
                }))->addColumn((new Column())->setDisplayName('Количество')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setFooterAttributes(['style' => 'text-align: center; vertical-align: middle;', 'class' => 'text-danger'])->setCallback(function (Item $oItem) use($cart) {
                    ?>
<input type="number" min="1" class="form-control input-sm text-center catalogue-item-count" value="<?php 
                    echo $cart->getCountById($oItem->getPrimaryKey());
                    ?>
" /><?php 
                })->setFooterCallback(function (array $aItems) use($cart) {
                    echo $cart->getTotalCount();
                }))->addColumn((new Column())->setDisplayName('Сумма')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setFooterAttributes(['style' => 'text-align: center; vertical-align: middle;', 'class' => 'text-danger'])->setCallback(function (Item $oItem) use($cart) {
                    echo $cart->getCountById($oItem->getPrimaryKey()) * $oItem->price, '<span class="glyphicon glyphicon-ruble"></span>';
                })->setFooterCallback(function (array $aItems) use($cart) {
                    /** @var Item[] $aItems */
                    $totalPrice = 0;
                    foreach ($aItems as $oItem) {
                        $totalPrice += $cart->getCountById($oItem->getPrimaryKey()) * $oItem->price;
                    }
                    echo $totalPrice, '<span class="glyphicon glyphicon-ruble"></span>';
                }))->addColumn((new Column())->setDisplayName('<span class="glyphicon glyphicon-option-horizontal"></span>')->setHeaderAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setBodyAttributes(['style' => 'text-align: center; vertical-align: middle;'])->setCallback(function (Item $oItem) {
                    echo '<a href="/catalogue?action=remove-from-cart?id=' . $oItem->getPrimaryKey() . '" class="btn btn-danger btn-xs catalogue-cart-remove" title="Удалить товар из конзины"><span class="glyphicon glyphicon-remove"></span></a>';
                }))->setDataSet($aItemsInCart);
                $view->DataGrid = $DataGrid;
                $view->goodCount = $cart->getTotalCount();
                $view->render();
                return;
                break;
            case 'set-cart-items':
                $items = Param::get('items')->asArray();
                foreach ($items as $itemId => $count) {
                    $this->cart->setItemCount($itemId, $count);
                }
                $this->Response->send('', ['totalCount' => $this->cart->getTotalCount()]);
                return;
                break;
            case 'order':
                break;
            default:
                $categoryId = Param::get('category_id', false)->asInteger(false);
                if (!$categoryId) {
                    $categoryId = 0;
                }
                $oCategories = DataSource::factory(Category::cls());
                $oCategories->builder()->where('deleted=0')->whereAnd()->where('active=1')->whereAnd()->where("category_id={$categoryId}");
                $aCategories = $oCategories->findAll();
                $oItems = DataSource::factory(Item::cls());
                $oItems->builder()->where('deleted=0')->whereAnd()->where('active=1')->whereAnd()->where("category_id={$categoryId}");
                $aItems = $oItems->findAll();
                $view = new ViewCatalogue();
                $view->categoriesPerRow = 4;
                $view->itemsPerRow = 4;
                $view->aCategories = $aCategories;
                $view->aItems = $aItems;
        }
        // Подготовка хлебных крошек
        $breadcrumbsParentPK = $categoryId;
        $categoryBreadcrumbs = [];
        while ($breadcrumbsParentPK) {
            /** @var Category $oParentCategory */
            $oParentCategory = DataSource::factory(Category::cls(), $breadcrumbsParentPK);
            $categoryBreadcrumbs[] = new Breadcrumb($oParentCategory->name, "?category_id={$oParentCategory->getPrimaryKey()}", true);
            $breadcrumbsParentPK = $oParentCategory->category_id;
        }
        $this->BreadcrumbsView->Breadcrumbs = array_merge($this->BreadcrumbsView->Breadcrumbs, array_reverse($categoryBreadcrumbs));
        if (isset($oItem)) {
            $this->BreadcrumbsView->Breadcrumbs[] = new Breadcrumb($oItem->name, '');
        }
        $view->backUrl = CoreFunctions::buildUrlByBreadcrumbs($this->BreadcrumbsView->Breadcrumbs, 1);
        $this->Frame->bindView('breadcrumbs', $this->BreadcrumbsView);
        $view->render();
    }
Beispiel #26
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $StructureHelper = new StructureHelper(SFW_APP_ROOT . 'Controllers' . DIRECTORY_SEPARATOR);
     $structureId = Param::post('structure-id', false)->asInteger(false);
     $name = Param::post('structure-name')->noEmpty('Заполните поле "Наименование"')->asString();
     $description = Param::post('structure-description')->asString();
     $parent = Param::post('structure-parent')->asInteger(true, 'Поле "Родительский раздел" заполнено неверно.');
     $path = Param::post('structure-path')->asString();
     $frame = Param::post('structure-frame')->asString();
     $module = Param::post('structure-module')->asInteger(true, 'Поле "Модуль" заполнено неверно.');
     $anchor = (int) Param::post('structure-anchor', false)->exists();
     $priority = Param::post('structure-priority', false)->asString();
     $isMain = (int) Param::post('structure-is-main', false)->exists();
     $active = (int) Param::post('structure-active', false)->exists();
     $seoTitle = Param::post('structure-seo-title', false)->asString();
     $seoDescription = Param::post('structure-seo-description', false)->asString();
     $seoKeywords = Param::post('structure-seo-keywords', false)->asString();
     $accept = Param::post('structure-accept', false);
     if (SCMSNotificationLog::instance()->hasProblems()) {
         $this->Response->send();
         return;
     }
     /** @var Structure $oStructure */
     $oStructure = DataSource::factory(Structure::cls(), $structureId == 0 ? null : $structureId);
     $oldPath = $StructureHelper->getPath($oStructure);
     $oStructure->name = $name;
     $oStructure->description = $description;
     $oStructure->structure_id = $parent;
     $oStructure->path = $path;
     $oStructure->frame = $frame;
     $oStructure->module_id = $module;
     $oStructure->anchor = $anchor;
     $oStructure->priority = $priority;
     $oStructure->is_main = $isMain;
     $oStructure->active = $active;
     $oStructure->seo_title = $seoTitle;
     $oStructure->seo_description = $seoDescription;
     $oStructure->seo_keywords = $seoKeywords;
     if (!$oStructure->getPrimaryKey()) {
         $oStructure->deleted = false;
     }
     if ($isMain) {
         $retriever = new StructureRetriever();
         $retriever->clearMainFlag();
     }
     $oStructure->commit();
     if ($oStructure->module_id) {
         $this->saveStructureSettings($oStructure);
     }
     if ($structureId != 0) {
         $StructureHelper->removeProxyController($oldPath);
     }
     $StructureHelper->createProxyController($StructureHelper->getPath($oStructure));
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         SCMSNotificationLog::instance()->pushMessage("Структура \"{$oStructure->name}\" успешно " . ($structureId == 0 ? 'добавлена' : 'отредактирована') . ".");
     }
     $redirect = "/admin/modules/structures/edit/?pk={$oStructure->getPrimaryKey()}";
     if ($accept->exists()) {
         $redirect = '/admin/modules/structures/' . ($oStructure->structure_id == 0 ? '' : "?parent_pk={$oStructure->structure_id}");
     } elseif ($structureId != 0) {
         $redirect = '';
     }
     $this->Response->send($redirect);
 }