/** * Authenticates a dummy user. * @return boolean always true. */ public function authenticate() { $student = Student::model()->findByAttributes(array('username' => $this->username)); if ($student === null) { $student = new Student(); $faculty = Faculty::model()->findByPk(1); if ($faculty === null) { $faculty = new Faculty(); $faculty->id = 1; $faculty->name = 'Dummy Faculty'; $faculty->save(false); } $student->username = $this->username; $student->name = $this->name; $student->is_admin = $this->isAdmin; $student->faculty_id = $faculty->id; $student->photo = Yii::app()->params['defaultProfilePhoto']; } $student->last_login_timestamp = date('Y-m-d H:i:s'); $student->save(); $this->id = $student->id; $this->name = $student->name; $this->setState('isAdmin', $student->is_admin); $this->setState('profilePhoto', $student->photo); return true; }
/** * 主界面 */ public function actionHome() { //查询课程 $lessons = Lesson::model()->findAll(array('select' => array('catalog_id', 'arrivals', 'price'))); //学员活跃度 $studentAllCount = Student::model()->count(); $criteria = new CDbCriteria(); $criteria->distinct = true; $criteria->addCondition('is_pays=:is_pay'); $criteria->params[':is_pay'] = 1; $studentActiveCount = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay", array(':is_pay' => 1)); $studentPercentage = round($studentActiveCount / $studentAllCount * 100) . '%'; //获取课程分类数组 $catalogs = Catalog::model()->findAllByAttributes(array('parent_id' => 6)); $allCountLesson = Lesson::model()->count(); foreach ($catalogs as $catalog) { //初始化 $lessonMoney[$catalog[id]] = 0; $allLesson[$catalog[id]] = 0; $catalogName[$catalog[catalog_name]] = $catalog[id]; //各分类中已报名课程和发布课程总量 $allLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id", array(":catalog_id" => $catalog[id])); $applyLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id AND actual_students<>:actual_students", array(":catalog_id" => $catalog[id], ":actual_students" => 0)); } //成交总金额 foreach ($lessons as $lesson) { $lessonMoney[$lesson[catalog_id]] = (int) $lesson[arrivals] * (int) $lesson[price]; } $this->render('home', array('catalogName' => json_encode($catalogName), 'lessonMoney' => json_encode($lessonMoney), 'allLesson' => json_encode($allLesson), 'applyLesson' => json_encode($applyLesson), 'studentPercentage' => $studentPercentage)); }
/** * 获取学员详细信息 */ public function actionGetStudentInfo() { if (!isset($_REQUEST['teacherId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['studentId'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('teacherId', null)); $token = trim(Yii::app()->request->getParam('token', null)); $studentId = trim(Yii::app()->request->getParam('studentId', null)); if (!ctype_digit($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } //用户名不存在,返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } if (empty($studentId) || $studentId <= 0) { $this->_return('MSG_ERR_FAIL_STUDENT'); } // 验证token if (Token::model()->verifyToken($user_id, $token)) { // 获取学员详细信息 $data = Student::model()->getStudentInfo($studentId); if (!$data) { $this->_return('MSG_NO_STUDENT'); } $this->_return('MSG_SUCCESS', $data); } else { $this->_return('MSG_ERR_TOKEN'); } }
/** * Tests the student update action with invalid input. */ public function testUpdateInvalid() { $model = $this->students('student1'); // Empty name $fakeStudent = Student::model()->findByPk($model->id); $fakeStudent->name = null; $this->assertFalse($fakeStudent->validate()); // Lengthy name $fakeStudent = Student::model()->findByPk($model->id); Yii::import('ext.randomness.*'); $fakeStudent->name = Randomness::randomString(Student::MAX_NAME_LENGTH + 1); $this->assertFalse($fakeStudent->validate()); // Empty faculty_id $fakeStudent = Student::model()->findByPk($model->id); $fakeStudent->faculty_id = null; $this->assertFalse($fakeStudent->validate()); // Invalid faculty_id $fakeStudent = Student::model()->findByPk($model->id); $fakeStudent->faculty_id = self::INVALID_ID; $this->assertFalse($fakeStudent->validate()); // Invalid file type $fakeStudent = Student::model()->findByPk($model->id); $fakeFile = $this->testFile; $fakeFile['name'] = 'Test.avi'; $fakeFile['type'] = 'video/x-msvideo'; $fakeStudent->file = new CUploadedFile($fakeFile['name'], $fakeFile['tmp_name'], $fakeFile['type'], $fakeFile['size'], $fakeFile['error']); $this->assertFalse($fakeStudent->validate()); // Invalid file size $fakeStudent = Student::model()->findByPk($model->id); $fakeFile = $this->testFile; $fakeFile['size'] = Student::MAX_FILE_SIZE * 2; $fakeStudent->file = new CUploadedFile($fakeFile['name'], $fakeFile['tmp_name'], $fakeFile['type'], $fakeFile['size'], $fakeFile['error']); $this->assertFalse($fakeStudent->validate()); }
/** * Consolidates the "from" and "to" fields by filling in data model objects from database. * In student mode, "from" will be the student model and "to" will be the employer model. * In employer mode, it will be wise versa. * @return boolean - true if the models are set successfully * @throws CException -if from and to fields are not valid or type is not a valid type */ private function _setFromAndTo() { if (!$this->hasErrors($this->from) && !$this->hasErrors($this->to)) { $criteria = new CDbCriteria(); $criteria->with = array('user' => array('select' => 'email, first_name, last_name', 'joinType' => 'INNER JOIN')); $criteria->together = true; switch ($this->type) { case self::TYPE_STU: $this->fromObj = Student::model()->findByPk($this->from, $criteria); $this->toObj = Employer::model()->findByPk($this->to, $criteria); $this->interviewObj = InterviewStudentJobTitle::model()->findByAttributes(array('stu_job_id' => $this->stu_job_id, 'employer_id' => $this->to, 'active' => 1)); break; case self::TYPE_EMP: $this->fromObj = Employer::model()->findByPk($this->from, $criteria); $this->toObj = Student::model()->findByPk($this->to, $criteria); //stu_job_id //$this->interviewObj=InterviewStudentJobTitle::model()->findByAttributes(array('stu_job_id'=>$this->stu_job_id,'employer_id'=>$this->from,'active'=>1)); $this->interviewObj = InterviewStudentJobTitle::model()->findByAttributes(array('employer_id' => $this->employer_id, 'stu_job_id' => $this->to)); break; default: throw new CException('Invalid type.'); break; } if ($this->fromObj != null && $this->toObj != null && $this->interviewObj != null) { return true; } else { return false; } } else { throw new CException('Cannot set From and To fields.'); } }
protected function loadStudent($id = null) { if ($this->_model === null) { if ($id !== null) { $this->_model = Student::model()->findByPk($id); } } return $this->_model; }
/** * Tests the login action. */ public function testLogin() { $identity = new UserIdentity('dummy.user'); $this->assertTrue($identity->authenticate()); $student = Student::model()->findByAttributes(array('username' => 'dummy.user')); $this->assertNotNull($student); $this->assertEquals('Dummy User', $student->name); $this->assertTrue($student->is_admin == 0); $this->assertTrue($student->faculty->id == 1); $this->assertEquals(Yii::app()->params['defaultProfilePhoto'], $student->photo); }
/** * Returns options for the related model multiple select * @param string $model * @return string options for relate model multiple select * @since 1.0 */ public function related_opts($model) { $relatedPKs = Student::extractPkValue($model->students); $options = ''; $products = GxHtml::listDataEx(Student::model()->findAllAttributes(null, true)); foreach ($products as $value => $text) { if (!$model->isNewRecord) { in_array($value, $relatedPKs) ? $options .= '<option selected="selected" value=' . $value . '>' . $text . '</option>\\n' : ($options .= '<option value=' . $value . '>' . $text . '</option>\\n'); } else { $options .= '<option value=' . $value . '>' . $text . '</option>\\n'; } } echo $options; }
/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $user = Student::model()->with(array('level'))->find('username = ? AND password = ?', array($this->username, $this->password)); if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { $this->student_id = $user->student_id; $this->username = $user->username; $auth = Yii::app()->authManager; Yii::app()->authManager->save(); $this->errorCode = self::ERROR_NONE; } return $this->errorCode == self::ERROR_NONE; }
public function sendCodes($controller) { if (!($student = Student::model()->findByAttributes(array('email' => $this->email)))) { return false; } $exercises = Exercise::model()->with('assignment')->sortByDuedate()->findAllByAttributes(array('student_id' => $student->id)); foreach ($exercises as $exercise) { $exercise->link = Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $exercise->generateAckKey())); } $options = array(); if (Helpers::getYiiParam('addOriginatingIP')) { $options['originating_IP'] = sprintf('[%s]', Yii::app()->request->userHostAddress); } return MailTemplate::model()->mailFromTemplate('send_codes', array($student->email => $student->name), array('student' => $student, 'exercises' => $exercises), $options); }
/** * Lists all notes. */ public function actionIndex() { $model = new Note('search'); if (isset($_GET['Note'])) { $model->attributes = $_GET['Note']; $dataProvider = $model->search(); } else { $dataProvider = new CActiveDataProvider('Note', array('criteria' => array('order' => 'upload_timestamp DESC'))); } $dataProvider->setPagination(array('pageSize' => 16)); $students = Student::model()->findAll(); $usernames = array(); foreach ($students as $student) { $usernames[] = $student->username; } $this->render('index', array('model' => $model, 'dataProvider' => $dataProvider, 'usernames' => $usernames)); }
public function actionPawd() { $this->_seoTitle = '学员 - 修改密码'; $studentModel = new StudentChangePassword(); if (isset($_POST['StudentChangePassword'])) { $studentModel->attributes = $_POST['StudentChangePassword']; if ($studentModel->validate()) { $new_password = Student::model()->findbyPk($this->_user['studentId']); $new_password->password = $studentModel->password; $new_password->verifyPassword = $studentModel->password; if ($new_password->save()) { Yii::app()->user->setFlash('success', '保存成功'); //这里提示保存成功后重定向到登陆页! } } } $this->render('password', array('studentModel' => $studentModel)); }
public function authenticate() { // $user_info = Student::model()->find( 'login_name = :username', array(':username'=>$this->username) ); $criteria = new CDbCriteria(); $criteria->addCondition('is_check=1'); $criteria->addCondition('login_name="' . $this->username . '"'); $user_info = Student::model()->find($criteria); if (!isset($user_info->login_psw)) { return $this->errorCode = self::ERROR_USERNAME_INVALID; } if ($user_info->login_psw != $this->password) { return $this->errorCode = self::ERROR_PASSWORD_INVALID; } $this->setState('student_name', $user_info->student_name); $this->setState('student_id', $user_info->student_id); $this->setState('class_id', $user_info->class_id); return !($this->errorCode = self::ERROR_NONE); }
/** * 获取学员详细信息 */ public function actionGetStudentInfo() { if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['memberId'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('userId', null)); $token = trim(Yii::app()->request->getParam('token', null)); $memberId = trim(Yii::app()->request->getParam('memberId', null)); // 用户ID格式错误 if (!ctype_digit($user_id)) { $this->_return('MSG_ERR_FAIL_USER'); } // 用户不存在,返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } if (empty($memberId) || $memberId <= 0) { $this->_return('MSG_ERR_FAIL_STUDENT'); } // 验证要添加的memberId是否和userId有绑定关系存在 $existMemberId = User::model()->existUserIdMemberId($user_id, $memberId); if (!$existMemberId) { $this->_return('MSG_ERR_FAIL_MEMBER'); } // 验证token if (Token::model()->verifyToken($user_id, $token)) { // 获取学员详细信息 $data = Student::model()->getStudentInfo($memberId); if (!$data) { $this->_return('MSG_NO_MEMBER'); } // 增加用户操作log $action_id = 2301; $params = ''; foreach ($_REQUEST as $key => $value) { $params .= $key . '=' . $value . '&'; } $params = substr($params, 0, -1); Log::model()->action_log($user_id, $action_id, $params); $this->_return('MSG_SUCCESS', $data); } else { $this->_return('MSG_ERR_TOKEN'); } }
public static function emailStudentActivation($user, $hash) { $student = Student::model()->with('college', 'program', 'educationLevel')->findByPk($user->user_id); $mail = new YiiMailer('studentActivation', array('student' => $student, 'user' => $user, 'hash' => $hash)); $mail->render(); $mail->From = Yii::app()->params['nonReplyEmail']; $mail->FromName = Yii::app()->name; $mail->Subject = Yii::app()->name . ' - Student account verification'; $mail->AddAddress(YII_DEBUG ? Yii::app()->params['adminEmail'] : $user->email); if ($mail->Send()) { $mail->ClearAddresses(); Yii::log("Mail sent via " . Yii::app()->params['nonReplyEmail'], 'log'); Yii::log("Mail sent successfully to " . (YII_DEBUG ? Yii::app()->params['adminEmail'] : $user->email), 'log'); return true; } else { Yii::log("Email error: " . $mail->getError(), 'log'); return false; } }
/** * 主界面 */ public function actionHome() { //查询课程 $lessons = Lesson::model()->findAll(array('select' => array('catalog_id', 'arrivals', 'price'))); //学员活跃度 $studentAllCount = Student::model()->count(); $studentActiveCount = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay", array(':is_pay' => 1)); $studentPercentage = @round($studentActiveCount / $studentAllCount * 100) . '%'; //学员月活跃度 $time = date('Y-m', time()); for ($i = -1; $i < 8; $i++) { $m = date('m', time()); $m = $m - $i - 1; $ii = $i + 1; $startTime[$m] = date('Y-m-d H:i:s', strtotime("{$time} -{$ii} month")); $endTime[$m] = date('Y-m-d H:i:s', strtotime("{$time} -{$i} month")); $sMoAcCount[$m] = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay AND pay_time>=:start_time AND pay_time<:end_time", array(':is_pay' => 1, ':start_time' => $startTime[$m], ':end_time' => $endTime[$m])); $sAllMoAcCount[$m] = Student::model()->countBySql('SELECT COUNT(id) FROM `seed_student` WHERE register_time>=:start_time AND register_time<:end_time', array(':start_time' => $startTime[$m], ':end_time' => $endTime[$m])); if ($sAllMoAcCount[$m] == 0) { $sMoPercentage[$m] = "0%"; } else { $sMoPercentage[$m] = round($sMoAcCount[$m] / $sAllMoAcCount[$m] * 100) . '%'; } } //获取课程分类数组 $catalogs = Catalog::model()->findAllByAttributes(array('parent_id' => 6)); $allCountLesson = Lesson::model()->count(); foreach ($catalogs as $catalog) { //初始化 $lessonMoney[$catalog[id]] = 0; $allLesson[$catalog[id]] = 0; $catalogName[$catalog[catalog_name]] = $catalog[id]; //各分类中已报名课程和发布课程总量 $allLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id", array(":catalog_id" => $catalog[id])); $applyLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id AND actual_students<>:actual_students", array(":catalog_id" => $catalog[id], ":actual_students" => 0)); } //成交总金额 foreach ($lessons as $lesson) { $lessonMoney[$lesson[catalog_id]] = (int) $lesson[arrivals] * (int) $lesson[price]; } $this->render('home', array('catalogName' => json_encode($catalogName), 'lessonMoney' => json_encode($lessonMoney), 'allLesson' => json_encode($allLesson), 'applyLesson' => json_encode($applyLesson), 'studentPercentage' => $studentPercentage, 'sMoPercentage' => $sMoPercentage)); }
public function actionSave($j_id, $c_id) { if (Yii::app()->session['role'] == 1) { if (!(isset($_POST['cv_id']) && isset($j_id) && isset($c_id))) { Yii::app()->user->setFlash('error', 'Error'); $this->redirect(array('index')); } $studinfo = Student::model()->findByPk(Yii::App()->user->id); $dept = $studinfo->getAttribute("dept"); $cpi = $studinfo->getAttribute("cpi"); $sqlcount = Yii::app()->db->createCommand("select count(*) from job_profile_branches as jpb where j_id =\n " . $j_id . " and c_id = " . $c_id . " and dept = '" . $dept . "'")->queryScalar(); $jobinfo = JobProfile::model()->find('j_id = ? and c_id = ? and CURRENT_TIMESTAMP<deadline', array($j_id, $c_id)); if (count($jobinfo)) { $cutoff = $jobinfo->getAttribute("cpi_cutoff"); if ($sqlcount && $cpi >= $cutoff) { try { $st_id = Yii::App()->user->id; $connection = Yii::App()->db; $sql = "INSERT INTO apply (j_id,c_id,cv_id,st_id) values(:j_id,:c_id,:cv_id,:st_id)"; $command = $connection->createCommand($sql); $command->bindParam(":j_id", $j_id, PDO::PARAM_STR); $command->bindParam(":c_id", $c_id, PDO::PARAM_STR); $command->bindParam(":cv_id", $_POST['cv_id'], PDO::PARAM_STR); $command->bindParam(":st_id", $st_id, PDO::PARAM_STR); $command->execute(); Yii::app()->user->setFlash('success', 'Successfully Applied '); } catch (Exception $e) { Yii::app()->user->setFlash('error', 'You are trying to reapply'); } } else { Yii::app()->user->setFlash('error', 'CPI cutoff not satisfied '); } } else { Yii::app()->user->setFlash('error', 'Deadline has been expired'); } $this->redirect(array('site/index')); } }
/** * Displays the form for granting testimonial privilege. */ public function actionGrant() { $model = new Testimonial(); if (isset($_POST['Testimonial'])) { $username = $_POST['Testimonial']['student_id']; $student = Student::model()->findByAttributes(array('username' => $username)); if ($student === null) { Yii::app()->user->setNotification('danger', 'Mahasiswa ' . $username . ' tidak terdaftar.'); } else { if ($model->grantTo($student)) { Yii::app()->user->setNotification('success', 'Hak berhasil diberikan.'); $model->student_id = null; } else { Yii::app()->user->setFlash('danger', 'Hak tidak berhasil diberikan.'); } } } $students = Student::model()->findAll(); $usernames = array(); foreach ($students as $student) { $usernames[] = $student->username; } $this->render('grant', array('model' => $model, 'usernames' => $usernames)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Student the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Student::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<a data-role='button' href="<?php echo $this->createUrl('index/tucao/self/true/cate_id/' . $_GET['cate_id']); ?> " id = "<?php echo $row->tucao_cate_id; ?> " name = "tucao" data-ajax='false' > <h1> 我要发表吐槽 </h1> </a> <?php foreach ($model as $row) { ?> <li> <h2>     <span class='light'> 吐槽者 </span>       <?php echo Student::model()->findByPk($row->student_id)->student_name; ?>        <span class='light'> 吐槽时间 </span>        <?php echo $row->tucao_time; ?>        <span class='light'> 吐槽内容</span>        <?php echo $row->content; ?>        <button id = 'support' name="<?php echo $row->tucao_id; ?> " data-min = 'true' data-inline='true'>赞</button>
if ($_GET['error'] == 2) { echo '<h1> 投票成功</h1>'; } if ($_GET['error'] == 0) { ?> <div data-role="navbar"> <ul> <?php foreach ($model as $row) { ?> <li> <a href="<?php echo Yii::app()->createUrl('index/vote/position_id/' . $row->position_id . '/competitor_id/' . $row->competitor_id); ?> " data-ajax="false" > <!-- <img src="/jq/mobile/images/demo/index/web.png" /> --> <h3><?php echo Student::model()->findByPK($row->competitor_id)->student_name; ?> </h3> </a> </li> <?php } ?> </ul> </div> <?php }
<?php return array('title' => 'Enter a check', 'showErrorSummary' => true, 'elements' => array('check' => array('type' => 'form', 'title' => 'Check Details', 'showErrorSummary' => true, 'elements' => array('amount' => array('type' => 'text', 'maxlength' => 20), 'check_num' => array('type' => 'text', 'maxlength' => 10), 'check_date' => array('type' => 'zii.widgets.jui.CJuiDatePicker', 'attribute' => 'check_date', 'model' => 'check', 'options' => array('showAnim' => 'fold', 'showButtonPanel' => true, 'autoSize' => true, 'dateFormat' => 'yy-mm-dd')), 'payee_id' => array('items' => CHtml::listData(Company::model()->findAll(), 'id', 'name'), 'type' => 'dropdownlist'), 'payer' => array('type' => 'text', 'maxlength' => 128), 'deposit_id' => array('items' => CHtml::listData(DepositDetails::model()->findAll(), 'id', 'deposited_date'), 'type' => 'dropdownlist'))), 'income' => array('type' => 'form', 'title' => 'Apply Payment', 'showErrorSummary' => true, 'elements' => array('student_id' => array('maxlength' => 10, 'prompt' => "Choose student...", 'items' => CHtml::listData(Student::model()->findAll(), 'id', 'full_name'), 'type' => 'dropdownlist'), 'class_id' => array('maxlength' => 10, 'prompt' => "Choose class...", 'items' => CHtml::listData(ClassInfo::model()->findAll(), 'id', 'class_name'), 'type' => 'dropdownlist'), 'amount' => array('type' => 'text', 'maxlength' => 10)))), 'buttons' => array('entry_form' => array('type' => 'submit', 'label' => 'Save')));
public function actionRegister() { $arrayAuthRoleItems = Yii::app()->authManager->getAuthItems(2, Yii::app()->user->getId()); $arrayKeys = array_keys($arrayAuthRoleItems); $role = strtolower($arrayKeys[0]); if ($role == 'admin' || $role == 'teacher') { $this->redirect('/'); } $this->layout = 'dangkyhoc'; $model = new Student(); if (isset($_GET['cid']) && (int) $_GET['cid']) { $model->class_id = $_GET['cid']; } $db = Yii::app()->db; if (isset($_POST['Student']) && $_POST['Student']) { $model->setAttributes($_POST['Student']); $gclass = ClassGuitar::model()->findByPk($model->class_id); $sql = "SELECT * FROM {{student}} WHERE user_id =" . Yii::app()->user->id . " ORDER BY id DESC"; $cmd = $db->createCommand($sql); $student = $cmd->queryRow(); if ($student) { // var_dump($studentơclass_id); $gclass2 = ClassGuitar::model()->findByPk($student['class_id']); if ($student['status'] == 'comp') { //Hoàn thành if ($gclass->tid <= $gclass2->tid) { $training = Training::model()->findByPk($gclass2->tid); Yii::app()->user->setFlash('error', 'Bạn đã hoàn thành một lớp thuộc khóa <b>' . $training->title . '</b>. Vui lòng đăng ký khóa học cao hơn.'); } } elseif ($student['status'] == 'reg') { // Mới đăng ký Yii::app()->user->setFlash('error', 'Bạn đã đăng ký học tại lớp <b>' . $gclass2->title . '</b>. Vui lòng hủy đơn đăng ký này trước khi đăng ký tham gia lớp học khác!'); } else { $center = Center::model()->findByPk($gclass2->cid); Yii::app()->user->setFlash('error', 'Bạn đang tham gia lớp học <b>' . $gclass2->title . '</b> tại cơ sở <b>' . $center->title . '</b>!'); } } else { } if (!Yii::app()->user->hasFlash('error') && $model->save()) { if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->end(); } else { Yii::app()->user->setFlash('success', 'Bạn đã đăng ký lớp học thành công. LNT sẽ sớm liên lạc lại với bạn.'); } } } else { $oldStudent = Student::model()->find('user_id=' . Yii::app()->user->id); if ($oldStudent) { $model->name = $oldStudent->name; $model->email = $oldStudent->email; $model->tel = $oldStudent->tel; $model->birthday = $oldStudent->birthday; } } $this->render('register', array('model' => $model)); }
public function actionUpdateRole($id) { $student = Student::model()->findByAttributes(array('id_user' => $id)); if (!$student) { $student = false; } $valid = true; if (isset($_POST['Student'])) { $student->attributes = $_POST['Student']; if ($_POST['Role'][3] == 1) { $valid = $valid && $student->save(); } } if (isset($_POST['Role']) && !empty($_POST['Role']) && $valid) { foreach ($_POST['Role'] as $key => $role) { $arrRol[] = $key; } if (RoleToUser::model()->changeRole($id, $arrRol)) { $this->redirect(array('allusers')); } } $roles = Role::model()->findAll(); $user = User::model()->findByPk($id); $this->render('update', array('user' => $user, 'roles' => $roles, 'student' => $student)); }
public function actionCreateMulti() { // ugly hack, but i need it $student = Student::model()->findByPk($_GET['student_id']); if ($student === null) { throw new CHttpException(404, 'The requested page does not exist.'); } // TODO: possibly double-end this with handling class id $models = array(); $flash = ""; if (isset($_POST['Signup'])) { // the saving and redisplaying $v = true; foreach ($_POST['Signup'] as $i => $s) { // I'm not bothering with them if the class is 0, ignore if ($_POST['Signup'][$i]['class_id'] > 0) { $models[$i] = new Signup(); $models[$i]->attributes = $_POST['Signup'][$i]; // XXX ugly, but cleaner than hidden form fields i think. $models[$i]->student_id = $student->id; if ($models[$i]->save()) { $v = $v && true; $flash .= CHtml::encode($models[$i]->class->summary) . ' succeeded for ' . CHtml::encode($models[$i]->student->summary) . "<br />"; // don't need to keep it around if it validated // this is important for when one line fails unset($models[$i]); } else { // something died $v = $v && false; } } } Yii::app()->user->setFlash('success', $flash); if ($v) { //everything validated and saved, so redirect us $this->redirect(array('student/view', 'id' => $student->id)); } } else { // create new form $count = isset($_POST['count']) ? $_POST['count'] : 2; for ($i = 0; $i < $count; $i++) { $models[$i] = new Signup(); $models[$i]->student_id = $student->id; // pre-fill it $models[$i]->signup_date = date("Y-m-d H:i:s"); } } $this->render('multi_entry', array('student' => $student, 'models' => $models)); }
static function CompetitorOptions($position_id) { $competitors = ClassCommittee::model()->findByPk($position_id)->competitors; $results = array('0' => '请选择竞争者'); foreach ($competitors as $row) { $results[$row->competitor_id] = Student::model()->findByPk($row->competitor_id)->student_name; } return $results; }
public function actionAjaxSave() { $attendance = array(); $students = Student::model()->findAll('ID_Class=:idClass', array('idClass' => $_SESSION['idClass'])); $attendance_status = Domain::getAttendanceStatus(); $attendance = $_POST['Attendance']; $error = array(); foreach ($students as $student) { if (!isset($attendance['Status_' . $student->Code])) { $error['Status_' . $student->Code] = 'error'; } } if (empty($error)) { if ($this->checkAttendanceSession($_SESSION['idSession'], $this->getAttendanceSession(Yii::app()->user->getState('idUser'), $this->getIdClassSubject($_SESSION['idClass'], $_SESSION['idSubject'], Yii::app()->user->getState('idUser'))))) { $idAttendance = $this->saveAttendance($attendance, $students); $this->saveAttendanceDetails($idAttendance, $students, $attendance); echo '<p class="text-success pd-3-15">Điểm danh thành công</p>' . $this->createTableAddtendance($attendance_status, $students, $attendance); } else { $attendance = Attendance::model()->find('Session=:idSession AND ID_Teacher=:idTeacher AND ID_Class_Subject=:idClassSubject', array('idSession' => $_SESSION['idSession'], 'idTeacher' => Yii::app()->user->getState('idUser'), 'idClassSubject' => $this->getIdClassSubject($_SESSION['idClass'], $_SESSION['idSubject'], Yii::app()->user->getState('idUser')))); $this->createTableAddtendance($attendance_status, $students, $attendance, true); } } else { echo '<p class="text-danger pd-3-15">Chưa điểm danh hết học viên</p>' . $this->createTableAddtendance($attendance_status, $students, $attendance); } }
</div> <!--The tree will be rendered in this div--> <div id="<?php echo Student::ADMIN_TREE_CONTAINER_ID; ?> " class='left'> </div> <div id='category_info'> <div id='pic'> </div> <div id='title'> <h3><?php echo Student::model()->findByPK($category_id)->name; ?> </h3> </div> </div> <div id="listview-wrapper" class="left"> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $prod_dataProvider, 'itemView' => 'application.views.classroom._view', 'id' => 'classroom-listview', 'afterAjaxUpdate' => 'js:function(id,data){$.bind_crud()}', 'pagerCssClass' => 'pager_wrapper clearfix')); ?> </div> </div> <!-- Content--> </div> <!-- ContentBox --> <script type="text/javascript">
</tr> </thead> <div class="text-left add-dom"> <a class="btn btn-red btn-normer btn-lg-padding" href="<?php echo Yii::app()->createUrl('master/default/addlesson'); ?> " role="button"> <i class="fa fa-plus"></i>增加课程 </a> </div> <tbody> <?php foreach ($lessons as $lesson) { $students = Student::model()->findAll(); ?> <tr> <td width="150"> <a href="<?php echo Yii::app()->createUrl('lesson/view', array('id' => $lesson->id)); ?> "> <img class="img-responsive" src="<?php echo $lesson->pic; ?> "> </a> </td> <td width="150">
public function actionSignup($id) { if (isset($id)) { if (Yii::app()->request->isPostRequest) { $event = Event::model()->findByPk($id); if ($event != null) { if (!$event->isPublic()) { $isStuFromCollege = Student::model()->exists('user_id=:user_id AND college_id=:college_id', array(':user_id' => Yii::app()->user->id, ':college_id' => $event->college_id)); if (!$isStuFromCollege) { throw new CHttpException(400, 'Sorry, you cannot sign up for this event.'); } } $studentEvent = new StudentEvent(); $studentEvent->user_id = Yii::app()->user->id; $studentEvent->post_item_id = $id; if ($studentEvent->save()) { Yii::app()->user->setFlash('success', Yii::t('app', 'msg.success.event_signup')); $this->redirect(array('view', 'id' => $id)); } } else { throw new CHttpException(400, 'Event not found.'); } } else { throw new CHttpException(400, 'Invalid Request'); } } else { throw new CHttpException(400, 'Event not found.'); } }