Example #1
0
 public function changeAdvSetting($para)
 {
     $action = NULL;
     if (isset($para->styles_per_page) && is_numeric($para->styles_per_page)) {
         $this->updateStylesPerPages($para->styles_per_page);
     }
     $description_show = false;
     $slug_show = false;
     $tours_show = false;
     if (isset($para->description_show) && $para->description_show == "description") {
         $description_show = true;
     }
     if (isset($para->slug_show) && $para->slug_show == "slug") {
         $slug_show = true;
     }
     if (isset($para->tours_show) && $para->tours_show == "tours") {
         $tours_show = true;
     }
     $this->updateColumnsShow($description_show, $slug_show, $tours_show);
     Model::autoloadModel('user');
     $userModel = new UserModel($this->db);
     $userBO = $userModel->get(Session::get("user_id"));
     $userModel->setNewSessionUser($userBO);
 }
 public function search($view, $para)
 {
     $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT;
     $internalflight = "internalflight";
     $userLoginBO = json_decode(Session::get("userInfo"));
     if ($userLoginBO != NULL) {
         if (isset($userLoginBO->internalflights_per_page) && is_numeric($userLoginBO->internalflights_per_page)) {
             $internalflights_per_page = (int) $userLoginBO->internalflights_per_page;
         }
     }
     if (!isset($internalflights_per_page)) {
         if (!isset($_SESSION['options'])) {
             $_SESSION['options'] = new stdClass();
             $_SESSION['options']->internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT;
             $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT;
         } elseif (!isset($_SESSION['options']->internalflights_per_page)) {
             $_SESSION['options']->internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT;
             $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT;
         }
     }
     $view->internalflights_per_page = $internalflights_per_page;
     $view->internalflight = $internalflight;
     try {
         $paraSQL = [];
         $sqlSelectAll = "SELECT DISTINCT \n                                cu.`meta_value` AS current_rating,\n                                vo.`meta_value` AS vote_times,\n                                im.`meta_value` AS image_id,\n                                te.`name` AS city_name,\n                                ta.`term_taxonomy_id` AS city_id,\n                                ts.`name` AS country_name,\n                                tc.`term_taxonomy_id` AS country_id,\n                                po.*  ";
         $sqlSelectCount = "SELECT COUNT(*) as countInternalflight ";
         //para: orderby, order, page, s, paged, countries, new_role, new_role2, action, action2
         $sqlFrom = " FROM\n                            posts AS po\n                            LEFT JOIN `postmeta` AS cu ON po.`ID` = cu.`post_id` AND cu.`meta_key` = 'current_rating' \n                            LEFT JOIN `postmeta` AS vo ON po.`ID` = vo.`post_id` AND vo.`meta_key` = 'vote_times' \n                            LEFT JOIN `postmeta` AS im ON po.`ID` = im.`post_id` AND im.`meta_key` = 'image_id'   \n                            LEFT JOIN `term_relationships` AS re ON po.`ID` = re.`object_id` \n                            JOIN `term_taxonomy` AS ta ON re.`term_taxonomy_id` = ta.`term_taxonomy_id` AND ta.`taxonomy` = 'city'                             \n                            LEFT JOIN `terms` AS te ON ta.`term_id` = te.`term_id` \n                            LEFT JOIN `term_relationships` AS rd ON po.`ID` = rd.`object_id` \n                            JOIN `term_taxonomy` AS tc ON rd.`term_taxonomy_id` = tc.`term_taxonomy_id` AND tc.`taxonomy` = 'country' \n                            LEFT JOIN `terms` AS ts ON tc.`term_id` = ts.`term_id` ";
         $sqlWhere = " WHERE po.`post_type` = 'internalflight' ";
         if (isset($para->s) && strlen(trim($para->s)) > 0) {
             $sqlWhere .= " AND (\n                                po.`post_content` LIKE :s \n                                OR po.`post_name` LIKE :s \n                                OR po.`post_title` LIKE :s \n                                OR te.`name` LIKE :s\n                                OR ts.`name` LIKE :s\n                              ) ";
             $paraSQL[':s'] = "%" . $para->s . "%";
             $view->s = $para->s;
         }
         $view->orderby = "post_title";
         $view->order = "asc";
         if (isset($para->orderby) && in_array($para->orderby, array("post_title", "city_name", "country_name", "current_rating", "vote_times"))) {
             switch ($para->orderby) {
                 case "post_title":
                     $para->orderby = "post_title";
                     $view->orderby = "post_title";
                     break;
                 case "current_rating":
                     $para->orderby = "current_rating";
                     $view->orderby = "current_rating";
                     break;
                 case "vote_times":
                     $para->orderby = "vote_times";
                     $view->orderby = "vote_times";
                     break;
                 case "city_name":
                     $para->orderby = "city_name";
                     $view->orderby = "city_name";
                     break;
                 case "country_name":
                     $para->orderby = "country_name";
                     $view->orderby = "country_name";
                     break;
             }
             if (isset($para->order) && in_array($para->order, array("desc", "asc"))) {
                 $view->order = $para->order;
             } else {
                 $para->order = "asc";
                 $view->order = "asc";
             }
             $sqlOrderby = " ORDER BY " . $para->orderby . " " . $para->order;
         } else {
             $sqlOrderby = " ORDER BY " . TB_POST_COL_POST_TITLE . " ASC";
         }
         $sqlCount = $sqlSelectCount . $sqlFrom . $sqlWhere;
         $sth = $this->db->prepare($sqlCount);
         $sth->execute($paraSQL);
         $countInternalflight = (int) $sth->fetch()->countInternalflight;
         $view->pageNumber = 0;
         $view->page = 1;
         $sqlLimit = "";
         if ($countInternalflight > 0) {
             $view->count = $countInternalflight;
             $view->pageNumber = floor($view->count / $view->internalflights_per_page);
             if ($view->count % $view->internalflights_per_page != 0) {
                 $view->pageNumber++;
             }
             if (isset($para->page)) {
                 try {
                     $page = (int) $para->page;
                     if ($para->page <= 0) {
                         $page = 1;
                     }
                 } catch (Exception $e) {
                     $page = 1;
                 }
             } else {
                 $page = 1;
             }
             if ($page > $view->pageNumber) {
                 $page = $view->pageNumber;
             }
             $view->page = $page;
             $startInternalflight = ($page - 1) * $view->internalflights_per_page;
             $sqlLimit = " LIMIT " . $view->internalflights_per_page . " OFFSET " . $startInternalflight;
             $sqlAll = $sqlSelectAll . $sqlFrom . $sqlWhere . $sqlOrderby . $sqlLimit;
             $sth = $this->db->prepare($sqlAll);
             $sth->execute($paraSQL);
             $count = $sth->rowCount();
             if ($count > 0) {
                 $internalflightList = $sth->fetchAll();
                 for ($i = 0; $i < sizeof($internalflightList); $i++) {
                     $internalflightInfo = $internalflightList[$i];
                     Model::autoloadModel('image');
                     $imageModel = new ImageModel($this->db);
                     if (isset($internalflightInfo->image_id)) {
                         $image_object = $imageModel->get($internalflightInfo->image_id);
                         if ($image_object != NULL) {
                             if (isset($image_object->attachment_metadata) && isset($image_object->attachment_metadata->sizes)) {
                                 if (isset($image_object->attachment_metadata->sizes->slider_thumb) && isset($image_object->attachment_metadata->sizes->slider_thumb->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->slider_thumb->url;
                                 } elseif (isset($image_object->attachment_metadata->sizes->thumbnail) && isset($image_object->attachment_metadata->sizes->thumbnail->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->thumbnail->url;
                                 } elseif (isset($image_object->attachment_metadata->sizes->post_thumbnail) && isset($image_object->attachment_metadata->sizes->post_thumbnail->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->post_thumbnail->url;
                                 } elseif (isset($image_object->attachment_metadata->sizes->medium) && isset($image_object->attachment_metadata->sizes->medium->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->medium->url;
                                 } elseif (isset($image_object->attachment_metadata->sizes->medium_large) && isset($image_object->attachment_metadata->sizes->medium_large->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->medium_large->url;
                                 } elseif (isset($image_object->attachment_metadata->sizes->large) && isset($image_object->attachment_metadata->sizes->large->url)) {
                                     $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->large->url;
                                 } else {
                                     $internalflightInfo->image_url = $image_object->guid;
                                 }
                             } else {
                                 $internalflightInfo->image_url = $image_object->guid;
                             }
                         }
                     }
                     $this->autoloadBO('internalflight');
                     $internalflightBO = new InternalflightBO();
                     $internalflightBO->setInternalflightInfo($internalflightInfo);
                     $internalflightBO->setPost($internalflightInfo);
                     $internalflightList[$i] = $internalflightBO;
                 }
                 $view->internalflightList = $internalflightList;
             } else {
                 $view->internalflightList = NULL;
             }
         } else {
             $view->internalflightList = NULL;
         }
     } catch (Exception $e) {
         $view->internalflightList = NULL;
     }
 }
Example #3
0
 public function index()
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR))) {
         Model::autoloadModel('country');
         $model = new CountryModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['type'])) {
             $this->para->type = $_POST['type'];
         }
         if (isset($_POST['orderby'])) {
             $this->para->orderby = $_POST['orderby'];
         }
         if (isset($_POST['order'])) {
             $this->para->order = $_POST['order'];
         }
         if (isset($_POST['page'])) {
             $this->para->page = $_POST['page'];
         }
         if (isset($_POST['s'])) {
             $this->para->s = $_POST['s'];
         }
         if (isset($_POST['paged'])) {
             $this->para->paged = $_POST['paged'];
         }
         if (isset($_POST['countries'])) {
             $this->para->countries = $_POST['countries'];
         }
         if (isset($_POST['action'])) {
             $this->para->action = $_POST['action'];
         }
         if (isset($_POST['action2'])) {
             $this->para->action2 = $_POST['action2'];
         }
         if (isset($_POST['description_show'])) {
             $this->para->description_show = $_POST['description_show'];
         }
         if (isset($_POST['slug_show'])) {
             $this->para->slug_show = $_POST['slug_show'];
         }
         if (isset($_POST['tours_show'])) {
             $this->para->tours_show = $_POST['tours_show'];
         }
         if (isset($_POST['countries_per_page'])) {
             $this->para->countries_per_page = $_POST['countries_per_page'];
         }
         if (isset($_POST['adv_setting'])) {
             $this->para->adv_setting = $_POST['adv_setting'];
         }
         if (isset($this->para->adv_setting) && $this->para->adv_setting == "adv_setting") {
             $model->changeAdvSetting($this->para);
         }
         if (isset($this->para->type) && in_array($this->para->type, array("action", "action2")) && isset($this->para->countries)) {
             $model->executeAction($this->para);
         }
         $model->search($this->view, $this->para);
         if (count((array) $this->para) > 0) {
             $this->view->ajax = TRUE;
             $this->view->renderAdmin(RENDER_VIEW_COUNTRY_INDEX, TRUE);
         } else {
             $this->view->renderAdmin(RENDER_VIEW_COUNTRY_INDEX);
         }
     } else {
         $this->login();
     }
 }
