public function save($title) { if ($title == "siteSettings") { $settingsData = Input::All(); while (list($key, $value) = each($settingsData)) { $settings = settings::where('fieldName', $key)->first(); if ($key == "activatedModules") { $settings->fieldValue = json_encode($value); } elseif ($key == "officialVacationDay") { $settings->fieldValue = json_encode($value); } elseif ($key == "daysWeekOff") { $settings->fieldValue = json_encode($value); } elseif ($key == "smsProvider") { $settings->fieldValue = json_encode($value); } elseif ($key == "mailProvider") { $settings->fieldValue = json_encode($value); } else { $settings->fieldValue = $value; } $settings->save(); } return $this->panelInit->apiOutput(true, $this->panelInit->language['editSettings'], $this->panelInit->language['settSaved']); } if ($title == "terms") { $settings = settings::where('fieldName', 'schoolTerms')->first(); $settings->fieldValue = htmlspecialchars(Input::get('fieldValue'), ENT_QUOTES); $settings->save(); return $this->panelInit->apiOutput(true, $this->panelInit->language['editSettings'], $this->panelInit->language['settSaved']); } }
public function proceed() { if (Input::get('nextStep') == "1") { $this->data['currStep'] = "1"; $this->data['nextStep'] = "2"; try { DB::connection()->getDatabaseName(); } catch (Exception $e) { $this->data['dbError'] = $e->getMessage(); $this->data['nextStep'] = "1"; } $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"; } if (Input::get('nextStep') == "3") { $this->data['currStep'] = "3"; $this->data['nextStep'] = "4"; if (Input::get('fullName') == "" || Input::get('username') == "" || Input::get('email') == "" || Input::get('password') == "" || Input::get('siteTitle') == "" || Input::get('systemEmail') == "") { $this->data['installErrors'][] = "Please fill in all required fields"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } if (Input::get('password') != Input::get('repassword')) { $this->data['installErrors'][] = "Password & repassword isn't identical"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) and Input::get('email') != "") { $this->data['installErrors'][] = "invalid e-mail address"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } if (Input::get('cpc') == "") { $this->data['installErrors'][] = "Purchase code is missing"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } if (Input::get('yearTitle') == "") { $this->data['installErrors'][] = "You must type default academic year"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } if (!isset($this->data['installErrors'])) { 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"; $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; } } if (!isset($this->data['installErrors'])) { $check = Schema::hasTable('users'); if (!$check) { DB::unprepared(file_get_contents('app/storage/dbsql')); } $User = new User(); $User->username = Input::get('username'); $User->email = Input::get('email'); $User->fullName = Input::get('fullName'); $User->password = Hash::make(Input::get('password')); $User->role = "admin"; $User->save(); $settings = settings::where('fieldName', 'siteTitle')->first(); $settings->fieldValue = Input::get('siteTitle'); $settings->save(); $settings = settings::where('fieldName', 'systemEmail')->first(); $settings->fieldValue = Input::get('systemEmail'); $settings->save(); $settings = new settings(); $settings->fieldName = 'finishInstall'; $settings->fieldValue = '1'; $settings->save(); $academicYear = new academicYear(); $academicYear->yearTitle = Input::get('yearTitle'); $academicYear->isDefault = "1"; $academicYear->save(); } } return View::make('install', $this->data); }
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); }
public function __construct() { $this->panelItems = array("dashboard" => array("title" => "dashboard", "icon" => "fa fa-dashboard", "url" => URL::to('#'), "permissions" => array('admin', 'teacher', 'student', 'parent')), "staticContent" => array("title" => "staticPages", "icon" => "fa fa-file-text", "activated" => "staticpagesAct", "url" => "", "permissions" => array('admin', 'teacher', 'student', 'parent'), "children" => array("controlStatic" => array("title" => "controlPages", "url" => URL::to('#static'), "icon" => "fa fa-cog", "permissions" => array('admin')))), "messages" => array("title" => "Messages", "url" => URL::to('#messages'), "icon" => "fa fa-envelope", "permissions" => array('admin', 'teacher', 'student', 'parent')), "calender" => array("title" => "Calender", "url" => URL::to('#calender'), "icon" => "fa fa-calendar", "permissions" => array('admin', 'teacher', 'student', 'parent')), "classSchedule" => array("title" => "classSch", "url" => URL::to('#classschedule'), "icon" => "fa fa-list", "permissions" => array('admin', 'teacher', 'student', 'parent')), "attendance" => array("title" => "Attendance", "url" => "", "icon" => "fa fa-bar-chart", "activated" => "attendanceAct", "permissions" => array('admin', 'teacher'), "children" => array("controlAttendance" => array("title" => "Attendance", "url" => URL::to('#attendance'), "icon" => "fa fa-check", "permissions" => array('admin', 'teacher')), "statsAttendance" => array("title" => "attendanceStats", "url" => URL::to('#attendanceStats'), "icon" => "fa fa-bar-chart", "permissions" => array('admin', 'teacher')))), "vacation" => array("title" => "Vacation", "url" => URL::to('#vacation'), "icon" => "fa fa-coffee", "activated" => "vacationAct", "permissions" => array('teacher', 'student')), "myAttendance" => array("title" => "Attendance", "url" => URL::to('#attendanceStats'), "icon" => "fa fa-bar-chart", "activated" => "attendanceAct", "permissions" => array('student', 'parent')), "staffAttendance" => array("title" => "staffAttendance", "url" => URL::to('#staffAttendance'), "icon" => "fa fa-check", "activated" => "staffAttendanceAct", "permissions" => array('admin')), "library" => array("title" => "Library", "url" => URL::to('#library'), "icon" => "fa fa-folder-open", "activated" => "bookslibraryAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "media" => array("title" => "mediaCenter", "url" => URL::to('#media'), "icon" => "fa fa-video-camera", "activated" => "mediaAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "teachers" => array("title" => "teachers", "url" => URL::to('#teachers'), "icon" => "fa fa-suitcase", "permissions" => array('admin')), "students" => array("title" => "students", "url" => URL::to('#students'), "icon" => "fa fa-users", "permissions" => array('admin', 'teacher', 'parent')), "parents" => array("title" => "parents", "url" => URL::to('#parents'), "icon" => "fa fa-user", "permissions" => array('admin')), "gradelevels" => array("title" => "gradeLevels", "url" => URL::to('#gradeLevels'), "icon" => "fa fa-check-square-o", "permissions" => array('admin')), "materials" => array("title" => "studyMaterial", "url" => URL::to('#materials'), "icon" => "fa fa-book", "activated" => "materialsAct", "permissions" => array('admin', 'teacher', 'student')), "assignments" => array("title" => "Assignments", "url" => URL::to('#assignments'), "icon" => "fa fa-file-pdf-o", "activated" => "assignmentsAct", "permissions" => array('admin', 'teacher', 'student')), "examslist" => array("title" => "examsList", "url" => URL::to('#examsList'), "icon" => "fa fa-graduation-cap", "permissions" => array('admin', 'teacher', 'student', 'parent')), "onlineexams" => array("title" => "onlineExams", "url" => URL::to('#onlineExams'), "icon" => "fa fa-graduation-cap", "activated" => "onlineexamsAct", "permissions" => array('admin', 'teacher', 'student')), "newsboard" => array("title" => "newsboard", "url" => URL::to('#newsboard'), "icon" => "fa fa-bullhorn", "activated" => "newsboardAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "events" => array("title" => "events", "url" => URL::to('#events'), "icon" => "fa fa-clock-o", "activated" => "eventsAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "controlPayments" => array("title" => "Payments", "url" => URL::to('#payments'), "icon" => "fa fa-money", "activated" => "paymentsAct", "permissions" => array('admin', 'student', 'parent')), "transportations" => array("title" => "Transportation", "url" => URL::to('#transports'), "icon" => "fa fa-bus", "activated" => "transportAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "classes" => array("title" => "classes", "url" => URL::to('#classes'), "icon" => "fa fa-sitemap", "permissions" => array('admin')), "subjects" => array("title" => "Subjects", "url" => URL::to('#subjects'), "icon" => "fa fa-book", "permissions" => array('admin')), "reports" => array("title" => "Reports", "url" => URL::to('#reports'), "icon" => "fa fa-pie-chart", "activated" => "reportsAct", "permissions" => array('admin')), "adminTasks" => array("title" => "adminTasks", "url" => "", "icon" => "fa fa-cog", "permissions" => array('admin'), "children" => array("permissions" => array("title" => "permissions", "url" => URL::to('#permissions'), "icon" => "fa fa-male", "permissions" => array('admin')), "academicyear" => array("title" => "academicyears", "url" => URL::to('#academicYear'), "icon" => "fa fa-calendar-check-o", "permissions" => array('admin')), "promotion" => array("title" => "Promotion", "url" => URL::to('#promotion'), "icon" => "fa fa-arrow-up", "permissions" => array('admin')), "mailsms" => array("title" => "mailsms", "url" => URL::to('#mailsms'), "icon" => "fa fa-send", "permissions" => array('admin')), "mailsmsTemplates" => array("title" => "mailsmsTemplates", "url" => URL::to('#mailsmsTemplates'), "icon" => "fa fa-envelope-o", "permissions" => array('admin')), "polls" => array("title" => "Polls", "url" => URL::to('#polls'), "icon" => "fa fa-tasks", "activated" => "pollsAct", "permissions" => array('admin')), "dormitories" => array("title" => "Dormitories", "url" => URL::to('#dormitories'), "icon" => "fa fa-building-o", "permissions" => array('admin')), "siteSettings" => array("title" => "generalSettings", "url" => URL::to('#settings'), "icon" => "fa fa-cog", "permissions" => array('admin')), "languages" => array("title" => "Languages", "url" => URL::to('#languages'), "icon" => "fa fa-font", "permissions" => array('admin')), "admins" => array("title" => "Administrators", "url" => URL::to('#admins'), "icon" => "fa fa-gears", "permissions" => array('admin')), "terms" => array("title" => "schoolTerms", "url" => URL::to('#terms'), "icon" => "fa fa-file-text-o", "permissions" => array('admin'))))); $settings = settings::get(); foreach ($settings as $setting) { $this->settingsArray[$setting->fieldName] = $setting->fieldValue; } if ($this->settingsArray['lastUpdateCheck'] + 86400 < time()) { $sb = $this->sbApi(); if ($sb == "err") { exit; } $latestUpdate = @file_get_contents("http://cr-house.com/apps/schoex/latest"); $latestUpdate = @json_decode($latestUpdate, true); $settings = settings::where('fieldName', 'lastUpdateCheck')->first(); $settings->fieldValue = time(); $settings->save(); if (is_array($latestUpdate)) { $settings = settings::where('fieldName', 'latestVersion')->first(); $settings->fieldValue = $latestUpdate['v']; $settings->save(); } } $staticPages = staticPages::where('pageActive', '1')->get(); foreach ($staticPages as $pages) { $this->panelItems['staticContent']['children'][md5(uniqid())] = array("title" => $pages->pageTitle, "url" => URL::to('#static') . "/" . $pages->id, "icon" => "fa fa-file-text", "permissions" => array('admin', 'teacher', 'student', 'parent')); } //Languages $defLang = $defLang_ = $this->settingsArray['languageDef']; if (isset($this->settingsArray['languageAllow']) and $this->settingsArray['languageAllow'] == "1" and !Auth::guest() and \Auth::user()->defLang != 0) { $defLang = \Auth::user()->defLang; } //Theme $this->defTheme = $this->settingsArray['layoutColor']; if (isset($this->settingsArray['layoutColorUserChange']) and $this->settingsArray['layoutColorUserChange'] == "1" and !Auth::guest() and \Auth::user()->defTheme != "") { $this->defTheme = \Auth::user()->defTheme; } $language = languages::whereIn('id', array($defLang, 1))->get(); if (count($language) == 0) { $language = languages::whereIn('id', array($defLang_, 1))->get(); } foreach ($language as $value) { if ($value->id == 1) { $this->language = json_decode($value->languagePhrases, true); } else { $this->isRTL = $value->isRTL; $phrases = json_decode($value->languagePhrases, true); while (list($key, $value) = each($phrases)) { $this->language[$key] = $value; } } } //Selected academicYear if (Session::has('selectAcYear')) { $this->selectAcYear = Session::get('selectAcYear'); } else { $currentAcademicYear = academicYear::where('isDefault', '1')->first(); $this->selectAcYear = $currentAcademicYear->id; Session::put('selectAcYear', $this->selectAcYear); } $this->baseURL = Request::url('index.php'); if (strpos($this->baseURL, 'index.php') == false) { $this->baseURL = URL::to('index.php'); } }
public function settingsSave() { if (Input::get('mailProvider')) { $settings = settings::where('fieldName', 'mailProvider')->first(); $settings->fieldValue = json_encode(Input::all()); $settings->save(); } else { $settings = settings::where('fieldName', 'smsProvider')->first(); $settings->fieldValue = json_encode(Input::all()); $settings->save(); } return $this->panelInit->apiOutput(true, $this->panelInit->language['saveSettings'], $this->panelInit->language['settSaved']); }
public function terms() { $settings = settings::where('fieldName', 'schoolTerms')->first()->toArray(); $this->data['terms'] = htmlspecialchars_decode($settings['fieldValue'], ENT_QUOTES); return View::make('terms', $this->data); }
public function settings_param() { $key_id = Input::get('data.key_id'); $data_key1 = Input::get('data.data_key'); $data_key2 = Input::get('data.country_id'); //is_null return true if variable holds null value //isset returns true if variable holds any value. FOR NULL it returns false //If NO $key_id pass from front end then api will return data based on $data_key if (!isset($key_id)) { null; } else { $searchmap['key_id'] = $key_id; } if (!empty($data_key1) && !is_null($data_key1)) { $searchmap['data_key'] = $data_key1; } if (!empty($data_key2) && !is_null($data_key2)) { $searchmap['country_id'] = $data_key2; } $mysettings = settings::where($searchmap)->get(); return $mysettings; }