Exemplo n.º 1
0
 public function promoteNow()
 {
     $returnResponse = array();
     $promote = Input::get('promote');
     if (count($promote) > 0) {
         $studentIdList = array();
         $studentDetailsList = array();
         while (list(, $value) = each($promote)) {
             $studentIdList[] = $value['id'];
         }
         $users = User::whereIn('id', $studentIdList)->get();
         foreach ($users as $value) {
             if (studentAcademicYears::where('studentId', $value->id)->where('academicYearId', $promote[$value->id]['acYear'])->count() > 0) {
                 $returnResponse[] = array("id" => $value->id, "fullName" => $value->fullName, "status" => "User already been in that academic year before");
             } else {
                 $studentAcademicYears = new studentAcademicYears();
                 $studentAcademicYears->studentId = $value->id;
                 $studentAcademicYears->academicYearId = $promote[$value->id]['acYear'];
                 $studentAcademicYears->classId = $promote[$value->id]['class'];
                 $studentAcademicYears->save();
                 User::where('id', $value->id)->update(['studentClass' => $promote[$value->id]['class'], 'studentAcademicYear' => $promote[$value->id]['acYear']]);
                 $returnResponse[] = array("id" => $value->id, "fullName" => $value->fullName, "status" => "User promoted successfully");
             }
         }
         return $returnResponse;
     }
 }