Example #4
0
<?php

Model::autoloadModel('post');
class AttachmentModel extends PostModel
{
    /**
     * Constructor, expects a Database connection
     * @param Database $db The Database object
     */
    public function __construct(Database $db)
    {
        parent::__construct($db);
    }
    /**
     * addToDatabase
     *
     * Adds new attachment to database
     *
     * @param AttachmentBO $attachmentInfo new attachment
     */
    public function addToDatabase($attachmentInfo)
    {
        try {
            $image_id = parent::addToDatabase($attachmentInfo);
            if (!is_null($image_id)) {
                if (isset($attachmentInfo->attachment_metadata)) {
                    $attachment_metadata = json_encode($attachmentInfo->attachment_metadata);
                    $this->addMetaInfoToDatabase($image_id, 'attachment_metadata', $attachment_metadata);
                }
                if (isset($attachmentInfo->attached_file)) {
                    $this->addMetaInfoToDatabase($image_id, 'attached_file', $attachmentInfo->attached_file);
Example #5
0
 public function loadOption()
 {
     Model::autoloadModel('Option');
     $model = new OptionModel($this->db);
     $model->loadOption();
 }
Example #6
0
 public function index()
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR))) {
         Model::autoloadModel('internalflight');
         $model = new InternalflightModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['type'])) {
             $this->para->type = $_POST['type'];
         }
         if (isset($_POST['orderby'])) {
             $this->para->orderby = $_POST['orderby'];
         }
         if (isset($_POST['order'])) {
             $this->para->order = $_POST['order'];
         }
         if (isset($_POST['page'])) {
             $this->para->page = $_POST['page'];
         }
         if (isset($_POST['s'])) {
             $this->para->s = $_POST['s'];
         }
         if (isset($_POST['paged'])) {
             $this->para->paged = $_POST['paged'];
         }
         if (isset($_POST['internalflights'])) {
             $this->para->internalflights = $_POST['internalflights'];
         }
         if (isset($_POST['action'])) {
             $this->para->action = $_POST['action'];
         }
         if (isset($_POST['action2'])) {
             $this->para->action2 = $_POST['action2'];
         }
         if (isset($_POST['city_show'])) {
             $this->para->city_show = $_POST['city_show'];
         }
         if (isset($_POST['current_rating'])) {
             $this->para->current_rating = $_POST['current_rating'];
         }
         if (isset($_POST['vote_times'])) {
             $this->para->vote_times = $_POST['vote_times'];
         }
         if (isset($_POST['internalflights_per_page'])) {
             $this->para->internalflights_per_page = $_POST['internalflights_per_page'];
         }
         if (isset($_POST['adv_setting'])) {
             $this->para->adv_setting = $_POST['adv_setting'];
         }
         if (isset($this->para->adv_setting) && $this->para->adv_setting == "adv_setting") {
             $model->changeAdvSetting($this->para);
         }
         if (isset($this->para->type) && in_array($this->para->type, array("action", "action2")) && isset($this->para->internalflights)) {
             $model->executeAction($this->para);
         }
         $model->search($this->view, $this->para);
         if (count((array) $this->para) > 0) {
             $this->view->ajax = TRUE;
             $this->view->renderAdmin(RENDER_VIEW_INTERNALFLIGHT_INDEX, TRUE);
         } else {
             $this->view->renderAdmin(RENDER_VIEW_INTERNALFLIGHT_INDEX);
         }
     } else {
         $this->login();
     }
 }
