/**
  * Создает новую модель Учителя.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new Teacher();
     if (Yii::app()->getRequest()->getPost('Teacher') !== null) {
         $model->setAttributes(Yii::app()->getRequest()->getPost('Teacher'));
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('TeacherModule.teacher', 'Запись добавлена!'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $this->render('create', ['model' => $model]);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Teacher();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Teacher'])) {
         $model->attributes = $_POST['Teacher'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Beispiel #3
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Teacher();
     if (isset($_POST['Teacher'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Teacher'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('teacher_create', array('model' => $model));
 }
Beispiel #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Teacher();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Teacher'])) {
         $model->attributes = $_POST['Teacher'];
         if ($model->save()) {
             Yii::app()->user->setFlash('info', '<span class="single-name">' . $model->singleName() . 'а</span> <b>' . $model->surname . ' ' . $model->initials . '</b> ' . Yii::app()->params['postActions'][Yii::app()->controller->action->id] . '!');
             $this->redirect(array('/teacher/admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Beispiel #5
0
 public function createTeacher(PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $teacher = new Teacher();
     $teacher->setPerson($this->getPerson());
     $teacher->save($con);
     $guard_user = $this->getPersonSfGuardUser();
     if (!is_null($guard_user)) {
         $teacher_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::TEACHER);
         if (!array_key_exists($teacher_group, $guard_user->getGroups())) {
             $guard_user->addGroupByName($teacher_group);
             $guard_user->save($con);
         }
     }
 }
Beispiel #6
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     //
     $faker = Faker\Factory::create();
     $minimum = $this->option('minimum');
     for ($is = 1; $is <= $minimum; $is++) {
         $first_name = $faker->firstname;
         $last_name = $faker->lastname;
         $email = $faker->safeEmail;
         $password = "******";
         $usergroup = rand(1, 3);
         $subjects = self::createSubjects();
         $user = Sentry::getUserProvider()->create(array('email' => $email, 'password' => $password, 'activated' => '1', 'first_name' => $first_name, 'last_name' => $last_name, 'created_at' => self::randDate('10th January 2013', date('jS F o'))));
         // Find the group using the group id
         $adminGroup = Sentry::getGroupProvider()->findById($usergroup);
         $user->addGroup($adminGroup);
         if ($usergroup == 1) {
             $teacher = new Teacher();
             $teacher->user_id = $user->id;
             $teacher->email = $email;
             $teacher->extra = $subjects;
             $teacher->dob = self::randDate('10th January 1950', '10th January 1995');
             $teacher->created_at = self::randDate('10th January 2013', date('jS F o'));
             $teacher->save();
         }
         if ($usergroup == 2) {
             $teacher = new Teacher();
             $teacher->user_id = $user->id;
             $teacher->email = $email;
             $teacher->extra = $subjects;
             $teacher->dob = self::randDate('10th January 1950', '10th January 1995');
             $teacher->created_at = self::randDate('10th January 2013', date('jS F o'));
             $teacher->save();
         }
         if ($usergroup == 3) {
             $student = new Student();
             $student->user_id = $user->id;
             $student->email = $email;
             $student->extra = $subjects;
             $student->dob = self::randDate('10th January 1995', '10th January 2005');
             $student->created_at = self::randDate('10th January 2013', date('jS F o'));
             $student->save();
         }
     }
 }
 /**
  * Создает новую модель Учителя.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $roles = ['1', '4'];
     $role = \Yii::app()->user->role;
     if (array_intersect($role, $roles)) {
         $model = new Teacher();
         if (Yii::app()->getRequest()->getPost('Teacher') !== null) {
             $model->setAttributes(Yii::app()->getRequest()->getPost('Teacher'));
             if ($model->save()) {
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('TeacherModule.teacher', 'Запись добавлена!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
             }
         }
         $this->render('create', ['model' => $model]);
     } else {
         throw new CHttpException(403, 'Ошибка прав доступа.');
     }
 }
 public function addTeacher()
 {
     $avatar = Input::get('avatar');
     $chinese_name = Input::get('chinese_name');
     $foreign_name = Input::get('foreign_name');
     $country = Input::get('country');
     $nation = Input::get('nation');
     $birthplace = Input::get('birthplace');
     $position = Input::get('position');
     $social_post = Input::get('social_post');
     $production = Input::get('production');
     $per_description = Input::get('per_description');
     $data = array('avatar' => $avatar, 'chinese_name' => $chinese_name, 'foreign_name' => $foreign_name, 'country' => $country, 'nation' => $nation, 'birthplace' => $birthplace, 'position' => $position, 'social_post' => $social_post, 'production' => $production, 'per_description' => $per_description);
     $rules = array('avatar' => 'required|image', 'chinese_name' => 'required', 'foreign_name' => 'required|alpha', 'country' => 'required', 'nation' => 'required', 'birthplace' => 'required', 'position' => 'required', 'social_post' => 'required', 'production' => 'required', 'per_description' => 'required');
     $messages = array('required' => 1, 'avatar.image' => 2, 'foreign_name.alpha' => 3);
     $validation = Validator::make($data, $rules, $messages);
     if ($validation->fails()) {
         $number = $validation->messages()->all();
         if ($number[0] == 1) {
             return Response::json(array('errCode' => 1, 'message' => '信息填写不完整!'));
         }
         if ($number[0] == 2) {
             return Response::json(array('errCode' => 2, 'message' => '必须为jpeg, png, bmp 或 gif的图片格式!'));
         }
         if ($number[0] == 3) {
             return Response::json(array('errCode' => 3, 'message' => '外文名必须为字母!'));
         }
     }
     $teacher = new Teacher();
     $teacher->avatar = $avatar;
     $teacher->chinese_name = $chinese_name;
     $teacher->foreign_name = $foreign_name;
     $teacher->country = $country;
     $teacher->nation = $nation;
     $teacher->birthplace = $birthplace;
     $teacher->position = $position;
     $teacher->social_post = $social_post;
     $teacher->production = $production;
     $teacher->per_description = $per_description;
     if (!$teacher->save()) {
         return Response::json(array('errCode' => 4, 'message' => '添加失败!'));
     }
     return Response::json(array('errCode' => 0, 'message' => '添加成功!'));
 }
    /**
     * Creates a new model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     */
    public function actionCreate()
    {
        $model=new Teacher;
        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);
        if(isset($_POST['Teacher']))
        {
            $_POST['Teacher']['foto_url']=$_FILES['Teacher']['name']['foto_url'];
            $model->attributes=$_POST['Teacher'];
            $model->avatar=$_FILES['Teacher'];

            if($model->save()) {
                StudentReg::model()->updateByPk($_POST['Teacher']['user_id'], array('role'=>1));
                $this->redirect(array('view', 'id' => $model->teacher_id));
            }
        }
        $this->render('create',array(
            'model'=>$model,
        ));
    }
 /**
  * Function that add a new teacher to the collection and return to add_teacher view
  *
  * @return view
  */
 public function addTeacher()
 {
     $user = new User();
     $user->user = trim(strtolower(Input::get('email')));
     $user->password = Hash::make(Input::get('email'));
     $user->rank = "teacher";
     $user->last_activity = null;
     // Try to save, if not work, then redirect back with an error message
     try {
         $user->save();
     } catch (MongoDuplicateKeyException $e) {
         return Redirect::back()->withErrors(array('error' => Lang::get('register_student.email_duplicated')));
     }
     $user = User::first(['user' => $user->user]);
     $teacher = new Teacher();
     $teacher->_id = $user->_id;
     $teacher->university_id = Auth::id();
     $teacher->name = trim(Input::get('name'));
     $teacher->last_name = trim(Input::get('last_name'));
     $teacher->phone = trim(Input::get('phone'));
     $teacher->cellphone = trim(Input::get('cellphone'));
     $teacher->email = trim(strtolower(Input::get('email')));
     $teacher->subjects_id = array();
     $teacher->sections_id = array();
     // Check for profile image, an then set to the teacher
     if (Input::hasFile('avatar_file')) {
         $data = Input::get('avatar_data');
         $image = new CropImage(null, $data, $_FILES['avatar_file']);
         $teacher->profile_image = $image->getURL();
     } else {
         $teacher->profile_image = null;
     }
     $teacher->save();
     return Redirect::to(Lang::get('routes.add_teacher'))->with('message', Lang::get('register_teacher.success'));
 }
