当前位置: 首页>>代码示例>>PHP>>正文


PHP Student::model方法代码示例

本文整理汇总了PHP中Student::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::model方法的具体用法?PHP Student::model怎么用?PHP Student::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student的用法示例。


在下文中一共展示了Student::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 /**
  * 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;
 }
开发者ID:ekospinach,项目名称:berkuliah,代码行数:30,代码来源:DummyUserIdentity.php

示例2: actionHome

 /**
  * 主界面
  */
 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));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:33,代码来源:DefaultController.php

示例3: actionGetStudentInfo

 /**
  * 获取学员详细信息
  */
 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');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:33,代码来源:StudentController.php

示例4: testUpdateInvalid

 /**
  * 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());
 }
开发者ID:ekospinach,项目名称:berkuliah,代码行数:37,代码来源:StudentTest.php

示例5: _setFromAndTo

 /**
  * 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.');
     }
 }
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:39,代码来源:InterviewCancelForm.php

示例6: loadStudent

 protected function loadStudent($id = null)
 {
     if ($this->_model === null) {
         if ($id !== null) {
             $this->_model = Student::model()->findByPk($id);
         }
     }
     return $this->_model;
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:9,代码来源:WebStudent.php

示例7: testLogin

 /**
  * 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);
 }
开发者ID:ekospinach,项目名称:berkuliah,代码行数:14,代码来源:UserIdentity.php

示例8: related_opts

 /**
  * 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;
 }
开发者ID:nov072008,项目名称:yiitesting,代码行数:20,代码来源:ClassroomController.php

示例9: authenticate

 /**
  * 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;
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:22,代码来源:StudentIdentity.php

示例10: sendCodes

 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);
 }
开发者ID:loristissino,项目名称:swu,代码行数:15,代码来源:SendcodesForm.php

示例11: actionIndex

 /**
  * 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));
 }
开发者ID:ekospinach,项目名称:berkuliah,代码行数:20,代码来源:HomeController.php

示例12: actionPawd

 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));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:18,代码来源:PasswordController.php

示例13: authenticate

 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);
 }
开发者ID:houyf,项目名称:class_system,代码行数:18,代码来源:UserIdentity.php

示例14: actionGetStudentInfo

 /**
  * 获取学员详细信息
  */
 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');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:47,代码来源:StudentController.php

示例15: emailStudentActivation

 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;
     }
 }
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:19,代码来源:Emailer.php


注:本文中的Student::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。