Example #7
0
 public function searchAjax($str = NULL)
 {
     Model::autoloadModel('tag');
     $model = new TagModel($this->db);
     $this->para = new stdClass();
     if (isset($str) && $str != NULL && $str != "") {
         $this->para->s = $str;
         $this->view->s = $str;
     } elseif (isset($_POST['s'])) {
         $this->para->s = $_POST['s'];
         $this->view->s = $_POST['s'];
     }
     $model->searchAjax($this->view, $this->para);
     $this->view->renderAdmin(RENDER_SEARCH_TAG_AJAX, TRUE);
 }
Example #8
0
 public function index()
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR))) {
         Model::autoloadModel('User');
         $model = new UserModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['type'])) {
             $this->para->type = $_POST['type'];
         }
         if (isset($_POST['role'])) {
             $this->para->role = $_POST['role'];
         }
         if (isset($_POST['orderby'])) {
             $this->para->orderby = $_POST['orderby'];
         }
         if (isset($_POST['order'])) {
             $this->para->order = $_POST['order'];
         }
         if (isset($_POST['page'])) {
             $this->para->page = $_POST['page'];
         }
         if (isset($_POST['s'])) {
             $this->para->s = $_POST['s'];
         }
         if (isset($_POST['paged'])) {
             $this->para->paged = $_POST['paged'];
         }
         if (isset($_POST['users'])) {
             $this->para->users = $_POST['users'];
         }
         if (isset($_POST['new_role'])) {
             $this->para->new_role = $_POST['new_role'];
         }
         if (isset($_POST['new_role2'])) {
             $this->para->new_role2 = $_POST['new_role2'];
         }
         if (isset($_POST['action'])) {
             $this->para->action = $_POST['action'];
         }
         if (isset($_POST['action2'])) {
             $this->para->action2 = $_POST['action2'];
         }
         if (isset($_POST['email_show'])) {
             $this->para->email_show = $_POST['email_show'];
         }
         if (isset($_POST['role_show'])) {
             $this->para->role_show = $_POST['role_show'];
         }
         if (isset($_POST['tours_show'])) {
             $this->para->tours_show = $_POST['tours_show'];
         }
         if (isset($_POST['users_per_page'])) {
             $this->para->users_per_page = $_POST['users_per_page'];
         }
         if (isset($_POST['adv_setting'])) {
             $this->para->adv_setting = $_POST['adv_setting'];
         }
         if (isset($this->para->adv_setting) && $this->para->adv_setting == "adv_setting") {
             $model->changeAdvSetting($this->para);
         }
         if (isset($this->para->type) && in_array($this->para->type, array("action", "action2", "new_role", "new_role2")) && isset($this->para->users)) {
             if (in_array($this->para->type, array("action", "action2"))) {
                 $model->executeAction($this->para);
             } else {
                 $model->changeRole($this->para);
             }
         }
         $model->search($this->view, $this->para);
         if (count((array) $this->para) > 0) {
             $this->view->ajax = TRUE;
             $this->view->renderAdmin(RENDER_VIEW_USER_INDEX, TRUE);
         } else {
             $this->view->renderAdmin(RENDER_VIEW_USER_INDEX);
         }
     } else {
         $this->login();
     }
 }
