本文整理汇总了PHP中Teacher::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Teacher::save方法的具体用法?PHP Teacher::save怎么用?PHP Teacher::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teacher
的用法示例。
在下文中一共展示了Teacher::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Создает новую модель Учителя.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @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]);
}
示例2: actionCreate
/**
* 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));
}
示例3: actionCreate
/**
* 录入
*
*/
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));
}
示例4: actionCreate
/**
* 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));
}
示例5: createTeacher
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);
}
}
}
示例6: fire
/**
* 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 = "user123456";
$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();
}
}
}
示例7: actionCreate
/**
* Создает новую модель Учителя.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @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, 'Ошибка прав доступа.');
}
}
示例8: addTeacher
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' => '添加成功!'));
}
示例9: actionCreate
/**
* 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,
));
}
示例10: addTeacher
/**
* 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'));
}
示例11: actionIndex
/**
* 首页
*/
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', '同意条款未勾选');
}
//.........这里部分代码省略.........
示例12: set_columns
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'));
}
示例13: set_teacher_language
/**
* 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;
}
示例14: switch_prefered_course
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));
}
示例15: create_teacher
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');
}
}