Beispiel #1
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();
 }
 public function actionIndex()
 {
     if (CoreFunctions::isAJAX()) {
         $this->executeModule($this->getStructure());
     } else {
         ob_start();
         $this->executeModule($this->getStructure());
         $content = ob_get_contents();
         ob_end_clean();
         $frame = $this->getActiveFrame($this->getStructure());
         $frame->bindData('content', $content);
         $frame->render();
     }
 }
Beispiel #3
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 #4
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 #5
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 #6
0
 public function actionIndex()
 {
     if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) {
         SCMSNotificationLog::instance()->pushError('Нет доступа!');
         $this->Response->send();
         return;
     }
     $this->needAuthenticate();
     $isCategory = Param::get('is_category')->asInteger(true, "Недопустимое значение параметра.");
     $id = Param::get('id')->asInteger();
     if ($isCategory) {
         /** @var Category $oCategory */
         $oCategory = DataSource::factory(Category::cls(), $id);
         $this->categoryDeepDelete($oCategory);
         SCMSNotificationLog::instance()->pushMessage("Категория \"{$oCategory->name}\" успешно удалена.");
     } else {
         /** @var Item $oItem */
         $oItem = DataSource::factory(Item::cls(), $id);
         $oItem->deleted = true;
         $oItem->commit();
         SCMSNotificationLog::instance()->pushMessage("Позиция \"{$oItem->name}\" успешно удалена.");
     }
     $this->Response->send();
 }
Beispiel #7
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);
 }