Example #9
0
 public function getMetaInfo($user_id)
 {
     $sth = $this->db->prepare("SELECT *\n                                   FROM   " . TABLE_USERMETA . "\n                                   WHERE  " . TB_USERMETA_COL_USER_ID . " = :user_id");
     $sth->execute(array(':user_id' => $user_id));
     $count = $sth->rowCount();
     if ($count > 0) {
         $userMetaInfoArray = $sth->fetchAll();
         foreach ($userMetaInfoArray as $userMeta) {
             if (isset($userMeta->meta_key) && in_array($userMeta->meta_key, array("manage_users_columns_show", "manage_countries_columns_show", "manage_cities_columns_show", "manage_hotels_columns_show", "manage_restaurants_columns_show", "manage_shoppings_columns_show", "manage_internalflights_columns_show", "manage_internationalflights_columns_show", "manage_activities_columns_show", "manage_nightlifes_columns_show", "manage_tags_columns_show", "manage_destinations_columns_show", "manage_eats_columns_show", "manage_styles_columns_show", "manage_types_columns_show"))) {
                 try {
                     $userMeta->meta_value = json_decode($userMeta->meta_value);
                 } catch (Exception $e) {
                     $userMeta->meta_value = NULL;
                 }
             }
             if (isset($userMeta->meta_key) && $userMeta->meta_key == "avatar") {
                 Model::autoloadModel('image');
                 $imageModel = new ImageModel($this->db);
                 $avatar_object = new stdClass();
                 $avatar_object->umeta_id = $userMeta->umeta_id;
                 $avatar_object->user_id = $userMeta->user_id;
                 $avatar_object->meta_key = 'avatar_object';
                 $avatar_object->meta_value = $imageModel->get($userMeta->meta_value);
                 $userMetaInfoArray[] = $avatar_object;
             }
         }
         return $userMetaInfoArray;
     } else {
         $_SESSION["fb_error"][] = ERR_LOGIN_FAILED;
         return false;
     }
 }
