コード例 #1
0
 function school_count_since_date($time)
 {
     $S = new Schools();
     //Best way to connect to database?
     $cursor = $this->dbstudent->emails->find();
     $pattern = "/(.*)@(.*)/";
     $schools = array();
     $school_names = array();
     foreach ($cursor as $doc) {
         $success = preg_match($pattern, $doc["email"], $match);
         if ($success && $doc["_id"]->getTimestamp() > $time) {
             if (array_key_exists($match[2], $schools)) {
                 $schools[$match[2]] += 1;
             } else {
                 $schools[$match[2]] = 1;
             }
         }
     }
     foreach ($schools as $key => $id) {
         if ($S->hasSchoolOf($key)) {
             if (array_key_exists($S->nameOf($key), $school_names)) {
                 $school_names[$S->nameOf($key)] += $id;
             } else {
                 $school_names[$S->nameOf($key)] = $id;
             }
         } else {
             if (array_key_exists($key, $school_names)) {
                 $school_names[$key] += $id;
             } else {
                 $school_names[$key] = $id;
             }
         }
     }
     return $school_names;
 }
コード例 #2
0
 function school_count_since_date($time)
 {
     $S = new Schools();
     //Best way to connect to database?
     $conn = MongoSingleton::getMongoCon();
     $db = $conn->sublite;
     $emails = $db->emails;
     $cursor = $emails->find();
     $pattern = "/(.*)@(.*)/";
     $schools = array();
     $school_names = array();
     foreach ($cursor as $doc) {
         $success = preg_match($pattern, $doc["email"], $match);
         if ($success && $doc["_id"]->getTimestamp() > $time) {
             $schools[$match[2]] += 1;
         }
     }
     foreach ($schools as $key => $id) {
         if ($S->hasSchoolOf($key)) {
             $school_names[$S->nameOf($key)] += $id;
         } else {
             $school_names[$key] += $id;
         }
     }
     return $school_names;
 }
コード例 #3
0
 public function getSchoolSettings()
 {
     $school = Schools::find($this->getSchoolId());
     $schedule = SchoolSchedule::where('school_id', '=', $this->getschoolId())->where('school_session_id', '=', $this->getSchoolSessionId())->get();
     $sessions = SchoolSession::where('school_id', '=', $this->getschoolId())->get();
     $current_session = SchoolSession::where('school_id', '=', $this->getschoolId())->where('current_session', '=', 1)->get()->first();
     return View::make('admin.school-settings')->with('schedules', $schedule)->with('sessions', $sessions)->with('school', $school)->with('current_session', $current_session);
 }
コード例 #4
0
 /**
  * Контроллер для работы выбора школ при редактировании персоны
  */
 public function actionSchoolr($id)
 {
     $result = array();
     $text = "";
     $model = Schools::model()->find("idSchool = {$id}");
     if (!empty($model)) {
         $text = $model->SchoolName;
     }
     $result = array("id" => $id, 'text' => $text);
     echo CJSON::encode($result);
 }
コード例 #5
0
ファイル: Schools.php プロジェクト: upmunspel/abiturient
 public static function DropDown($KOATUUCode = '0000000000', $MaskLen = 4)
 {
     $res = array();
     //debug('$MaskLen = '.$MaskLen);
     $KOATUUCode = substr($KOATUUCode, 0, $MaskLen);
     //debug($KOATUUCode);
     foreach (Schools::model()->findAll("KOATUUCode like :KOATUUCode ORDER BY SchoolName", array(":KOATUUCode" => $KOATUUCode . "%")) as $record) {
         $res[$record->idSchool] = $record->SchoolName;
     }
     return $res;
 }
