コード例 #1
0
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $message = "";
         Yii::app()->page->title = Yii::t("user", "Избранное");
         $userModel = CatalogUsers::fetch(Yii::app()->user->id);
         $del = (int) Yii::app()->request->getParam("del", 0);
         if ($del > 0) {
             Yii::app()->favorites->delete($del, "catalog_items");
         }
         $list = Yii::app()->favorites->getListId("catalog=:catalog", array(":catalog" => "catalog_items"));
         if (sizeof($list) > 0) {
             $sql = " ( ";
             foreach ($list as $key => $value) {
                 if ($sql != " ( ") {
                     $sql .= " OR ";
                 }
                 $sql .= "id='" . $value . "'";
             }
             $sql .= " )";
             $items = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("status_id=1")->setConditions($sql)->setCache(0));
         } else {
             $items = array();
         }
         $this->render("index", array("message" => $message, "items" => $items, "userModel" => $userModel));
     }
 }
コード例 #2
0
 public function beforeAction($action)
 {
     if (Yii::app()->user->isGuest) {
         $controller = Yii::app()->controller->getId();
         if ($controller != "default" || $action->getId() != 'login' && $action->getId() != 'index' && $action->getId() != 'captcha') {
             $this->redirect('/console/default/login');
         }
     } else {
         $userModel = CatalogUsers::fetch(Yii::app()->user->id);
         if (!$userModel || !$userModel->type_id) {
             Yii::app()->user->logout();
             $this->redirect('/console/default/login');
         }
         if ($userModel->type_id->id == 1) {
             $this->redirect('/');
         }
     }
     /*
             if ($this->getBackendUser()->getState('expires') > 0 && $this->getBackendUser()->getState('expires') < time()) {
                 $this->getBackendUser()->logout(false);
                 $this->redirect('/console');
             } else {
                 $this->checkAccess();
             }*/
     return parent::beforeAction($action);
 }
コード例 #3
0
 public function checked_exists_user($attribute, $params)
 {
     if (!$this->hasErrors() && !empty($this->user_id) && $this->user_id > 0) {
         $exists = CatalogUsers::fetch($this->user_id);
         if (sizeof($exists) == 0) {
             $this->addErrors(array("0" => Yii::t("models", "Указан не существующий ID пользователя")));
         }
     }
 }
コード例 #4
0
ファイル: UserHelper.php プロジェクト: bogiesoft/yii-travel
 public static function getAmount(CatalogUsers $user = null)
 {
     if (empty($user)) {
         $user = CatalogUsers::fetch(Yii::app()->user->id);
     }
     $amount = $user->amount;
     if (empty($amount)) {
         $amount = 0;
     }
     return $amount;
 }
コード例 #5
0
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->page->title = "Мои заказы";
         $user = CatalogUsers::fetch(Yii::app()->user->id);
         $orders = OrderRequest::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)->setConditions("user_id=:user_id")->setParams(array(":user_id" => Yii::app()->user->id))->setLimit(200)->setOrderBy("date"));
         $this->render("index", array("user" => $user, "orders" => $orders));
     } else {
         $this->redirect(SiteHelper::createUrl("/"));
     }
 }
コード例 #6
0
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $message = "";
         Yii::app()->page->title = Yii::t("user", "Рабочий стол");
         $userModel = CatalogUsers::fetch(Yii::app()->user->id);
         if (!empty($_POST["desktop_save"])) {
             $desktopID = (int) Yii::app()->request->getParam("desktopID", 0);
             $userModel->desktop = $desktopID;
             $userModel->save();
             $userModel->formMessage = Yii::t("user", "Рабочий стол успешно сохранен");
         }
         $items = CatalogDesktops::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0));
         $this->render("index", array("message" => $message, "items" => $items, "userModel" => $userModel));
     }
 }
コード例 #7
0
 public function check_passwords($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $key = !empty($_GET["key"]) ? SiteHelper::checkedVaribal($_GET["key"], "string") : "";
         $confirm = CatalogUsersConfirm::findByAttributes(array("confirm_key" => $key));
         if (!empty($confirm) && sizeof($confirm) == 1) {
             $userModel = CatalogUsers::fetch($confirm[0]->user_id->id);
             if ($userModel->active == 0) {
                 $error = Yii::t("models", "Ваш аккаунт не активирован");
             }
         } else {
             $error = Yii::t("models", "Указан не верный ключ");
         }
         if (!empty($error)) {
             $this->addErrors(array("0" => $error));
         } else {
             $confirm[0]->delete();
         }
     }
 }