Exemplo n.º 2
0
 public function proceed()
 {
     if (Input::get('nextStep') == "1") {
         if (filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
             if (!Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) {
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         } else {
             if (!Auth::attempt(array('username' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) {
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         }
         if (!isset($loginError)) {
             file_put_contents('app/storage/meta/lc', Input::get('cpc'));
             if ($this->sbApi() == "err") {
                 @unlink('app/storage/meta/lc');
                 $this->data['installErrors'][] = "Purchase code is missing";
                 $loginError = false;
                 $this->data['loginError'] = "loginError";
             }
         }
         $this->data['currStep'] = "welcome";
         if (!isset($loginError)) {
             $this->data['currStep'] = "1";
             $this->data['nextStep'] = "2";
             $testData = uniqid();
             @file_put_contents("uploads/assignments/test", $testData);
             @file_put_contents("uploads/books/test", $testData);
             @file_put_contents("uploads/cache/test", $testData);
             @file_put_contents("uploads/media/test", $testData);
             @file_put_contents("uploads/profile/test", $testData);
             @file_put_contents("uploads/studyMaterial/test", $testData);
             @file_put_contents("uploads/assignmentsAnswers/test", $testData);
             @file_put_contents("app/storage/cache/test", $testData);
             @file_put_contents("app/storage/logs/test", $testData);
             @file_put_contents("app/storage/meta/test", $testData);
             @file_put_contents("app/storage/sessions/test", $testData);
             @file_put_contents("app/storage/views/test", $testData);
             if (@file_get_contents("uploads/assignments/test") != $testData) {
                 $this->data['perrors'][] = "uploads/assignments";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/assignments";
             }
             if (@file_get_contents("uploads/books/test") != $testData) {
                 $this->data['perrors'][] = "uploads/books";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/books";
             }
             if (@file_get_contents("uploads/cache/test") != $testData) {
                 $this->data['perrors'][] = "uploads/cache";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/cache";
             }
             if (@file_get_contents("uploads/media/test") != $testData) {
                 $this->data['perrors'][] = "uploads/media";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/media";
             }
             if (@file_get_contents("uploads/profile/test") != $testData) {
                 $this->data['perrors'][] = "uploads/profile";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/profile";
             }
             if (@file_get_contents("uploads/studyMaterial/test") != $testData) {
                 $this->data['perrors'][] = "uploads/studyMaterial";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/studyMaterial";
             }
             if (@file_get_contents("uploads/assignmentsAnswers/test") != $testData) {
                 $this->data['perrors'][] = "uploads/assignmentsAnswers";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "uploads/assignmentsAnswers";
             }
             if (@file_get_contents("app/storage/cache/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/cache";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/cache";
             }
             if (@file_get_contents("app/storage/logs/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/logs";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/logs";
             }
             if (@file_get_contents("app/storage/meta/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/meta";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/meta";
             }
             if (@file_get_contents("app/storage/sessions/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/sessions";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/sessions";
             }
             if (@file_get_contents("app/storage/views/test") != $testData) {
                 $this->data['perrors'][] = "app/storage/views";
                 $this->data['nextStep'] = "1";
             } else {
                 $this->data['success'][] = "app/storage/views";
             }
         }
     }
     if (Input::get('nextStep') == "2") {
         $this->data['currStep'] = "2";
         $this->data['nextStep'] = "3";
         $testInstalled = settings::where('fieldName', 'thisVersion')->first();
         if ($testInstalled->fieldValue == "1.2" || $testInstalled->fieldValue == "1.3") {
             //Upgrade from first version to 1.4
             DB::unprepared(file_get_contents('app/storage/dbsqlUp14'));
             $settings = settings::where('fieldName', 'thisVersion')->first();
             $settings->fieldValue = '1.4';
             $settings->save();
             $testInstalled->fieldValue = "1.4";
         }
         if ($testInstalled->fieldValue == "1.4") {
             //Upgrade from first version to 1.4
             DB::unprepared(file_get_contents('app/storage/dbsqlUp20'));
             //Classes and relation with subjects
             $classes = classes::get();
             foreach ($classes as $class) {
                 $classesUpdateArray = array();
                 $subjects = subject::where('classId', $class->id)->get();
                 foreach ($subjects as $subject) {
                     $classesUpdateArray[] = $subject->id;
                 }
                 $classesUpdateArray = json_encode($classesUpdateArray);
                 classes::where('id', $class->id)->update(array('classSubjects' => $classesUpdateArray));
                 unset($classesUpdateArray);
             }
             //create academic years
             $users = User::where('role', 'student')->get();
             foreach ($users as $user) {
                 $studentAcademicYears = new studentAcademicYears();
                 $studentAcademicYears->studentId = $user->id;
                 $studentAcademicYears->academicYearId = 1;
                 $studentAcademicYears->classId = $user->studentClass;
                 $studentAcademicYears->save();
             }
             DB::unprepared('ALTER TABLE `subject` CHANGE `teacherId` `teacherId` int(250)   NOT NULL after `subjectTitle` ,DROP COLUMN `classId` ;');
             $settings = settings::where('fieldName', 'thisVersion')->first();
             $settings->fieldValue = '2.0';
             $settings->save();
         }
     }
     if (Input::get('nextStep') == "3") {
         $this->data['currStep'] = "3";
         $settings = settings::where('fieldName', 'thisVersion')->first();
         $settings->fieldValue = '1.4';
         $settings->save();
     }
     return View::make('upgrade', $this->data);
 }
Exemplo n.º 3
0
 public function registerPost()
 {
     if (Input::get('role') == "") {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['mustSelAccType']));
         exit;
     }
     if (Input::get('username') == "") {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['mustSelUsername']));
         exit;
     }
     if (Input::get('password') == "") {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['mustTypePwd']));
         exit;
     }
     if (Input::get('fullName') == "") {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['mustTypeFullName']));
         exit;
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) and Input::get('email') != "") {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['invEmailAdd']));
         exit;
     }
     if (User::where('username', trim(Input::get('username')))->count() > 0) {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['usernameUsed']));
         exit;
     }
     if (User::where('email', Input::get('email'))->count() > 0) {
         return json_encode(array("jsTitle" => $this->panelInit->language['registerAcc'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['mailUsed']));
         exit;
     }
     $user = new User();
     $user->username = Input::get('username');
     if (Input::get('email') == "") {
         $user->email = "";
     } else {
         $user->email = Input::get('email');
     }
     $user->password = Hash::make(Input::get('password'));
     $user->fullName = Input::get('fullName');
     $user->role = Input::get('role');
     $user->activated = 0;
     $user->studentRollId = Input::get('studentRollId');
     if (Input::get('birthday') != "") {
         $birthday = explode("/", Input::get('birthday'));
         $birthday = mktime(0, 0, 0, $birthday['0'], $birthday['1'], $birthday['2']);
         $user->birthday = $birthday;
     }
     $user->gender = Input::get('gender');
     $user->address = Input::get('address');
     $user->phoneNo = Input::get('phoneNo');
     $user->mobileNo = Input::get('mobileNo');
     if (Input::get('studentClass') != "") {
         $user->studentAcademicYear = $this->panelInit->selectAcYear;
         $user->studentClass = Input::get('studentClass');
     }
     $user->parentProfession = Input::get('parentProfession');
     if (Input::get('studentInfo') != "") {
         $user->parentOf = json_encode(Input::get('studentInfo'));
     }
     $user->save();
     $studentAcademicYears = new studentAcademicYears();
     $studentAcademicYears->studentId = $user->id;
     $studentAcademicYears->academicYearId = $this->panelInit->selectAcYear;
     $studentAcademicYears->classId = Input::get('studentClass');
     $studentAcademicYears->save();
     $array = array("id" => $user->id);
     return $array;
     exit;
 }