コード例 #6
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), array('first_name' => 'required|max:30', 'last_name' => 'required|max:30', 'city' => 'required|max:30', 'state' => 'required|max:30', 'sex' => 'required', 'school_registration_code' => 'required|max:80', 'user_registration_code' => 'required|max:80', 'email' => 'max:60|email|unique:users', 'password' => 'required|min:6', 'password_again' => 'required|same:password'));
     if ($validator->fails()) {
         return Redirect::route('user-account-create')->withErrors($validator)->withInput();
     } else {
         $school_registration_code = Input::get('school_registration_code');
         $user_registration_code = Input::get('user_registration_code');
         $school = Schools::where('registration_code', '=', $school_registration_code)->where('code_for_students', '=', $user_registration_code)->where('active', '=', 1)->get();
         if (!$school->count()) {
             return Redirect::route('admin-account-create')->with('global', 'Please input Correct School code and Admin Code.');
         }
         $first_name = Input::get('first_name');
         $last_name = Input::get('last_name');
         $email = Input::get('email');
         $sex = Input::get('sex');
         $city = Input::get('city');
         $state = Input::get('state');
         $password = Input::get('password');
         // Unique Username
         $username = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(1, 10))), 1, 10);
         //Activation Code
         $code = str_random(60);
         $now = date("Y-m-d H-i-s");
         $groups = Groups::find(1);
         $User = User::create(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'email_updated_at' => $now, 'password' => Hash::make($password), 'password_updated_at' => $now, 'username' => $username, 'sex' => $sex, 'city' => $city, 'state' => $state, 'address_updated_at' => $now, 'code' => $code, 'active' => 0, 'mobile_verified' => 0, 'permissions' => $groups->id, 'school_id' => $school->first()->id));
         if ($User) {
             //send email
             Mail::send('emails.auth.activate.activate-user', array('link' => URL::route('user-account-activate', $code), 'username' => $username), function ($message) use($User) {
                 $message->to($User->email, $User->voter_id)->subject('Activate Your Account');
             });
             return Redirect::route('user-sign-in')->with('global', 'You have been Registered. You can activate Now.');
         } else {
             return Redirect::route('user-sign-in')->with('global', 'You have not Been Registered. Try Again Later Some time.');
         }
     }
 }
コード例 #7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Schools::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #8
0
 /**
  *
  */
 public function schools()
 {
     $schools = new Schools();
     return $schools->get_by_school_approval_level($this->id);
 }
コード例 #9
0
 /**
  * Метод асинхронно повертає список НЗ, що закінчили персони
  */
 public function actionSchools()
 {
     $models = Schools::model()->findAll('1 ORDER BY SchoolName ASC');
     $result = array();
     foreach ($models as $model) {
         /* @var $model Schools */
         $result[] = array('text' => str_replace('"', "'", $model->SchoolName), 'id' => $model->idSchool);
     }
     echo CJSON::encode($result);
 }
コード例 #10
0
 public function postValidateSchool()
 {
     $registration_code = Input::get('registration_code');
     $group_id = Input::get('group_id');
     try {
         // Find the group using the group id
         $group = Sentry::findGroupById($group_id);
         // Get the group permissions
         $groupPermissions = $group->getPermissions();
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group does not exist.';
     }
     if ($group->count() > 0) {
         if ($group->id == 3) {
             $code_for_teachers = Input::get('code_for_teachers');
             $school = Schools::where('registration_code', '=', $registration_code)->where('code_for_teachers', '=', $code_for_teachers)->get()->first();
         } elseif ($group_id == 2) {
             $code_for_students = Input::get('code_for_students');
             $school = Schools::where('registration_code', '=', $registration_code)->where('code_for_students', '=', $code_for_students)->get()->first();
         } elseif ($group_id == 1) {
             $code_for_admin = Input::get('code_for_admin');
             $school = Schools::where('registration_code', '=', $registration_code)->where('code_for_admin', '=', $code_for_admin)->get()->first();
         }
         if ($school->count() > 0) {
             $user = Sentry::getUser();
             $user->school_id = $school->id;
             $user->save();
             $users_login_info = new UsersLoginInfo();
             $users_login_info->user_id = $user->id;
             $users_login_info->school_id = $school->id;
             $users_login_info->save();
             $response = array('status' => 'success', 'result' => array('school' => $school));
             return Response::json($response);
         } else {
             $response = array('status' => 'failed', 'result' => array('school' => null));
             return Response::json($response);
         }
     }
 }
コード例 #11
0
 /**
  *
  */
 public function schools()
 {
     $schools = new Schools();
     return $schools->get_by_school_type($this->id);
 }