public function init() { date_default_timezone_set('Asia/Ho_Chi_Minh'); parent::init(); $this->pageTitle = Yii::app()->params['page_title']; $this->metaKeywords = 'hoc online, training online'; $this->metaDescription = 'hoc online, training online'; $cs = Yii::app()->getClientScript(); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/global.js'); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/countdown.js'); $language = Yii::app()->session->get('language') ? Yii::app()->session->get('language') : 'en'; Yii::app()->setLanguage($language); //echo Yii::app()->user->id; exit(); if (Yii::app()->user->id) { //$user = new WUsers; $userInfo = WUser::getUserById(Yii::app()->user->id); //$agen = unserialize($userInfo['group']); $this->username = Yii::app()->user->name; Yii::app()->session['username'] = $this->username; Yii::app()->session['fullname'] = $userInfo['fullname']; Yii::app()->session['group_id'] = $userInfo['user_group_id']; if (Yii::app()->session['group_id'] == 2) { Yii::app()->session['company_code'] = $userInfo['company_code']; } // var_dump($userInfo['avatar']); $string_avatar_none = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->theme->baseUrl . '/img/no_avatar.jpg'; if (isset($userInfo['user_group_id']) && !empty($userInfo['user_group_id'])) { // gv if ($userInfo['user_group_id'] == 1) { $string_avatar_none = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->theme->baseUrl . '/img/trainer.gif'; } // hs if ($userInfo['user_group_id'] == 2) { $string_avatar_none = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->theme->baseUrl . '/img/trainee.gif'; } // sp if ($userInfo['user_group_id'] == 3) { $string_avatar_none = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->theme->baseUrl . '/img/supervisor.gif'; } } Yii::app()->session['avatar'] = (isset($userInfo['avatar']) and !empty($userInfo['avatar'])) ? Yii::app()->params['url_base'] . '/uploads/avatars/user/' . $userInfo['avatar'] : $string_avatar_none; } //load XML Config //$xmlPath = realpath($path = Yii::app()->basePath.'/../'.Yii::app()->params['config_folder'].'/'); //$xmlFile = Yii::app()->params['config_file_name']; //$this->config = new LoadConfigXML($xmlPath,$xmlFile); Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php')); }
public function actionSendComment() { $dataType = $_REQUEST["dataType"]; $dataId = $_REQUEST["dataId"]; $action_url = $_REQUEST["action_url"]; $contentComment = $_REQUEST["contentComment"]; $parent_id = $_REQUEST["parent_id"]; $_db = Yii::app()->db; $comm = $_db->createCommand(); $result = $comm->insert('pls_comment', array('parent_id' => $parent_id, 'user_id' => Yii::app()->user->id, 'content' => $contentComment, 'data_id' => $dataId, 'data_type' => $dataType, 'status' => 1, 'created_date' => date('Y-m-d H:i:s'), 'action_url' => strtolower($action_url))); if ($result) { $idnewrecord = Yii::app()->db->getLastInsertID($result); if ($dataType == "course") { $courseDetails = WCourse::model()->find("id=" . $dataId); if (Yii::app()->user->id != $courseDetails->created_by) { $title = "Bình Luận Khóa học: " . $courseDetails->course_name; $content = ""; $user = WUser::getUserById(Yii::app()->user->id); if (Yii::app()->session["group_id"] == 1) { $content .= "Có giáo viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 2) { $content .= "Có học viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 3) { $content .= "Có Quản trị viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } } } $content .= '<br/>Click xem chi tiết: <a href="' . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . '">' . $courseDetails->course_name . '</a>'; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $courseDetails->created_by); } } elseif ($dataType == "courselecture") { $courseLecture = WLecture::model()->find("id=" . $dataId); if (Yii::app()->user->id != $courseLecture->created_by) { $title = "Bình Luận Bài Giảng: " . $courseLecture->lecture_name; $content = ""; $user = WUser::getUserById(Yii::app()->user->id); if (Yii::app()->session["group_id"] == 1) { $content .= "Có giáo viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 2) { $content .= "Có học viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 3) { $content .= "Có Quản trị viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } } } $content .= '<br/>Click xem chi tiết: <a href="' . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . '">' . $courseLecture->lecture_name . '</a>'; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $courseLecture->created_by); } } echo json_encode(array("result" => "true")); } else { echo json_encode(array("result" => "false")); } }