Exemplo n.º 4
0
 function edit($id)
 {
     if ($this->data['users']->role != "admin") {
         exit;
     }
     if (User::where('username', trim(Input::get('username')))->where('id', '<>', $id)->count() > 0) {
         return $this->panelInit->apiOutput(false, $this->panelInit->language['editStudent'], $this->panelInit->language['usernameUsed']);
     }
     if (User::where('email', Input::get('email'))->where('id', '<>', $id)->count() > 0) {
         return $this->panelInit->apiOutput(false, $this->panelInit->language['editStudent'], $this->panelInit->language['mailUsed']);
     }
     $User = User::find($id);
     $User->email = Input::get('email');
     $User->username = Input::get('username');
     $User->fullName = Input::get('fullName');
     if (Input::get('password') != "") {
         $User->password = Hash::make(Input::get('password'));
     }
     $User->studentRollId = Input::get('studentRollId');
     $User->gender = Input::get('gender');
     $User->address = Input::get('address');
     $User->phoneNo = Input::get('phoneNo');
     $User->mobileNo = Input::get('mobileNo');
     $User->studentClass = Input::get('studentClass');
     $User->transport = Input::get('transport');
     if (Input::get('birthday') != "") {
         $birthday = explode("/", Input::get('birthday'));
         $birthday = mktime(0, 0, 0, $birthday['0'], $birthday['1'], $birthday['2']);
         $User->birthday = $birthday;
     }
     if (Input::hasFile('photo')) {
         $fileInstance = Input::file('photo');
         $newFileName = "profile_" . $User->id . ".jpg";
         $file = $fileInstance->move('uploads/profile/', $newFileName);
         $User->photo = "profile_" . $User->id . ".jpg";
     }
     $User->save();
     if (input::has('academicYear')) {
         $studentAcademicYears = input::get('academicYear');
         $academicYear = studentAcademicYears::where('studentId', $id)->get();
         foreach ($academicYear as $value) {
             if (isset($studentAcademicYears[$value->academicYearId]) and $studentAcademicYears[$value->academicYearId] != $value->classId) {
                 $studentAcademicYearsUpdate = studentAcademicYears::where('studentId', $User->id)->where('academicYearId', $value->academicYearId)->first();
                 $studentAcademicYearsUpdate->classId = $studentAcademicYears[$value->academicYearId];
                 $studentAcademicYearsUpdate->save();
                 attendance::where('classId', $value->classId)->where('studentId', $User->id)->update(['classId' => $studentAcademicYears[$value->academicYearId]]);
                 examMarks::where('classId', $value->classId)->where('studentId', $User->id)->update(['classId' => $studentAcademicYears[$value->academicYearId]]);
                 if ($value->academicYearId == $User->studentAcademicYear) {
                     $User->studentClass = $studentAcademicYears[$value->academicYearId];
                     $User->save();
                 }
             }
         }
     }
     return $this->panelInit->apiOutput(true, $this->panelInit->language['editStudent'], $this->panelInit->language['studentModified'], $User->toArray());
 }