Beispiel #11
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $teacherModel = new Teacher();
     $studentModel = new Student();
     $hostModel = new Host();
     if (XUtils::method() == 'POST') {
         /*switch($_POST){
         				case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master';  break;
         				case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break;
         				case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break;
         				default: $nowModel = 0;
         			}
         			if($nowModel){
         				$nowModel->attributes = $nowAttributes;
         
         
                         if ($nowModel->validate() && $nowModel->save()) {
         
                             parent::_stateWrite(
                                     array(
                                 'masterId' => $nowModel->id,
         						
                                 'name' => $nowModel->name,
                                     ), array('prefix' => '_master')
                             );
         
                             $cookie = new CHttpCookie('userName', $nowModel->name);
                             Yii::app()->request->cookies['userName'] = $cookie;
                             $this->redirect(array($nowRedirect));
                         }
         			}*/
         if (isset($_POST['Teacher'])) {
             $teacherModel->attributes = $_POST['Teacher'];
             $studentUser = Student::model()->countByAttributes(array('user' => $teacherModel->user));
             $hostUser = Host::model()->countByAttributes(array('user' => $teacherModel->user));
             //echo CActiveForm::validate($hostModel);
             //判断账号与其他角色账号是否相同
             if ($studentUser != 0 || $hostUser != 0) {
                 Yii::app()->user->setFlash('TeacherUserError', '您的手机号已在其他角色注册');
             }
             $tAgree = Yii::app()->request->getPost('teacherAgree');
             if ($tAgree === NULL) {
                 Yii::app()->user->setFlash('teacherAgreeMessage', '同意条款未勾选');
             }
             if ($teacherModel->validate() && $studentUser == 0 && $hostUser == 0 && $tAgree === 'on' && $teacherModel->save()) {
                 parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master'));
                 if ($teacherModel->name == '') {
                     $teacherModel->name = '导师';
                 }
                 $cookie = new CHttpCookie('userName', $teacherModel->name);
                 Yii::app()->request->cookies['userName'] = $cookie;
                 $this->_cookiesSet('userId', $teacherModel->id);
                 $this->_cookiesSet('userType', 'student');
                 Yii::app()->user->setFlash('TSSuccess', '注册成功!请完善个人信息并提交身份认证即可发布课程');
                 $this->redirect(array('/master'));
             }
         } else {
             if (isset($_POST['Student'])) {
                 $studentModel->attributes = $_POST['Student'];
                 //echo CActiveForm::validate($studentModel);
                 $teacherUser = Teacher::model()->countByAttributes(array('user' => $studentModel->user));
                 $hostUser = Host::model()->countByAttributes(array('user' => $studentModel->user));
                 //echo CActiveForm::validate($hostModel);
                 //判断账号与其他角色账号是否相同
                 if ($teacherUser != 0 || $hostUser != 0) {
                     Yii::app()->user->setFlash('StudentUserError', '您的手机号已在其他角色注册');
                 }
                 $sAgree = Yii::app()->request->getPost('studentAgree');
                 if ($sAgree === NULL) {
                     Yii::app()->user->setFlash('studentAgreeMessage', '同意条款未勾选');
                 }
                 $studentModel->register_time = date('Y-m-d H:m:s', time());
                 if ($studentModel->validate() && $teacherUser == 0 && $hostUser == 0 && $sAgree === 'on' && $studentModel->save()) {
                     parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student'));
                     if ($studentModel->name == '') {
                         $studentModel->name = '学员';
                     }
                     $cookie = new CHttpCookie('userName', $studentModel->name);
                     Yii::app()->request->cookies['userName'] = $cookie;
                     $this->_cookiesSet('userId', $studentModel->id);
                     $this->_cookiesSet('userType', 'student');
                     $this->redirect(array('/student/info/sinfo'));
                 }
             } else {
                 if (isset($_POST['Host'])) {
                     $hostModel->attributes = $_POST['Host'];
                     $teacherUser = Teacher::model()->countByAttributes(array('user' => $hostModel->user));
                     $studentUser = Student::model()->countByAttributes(array('user' => $hostModel->user));
                     //echo CActiveForm::validate($hostModel);
                     //判断账号与其他角色账号是否相同
                     if ($studentUser != 0 || $teacherUser != 0) {
                         Yii::app()->user->setFlash('HostUserError', '您的手机号已在其他角色注册');
                     }
                     $hAgree = Yii::app()->request->getPost('hostAgree');
                     if ($hAgree === NULL) {
                         Yii::app()->user->setFlash('hostAgreeMessage', '同意条款未勾选');
                     }
                     if ($hostModel->validate() && $studentUser == 0 && $teacherUser == 0 && $hAgree === 'on' && $hostModel->save()) {
                         parent::_stateWrite(array('hostId' => $hostModel->id, 'name' => $hostModel->name), array('prefix' => '_host'));
                         if ($hostModel->name == '') {
                             $hostModel->name = '场地主';
                         }
                         $cookie = new CHttpCookie('userName', $hostModel->name);
                         Yii::app()->request->cookies['userName'] = $cookie;
                         $this->_cookiesSet('userId', $hostModel->id);
                         $this->_cookiesSet('userType', 'host');
                         $this->redirect(array('/host'));
                     }
                 }
             }
         }
     }
     $this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel));
 }