Example #10
0
<?php

Model::autoloadModel('attachment');
class ImageModel extends AttachmentModel
{
    public $is_create_thumb = false;
    public $is_slider_thumb = false;
    public $slider_thumb_height;
    public $slider_thumb_width;
    public $slider_thumb_crop = true;
    public $slider_thumb_quality = 100;
    public $is_thumbnail = false;
    public $thumbnail_height;
    public $thumbnail_width;
    public $thumbnail_crop = true;
    public $thumbnail_quality = 100;
    public $is_post_thumbnail = false;
    public $post_thumbnail_height;
    public $post_thumbnail_width;
    public $post_thumbnail_crop = true;
    public $post_thumbnail_quality = 100;
    public $is_medium = false;
    public $medium_height;
    public $medium_width;
    public $medium_crop = true;
    public $medium_quality = 100;
    public $is_medium_large = false;
    public $medium_large_height;
    public $medium_large_width;
    public $medium_large_crop = true;
    public $medium_large_quality = 100;
Example #11
0
<?php

Model::autoloadModel('term');
class TaxonomyModel extends TermModel
{
    /**
     * Constructor, expects a Database connection
     * @param Database $db The Database object
     */
    public function __construct(Database $db)
    {
        parent::__construct($db);
    }
    public function isExistName($name, $taxonomy)
    {
        $sth = $this->db->prepare("SELECT u." . TB_TERM_TAXONOMY_COL_TERM_TAXONOMY_ID . " " . " FROM " . TABLE_TERM_TAXONOMY . " AS u, " . TABLE_TERMS . " AS m " . " WHERE  m." . TB_TERMS_COL_NAME . " = :name " . " AND m." . TB_TERMS_COL_TERM_ID . " = u." . TB_TERM_TAXONOMY_COL_TERM_ID . " " . " AND u." . TB_TERM_TAXONOMY_COL_TAXONOMY . " = :taxonomy ");
        $sth->execute(array(':name' => $name, ':taxonomy' => $taxonomy));
        $count = $sth->rowCount();
        if ($count != 0) {
            $result = $sth->fetch();
            return $result->term_taxonomy_id;
        }
        return FALSE;
    }
    public function isExistSlug($slug, $taxonomy)
    {
        $sth = $this->db->prepare("SELECT u." . TB_TERM_TAXONOMY_COL_TERM_TAXONOMY_ID . " " . " FROM " . TABLE_TERM_TAXONOMY . " AS u, " . TABLE_TERMS . " AS m " . " WHERE  m." . TB_TERMS_COL_SLUG . " = :slug " . " AND m." . TB_TERMS_COL_TERM_ID . " = u." . TB_TERM_TAXONOMY_COL_TERM_ID . " " . " AND u." . TB_TERM_TAXONOMY_COL_TAXONOMY . " = :taxonomy ");
        $sth->execute(array(':slug' => $slug, ':taxonomy' => $taxonomy));
        $count = $sth->rowCount();
        if ($count != 0) {
            $result = $sth->fetch();