コード例 #8
0
ファイル: Controller.php プロジェクト: bogiesoft/yii-travel
 public function render($view, $data = array(), $return = false)
 {
     if ($this->beforeRender($view)) {
         if (!Yii::app()->user->isGuest) {
             $userModel = CatalogUsers::fetch(Yii::app()->user->getId());
             if ($userModel->id > 0) {
                 $USER = $userModel;
             } else {
                 Yii::app()->user->logout();
                 $this->redirect(SiteHelper::createUrl("/"));
             }
         } else {
             $USER = new CatalogUsers();
         }
         $data = array_merge($data, array("Theme" => Yii::app()->getTheme(), "controller" => $this, "USER" => $USER));
         $output = $this->renderPartial($view, $data, true);
         if (($layoutFile = $this->getLayoutFile($this->layout)) !== false) {
             $output = $this->renderFile($layoutFile, array_merge($data, array("content" => $output)), true);
         }
         $this->afterRender($view, $output);
         $output = $this->processOutput($output);
         if ($return) {
             return $output;
         } else {
             echo $output;
         }
     }
 }
コード例 #9
0
 public function send($key, $types, $userId, array $arrayParams = array())
 {
     $status = false;
     $notification = NotificationsType::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("`key`=:key")->setParams(array(":key" => $key)));
     if (!empty($notification) && sizeof($notification) > 0) {
         $notificationMessage = NotificationsActions::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)->setConditions("type_id=:type_id")->setParams(array(":type_id" => $notification[0]->id)));
         if (!empty($notificationMessage) && sizeof($notificationMessage) > 0) {
             for ($i = 0; $i < sizeof($notificationMessage); $i++) {
                 if (strtolower($notificationMessage[$i]->key_word) == "info") {
                     $NItem = new Notifications();
                     $NItem->type_id = $notification[0]->id;
                     $NItem->is_new = 1;
                     $NItem->action_id = $notificationMessage[$i]->id;
                     $message = $notificationMessage[$i]->mesage;
                     $subject = $notificationMessage[$i]->subject;
                     foreach ($arrayParams as $key => $value) {
                         $message = str_replace("{" . $key . "}", $value, $message);
                         $subject = str_replace("{" . $key . "}", $value, $subject);
                     }
                     $NItem->message = $message;
                     $NItem->subject = $subject;
                     if (!$notificationMessage[$i]->to_user) {
                         $NItem->user_id = $userId;
                     } else {
                         $toUserModel = CatalogUsers::findByAttributes(array("email" => $notificationMessage[$i]->to_user));
                         if ($toUserModel[0]->id > 0) {
                             $NItem->user_id = $toUserModel[0]->id;
                         } else {
                             $this->errors[] = array("Ошибка обработки действвий", "Событие: #" . $notification[$i] . ", Действие: #" . $notificationMessage[$i] . " - Email указыыный в поле TO_USER не зарегестрирован в базе");
                         }
                     }
                     $NItem->date = time();
                     if (!empty($arrayParams["catalog"])) {
                         $NItem->catalog = $arrayParams["catalog"];
                     }
                     if (!empty($arrayParams["item_id"])) {
                         $NItem->item_id = $arrayParams["item_id"];
                     }
                     if (sizeof($this->errors) == 0) {
                         if (!$NItem->save()) {
                             $this->errors[] = print_r($NItem->getErrors(), true);
                         }
                     }
                 }
                 if (strtolower($notificationMessage[$i]->key_word) == "mail") {
                     if (!$notificationMessage[$i]->to_user) {
                         $userTo = CatalogUsers::fetch($userId);
                     } else {
                         $toUserModel = CatalogUsers::findByAttributes(array("email" => $notificationMessage[$i]->to_user));
                         if ($toUserModel[0]->id > 0) {
                             $userTo = $toUserModel[0];
                         } else {
                             $this->errors[] = array("Ошибка обработки действвий", "Событие: #" . $notification[$i] . ", Действие: #" . $notificationMessage[$i] . " - Email указыыный в поле TO_USER не зарегестрирован в базе");
                         }
                     }
                     if (!empty($userTo) && $userTo->id > 0) {
                         $messages = $notificationMessage[$i]->mesage;
                         foreach ($arrayParams as $key => $value) {
                             $messages = str_replace("{" . $key . "}", $value, $messages);
                         }
                         SiteHelper::mailto($notificationMessage[$i]->subject, $notificationMessage[$i]->send_from, $userTo->email, $messages, $notificationMessage[$i]->copy_sender);
                         $status = true;
                     } else {
                         $this->errors[] = array("Ошибка отправки сообщения", "Указан не верный ID пользователя");
                         return false;
                     }
                 }
             }
         } else {
             $this->errors[] = array("Ошибка события", "Для данного соьытия ( #" . $notification[0]->id . " ) не указы события");
         }
     } else {
         $this->errors[] = array("Ошибка события", "Ошибка определения типа события");
     }
     if (is_array($this->errors) && sizeof($this->errors) > 0) {
         throw new Exception(print_r($this->errors, true));
     }
     return $status;
 }
