Exemplo n.º 1
0
 public function actionDelete()
 {
     Yii::app()->page->title = Yii::t("user", "Запись удалена");
     $message = "";
     $id = (int) Yii::app()->request->getParam("id", 0);
     $catalog = Yii::app()->request->getParam("catalog");
     if ($id > 0 && !empty($catalog)) {
         $item = $catalog::fetch($id);
         if ($item->user_id && $item->user_id->id > 0) {
             $id = $item->user_id->id;
         } else {
             $id = $item->firm_id->user_id->id;
         }
         if ($item->id > 0 && $id == Yii::app()->user->getId()) {
             foreach (CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions(" item_id=:itemId AND catalog=:catalog ")->setParams(array(":itemId" => $item->id, ":catalog" => $item->tableName()))) as $galItem) {
                 $galItem->delete();
             }
             $item->delete();
             SiteHelper::setLog($item->tableName(), "delete", $item->id, Yii::app()->user->getId());
             echo 1;
             return;
         }
     }
     return;
 }
Exemplo n.º 2
0
 public function actionTree()
 {
     $id = Yii::app()->request->getParam("id", 0);
     if (!empty($id)) {
         $images = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => "catalog_gardens_tree", ":item_id" => $id))->setLimit(10));
         $tree = CatalogGardensTree::fetch($id);
         $this->render("usertree", array("images" => $images, "tree" => $tree));
     }
 }
Exemplo n.º 3
0
 public function run()
 {
     $conditions = "catalog=:catalog";
     $params = array(":catalog" => $this->catalog);
     if (!empty($id)) {
         $conditions .= " sAND item_id=:item_id";
         $params = array_merge($params, array(":id" => $id));
     }
     $images = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($conditions)->setParams($params)->setLimit(10));
     $this->render("gallery", array('images' => $images));
 }
 public function actionIndex()
 {
     $page = (int) Yii::app()->request->getParam("p", 1);
     $this->layout = '//layouts/main-landing';
     if (!empty($_GET["country"])) {
         $model = CatalogCountry::fetchBySlug(trim($_GET["country"]));
     }
     if ($model && $model->id > 0) {
         $item = $model;
         Yii::app()->page->setInfo(array("description" => $item->name . "," . $this->description, "keyWord" => $item->name . "," . $this->keyWord));
         if (!empty($item) && $item->id > 0) {
             Yii::app()->page->title = $item->name;
             $this->render('index', array("item" => $item, "page" => $page, "tours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("rating DESC")->setLimit(12)), "gallerySlide" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_country' AND type='slide-gallery' AND item_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("pos")->setLimit(-1)), "gallery" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_country' AND type='' AND item_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("pos")->setLimit(9)), "info" => CatalogInfo::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("category_id=(SELECT id FROM catalog_info_category WHERE slug=:slug LIMIT 1)")->setParams(array(":slug" => $item->slug))), "monuments" => CatalogMonuments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:id")->setParams(array(":id" => $item->id)))));
         } else {
             throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
         }
     } else {
         throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
     }
 }
Exemplo n.º 5
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionEdit()
 {
     if (!empty($this->catalog)) {
         $message = "";
         $catalog = $this->catalog;
         $action = Yii::app()->request->getParam("action", "");
         if ($this->id) {
             $item = $catalog::fetch($this->id);
         } else {
             $item = new $catalog();
         }
         // Удаление картинки
         if ($action == "img_del") {
             $imageField = Yii::app()->request->getParam("field", "");
             if (!empty($imageField)) {
                 ImageHelper::deleteFile($item, $imageField);
                 $item->save();
                 $message = "Фото успешно удаленно";
             }
         }
         // Удаляем картинки в галлере
         if ($action == "gal_del") {
             $id = (int) Yii::app()->request->getParam("img_id", 0);
             if (!empty($id)) {
                 $imageModel = CatGallery::fetch($id);
                 if ($imageModel->id > 0) {
                     $imageModel->delete();
                     $message = "Фото успешно удаленно";
                 }
             }
         }
         $addGallery = new CatGallery();
         if ($item->id > 0) {
             $listImage = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setOrderBy("pos, id")->setCache(0)->setLimit(-1));
         } else {
             $listImage = array();
         }
         $this->arrayParams["catalog"] = $catalog;
         $this->render('edit', array('arrayParams' => $this->arrayParams, 'controller' => $this, 'form' => $item, 'catalog' => SiteHelper::getCamelCase($item->tableName()), 'listImage' => $listImage, 'message' => $message, 'addGallery' => $addGallery));
     }
 }