Beispiel #12
0
 public function set_columns()
 {
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $teacher = new Teacher();
     $teacher->get_by_id($this->usermanager->get_teacher_id());
     $teacher->widget_columns = (int) $this->input->post('widget_columns');
     if ($teacher->widget_columns >= 1 && $teacher->widget_columns <= 4) {
         if ($teacher->save()) {
             $widget = new Admin_widget();
             $widget->where_related('teacher', $teacher);
             $widget->where('column >', $teacher->widget_columns);
             $widget->limit(1);
             $widget->get();
             if ($widget->exists()) {
                 $widget->where('column', $teacher->widget_columns);
                 $widget->where_related('teacher', $teacher);
                 $widget->limit(1);
                 $widget->order_by('position', 'desc');
                 $widget->get();
                 $position = 1;
                 if ($widget->exists()) {
                     $position += $widget->position;
                 }
                 $widget->select('id');
                 $widget->where('column >', $teacher->widget_columns);
                 $widget->where_related('teacher', $teacher);
                 $widget->order_by('column', 'asc');
                 $widget->order_by('position', 'asc');
                 $widget->get();
                 $updates = TRUE;
                 foreach ($widget->all as $widget_to_update) {
                     $widget_to_update->column = $teacher->widget_columns;
                     $widget_to_update->position = $position;
                     if (!$widget_to_update->save()) {
                         $updates = FALSE;
                     } else {
                         $position++;
                     }
                 }
                 if ($updates) {
                     $this->db->trans_commit();
                     $this->messages->add_message($this->lang->line('admin_dashboard_message_columns_saved'), Messages::MESSAGE_TYPE_SUCCESS);
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message($this->lang->line('admin_dashboard_message_columns_save_fail'), Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->db->trans_commit();
                 $this->messages->add_message($this->lang->line('admin_dashboard_message_columns_saved'), Messages::MESSAGE_TYPE_SUCCESS);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message($this->lang->line('admin_dashboard_message_columns_save_fail'), Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message($this->lang->line('admin_dashboard_message_columns_save_fail_count'), Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(create_internal_url('admin_dashboard'));
 }
Beispiel #13
0
 /**
  * Set new default teacher language idiom to database and session. Teacher must be loged in!
  * @param string $language the language idiom to be set as default for teacher account.
  * @return boolean TRUE, if language is set and session stored, FALSE otherwise.
  */
 public function set_teacher_language($language)
 {
     if ($this->is_teacher_session_valid()) {
         $all_langs = $this->CI->lang->get_list_of_languages();
         if (array_key_exists($language, $all_langs)) {
             $teacher = new Teacher();
             $teacher->get_by_id($this->get_teacher_id());
             $teacher->language = $language;
             if ($teacher->save()) {
                 $userdata = $this->CI->session->userdata(SESSION_AUTH_LOGIN_TEACHER);
                 $userdata['language'] = $language;
                 $this->CI->session->set_userdata(SESSION_AUTH_LOGIN_TEACHER, $userdata);
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
Beispiel #14
0
 public function switch_prefered_course($course_id, $current_url)
 {
     $this->usermanager->teacher_login_protected_redirect();
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $teacher = new Teacher();
     $teacher->get_by_id($this->usermanager->get_teacher_id());
     if ($teacher->exists()) {
         $course = new Course();
         $course->get_by_id($course_id);
         if ($teacher->save(array('prefered_course' => $course))) {
             $this->db->trans_commit();
             $this->usermanager->refresh_teacher_userdata();
             $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_success', Messages::MESSAGE_TYPE_DEFAULT);
             $this->load->library('filter');
             $this->filter->set_all_filters_course($teacher->prefered_course_id);
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(decode_from_url($current_url));
 }
 public function create_teacher()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_nuevo_profesor', $data["actions"])) {
             // Validate the info, create rules for the inputs
             $attributes = array('dni' => 'DNI del Profesor', 'names' => 'Nombres del Profesor', 'lastname' => 'Apellidos del Profesor', 'birthdate' => 'Fecha de nacimiento', 'email' => 'E-mail', 'telephone' => 'Teléfono o Celular');
             $messages = array();
             $rules = array('dni' => 'required|digits:8|unique:users,dni,NULL,id,deleted_at,NULL', 'names' => 'required|alpha_num_dash|max:45', 'lastname' => 'required|alpha_num_dash|max:45', 'email' => 'required|email|max:100|unique:users,email,NULL,id,deleted_at,NULL');
             // Run the validation rules on the inputs from the form
             $validator = Validator::make(Input::all(), $rules, $messages, $attributes);
             // If the validator fails, redirect back to the form
             if ($validator->fails()) {
                 return Redirect::to('people/new_teacher')->withErrors($validator)->withInput(Input::all());
             } else {
                 // se crea el usuario primero
                 $user = new User();
                 $user->dni = Input::get('dni');
                 $e = Input::get('email');
                 if ($e != '') {
                     $user->email = $e;
                 }
                 $user->password = Hash::make('12345678');
                 $user->save();
                 $user->profiles()->attach(Profile::where('name', '=', 'Profesor')->first()->id);
                 $teacher = new Teacher();
                 $teacher->names = Input::get('names');
                 $teacher->lastname = Input::get('lastname');
                 $b = Input::get('birthdate');
                 if ($b != '') {
                     $teacher->birthdate = date('Y-m-d', strtotime($b));
                 }
                 $teacher->telephone = Input::get('telephone');
                 $teacher->state = 'A';
                 $teacher->user_id = $user->id;
                 $teacher->save();
                 Session::flash('message', 'Se creó correctamente el Profesor.');
                 // Llamo a la función para registrar el log de auditoria
                 $log_description = "Se creó el Profesor con id: {{$teacher->id}}";
                 Helpers::registerLog(3, $log_description);
                 return Redirect::to('people/list_teachers');
             }
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
 protected function validateconfirm()
 {
     $required = array("teacher_id" => "Teacher Id", "admission_date" => "Admission Date", "name" => "Name", "subject_id" => "Subject", "date_of_birth" => "Date of Birth", "gender" => "Gender", "mobile" => "Mobile");
     global $user;
     global $objPDO;
     $student = new Student($objPDO, $user->getuserId());
     if ($user->checkAdmin() == true || $student->checkTeacher() == true) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             if (!is_numeric($_POST['mobile'])) {
                 echo "Mobile number must be Numeric";
             } else {
                 if (isset($_POST['permanent_pincode']) && $_POST['permanent_pincode'] != '' && !is_numeric($_POST['permanent_pincode']) || isset($_POST['correspondence_pincode']) && $_POST['correspondence_pincode'] != '' && !is_numeric($_POST['correspondence_pincode'])) {
                     echo "Pincode must be Numeric";
                 } else {
                     echo 'Saving...';
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/teacher_class.php';
                     $teacherProfile = new Teacher($objPDO);
                     if ($user->checkAdmin() == true) {
                         $teacher_id = $_GET['uid'];
                     } else {
                         $teacher_id = $student->getID();
                     }
                     if ($_POST['blood_group'] == 'select') {
                         unset($_POST['blood_group']);
                     }
                     $teacherProfile->loadByUserId($teacher_id);
                     $teacherProfile->setByArray($_POST);
                     $teacherProfile->save();
                     echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/teacher/view/' . $teacher_id . '"/>';
                 }
             }
         }
     } else {
         echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/teacher/view/"/>';
     }
 }
Beispiel #17
0
 public function comments_subscribe($task_set_id)
 {
     $output = new stdClass();
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->get_by_id(intval($task_set_id));
     $teacher = new Teacher();
     $teacher->get_by_id($this->usermanager->get_teacher_id());
     if ($teacher->exists() && $task_set->exists() && $teacher->save(array('comment_subscription' => $task_set))) {
         $this->db->trans_commit();
         $output->message = $this->lang->line('admin_task_sets_comments_my_settings_subscribe_success');
         $output->result = TRUE;
     } else {
         $this->db->trans_rollback();
         $output->message = $this->lang->line('admin_task_sets_comments_my_settings_subscribe_error');
         $output->result = FALSE;
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
 public function register()
 {
     if (Sentry::check()) {
         // User is logged in
         return Redirect::to('/');
     }
     $captcha_type = Config::get('app.captcha');
     if ($captcha_type == "captcha") {
         $captcha_field = "captcha";
         $captcha_validation = 'required|min:5|captcha';
     } elseif ($captcha_type == "recaptcha") {
         $captcha_field = "recaptcha_response_field";
         $captcha_validation = 'required|min:5|recaptcha';
     } elseif ($captcha_type == "checkbox") {
         $captcha_field = "checkbox_captcha";
         $captcha_validation = "required|checkbox_captcha";
     }
     $validator = Validator::make(Input::all(), array('fname' => 'required|min:3|alpha|different:lname', 'lname' => 'required|min:3|alpha|different:fname', 'email' => 'required|min:5|email|usercheck', 'password' => 'required|min:8|different:lname|different:fname|different:email|confirmed', 'dob' => 'before:2005-01-01|after:1900-01-01', 'actype' => 'required', $captcha_field => $captcha_validation));
     if ($validator->fails()) {
         Input::flash();
         return Redirect::to('register')->withErrors($validator);
     } else {
         $email = Input::get('email');
         $password = Input::get('password');
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         $actype = Input::get('actype');
         $subjects = Input::get('subjects');
         // Let's register a user.
         $user = Sentry::register(array('email' => $email, 'password' => $password, 'first_name' => $fname, 'last_name' => $lname));
         if ($actype == 'students' || $actype == 'teachers') {
             $group = Sentry::getGroupProvider()->findByName($actype);
             $useract = Sentry::getUserProvider()->findByLogin($email);
             if ($useract->addGroup($group)) {
                 // Group assigned successfully
             } else {
                 // Group was not assigned
                 //Log the Error of User Group set
                 Log::error("assigning {$useract} to {$group} failed.");
             }
         }
         // Let's get the activation code
         $activationcode = $useract->getActivationCode();
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         if ($actype == 'students') {
             $student = new Student();
             $student->user_id = $useract->id;
             $student->email = $useract->email;
             $student->dob = Input::get('dob');
             $student->extra = serialize($subjects);
             $student->save();
         }
         if ($actype == 'teachers') {
             $teacher = new Teacher();
             $teacher->user_id = $useract->id;
             $teacher->email = $useract->email;
             $teacher->dob = Input::get('dob');
             $teacher->extra = serialize($subjects);
             $teacher->save();
         }
         $data = ['activation_code' => $activationcode, 'fname' => $fname, 'lname' => $lname, 'email' => $email, 'fullname' => $fname . ' ' . $lname];
         Mail::send('emails.welcome', $data, function ($message) use($user) {
             $usermail = DB::table('users')->where('email', $user->getLogin())->first();
             $fullname = $usermail->first_name . ' ' . $usermail->last_name;
             $message->to($user->getLogin(), $fullname)->subject('Welcome! to EdLara');
         });
         return Redirect::to('/');
     }
 }
Beispiel #19
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $teacherModel = new Teacher();
     $studentModel = new Student();
     $hostModel = new Host();
     if (XUtils::method() == 'POST') {
         /*switch($_POST){
         				case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master';  break;
         				case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break;
         				case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break;
         				default: $nowModel = 0;
         			}
         			if($nowModel){
         				$nowModel->attributes = $nowAttributes;
         
         
                         if ($nowModel->validate() && $nowModel->save()) {
         
                             parent::_stateWrite(
                                     array(
                                 'masterId' => $nowModel->id,
         						
                                 'name' => $nowModel->name,
                                     ), array('prefix' => '_master')
                             );
         
                             $cookie = new CHttpCookie('userName', $nowModel->name);
                             Yii::app()->request->cookies['userName'] = $cookie;
                             $this->redirect(array($nowRedirect));
                         }
         			}*/
         if (isset($_POST['Teacher'])) {
             $teacherModel->attributes = $_POST['Teacher'];
             if ($teacherModel->validate() && $teacherModel->save()) {
                 parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master'));
                 if ($teacherModel->name == '') {
                     $teacherModel->name = '导师';
                 }
                 $cookie = new CHttpCookie('userName', $teacherModel->name);
                 Yii::app()->request->cookies['userName'] = $cookie;
                 $this->_cookiesSet('userId', $teacherModel->id);
                 $this->_cookiesSet('userType', 'student');
                 Yii::app()->user->setFlash('TSSuccess', '注册成功!请完善个人信息并提交身份认证即可发布课程');
                 $this->redirect(array('/master'));
             }
         } else {
             if (isset($_POST['Student'])) {
                 $studentModel->attributes = $_POST['Student'];
                 //echo CActiveForm::validate($studentModel);
                 if ($studentModel->validate() && $studentModel->save()) {
                     parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student'));
                     if ($studentModel->name == '') {
                         $studentModel->name = '学员';
                     }
                     $cookie = new CHttpCookie('userName', $studentModel->name);
                     Yii::app()->request->cookies['userName'] = $cookie;
                     $this->_cookiesSet('userId', $studentModel->id);
                     $this->_cookiesSet('userType', 'student');
                     $this->redirect(array('/student/info/sinfo'));
                 }
             } else {
                 if (isset($_POST['Host'])) {
                     $hostModel->attributes = $_POST['Host'];
                     //echo CActiveForm::validate($hostModel);
                     if ($hostModel->validate() && $hostModel->save()) {
                         parent::_stateWrite(array('hostId' => $hostModel->id, 'name' => $hostModel->name), array('prefix' => '_host'));
                         if ($hostModel->name == '') {
                             $hostModel->name = '场地主';
                         }
                         $cookie = new CHttpCookie('userName', $hostModel->name);
                         Yii::app()->request->cookies['userName'] = $cookie;
                         $this->_cookiesSet('userId', $hostModel->id);
                         $this->_cookiesSet('userType', 'host');
                         $this->redirect(array('/host'));
                     }
                 }
             }
         }
     }
     $this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel));
 }
Beispiel #20
0
 /**
  * Creates new teacher from console.
  */
 public function new_teacher()
 {
     $this->load->database();
     $languages = $this->lang->get_list_of_languages();
     echo 'Create new teacher' . "\n\n";
     $name = $this->_get_cli_user_input('Teacher full name');
     $email = $this->_get_cli_user_input('Teacher e-mail');
     $password = $this->_get_cli_user_input('Teacher password');
     if (count($languages)) {
         echo 'Available languages:';
         foreach ($languages as $language_key => $language_value) {
             echo "\n" . '  (' . $language_key . ') for ' . normalize($language_value) . '';
         }
     }
     $language = $this->_get_cli_user_input("\n" . 'Select teacher language');
     $this->load->library('form_validation');
     if (!$this->form_validation->required($name) || !$this->form_validation->required($email) || !$this->form_validation->required($password) || !$this->form_validation->required($language)) {
         echo 'ERROR: Some parameter(s) is(are) missing.' . "\n";
     } elseif (!$this->form_validation->valid_email($email)) {
         echo 'ERROR: E-mail is invalid.' . "\n";
     } elseif (!$this->form_validation->is_unique($email, 'teachers.email')) {
         echo 'ERROR: E-mail must be unique.' . "\n";
     } elseif (!$this->form_validation->min_length($password, 6)) {
         echo 'ERROR: Password must have at least 6 characters.' . "\n";
     } elseif (!$this->form_validation->max_length($password, 20)) {
         echo 'ERROR: Password must not be longer than 20 characters.' . "\n";
     } elseif (!array_key_exists($language, $languages)) {
         echo 'ERROR: Desired language not found.' . "\n";
     } else {
         $teacher = new Teacher();
         $teacher->fullname = $name;
         $teacher->email = $email;
         $teacher->password = sha1($password);
         $teacher->language = $language;
         $this->db->trans_begin();
         $teacher->save();
         $teacher->get_by_email($email);
         if ($teacher->result_count() == 1) {
             $this->db->trans_commit();
             echo "\n" . 'Teacher account created!';
         } else {
             $this->db->trans_rollback();
             echo "\n" . 'Teacher account failed to be created!';
         }
     }
 }