コード例 #10
0
ファイル: wap-main.php プロジェクト: bogiesoft/yii-travel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php 
$this->renderPartial('//layouts/header');
?>
</head>

<?php 
Yii::app()->session["otherStyle"] = false;
$mainClass = "";
if (Yii::app()->controller->getId() != "site") {
    $mainClass = "MInnerPage";
}
if (!Yii::app()->user->isGuest) {
    $userModel = CatalogUsers::fetch(Yii::app()->user->getId());
    if ($userModel->desktop->id > 0 && $userModel->desktop->class_name) {
        if (!empty($mainClass)) {
            $mainClass .= " ";
        }
        $mainClass .= "otherStyle " . $userModel->desktop->class_name;
        Yii::app()->session["otherStyle"] = true;
    }
}
?>

<body>
<div id="Main" <?php 
echo !empty($mainClass) ? ' class="' . $mainClass . '"' : '';
?>
>
コード例 #11
0
 public static function step2()
 {
     $userModel = CatalogUsers::fetch(Yii::app()->user->getId());
     Yii::app()->controller->widget("trainingsWidget", array("template" => "trainings_2Step", "param" => array("type_id" => $userModel->type_id->id)));
 }
コード例 #12
0
ファイル: CatalogUsers.php プロジェクト: bogiesoft/yii-travel
 public function updatePasswordHashMD5($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $DBUser = CatalogUsers::fetch(Yii::app()->user->id);
         if ($this->password != $DBUser->password) {
             $this->password = md5($this->password);
         }
     }
 }
コード例 #13
0
ファイル: UserNotifier.php プロジェクト: bogiesoft/yii-travel
 static function lostPasswordConfirm($event)
 {
     $userSender = $event->sender[0];
     $user = CatalogUsers::fetch($userSender->user_id->id);
     $user->password = md5($_POST["CatalogUsersLostConfirm"]["password"]);
     $user->save();
     SiteHelper::setLog("catalog_users", "lost_password", $user->id);
     if ($user->hasErrors() && sizeof($user) > 0) {
         $errors = "Ошибка сохранение нового пароля: ";
         foreach ($user->getErrors() as $data) {
             foreach ($data as $key => $value) {
                 $errors .= $value . ", ";
             }
         }
         throw new Exception($errors);
     } else {
         // Отправляем письмо уведомления о смене пароля
         Yii::app()->notifications->send("lostpassword_save", ["mail"], $user->id);
     }
 }
コード例 #14
0
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $user = new CatalogUsersAuth();
     if (!empty($_POST["CatalogUsersAuth"])) {
         Yii::app()->page->title = Yii::t("user", "Авторизация");
         $user->setAttributes($_POST["CatalogUsersAuth"]);
         if ($user->validate()) {
             $identity = new UserIdentity($user->email, $user->password);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity);
             }
             Yii::app()->session["userFirstIn"] = true;
             $user->onLogin(new CModelEvent(CatalogUsers::fetch(Yii::app()->user->id)));
             if (Yii::app()->session['redirect']) {
                 $redirectUrl = Yii::app()->session['redirect'];
                 Yii::app()->session['redirect'] = "";
                 $this->redirect($redirectUrl);
             }
             $this->redirect($this->createUrl("/user"));
         }
     }
     $this->render('login', array('form' => $user));
 }
コード例 #15
0
 public function actionGetUserInfo()
 {
     $id = (int) Yii::app()->request->getParam("id", 0);
     $field = Yii::app()->request->getParam("field", "");
     if ($id > 0 && !empty($field)) {
         $userModel = CatalogUsers::fetch($id);
         if ($userModel->id > 0 && property_exists($userModel, $field)) {
             Yii::app()->ih->load($_SERVER['DOCUMENT_ROOT'] . '/f/temp/1.jpg')->text($userModel->{$field}, $_SERVER['DOCUMENT_ROOT'] . '/themes/classic/font/georgia.ttf', 11, array(2, 95, 160), CImageHandler::CORNER_LEFT_BOTTOM, 3, 3)->save($_SERVER['DOCUMENT_ROOT'] . '/f/temp/2.jpg');
             echo '<img src="/f/temp/2.jpg" />';
         }
     }
 }