Exemplo n.º 6
0
 public function actionDescription($gallError = "")
 {
     $_POST["CatalogWorkResumeAdd"]["user_id"] = Yii::app()->user->getId();
     $_POST["CatalogWorkResumeAdd"]["type_id"] = 1;
     if (!Yii::app()->user->isGuest) {
         Yii::app()->page->title = Yii::t("page", "Описание");
         $id = (int) Yii::app()->request->getParam("id", 0);
         $status = Yii::app()->request->getParam("status", "");
         $error = Yii::app()->request->getParam("error", "");
         $addClass = $this->addModel;
         if (!empty($id)) {
             $item = $addClass::fetch($id);
         } else {
             $item = new $addClass();
             SiteHelper::setLog($item->tableName(), "open_add_form", $item->id, Yii::app()->user->getId());
         }
         if (!$item->id || $item->user_id->id == Yii::app()->user->getId()) {
             $message = !empty($status) && $status == 'saved' ? Yii::t("user", "Сохранено") : "";
             // Описание объявления
             if (!empty($_POST["update"])) {
                 if (!$item->id) {
                     $isAdd = true;
                 } else {
                     $isAdd = false;
                 }
                 $item->setAttributesFromArray($_POST[$addClass]);
                 //$item->is_resume = 0;
                 if (!$item->date) {
                     $item->date = time();
                 }
                 if (!$item->id) {
                     $item->user_id = Yii::app()->user->getId();
                 }
                 if ($item->save()) {
                     if ($isAdd) {
                         $action = "create";
                     } else {
                         $action = "edit";
                     }
                     SiteHelper::setLog($item->tableName(), $action, $item->id, Yii::app()->user->getId());
                     $this->redirect(SiteHelper::createUrl("/user/" . Yii::app()->controller->getId() . "/description/", array("id" => $item->id, "status" => "saved")));
                     die;
                     //if( !$isAdd )$message = "Описание успешно обновленно";
                     //        else $message = "Запись успешно добавлена";
                 }
                 //                    else $message = "Произошла ошибка обновления описания";
             }
             $action = Yii::app()->request->getParam("action");
             $gall_id = (int) Yii::app()->request->getParam("gall_id", 0);
             $comMessage = "";
             $gallMessage = "";
             if (!empty($gallError)) {
                 $message = $gallError;
             }
             // Удаление фотографии
             if (!empty($action) && $gall_id > 0) {
                 $comModel = CatGallery::fetch($gall_id);
                 if ($comModel->id > 0 && $comModel->item_id == $item->id) {
                     if ($action == "delGallery") {
                         $comModel->delete();
                         $gallMessage = Yii::t("user", "Картинка удалена");
                     }
                 }
             }
             $comm_id = (int) Yii::app()->request->getParam("comm_id", 0);
             if (!empty($action) && $comm_id > 0) {
                 $comModel = CatComments::fetch($comm_id);
                 if ($comModel->id > 0 && $comModel->item_id->id == $item->id) {
                     if ($action == "delComment") {
                         $comModel->delete();
                         $comMessage = Yii::t("user", "Комментарий удален");
                     }
                     if ($action == "validComment") {
                         $comModel->is_valid = 1;
                         $comModel->save();
                         $comMessage = Yii::t("user", "Комментарий успешно опубликован");
                     }
                 }
             }
             $addImage = new CatGalleryAdd();
             if ($error == "gallError") {
                 $addImage->addError("error upload", Yii::t("user", "Произошла ошибка добавления фото, попробуте заново или обратитеcь к тех. потдержке") . " ( Email : " . Yii::app()->params["supportEmail"] . " ) ");
             }
             if (!empty($_POST["sendGallery"])) {
                 if ($id > 0) {
                     $this->uploadImages((int) $id, get_class($item));
                 }
             }
             // Сохранение подписи для фотографий
             if (!empty($_POST["saveTitle"])) {
                 $this->gallerySaveTitle();
             }
             $listComments = CatComments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setLimit(50)->setCache(0));
             $listGallery = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setLimit(50)->setCache(0));
             $this->render("description", array("item" => $item, "firm" => null, "listGallery" => $listGallery, "message" => $message, "addImage" => $addImage, "comMessage" => $comMessage, "gallMessage" => $gallMessage, "listComments" => $listComments));
         }
     }
 }
 public function actionDescription()
 {
     Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord));
     $id = 0;
     $class = $this->classModel;
     if (!empty($_GET["slug"])) {
         $model = $class::fetchBySlug(trim($_GET["slug"]));
         if ($model->id > 0) {
             $_GET["id"] = $model->id;
             $id = $model->id;
         }
     }
     if (empty($id)) {
         $id = (int) Yii::app()->request->getParam("id", 0);
     }
     $error = Yii::app()->request->getParam("error", "");
     $tab = Yii::app()->request->getParam("tab", "");
     $tabArray = array("description", "pcomments", "tours");
     if (!in_array($tab, $tabArray)) {
         $tab = "";
     }
     // Ошибка при не правельно ID
     $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы");
     if (empty($id) && !empty($_GET["slug"])) {
         $ar = explode("-", $_GET["slug"]);
         $id = $ar[0];
     }
     if ($id > 0) {
         $item = CatalogFirmsInfo::fetch($id);
         if (empty($tab)) {
             $activeTab = "description";
         } else {
             $activeTab = $tab;
         }
         if ($item->id > 0) {
             LogHelper::save("firms", $item->id, "show");
             CCModelHelper::colCounter($item);
             $commentModel = new CatalogFirmsCommentsAdd();
             if (!empty($_POST["send_comment"])) {
                 $activeTab = "pcomments";
                 $commentModel->setAttributesFromArray($_POST["CatalogFirmsCommentsAdd"]);
                 $commentModel->firm_id = $id;
                 if (Yii::app()->user && Yii::app()->user->getId() > 0) {
                     $commentModel->user_id = Yii::app()->user->getId();
                 }
                 $commentModel->date = time();
                 if ($commentModel->save()) {
                     $item->onFirmNewComment(new CEvent($commentModel), array("subject" => $commentModel->name, "firm_name" => $item->name, "date" => date("d.m.Y H:i"), "user_name" => $commentModel->fio, "description" => $commentModel->message, "link" => SiteHelper::createUrl("/user/firms/description", array("id" => $item->id, "tab" => "pcomments"))));
                     $commentModel = new CatalogFirmsCommentsAdd();
                     $commentModel->formMessage = Yii::t("tours", "Сообщение отправлено, после модерации оно будет Опубликовано.");
                 }
             }
             Yii::app()->page->title = $item->name . " - " . Yii::t("page", "туристическое агенство") . " " . $item->country_id->name_2 . " " . $item->city_id->name;
             // Поля про поиско по турам
             $tourClass = new CatalogToursFirms();
             $arrSearchFieldsTours = $tourClass->getSearchAttributes();
             $this->render('description', array("item" => $item, "activeTab" => $activeTab, "commentModel" => $commentModel, "otherFirms" => CatalogFirms::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND id!=:id")->setParams(array(":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "listGallery" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:items_id")->setParams(array(":catalog" => "catalog_firms", ":items_id" => $item->id))->setLimit(15)), "arrSearchFieldsTours" => $arrSearchFieldsTours));
         } else {
             throw new CHttpException("", "К сожалению описание данного тура не найденно в базе");
         }
     } else {
         throw new CHttpException("", "К сожалению описание данного тура не найденно в базе");
     }
 }
Exemplo n.º 8
0
 public static function getImages(CCModel $itemObject, $limit = 10)
 {
     if ($itemObject->id > 0) {
         // Так как у нас картинки сохраненны только для русской версии, то если язык другой то проверяем базовую таблицы ( без EN )
         $tableName = $itemObject->tableName();
         if (Yii::app()->getLanguage() != "ru") {
             $arr = explode("_", $tableName);
             unset($arr[sizeof($arr) - 1]);
             $tableName = implode("_", $arr);
         }
         $queryParams = DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:id")->setParams(array(":catalog" => $tableName, ":id" => $itemObject->id))->setLimit($limit)->setCache(0);
         return CatGallery::fetchAll($queryParams);
     }
     return false;
 }
Exemplo n.º 9
0
 public function actionDescription($gallError = "")
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->page->title = Yii::t("page", "Описание");
         $id = (int) Yii::app()->request->getParam("id", 0);
         $status = Yii::app()->request->getParam("status", "");
         $error = Yii::app()->request->getParam("error", "");
         $addClass = $this->addModel;
         if (!empty($id)) {
             $item = $addClass::fetch($id);
         } else {
             $item = new $addClass();
             SiteHelper::setLog($item->tableName(), "open_add_form", $item->id, Yii::app()->user->getId());
         }
         if (!$item->id || ($item->user_id && $item->user_id->id == Yii::app()->user->getId() || $item->firm_id && $item->firm_id->user_id->id == Yii::app()->user->getId())) {
             if (property_exists($item, "firm_id") && $item->firm_id) {
                 $firm = $item->firm_id;
             }
             if (!property_exists($item, "firm_id") && $item->id) {
                 $firm = $item;
             }
             if (empty($firm) || $firm->id == 0) {
                 $fid = (int) Yii::app()->request->getParam("fid", 0);
                 $firm = CatalogFirms::fetch($fid);
             }
             $message = !empty($status) && $status == 'saved' ? Yii::t("user", "Сохранено") : "";
             // Описание объявления
             if (!empty($_POST["update"])) {
                 if (!$item->id) {
                     $isAdd = true;
                 } else {
                     $isAdd = false;
                 }
                 $item->setAttributesFromArray($_POST[$addClass]);
                 //$item->is_resume = 0;
                 if (!$item->date) {
                     $item->date = time();
                 }
                 if (property_exists($item, "edit_date")) {
                     $item->edit_date = time();
                 }
                 $item->user_id = Yii::app()->user->getId();
                 if ($item->save()) {
                     if ($isAdd) {
                         $action = "create";
                     } else {
                         $action = "edit";
                     }
                     SiteHelper::setLog($item->tableName(), $action, $item->id, Yii::app()->user->getId());
                     switch (Yii::app()->controller->getId()) {
                         case "firms":
                             LogHelper::saveCatLogEdit(1, 0);
                             break;
                         case "tours":
                             LogHelper::saveCatLogEdit(0, 1);
                             break;
                     }
                     $arrayParam = array("id" => $item->id, "status" => "saved");
                     if ($firm->id > 0) {
                         $arrayParam["fid"] = $firm->id;
                     }
                     switch ($item->tableName()) {
                         case "catalog_firms":
                             $item->onAddFirm(new CModelEvent($item), array());
                             break;
                         case "catalog_tours":
                             $item->onAddTour(new CModelEvent($item), array());
                             break;
                         case "catalog_firms_items":
                             $item->onAddFirmsItems(new CModelEvent($item), array());
                             break;
                         case "catalog_firms_service":
                             $item->onAddFirmsService(new CModelEvent($item), array());
                             break;
                         case "catalog_firms_banner":
                             $item->onAddFirmsBanners(new CModelEvent($item), array());
                             break;
                     }
                     // Добавляем в очередь на нотификацию
                     // В течении 24 часов после добавления или сохранения пользователю приходят уведомления
                     // О том что заполнил не полностью, не опубликовал, не добавил картинок и т.д.
                     AutoNotifier::addInNotificationsQueue($item->tableName(), $item->id);
                     $this->redirect(SiteHelper::createUrl("/user/" . Yii::app()->controller->getId() . "/description/", $arrayParam));
                     die;
                 }
             }
             $action = Yii::app()->request->getParam("action");
             $gall_id = (int) Yii::app()->request->getParam("gall_id", 0);
             $comMessage = "";
             $gallMessage = "";
             if (!empty($gallError)) {
                 $message = $gallError;
             }
             // Удаление фотографии
             if (!empty($action) && $gall_id > 0) {
                 $comModel = CatGallery::fetch($gall_id);
                 if ($comModel->id > 0 && $comModel->item_id == $item->id) {
                     if ($action == "delGallery") {
                         $comModel->delete();
                         $gallMessage = Yii::t("user", "Картинка удалена");
                     }
                 }
             }
             $comm_id = (int) Yii::app()->request->getParam("comm_id", 0);
             if (!empty($action) && $comm_id > 0) {
                 $comModel = CatComments::fetch($comm_id);
                 if ($comModel->id > 0 && $comModel->item_id->id == $item->id) {
                     if ($action == "delComment") {
                         $comModel->delete();
                         $comMessage = Yii::t("user", "Комментарий удален");
                     }
                     if ($action == "validComment") {
                         $comModel->is_valid = 1;
                         $comModel->save();
                         $comMessage = Yii::t("user", "Комментарий успешно опубликован");
                     }
                 }
             }
             $addImage = new CatGalleryAdd();
             if ($error == "gallError") {
                 $addImage->addError("error upload", Yii::t("user", "Произошла ошибка добавления фото, попробуте заново или обратитеcь к тех. потдержке") . " ( Email : " . Yii::app()->params["supportEmail"] . " ) ");
             }
             if (!empty($_POST["sendGallery"])) {
                 if ($id > 0) {
                     $this->uploadImages((int) $id, get_class($item));
                 }
             }
             // Сохранение подписи для фотографий
             if (!empty($_POST["saveTitle"])) {
                 $this->gallerySaveTitle();
             }
             $listComments = CatComments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setLimit(50)->setCache(0));
             $listGallery = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => $item->tableName(), ":item_id" => $item->id))->setLimit(50)->setCache(0));
             if (!empty($message)) {
                 $item->formMessage = $message;
             }
             $this->render("description", array("item" => $item, "firm" => $firm, "listGallery" => $listGallery, "message" => $message, "addImage" => $addImage, "comMessage" => $comMessage, "gallMessage" => $gallMessage, "listComments" => $listComments));
         }
     }
 }