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


PHP Model_User::create方法代码示例

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


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

示例1: action_responsible_teacher

 public function action_responsible_teacher()
 {
     $programs = Model_Education_Programs::create();
     $request = $this->getRequest();
     $method = 'post';
     if (empty($request->{$method})) {
         $users = Model_User::create();
         $this->set('teachers', $users->getTeachersList());
         $this->set('disciplines', $programs->getDisciplinesResponsibleTeachersList());
         $this->set('courses', $programs->getCoursesResponsibleTeachersList());
         $this->render('assignment/responsible_teacher');
     } else {
         /**
          * @todo Переделать для использования Form_Abstract.
          */
         $requestData = $request->{$method};
         if (isset($requestData['courses'])) {
             foreach ($requestData['courses'] as $courseId => $teacherId) {
                 $programs->setCoursesResponsibleTeacher($courseId, $teacherId);
             }
         }
         if (isset($requestData['disciplines'])) {
             foreach ($requestData['disciplines'] as $disciplineId => $teacherId) {
                 $programs->setDisciplineResponsibleTeacher($disciplineId, $teacherId);
             }
         }
         $links = Resources::getInstance()->links;
         $this->flash('Ответсвенные преподаватели успешно назначены', $links->get('admin.responsible-teachers'), 3);
     }
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:30,代码来源:Assignment.php

示例2: testCanDeleteUsername

 public function testCanDeleteUsername()
 {
     Model_User::create($this->username, $this->password);
     $user = Model_User::findByUsername($this->username);
     $user->delete();
     $userNotFound = Model_User::findByUsername($this->username);
     $this->assertFalse($userNotFound);
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:8,代码来源:UserTest.php

示例3: action_discipline

 /**
  * Отображение списка слушателей, изучающих дисциплину.
  *
  * @params['discipline_id'] Идентификатор дисциплины.
  */
 public function action_discipline($params)
 {
     $modelEducationPrograms = Model_Education_Programs::create();
     $modelOpenSect = Model_OpenSection::create();
     $modelCredit = Model_Credit::create();
     $modelControlWork = Model_ControlWork::create();
     $modelUser = Model_User::create();
     $data = array();
     $userList = $modelEducationPrograms->getStudentsByDiscipline($params['discipline_id']);
     $openSections = $modelOpenSect->getOpenSectionsByDiscipline($params['discipline_id']);
     $creditSections = $modelCredit->getCreditsByDiscipline($params['discipline_id']);
     //print_r($creditSections); die();
     $modelEducationPrograms->getDiscipline($params['discipline_id'], $title, $labourIntensive, $coef);
     $sections = $modelEducationPrograms->getSectionsByDiscipline($params['discipline_id']);
     // вот чисто философский вопрос: а этот код действительно должн быть здесь?
     //print_r($userList); die();
     foreach ($userList as &$rec) {
         $userInfo = $modelUser->getUserInfo($rec['user_id']);
         $name = $userInfo['surname'] . ' ' . $userInfo['name'] . ' ' . $userInfo['patronymic'];
         $data[$rec['user_id']] = array('name' => $name, 'open_sections' => array(), 'credit_sections' => array('ids' => array(), 'dates' => array()));
         for ($i = 0; $i < count($openSections); $i++) {
             if ($openSections[$i]['student_id'] == $rec['user_id']) {
                 array_push($data[$rec['user_id']]['open_sections'], $openSections[$i]['section_id']);
                 unset($openSections[$i][$rec['user_id']]);
             }
         }
         $lastCreditedSection = -1;
         for ($i = 0; $i < count($creditSections); $i++) {
             if ($creditSections[$i]['student_id'] == $rec['user_id']) {
                 $lastCreditedSection = $creditSections[$i]['section_id'];
                 array_push($data[$rec['user_id']]['credit_sections']['ids'], $creditSections[$i]['section_id']);
                 array_push($data[$rec['user_id']]['credit_sections']['dates'], $creditSections[$i]['created_date']);
                 unset($creditSections[$i][$rec['user_id']]);
             }
         }
         if (!$modelCredit->isDisciplineCredited($params['discipline_id'], $rec['user_id'])) {
             if ($lastCreditedSection == -1) {
                 $firstSectAr = $modelEducationPrograms->getFirstSectionIdOfDiscipline($params['discipline_id']);
                 $data[$rec['user_id']]['first_uncredited_section'] = $firstSectAr;
             } else {
                 $data[$rec['user_id']]['first_uncredited_section'] = $modelEducationPrograms->getNextSectionOfDiscipline($params['discipline_id'], $lastCreditedSection);
             }
             $data[$rec['user_id']]['cur_control_works'] = $modelControlWork->getStudentMarksBySection($rec['user_id'], $data[$rec['user_id']]['first_uncredited_section']);
         }
     }
     //print_r($data); die();
     $this->set('discipline_id', $params['discipline_id']);
     $this->set('discipline_title', $title);
     $this->set('data', $data);
     $this->set('sections', $sections);
     $this->set('TYPE_NAMES', $modelControlWork->getControlNamesMap());
     $this->set('MARK_NAMES', $modelControlWork->getMarkNamesMap());
     $this->render('teacher_courses/discipline');
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:59,代码来源:Courses.php

示例4: prepare

 /**
  * @BeforeSuite
  */
 public static function prepare(SuiteEvent $event)
 {
     // Clear the user table.
     $query = DB::delete('users')->execute();
     // Setup the test user for login.
     $user = new Model_User();
     $user->username = 'username';
     $user->password = 'password';
     $user->email = 'username@test.com';
     $user->timezone_id = 1;
     $user->create();
     $user->add('roles', Model_Role::LOGIN);
 }
开发者ID:modulargaming,项目名称:user,代码行数:16,代码来源:FeatureContext.php

示例5: fromJSON

 public static function fromJSON($json)
 {
     $user_data = json_decode($json, true);
     Database::setup();
     $user = R::dispense(Model_User::$table_name);
     if (isset($user_data)) {
         if (isset($user_data['username'])) {
             $username = $user_data['username'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['name'])) {
             $name = $user_data['name'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['email'])) {
             $email = $user_data['email'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['date'])) {
             $date = $user_data['date'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['password'])) {
             $password = $user_data['password'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['status'])) {
             $status = $user_data['status'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['persona'])) {
             $persona = $user_data['persona'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
         if (isset($user_data['progress'])) {
             $progress = $user_data['progress'];
         } else {
             throw new InvalidCreationJSONObjectException();
         }
     } else {
         throw new InvalidCreationJSONObjectException();
     }
     return Model_User::create($username, $name, $email, $date, $password, $status, $persona, $progress);
 }
开发者ID:33windowlicker,项目名称:web-lmul-rangers,代码行数:51,代码来源:Model_User.php

示例6: action_send

 public function action_send()
 {
     $links = Resources::getInstance()->links;
     $args = func_get_args();
     $request = $this->getRequest();
     $action = $links->get('messages.send');
     $form = new Form_Message_Send($action);
     if (count($args)) {
         //$form->setValue('recipients', $args[0]['to_id']);
         $form->setValue('recipient', $args[0][0]);
     }
     $this->set('form', $form);
     $method = $form->method();
     $user = Model_User::create();
     $udata = $user->getAuth();
     //print_r($udata);
     $this->set('filterExists', $udata['role'] == Model_User::ROLE_ADMIN);
     $messages = new Model_Messages();
     $recipients = $messages->getRecipientsList();
     $this->set('recipients', $recipients);
     $requestData = $request->{$method};
     //print_r($requestData);
     if (empty($requestData) || !$form->validate($request)) {
         $this->render('messages/send');
     }
     /**
      * @todo Form_Abstract automatically processes values for all defined
      * fields to protect them from XSS.
      */
     $recipients = explode(',', $requestData['recipient']);
     $messageIds = array();
     foreach ($recipients as $rec) {
         $messageIds[] = $messages->sendMessage($rec, htmlspecialchars($requestData['subject']), htmlspecialchars($requestData['message']));
     }
     if (isset($_FILES['attachment'])) {
         $messages->addAttachments($messageIds, $_FILES['attachment']);
     }
     /*
     $messageId = $messages->sendMessage($requestData['recipient'], htmlspecialchars($requestData['subject']), htmlspecialchars($requestData['message']));
     
     if (isset($_FILES['attachment'])) {
         $messages->addAttachments($messageId, $_FILES['attachment']);
     }
     */
     $this->flash('Сообщение отправлено', $links->get('messages.inbox'), 3);
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:46,代码来源:Messages.php

示例7: action_discipline

 /**
  * Отображение куратору успеваемости слушателя по дисциплине.
  *
  * @params['student_id'] Идентификатор студента.
  * @params['discipline_id'] Идентификатор дисциплины.
  */
 public function action_discipline($params)
 {
     $model_credit = Model_Credit::create();
     $model_control_work = Model_ControlWork::create();
     $model_education_programs = Model_Education_Programs::create();
     $model_user = Model_User::create();
     $model_education_programs->getDiscipline($params['discipline_id'], $title, $labourIntensive, $coef);
     $this->set('test_results', $model_control_work->getStudentTestResultsByDiscipline($params['student_id'], $params['discipline_id']));
     $this->set('credits', $model_credit->getStudentCreditsByDiscipline($params['student_id'], $params['discipline_id']));
     $this->set('control_works', $model_control_work->getStudentMarksByDiscipline($params['student_id'], $params['discipline_id']));
     $this->set('control_names_map', $model_control_work->getControlNamesMap());
     $this->set('mark_names_map', $model_control_work->getMarkNamesMap());
     $this->set('discipline_title', $title);
     $this->set('sections', $model_education_programs->getSectionsByDiscipline($params['discipline_id']));
     $this->set('user_id', $params['student_id']);
     $this->set('user_info', $model_user->getUserInfo($params['student_id']));
     $this->render('teacher_students/discipline');
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:24,代码来源:Students.php

示例8: action_edit_account

 public function action_edit_account($params)
 {
     $links = Resources::getInstance()->links;
     $opts = array('user_id' => $params['user_id']);
     $action = $links->get('users.edit', $opts);
     $form = Form_Profile_Edit::create($action);
     $users = Model_User::create();
     $this->set('form', $form);
     $this->set('rolesCaptions', $this->_roles_captions);
     $request = $this->getRequest();
     $method = $form->method();
     $requestData = $request->{$method};
     if (empty($requestData)) {
         if (($userInfo = $users->getUserInfo($params['user_id'])) === FALSE) {
             $this->flash('Пользователь не существует', $links->get('users.list') . 'all/fio/asc/', 5);
         }
         $form->setValue('surname', $userInfo['surname']);
         $form->setValue('name', $userInfo['name']);
         $form->setValue('patronymic', $userInfo['patronymic']);
         $form->setValue('role', $userInfo['role']);
     } else {
         if ($form->validate($request)) {
             $userInfo = array('name' => $requestData['name'], 'surname' => $requestData['surname'], 'patronymic' => $requestData['patronymic'], 'role' => $requestData['role'], 'user_id' => $params['user_id']);
             $users->setUserInfo($userInfo);
             $this->flash('Данные пользователя успешно изменены', $links->get('users.list') . 'all/fio/asc/', 3);
         }
     }
     $this->render('users/edit_account');
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:29,代码来源:Users.php

示例9: action_available

 /**
  * Отображение доступных для слушателя программ и дисциплин.
  * Все доступные дисциплины сохраняются в сесиию
  */
 public function action_available()
 {
     /* Получаем данные слушателя */
     $user = Model_User::create();
     $udata = (object) $user->getAuth();
     $session = Resources_Abstract::getInstance()->session;
     unset($session->availDisciplines);
     $student = Model_Education_Students::create();
     $avail_programs = $student->getAvailDisciplinesForPrograms($udata->user_id);
     $avail_disciplines = $student->getAvailDisciplinesSeparate($udata->user_id);
     //echo 'Test message in file: '.__FILE__.', on line: '.__LINE__; print_r($avail_programs);
     //echo 'Test message in file: '.__FILE__.', on line: '.__LINE__; print_r($avail_disciplines);
     //var_dump ($session->availDisciplines); die();
     $this->set('programs', $avail_programs);
     $this->set('disciplines', $avail_disciplines);
     $this->render();
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:21,代码来源:Programs.php

示例10: action_show

 /**
  * Отображение доступных учебных материалов.
  */
 public function action_show(array $params = array())
 {
     $a = Model_Test::create();
     $a->test();
     $links = Resources::getInstance()->links;
     if (!isset($params['discipline_id']) || is_int($params['discipline_id'])) {
         $this->flash('Не указан идентификатор дисциплины', $links->get('student.programs'));
     }
     $discipline_id = intval($params['discipline_id']);
     $user = Model_User::create();
     $udata = (object) $user->getAuth();
     $session = Resources_Abstract::getInstance()->session;
     // если данных о доступных дисциплинах нет - вычислить
     if (!isset($session->availDisciplines)) {
         $student = Model_Education_Students::create();
         $avail_programs = $student->getAvailDisciplinesForPrograms($udata->user_id);
         $avail_disciplines = $student->getAvailDisciplinesSeparate($udata->user_id);
     }
     $discipline_open = in_array($discipline_id, $session->availDisciplines);
     if ($discipline_open) {
         // дисциплина доступна
         $disc = Model_Discipline::create();
         $discipline_data = $disc->get($discipline_id);
         $section = Model_Section::create();
         $sections = $section->getAllByDiscipline($discipline_id);
         $modelApps = Model_Application::create();
         $statuses = $modelApps->getAppsStatus($discipline_id, $udata->user_id);
         //== Model_Application::STATUS_FINISHED;
         $statusFinished = array_key_exists(Model_Application::STATUS_FINISHED, $statuses);
         $material = Model_Educational_Materials::create();
         $materials = $material->getAllByDiscipline($discipline_id, $statusFinished);
         $control_work = Model_ControlWork::create();
         $tests = $control_work->getTestsByDiscipline($discipline_id);
         $this->set('discipline', $discipline_data);
         $this->set('sections', $sections);
         $this->set('materials', $materials);
         $this->set('tests', $tests);
         $this->set('user_id', $udata->user_id);
         //print_r($materials);
         $this->render();
     } else {
         $this->flash('Данная дисциплина на данный Вам недоступна. Возможно Вы не полностью оплатили заявку по данной дисциплине или программе, содержащей данную дисциплину, либо вообще не подавали заявку на ее изучение.', $links->get('student.programs'), 5);
     }
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:47,代码来源:Materials.php

示例11: _checkPermissions

 /**
  * Проверка прав на доступ к контроллеру/действию.
  * 
  * @param  array $handler Обработчик запроса.
  * @return boolean
  */
 protected function _checkPermissions(array $handler)
 {
     $path = $handler['controller'] . '/' . $handler['action'];
     /* Если путь не общедоступный */
     if (isset($this->_private_paths[$path])) {
         $user = Model_User::create();
         /* Проверяем, авторизован ли пользователь */
         if (false === ($udata = $user->getAuth())) {
             return false;
         }
         $udata = (object) $udata;
         $perms =& $this->_permissions[$udata->role];
         /* Проверяем, установлено ли разрешение на доступ */
         if (!isset($perms[$path])) {
             return false;
         }
     }
     return true;
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:25,代码来源:Dispatcher.php

示例12: _saveExamResults

 protected function _saveExamResults($test_id, $num_errors, $num_questions, $time, $passed)
 {
     $sql = '
             INSERT INTO ' . $this->_tables['examinations'] . '
             (user_id, test_id, time, num_errors, num_questions, passed,
             created)
             VALUES
             (:uid, :tid, :time, :num_errors, :num_questions, :passed, NOW())
         ';
     $user = Model_User::create();
     $udata = (object) $user->getAuth();
     $values = array('uid' => $udata->user_id, 'tid' => $test_id, 'time' => $time, 'num_errors' => $num_errors, 'num_questions' => $num_questions, 'passed' => $passed ? 'true' : 'false');
     $stmt = $this->prepare($sql);
     $stmt->execute($values);
     return $this->lastInsertId();
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:16,代码来源:Test.php

示例13: getRecipientsList

 /**
  * Возвращает список потенциальных получателей сообщений для текущего пользователя
  *
  * @return |array
  */
 public function getRecipientsList()
 {
     if ($this->userRole == Model_User::ROLE_STUDENT || $this->userRole == Model_User::ROLE_TEACHER) {
         $admin = array();
         $sql = 'SELECT `user_id` FROM `' . $this->_tables['users'] . '` WHERE `role`=\'admin\' LIMIT 1';
         $stmt = $this->prepare($sql);
         $stmt->execute();
         $adminId = $stmt->fetchColumn();
         $admin[$adminId] = array('recipient_name' => 'Администратор', 'recipient_description' => array('Администратор'));
     }
     $user = Model_User::create();
     switch ($this->userRole) {
         case Model_User::ROLE_STUDENT:
             $teachers = $user->getResponsibleTeacherInfoForStudent();
             $retval = $admin + $teachers;
             break;
         case Model_User::ROLE_TEACHER:
             $students = $user->getStudentsInfoForResponsibleTeacher();
             $retval = $admin + $students;
             break;
         case Model_User::ROLE_ADMIN:
             $teachers = $user->getAllTeachersResponsibleInfo();
             array_walk($teachers, function (&$value, $key) {
                 $value['role'] = Model_User::ROLE_TEACHER;
             });
             $students = $user->getStudentsList();
             array_walk($students, function (&$value, $key) {
                 $value['role'] = Model_User::ROLE_STUDENT;
                 $value['recipient_name'] = $value['surname'] . ' ' . $value['name'] . ' ' . $value['patronymic'];
                 //$value['recipient_name'] =  $recipient['surname'] . ' ' . mb_substr($recipient['name'], 0, 1, 'utf-8') . '. ' . mb_substr($recipient['pat    ronymic'], 0, 1, 'utf-8') . '.';
                 unset($value['name'], $value['surname'], $value['patronymic']);
             });
             $retval = $teachers + $students;
             //print_r($retval); die();
     }
     return $retval;
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:42,代码来源:Messages.php

示例14:

<?php

require_once './global.php';
Model_User::create("jfonseca", "Joao Fonseca", "joao.fonseca@fe.up.pt", "05/06/1992", "qwertz", 0, "thief", 0);
Model_User::create("jmorais", "Joao Morrais", "matteo.morrais@fe.up.pt", "05/06/1992", "qwertz", 0, "cook", 0);
开发者ID:33windowlicker,项目名称:web-lmul-rangers,代码行数:5,代码来源:seed.php

示例15: action_change_app_status

 public function action_change_app_status($params)
 {
     $links = Resources::getInstance()->links;
     $user = Model_User::create();
     $udata = $user->getAuth();
     $new_status = $params['new_status'];
     $app_id = $params['app_id'];
     $app = Model_Application::create();
     $app->setAppStatus($new_status, $app_id);
     /*
     if ('signed' == $new_status) {
         $programs = Model_Education_Programs::create();
         $model_checkpoint = Model_Checkpoint::create();
         $app_info = $app->getAppInfo($app_id);
         if ('discipline' == $app_info[0]['type']) {
             $first_section = $programs->getFirstSectionOfDiscipline($app_info[0]['object_id']);
             //echo '<pre>';var_dump($app_info );echo '</pre>'; die();
             $model_checkpoint->setCheckpointPass($app_info[0]['user_id'], $first_section['section_id']);
         }
         if ('program' == $app_info[0]['type']) {
             $first_discipline = $programs->getFirstDisciplineOfProgram($app_info[0]['object_id']);
             $first_section = $programs->getFirstSectionOfDiscipline($first_discipline[0]['discipline_id']);
             $model_checkpoint->setCheckpointPass($app_info[0]['user_id'], $first_section['section_id']);
         }
     }
     */
     /**
      * @TODO
      * Надо сделать проверку правильности изменения статуса на "окончена" через контрольную точку
      *
      */
     $map = Model_Application::getStatusMap();
     $this->flash('Заявка ' . $map[$new_status], $links->get('admin.applications'), 5);
     $this->render();
 }
开发者ID:vyrus,项目名称:remote-edu,代码行数:35,代码来源:Applications.php


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