Ejemplo n.º 1
0
 /**
  * Отправка сообщения на Email
  * @return void
  */
 public function action_send()
 {
     $user = ORM::factory('user', $this->request->param('id', NULL));
     if (!$user->loaded()) {
         $this->request->redirect('admin');
     }
     $feedback_id = Arr::get($_GET, 'feedback', 0);
     $email_from = array('no-reply' => '*****@*****.**', 'sekretar' => '*****@*****.**');
     if ($_POST) {
         $message = ORM::factory('message');
         $message->values($_POST, array('title', 'text', 'from'));
         $message->user_id = $user->id;
         $message->feedback_id = $feedback_id;
         $message->date = Date::formatted_time();
         try {
             $message->save();
             $this->add_to_email_queue($user->id, $message->id, $message->from);
             Message::set(Message::SUCCESS, 'Сообщения пользователю "' . $user->username . '" отправлено в очередь на отправку');
             $this->request->redirect('admin/message');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('backend/message/send')->set('values', $this->values)->set('errors', $this->errors)->set('email_from', $email_from)->set('user', $user);
     $this->template->title = 'Отправка сообщения';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 2
0
 public function format_message(array $message, $format = "time --- level: body")
 {
     $message['time'] = Date::formatted_time('@' . $message['time']);
     $message['level'] = $this->_log_levels[$message['level']];
     $string = strtr($format, $message);
     return $string;
 }
Ejemplo n.º 3
0
 public function action_createOrDeleteAccess()
 {
     try {
         $post = Validate::factory($_POST)->rule('menu_id', 'not_empty')->rule('group_id', 'not_empty');
         if (!$post->check()) {
             echo "0|ERROR - Empty Data Post";
             die;
         }
         $menu_id = $_POST['menu_id'];
         $group_id = $_POST['group_id'];
         $privilege = new Model_Privilege();
         $privilege = ORM::factory('Privilege')->where('idMenu', '=', $menu_id)->where('idGroup', '=', $group_id)->find();
         if ($privilege->loaded() == TRUE) {
             $privilege->delete();
         } else {
             $privilege->idMenu = $menu_id;
             $privilege->idGroup = $group_id;
             $privilege->grantDate = Date::formatted_time();
             $privilege->idUser = $this->getSessionParameter('user_id');
             $privilege->save();
         }
         echo "1|ok";
     } catch (Exception $exc) {
         echo "0|" . $exc->getTraceAsString();
     }
     die;
 }
Ejemplo n.º 4
0
 /**
  * Редактирование контента
  * @return void
  */
 public function action_edit()
 {
     $content = ORM::factory('content_site', $this->request->param('id', NULL));
     if (!$content->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'content_not_found'));
         $this->request->redirect('admin/content/portal');
     }
     $this->values = $content->as_array();
     if ($_POST) {
         $active = Arr::get($_POST, 'active', 0);
         try {
             $content->values($_POST, array('title', 'url', 'keywords', 'description', 'text'));
             $content->active = $active;
             $content->date = Date::formatted_time();
             $content->update();
             $this->route_update();
             Message::set(Message::SUCCESS, 'Страница "' . $content->title . '" отреакдтирована');
             $this->request->redirect('admin/content/portal');
         } catch (ORM_Validation_Exception $e) {
             $this->values = $_POST;
             $this->errors = $e->errors('models');
         }
     }
     $this->view = View::factory('backend/content/portal/form')->set('values', $this->values)->set('errors', $this->errors)->set('url', 'admin/content/portal/edit/' . $this->request->param('id'));
     $this->template->title = 'Добавление страницы';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 5
0
 function action_edit()
 {
     $vacancy = ORM::factory('vacancy', $this->request->param('id', NULL));
     if (!$vacancy->loaded() or $vacancy->user_id != $this->user->id) {
         Message::set(Message::ERROR, Kohana::message('cabinet', 'vacancy_not_found'));
         $this->request->redirect('cabinet/vacancy');
     }
     $services = array();
     foreach ($this->user->services->find_all() as $service) {
         $services[$service->id] = $service->name;
     }
     if ($_POST) {
         try {
             $vacancy->values($_POST, array('title', 'text', 'service_id'));
             $vacancy->user_id = $this->user->id;
             $vacancy->active = 1;
             $vacancy->date = Date::formatted_time();
             $vacancy->update();
             // Обновляем дату редактирования у компании
             DB::update('services')->set(array('date_edited' => Date::formatted_time()))->where('id', '=', $vacancy->service_id)->execute();
             Message::set(Message::SUCCESS, 'Вакансия успешно отредактирована');
             $this->request->redirect('cabinet/vacancy');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     } else {
         $this->values = $vacancy->as_array();
     }
     $this->view = View::factory('frontend/cabinet/vacancy/form')->set('url', 'cabinet/vacancy/edit/' . $vacancy->id)->set('services', $services)->set('values', $this->values)->set('errors', $this->errors);
     $this->template->title = $this->site_name . 'Редактирование вакансии';
     $this->template->bc['#'] = 'Редактирование вакансии';
     $this->template->content = $this->view;
 }
Ejemplo n.º 6
0
 /**
  * Редактирование новости автомира
  * @return void
  */
 public function action_edit()
 {
     $news = ORM::factory('newsworld', $this->request->param('id', NULL));
     if (!$news->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'news_not_found'));
         $this->request->redirect('admin/news/world');
     }
     if ($_POST) {
         $active = Arr::get($_POST, 'active', 0);
         try {
             $news->values($_POST, array('title', 'text'));
             $news->active = $active;
             $news->date = Date::formatted_time();
             $news->update();
             Message::set(Message::SUCCESS, 'Новость автомира "' . $news->title . '" отредактирована');
             $this->request->redirect('admin/news/world');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     } else {
         $this->values = $news->as_array();
     }
     $this->view = View::factory('backend/news/form')->set('errors', $this->errors)->set('values', $this->values)->set('url', 'admin/news/world/edit/' . $news->id);
     $this->template->title = 'Редактирование новости автомира "' . $news->title . '"';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 7
0
 function action_index()
 {
     if ($_POST) {
         $feedback = ORM::factory('feedback');
         try {
             $feedback->values($_POST, array('title', 'text'));
             $feedback->type = 1;
             $feedback->user_id = $this->user->id;
             $feedback->date = Date::formatted_time();
             $feedback->save();
             $email_view = View::factory('email/feedback')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text)->render();
             Email::send('*****@*****.**', array('*****@*****.**', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE);
             Message::clear();
             Message::set(Message::SUCCESS, 'Спасибо! Ваше сообщение отправлено администрации сайта');
             $this->request->redirect('cabinet');
         } catch (ORM_Validation_Exception $e) {
             Message::set(Message::ERROR, 'Произошла ошибка при отправке сообщения');
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/feedback/create_feedback')->set('errors', $this->errors)->set('values', $this->values);
     $this->template->title = 'Обратная связь';
     $this->template->content = $this->view;
 }
Ejemplo n.º 8
0
 public function action_createOrUpdateDiscount()
 {
     try {
         $post = Validate::factory($_POST)->rule('discount_value', 'not_empty');
         if (!$post->check()) {
             echo "0|ERROR";
             die;
         }
         $dicount_value = $_POST['discount_value'];
         $discount_id = $_POST['discount_id'];
         $discount = new Model_Discount();
         if ($discount_id != 0) {
             $discount = ORM::factory('Discount', $discount_id);
         } else {
             $discount->registrationDate = Date::formatted_time();
         }
         $discount->discount = trim($dicount_value);
         $discount->status = $this->GENERAL_STATUS['ACTIVE'];
         $discount->save();
         echo "1|ok";
     } catch (Exception $exc) {
         echo "0|" . $exc->getTraceAsString();
     }
     die;
 }
Ejemplo n.º 9
0
 function action_edit()
 {
     $stock = ORM::factory('stock', $this->request->param('id', NULL));
     if (!$stock->loaded() or $stock->user_id != $this->user->id) {
         $this->request->redirect('cabinet/stock');
     }
     $services = array();
     foreach ($this->user->services->find_all() as $service) {
         $services[$service->id] = $service->name;
     }
     if ($_POST) {
         try {
             $stock->values($_POST, array('text', 'service_id'));
             $stock->update();
             // Обновляем дату редактирования у компании
             DB::update('services')->set(array('date_edited' => Date::formatted_time()))->where('id', '=', $stock->service_id)->execute();
             Message::set(Message::SUCCESS, 'Акция отредактирована');
             $this->request->redirect('cabinet/stock');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     } else {
         $this->values = $stock->as_array();
     }
     $this->view = View::factory('frontend/cabinet/stock/form')->set('url', 'cabinet/stock/edit/' . $stock->id)->set('values', $this->values)->set('errors', $this->errors)->set('services', $services);
     $this->template->title = $this->site_name . 'Редактирование акции';
     $this->template->bc['#'] = 'Редактирование акции';
     $this->template->content = $this->view;
 }
Ejemplo n.º 10
0
 function action_view()
 {
     $open_coupon = Arr::get($_GET, 'print_coupon', FALSE);
     $service = ORM::factory('service', $this->request->param('id', NULL));
     if (!$service->loaded() || !$service->active) {
         Message::set(Message::ERROR, 'Такой сервис не найден');
         $this->request->redirect('/');
     }
     $this->validation = Validation::factory($_POST)->rule('antibot', 'not_empty');
     if ($_POST) {
         $review = ORM::factory('review');
         try {
             $review->values($_POST, array('text', 'email'));
             $review->date = Date::formatted_time();
             $review->service_id = $service->id;
             $review->active = 0;
             //$review->user_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
             $review->save($this->validation);
             Message::set(Message::SUCCESS, Kohana::message('success_msg', 'review_created'));
             $this->request->redirect('services/' . $service->id);
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/services/view_service')->set('service', $service)->set('open_coupon', $open_coupon)->set('coupon_frame', HTML::iframe('services/get_coupon/' . $service->id, 'coupon_frame'))->set('values', $this->values)->set('errors', $this->errors);
     $this->template->bc['/'] = 'Главная';
     $this->template->bc['#'] = $service->name;
     $this->template->title = 'Автосервис ' . $service->name . ' ' . $service->about;
     $this->template->meta_description = strip_tags($service->about);
     $this->add_js('http://api-maps.yandex.ru/1.1/index.xml?key=' . $this->settings['YMaps_key'] . '&onerror=map_alert');
     $this->add_js('assets/js/maps_detail.js');
     $this->add_js('assets/share42/share42.js');
     $this->template->content = $this->view;
 }
Ejemplo n.º 11
0
 /**
  * Редактирование страницы фильтра
  * @return void
  */
 public function action_edit()
 {
     $content = ORM::factory('content_filter', $this->request->param('id', NULL));
     if (!$content->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'content_not_found'));
         $this->request->redirect('admin/content/filter');
     }
     // Город страницы
     $city = $content->city->name;
     $type = __('filter_type_' . $content->type);
     if ($_POST) {
         try {
             $content->text = Arr::get($_POST, 'text', NULL);
             $content->date_edited = Date::formatted_time();
             $content->update();
             Message::set(Message::SUCCESS, 'Страница фильтра для города ' . $city . ' успешно отредактирована');
             $this->request->redirect('admin/content/filter/index/' . $content->type);
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     } else {
         $this->values = $content->as_array();
     }
     $this->view = View::factory('backend/content/filter/edit')->set('url', 'admin/content/filter/edit/' . $content->id)->set('city', $city)->set('type', $type)->set('values', $this->values)->set('errors', $this->errors);
     $this->template->title = 'Редактирование страницы фильтра для г. ' . $city;
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 12
0
 public function action_add()
 {
     $cities = ORM::factory('city')->get_cities();
     $services = ORM::factory('service')->get_services_as_array();
     if ($_POST) {
         if (isset($_POST['city_id']) and $_POST['city_id'] != 0) {
             $services = ORM::factory('service')->get_services_as_array(array('city_id' => $_POST['city_id']));
         }
         $review = ORM::factory('review');
         try {
             $review->values($_POST, array('name', 'email', 'text', 'service_id'));
             if ($this->user) {
                 $review->user_id = $this->user->id;
             }
             $review->active = 0;
             $review->date = Date::formatted_time();
             $review->save();
             Message::set(Message::SUCCESS, __('review_adding_complete'));
             $this->request->redirect('reviews');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/review/add')->set('values', $this->values)->set('errors', $this->errors)->set('cities', $cities)->set('services', $services);
     $this->template->title = 'Написать отзыв';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 13
0
 public function action_index()
 {
     $company_pages_hits = array();
     $company = ORM::factory('service');
     foreach ($company->find_all() as $c) {
         foreach ($c->visits->find_all() as $visit) {
             if (!array_key_exists(Date::formatted_time($visit->date, 'Y-m-d H'), $company_pages_hits)) {
                 $company_pages_hits[Date::formatted_time($visit->date, 'Y-m-d H')] = 1;
             } else {
                 $company_pages_hits[Date::formatted_time($visit->date, 'Y-m-d H')] += 1;
             }
         }
     }
     ksort($company_pages_hits);
     $company_pages_hits_line = array();
     foreach ($company_pages_hits as $date => $hints) {
         $company_pages_hits_line[] = array($date . ':00 PM', $hints);
     }
     $this->add_js('assets/js/jqplot/plugins/jqplot.highlighter.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.cursor.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.pointLabels.min.js');
     $this->template->content = View::factory('backend/statistics/total_chart')->set('company_line', json_encode($company_pages_hits_line));
     FirePHP::getInstance(TRUE)->log($company_pages_hits);
 }
Ejemplo n.º 14
0
 function action_index()
 {
     $services[0] = 'Выбрать компанию';
     foreach ($this->user->services->find_all() as $service) {
         $services[$service->id] = $service->name;
     }
     if ($_POST) {
         $feedback = ORM::factory('feedback');
         try {
             $feedback->values($_POST, array('title', 'text'));
             $feedback->type = 2;
             $feedback->user_id = $this->user->id;
             $feedback->service_id = Arr::get($_POST, 'service_id', 0);
             $feedback->date = Date::formatted_time();
             $feedback->save();
             $email_view = View::factory('email/adv')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text);
             if ($feedback->service_id != 0) {
                 $email_view->set('service', $this->user->services->where('id', '=', $feedback->service_id)->find());
             }
             $email_view->render();
             Email::send('*****@*****.**', array('*****@*****.**', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE);
             Message::set(Message::SUCCESS, 'Спасибо! Ваше заявка принята на рассмотрение администрацией сайта');
             $this->request->redirect('cabinet');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/adv/create_blank')->set('services', $services)->set('errors', $this->errors)->set('values', $this->values);
     $this->template->title = 'Реклама на сайте';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
Ejemplo n.º 15
0
 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $user = Auth::instance()->get_user();
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             $activate = FALSE;
             //admin whatever he wants
             if ($user->is_admin()) {
                 $activate = TRUE;
             } elseif ($user->id_user == $active_ad->id_user and !in_array(core::config('general.moderation'), Model_Ad::$moderation_status)) {
                 $activate = TRUE;
             } else {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
             }
             //its not published
             if ($active_ad->status == Model_Ad::STATUS_PUBLISHED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
             }
             //expired but cannot reactivate option
             if (Core::config('advertisement.expire_reactivation') == FALSE and core::config('advertisement.expire_date') > 0 and Date::formatted_time($active_ad->published . '+' . core::config('advertisement.expire_date') . ' days') < Date::formatted_time()) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement can not be marked as “active”. It's expired."));
             }
             //pending payment
             if ($activate === TRUE and ($order = $active_ad->get_order()) !== FALSE and $order->status == Model_Order::STATUS_CREATED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement can not be marked as “active”. There is a pending payment."));
             }
             //activate the ad
             if ($activate === TRUE) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = Model_Ad::STATUS_PUBLISHED;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             } else {
                 HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
             }
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads-activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title));
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
 }
Ejemplo n.º 16
0
 function action_add()
 {
     $this->check_entrance_fee();
     //  выбираем среди платежей тот, который  вступительный.
     //Если он есть - больше в списке не показываем. Нет - показываем и позволяем выбирать только его
     $entrance_fee = DB::select('id')->from('invoice')->where('user_id', '=', $this->user->id)->where('status', '=', 'P')->where('entrance_fee', '=', 'Y')->limit(1)->execute()->as_array('id');
     $settings = DB::select('id', 'name', 'price', 'days', 'system_name')->from('payment_settings')->where('status', '=', 'Y')->where('in_list', '=', 'Y');
     if (empty($entrance_fee)) {
         $settings->where("system_name", "=", "entrance_fee");
     } else {
         $settings->where_open()->where("system_name", "!=", "entrance_fee")->or_where("system_name", "=", NULL)->where_close();
     }
     $settings = $settings->order_by('sort', 'ASC')->execute()->as_array('id');
     $payments = DB::select('id', 'payment_name', 'tips', 'description')->from('payment')->where('status', '=', 'Y')->order_by('position', 'ASC')->execute()->as_array('id');
     if (empty($payments) || empty($settings)) {
         Message::set(Message::ERROR, "Не заданы тарифы оплаты. Обратитесь к администратору сайта.");
         $this->request->redirect('cabinet/payment/');
     }
     if ($_POST) {
         $payment_value = Arr::get($_POST, "payment_value");
         $payment_system = Arr::get($_POST, "payment_system");
         $invoice = ORM::factory('invoice');
         try {
             if (empty($payment_value) || empty($payment_value)) {
                 throw new Exception('empty_value');
             }
             if (!isset($settings[$payment_value]) || !isset($payments[$payment_system])) {
                 throw new Exception('not_exists');
             }
             $invoice->user_id = $this->user->id;
             $invoice->payment_id = $payment_system;
             $invoice->amount = $settings[$payment_value]['price'];
             $invoice->days_amount = $settings[$payment_value]['days'];
             $invoice->create_date = Date::formatted_time();
             $invoice->modify_date = Date::formatted_time();
             $invoice->status = 'N';
             // проверяем не вступительный ли платеж
             if ($settings[$payment_value]['system_name'] == "entrance_fee") {
                 $invoice->entrance_fee = "Y";
             }
             $invoice->save();
             $this->request->redirect('cabinet/payment/show/' . $invoice->id);
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         } catch (Exception $e) {
             Message::set(Message::ERROR, 'Ошибка при обработке платежа');
             Message::set(Message::ERROR, $e->getMessage());
             $this->errors = array();
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/payment/add')->set('values', $this->values)->set('errors', $this->errors)->set('settings', $settings)->set('payments', $payments);
     $this->template->title = 'Добавить платеж';
     $this->template->bc['#'] = 'Добавить платеж';
     $this->template->content = $this->view;
 }
Ejemplo n.º 17
0
 public static function full_date($date_str, $with_time = false, $without_year = false)
 {
     $time_stamp = $with_time ? 'd * Y H:i' : 'd * Y';
     if ($without_year === true) {
         $time_stamp = str_replace(' Y', '', $time_stamp);
     }
     $formatted_date = Date::formatted_time($date_str, $time_stamp);
     return __($formatted_date, array('*' => __('genitive_month_' . Date::formatted_time($date_str, 'm'))));
 }
Ejemplo n.º 18
0
 public function action_createOrUpdateUser()
 {
     try {
         $post = Validate::factory($_POST)->rule('person_fname', 'not_empty')->rule('person_lname', 'not_empty')->rule('person_email', 'not_empty')->rule('user_id', 'not_empty')->rule('user_name', 'not_empty')->rule('user_password', 'not_empty')->rule('user_group', 'not_empty')->rule('person_country', 'not_empty');
         if (!$post->check()) {
             echo "0|ERROR - Empty Data Post";
             die;
         }
         $person_fname = StringHelper::cleanEmptyString4NULL($_POST['person_fname']);
         $person_lname = StringHelper::cleanEmptyString4NULL($_POST['person_lname']);
         $person_email = StringHelper::cleanEmptyString4NULL($_POST['person_email']);
         $user_id = $_POST['user_id'];
         $user_name = StringHelper::cleanEmptyString4NULL($_POST['user_name']);
         $user_password = $_POST['user_password'];
         $user_group = $_POST['user_group'];
         $person_country = $_POST['person_country'];
         $person_phone1 = StringHelper::cleanEmptyString4NULL($_POST['person_phone1']);
         $person_phone2 = StringHelper::cleanEmptyString4NULL($_POST['person_phone2']);
         $person_cellphone = StringHelper::cleanEmptyString4NULL($_POST['person_cellphone']);
         $person_address1 = StringHelper::cleanEmptyString4NULL($_POST['person_address1']);
         $person_address2 = StringHelper::cleanEmptyString4NULL($_POST['person_address2']);
         $person_city = StringHelper::cleanEmptyString4NULL($_POST['person_city']);
         $person_zipcode = StringHelper::cleanEmptyString4NULL($_POST['person_zipcode']);
         $person_array_data = array('fName' => $person_fname, 'lName' => $person_lname, 'phone1' => $person_phone1, 'phone2' => $person_phone2, 'address1' => $person_address1, 'address2' => $person_address2, 'idCountry' => $person_country, 'email' => $person_email, 'city' => $person_city, 'zipcode' => $person_zipcode, 'type' => $this->USER_TYPE['EMPLOYEE']);
         $user_array_data = array('idUser' => NULL, 'userName' => $user_name, 'password' => $user_password, 'status' => $this->GENERAL_STATUS['ACTIVE'], 'registrationDate' => NULL, 'idGroup' => $user_group);
         DB::query(NULL, "BEGIN WORK")->execute();
         $success = FALSE;
         if ($user_id == 0) {
             //CREATE PERSON
             $person_saved = DB::insert('person', array_keys($person_array_data))->values($person_array_data)->execute();
             //CREATE USER
             $user_array_data['idUser'] = $person_saved[0];
             $user_array_data['registrationDate'] = Date::formatted_time();
             $user_saved = DB::insert('user', array_keys($user_array_data))->values($user_array_data)->execute();
             $success = ($person_saved[1] and $user_saved[1]);
         } else {
             //UPDATE PERSON
             $person_update = DB::update('person')->set($person_array_data)->where('idPerson', '=', $user_id)->execute();
             //UPDATE USER
             unset($user_array_data['idUser']);
             unset($user_array_data['registrationDate']);
             $user_update = DB::update('user')->set($user_array_data)->where('idUser', '=', $user_id)->execute();
             $success = ($person_update >= 0 or $user_update >= 0);
         }
         if ($success) {
             DB::query(NULL, "COMMIT")->execute();
             echo "1|ok";
         }
     } catch (Exception $exc) {
         DB::query(NULL, "ROLLBACK")->execute();
         echo "0|COMMIT ERROR - ROLLBACK ACTION SUCCESS - " . $exc->getTraceAsString();
     }
     die;
 }
Ejemplo n.º 19
0
 /**
  * Обновление географического кеша
  * @return void
  */
 public function action_geo_cache_updater()
 {
     if (Arr::get($_GET, 'start') != 'geo_cache') {
         return;
     }
     if (Geography::update_geography_params()) {
         echo "Географический кэш успешно обновлен в " . Date::formatted_time() . " \n";
     } else {
         echo "Ошибка обновления географического кэша \n";
     }
 }
 /**
  * Formats a log entry.
  *
  * @param   array   $message
  * @param   string  $format
  * @return  string
  */
 public function format_message(array $message, $format = "time --- level: body in file:line")
 {
     $message['time'] = Date::formatted_time('@' . $message['time'], Log_Writer::$timestamp, Log_Writer::$timezone, TRUE);
     $message['level'] = $this->_log_levels[$message['level']];
     $string = strtr($format, array_filter($message, 'is_scalar'));
     if (isset($message['additional']['exception'])) {
         // Re-use as much as possible, just resetting the body to the trace
         $message['body'] = $message['additional']['exception']->getTraceAsString();
         $message['level'] = $this->_log_levels[Log_Writer::$strace_level];
         $string .= PHP_EOL . strtr($format, array_filter($message, 'is_scalar'));
     }
     return $string;
 }
Ejemplo n.º 21
0
Archivo: docs.php Proyecto: nexeck/docs
	public function action_static()
	{
		$category = $this->request->param('category');
		$article = $this->request->param('article');
		
		try
		{
			// Load the article
			$view = new View("docs/{$this->lang}/$category/$article");
		}
		catch (Exception $e)
		{
			// Oh noes!
			$this->response->status(404);
			$view = new View('404');
		}

		$this->template->content = $view;

		if (($feed = Cache::instance()->get('feed')) === NULL)
		{
			// GitHub atom feed URL
			$url = 'https://github.com/goyote/docs/commits/master.atom';

			// Grab the 10 latest entries
			$entries = Feed::parse($url, 10);

			$feed = array();
			foreach ($entries as $entry)
			{
				$feed[] = array(
					'title' => $entry['title'],
					'href' => (string) $entry['link']['href'],
					'date' => Date::formatted_time($entry['updated'], 'n-d-Y'),
				);
			}

			// Cache the entries for 1 day
			Cache::instance()->set('feed', $feed, Date::DAY);
		}

		$this->template->set(array(
			'category' => ucwords(Inflector::humanize($category)),
			'article' => ucwords(Inflector::humanize($article)),
			'url' => array('category' => $category, 'article' => $article),
			'navigation' => $this->_config['navigation'],
			'resources' => Arr::path($this->_config, "resources.$category.$article"),
			'languages' => $this->_config['language']['supported'],
			'feed' => $feed,
		));
	}
Ejemplo n.º 22
0
 public function action_view()
 {
     $question = ORM::factory('question', $this->request->param('id', NULL));
     if (!$question->loaded()) {
         Message::set(Message::ERROR, 'Запрос не найден');
         $this->request->redirect('cabinet/qa');
     }
     //		C::pr($question);
     if ($question->active == 0) {
         Message::set(Message::ERROR, 'Запрос не найден');
         $this->request->redirect('cabinet/qa');
     }
     $works = array();
     foreach ($question->works->find_all() as $work) {
         $works[] = $work->name;
     }
     $services = array();
     foreach ($this->user->services->find_all() as $service) {
         $services[$service->id] = $service->name;
     }
     //		C::pr($this->user);
     if ($_POST) {
         $answer = ORM::factory('answer');
         try {
             $answer->values($_POST, array('text', 'service_id'));
             $answer->question_id = $question->id;
             $answer->date = Date::formatted_time();
             $answer->save();
             $email_view = View::factory('email/qa_answer')->set('text', $answer->text)->set('username', $question->contact)->set('message_id', $answer->id)->set('service_id', $answer->service_id)->set('service_name', $services[$answer->service_id])->render();
             $message = ORM::factory('emailsender');
             $message->mail_to = $question->email;
             $message->mail_from = '*****@*****.**';
             $message->title = 'Ответ на ваш вопрос на сайте as-avtoservice.ru';
             $message->text = $email_view;
             $message->status = 'queue';
             $message->date_create = Date::formatted_time();
             $message->save();
             Message::set(Message::SUCCESS, 'Ответ на запрос успешно добавлен');
             $this->request->redirect('cabinet/qa');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/qa/form')->set('url', 'cabinet/qa/view/' . $question->id)->set('question', $question)->set('works', $works)->set('services', $services)->set('values', $this->values)->set('errors', $this->errors);
     $this->template->title = $this->site_name . 'Ответ на запрос';
     $this->template->bc['#'] = 'Ответ на запрос';
     $this->template->content = $this->view;
 }
Ejemplo n.º 23
0
 public function action_company()
 {
     $visitor_data = Arr::get($_POST, 'data') ? unserialize(Encrypt::instance('statistics')->decode($_POST['data'])) : NULL;
     $company = ORM::factory('service', $this->request->param('id'));
     if (!$company->loaded() or !$visitor_data) {
         return FALSE;
     }
     $request = Request::factory(Route::get('company_info')->uri(array('id' => $company->id, 'company_type' => Model_Service::$type_urls[$company->type])));
     // Если URI не совпадает или истекло время
     if ($request->uri() != $visitor_data['uri'] or strtotime(Date::formatted_time()) - $visitor_data['time_created'] > 60) {
         return FALSE;
     }
     $visit_data = array('date' => Date::formatted_time(), 'uri' => $request->uri(), 'directory' => $request->directory(), 'controller' => $request->controller(), 'action' => $request->action(), 'params' => json_encode($request->get_params()), 'client_ip' => $visitor_data['client_ip'], 'referrer' => $visitor_data['referrer']);
     ORM::factory('visit')->save_visit($visit_data);
 }
Ejemplo n.º 24
0
 public function save_visit($request_data = NULL)
 {
     $request = Request::current();
     $this->date = isset($request_data['date']) ? $request_data['date'] : Date::formatted_time();
     $this->uri = isset($request_data['uri']) ? $request_data['uri'] : $request->uri();
     $this->directory = isset($request_data['directory']) ? $request_data['directory'] : $request->directory();
     $this->controller = isset($request_data['controller']) ? $request_data['controller'] : $request->controller();
     $this->action = isset($request_data['action']) ? $request_data['action'] : $request->action();
     $this->params = isset($request_data['params']) ? $request_data['params'] : json_encode($request->get_params());
     $this->client_ip = isset($request_data['client_ip']) ? $request_data['client_ip'] : Request::$client_ip;
     if (isset($request_data['referrer'])) {
         $this->referrer = $request_data['referrer'] == 'havent_referrer' ? NULL : $request_data['referrer'];
     } else {
         $this->referrer = isset($_SERVER['HTTP_REFERER']) ? $request->referrer() : NULL;
     }
     $this->save();
 }
Ejemplo n.º 25
0
 /**
  * Displays a list of all users
  *
  * @uses  Request::is_datatables
  * @uses  ORM::dataTables
  * @uses  Text::plain
  * @uses  Text::auto_link
  * @uses  User::roles
  * @uses  HTML::anchor
  * @uses  HTML::icon
  * @uses  Route::get
  * @uses  Route::url
  * @uses  Date::formatted_time
  * @uses  Assets::popup
  */
 public function action_list()
 {
     $is_datatables = Request::is_datatables();
     if ($is_datatables) {
         $users = ORM::factory('user');
         // @todo fix dummy id column for roles to match the column order
         $this->_datatables = $users->dataTables(array('name', 'mail', 'created', 'login', 'id', 'status'));
         foreach ($this->_datatables->result() as $user) {
             $this->_datatables->add_row(array(HTML::anchor($user->url, Text::plain($user->nick)), Text::auto_link($user->mail), Date::formatted_time($user->created, 'M d, Y'), $user->login > 0 ? Date::formatted_time($user->login, 'M d, Y') : __('Never'), User::roles($user), $user->status == 1 ? '<span class="status-active"><i class="fa fa-check-circle"></i></span>' : '<span class="status-blocked"><i class="fa fa-ban"></i></span>', HTML::icon(Route::get('admin/user')->uri(array('action' => 'edit', 'id' => $user->id)), 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit User'))) . '&nbsp;' . HTML::icon(Route::get('admin/permission')->uri(array('action' => 'user', 'id' => $user->id)), 'fa-key', array('class' => '', 'title' => __('Edit Permission'))) . '&nbsp;' . HTML::icon($user->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete User'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-users'))));
         }
     }
     Assets::popup();
     $this->title = __('Users');
     $url = Route::url('admin/user', array('action' => 'list'), TRUE);
     $view = View::factory('admin/user/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('url', $url);
     $this->response->body($view);
 }
Ejemplo n.º 26
0
 function action_add()
 {
     if ($_POST) {
         $service = ORM::factory('service');
         try {
             $service->values($_POST, array('name'));
             $service->user_id = $this->user->id;
             $service->date = Date::formatted_time();
             $service->save();
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/service/add')->set('values', $this->values)->set('errors', $this->errors);
     $this->template->title = $this->site_name . 'Добавление сервиса';
     $this->template->content = $this->view;
 }
Ejemplo n.º 27
0
 /**
  * Редактирование страницы поиска по округу
  * @return void
  */
 public function action_edit()
 {
     $content = ORM::factory('content_district', $this->request->param('id', NULL));
     if (!$content->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'content_not_found'));
         $this->request->redirect('admin/content/district');
     }
     $this->values = $content->as_array();
     if ($_POST) {
         $content->values($_POST, array('text'));
         $content->date_edited = Date::formatted_time();
         $content->update();
         Message::set(Message::SUCCESS, 'Страница для поиска по округу "' . $content->district->name . '" отредактирована');
         $this->request->redirect('admin/content/district');
     }
     $this->view = View::factory('backend/content/cars_works_edit')->set('content', $content)->set('url', 'admin/content/district/edit/' . $content->id)->set('values', $this->values);
     $this->template->bc['#'] = 'Редактирование страницы поиска по округу ' . $content->district->name;
     $this->template->content = $this->view;
 }
Ejemplo n.º 28
0
 /**
  * Formats a log entry
  *
  * @param   array   $message  Message
  * @param   string  $format   Message format [Optional]
  * @return  string
  *
  * @uses    Date::formatted_time
  */
 public function format_message(array $message, $format = NULL)
 {
     if (is_null($format)) {
         $format = Log_Writer::$format_string;
     }
     $exception = isset($message['additional']['exception']) ? $message['additional']['exception'] : NULL;
     $message['time'] = Date::formatted_time($message['time'], Log_Writer::$timestamp, Log_Writer::$timezone);
     $message['level'] = $this->_log_levels[$message['level']];
     unset($message['additional'], $message['trace']);
     // FIX: $message should consist of an array of strings
     $message = array_filter($message, 'is_string');
     $string = strtr($format, $message);
     if ($exception) {
         // Re-use as much as possible, just resetting the body to the trace
         $message['body'] = $exception->getTraceAsString();
         $message['level'] = $this->_log_levels[Log_Writer::$strace_level];
         $string .= PHP_EOL . strtr($format, $message);
     }
     return $string;
 }
Ejemplo n.º 29
0
 /**
  * Display a list of incoming messages
  *
  * @uses  Assets::popup
  * @uses  Route::url
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  Request::is_datatables
  * @uses  Form::checkbox
  * @uses  HTML::anchor
  * @uses  Date::formatted_time
  * @uses  HTML::icon
  * @uses  Text::limit_chars
  */
 public function action_inbox()
 {
     Assets::popup();
     $url = Route::url('user/message', array('action' => 'inbox'), TRUE);
     $redirect = Route::get('user/message')->uri(array('action' => 'inbox'));
     $form_action = Route::get('user/message')->uri(array('action' => 'bulk', 'id' => PM::INBOX));
     $destination = '?destination=' . $redirect;
     $is_datatables = Request::is_datatables();
     /** @var $messages Model_Message */
     $messages = ORM::factory('Message')->loadInbox();
     if ($is_datatables) {
         $this->_datatables = $messages->dataTables(array('id', 'subject', 'sender', 'sent'));
         foreach ($this->_datatables->result() as $message) {
             $this->_datatables->add_row(array(Form::checkbox('messages[' . $message->id . ']', $message->id, isset($_POST['messages'][$message->id])), HTML::anchor($message->user->url, $message->user->nick, array('class' => 'message-' . $message->status)), HTML::anchor($message->url, Text::limit_chars($message->subject, 20), array('class' => 'message-' . $message->status)) . ' ' . HTML::anchor($message->url, Text::limit_chars(strip_tags($message->body), 80)), Date::formatted_time($message->sent, 'M d, Y'), HTML::icon($message->delete_url . $destination, 'fa-trash-o', array('title' => __('Delete Message'), 'data-toggle' => 'popup', 'data-table' => '#user-message-inbox'))));
         }
     }
     $this->title = __('Inbox');
     $view = View::factory('message/inbox')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('action', $form_action)->set('url', $url);
     $this->response->body($view);
 }
Ejemplo n.º 30
0
 function action_index()
 {
     // Model initial
     $service = $this->user->services;
     $news = $this->user->news_service;
     $stock = $this->user->stocks;
     $vacancy = $this->user->vacancies;
     $question = ORM::factory('question');
     $statistics = array('labels' => array(), 'charts' => array());
     $reviews = array();
     foreach ($service->find_all() as $s) {
         $chart = array();
         foreach ($s->visits->find_all() as $visit) {
             $date = Date::formatted_time($visit->date, 'Y-m-d');
             if (array_key_exists($date, $chart) === false) {
                 $chart[$date] = array($date, 1);
             } else {
                 $chart[$date][1] += 1;
             }
         }
         if (count($chart) > 0 and count($chart) < 2) {
             $chart[] = array(Date::formatted_time('now', 'Y-m-d'), 0);
         }
         $chart = array_values($chart);
         $statistics['labels'][] = array('label' => $s->name);
         $statistics['charts'][] = $chart;
         foreach ($s->reviews->order_by('date', 'DESC')->find_all() as $r) {
             $reviews[] = array('service_name' => $s->name, 'date' => $r->date, 'text' => $r->text);
         }
     }
     $this->view = View::factory('frontend/cabinet/dashboard')->set('statistics', json_encode($statistics))->set('service', $this->user->services)->set('news', $news)->set('stock', $stock)->set('vacancy', $vacancy)->set('question', $question)->set('reviews', $reviews)->set('notices_unread_count', 0)->set('notices_all_count', 0);
     $this->template->title = $this->site_name . 'Личный кабинет';
     $this->template->content = $this->view;
     $this->add_css('assets/js/jqplot/jquery.jqplot.min.css');
     $this->add_js('assets/js/jqplot/jquery.jqplot.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.highlighter.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.cursor.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js');
     $this->add_js('assets/js/jqplot/plugins/jqplot.pointLabels.min.js');
     $this->add_js('assets/js/statistics_main.js');
 }