function delSubject($id) { $su = new Subject(); $condition = '`id`=' . $id; $r = $su->subject_delete($condition); header('Location:' . $_SERVER['HTTP_REFERER']); }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); MMapManager::checkSessionExpiration(); $username = $request->issetPOST('username') ? $request->getPOST('username') : ''; $password = $request->issetPOST('password') ? $request->getPOST('password') : ''; $loginPage = $request->issetPOST('loginPage') ? $request->getPOST('loginPage') : ''; $subject = new Subject(); $loginContext = new LoginContext('eyeos-login', $subject); $cred = new EyeosPasswordCredential(); $cred->setUsername($username); $cred->setPassword($password, true); $subject->getPrivateCredentials()->append($cred); try { $loginContext->login(); $memoryManager = MemoryManager::getInstance(); Kernel::enterSystemMode(); $memoryManager->set('isExternLogin', 1); $memoryManager->set('username', $username); $memoryManager->set('password', $password); $memoryManager->set('loginPage', $loginPage); Kernel::exitSystemMode(); header("Location: index.php"); } catch (Exception $e) { header("Location:" . $loginPage . "?errorLogin=1"); } }
/** * 录入 * */ public function actionCreate() { parent::_acl('subject_create'); $model = new Subject(); $imageList = $this->_gets->getPost('imageList'); $layoutList = $this->_gets->getPost('layoutList'); $imageListSerialize = XUtils::imageListSerialize($imageList); $layoutListSerialize = XUtils::imageListSerialize($layoutList); if (isset($_POST['Subject'])) { $file = XUpload::upload($_FILES['attach']); $model->attributes = $_POST['Subject']; $model->date = strtotime($_POST['Subject']['date']); if (is_array($file)) { $model->room_type_image = $file['pathname']; } $model->image_list = $imageListSerialize['dataSerialize']; $model->layout_list = $layoutListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入项目,ID:' . $model->id)); $this->redirect(array('index')); } } $this->city_list = parent::_groupList('city'); $this->render('create', array('model' => $model, 'imageList' => $imageListSerialize['data'], 'layoutList' => $layoutListSerialize['data'])); }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); DB::table('propel_fellow_wingman')->delete(); DB::table('propel_student_wingman')->delete(); Subject::truncate(); DB::table('propel_city_subject')->delete(); CalendarEvent::truncate(); CancelledCalendarEvent::truncate(); WingmanModule::truncate(); WingmanTime::truncate(); VolunteerTime::truncate(); WingmanJournal::truncate(); $fellow = Fellow::find(1); $wingman1 = Wingman::find(2); $wingman2 = Wingman::find(3); $fellow->wingman()->attach($wingman1); $fellow->wingman()->attach($wingman2); $student1 = Student::find(3); $student2 = Student::find(4); $wingman1->student()->attach($student1); $wingman1->student()->attach($student2); $cEvent1 = new CalendarEvent(); $cEvent1->type = 'volunteer_time'; $cEvent1->student()->associate($student1); $cEvent1->status = 'created'; $cEvent1->save(); $vTime1 = new VolunteerTime(); $vTime1->calendarEvent()->associate($cEvent1); $volunteer1 = Volunteer::find(4); $vTime1->volunteer()->associate($volunteer1); $subject1 = new Subject(); $subject1->name = "English"; $subject1->save(); $vTime1->subject()->associate($subject1); $vTime1->save(); $cEvent2 = new CalendarEvent(); $cEvent2->type = 'wingman_time'; $cEvent2->student()->associate($student1); $cEvent2->status = 'created'; $cEvent2->save(); $wTime1 = new WingmanTime(); $wTime1->calendarEvent()->associate($cEvent2); $wTime1->wingman()->associate($wingman1); $wModule1 = new WingmanModule(); $wModule1->name = "Programming"; $wModule1->save(); $wTime1->wingmanModule()->associate($wModule1); $wTime1->save(); $city1 = City::find(1); $subject1->city()->attach($city1); $wJournal1 = new WingmanJournal(); $wJournal1->type = 'formal'; $wJournal1->title = "Day at Navy Camp"; $wJournal1->mom = "It was awesome"; $wJournal1->student()->associate($student1); $wJournal1->wingman()->associate($wingman1); $wJournal1->save(); }
/** * @inheritdoc */ public function update(Subject $subject) { if ($subject->getState() == 'logged in') { $this->sendUserHasLoggedInMail(); } else { $this->sendUserHasLoggedOutMail(); } }
public function get_names() { $temp_subject = new Subject(); $temp_subject->load($this->subject_id_1); $this->subject_1_name = $temp_subject->print_name(); $temp_subject->load($this->subject_id_2); $this->subject_2_name = $temp_subject->print_name(); }
/** * Сурогат говорит * * @return string */ public function send() { // Подключать реальный объект можно и в контролере. // Или агригировать его на этапе создания суррогата. // Все зависит от конечных целей. if ($this->realSubject == null) { $this->realSubject = new RealSubject(); } return "<strong>" . $this->realSubject->send() . "</strong>"; }
public function processRequest(MMapRequest $request, MMapResponse $response) { $oauth_verifier = null; $oauth_token = null; if ($request->issetGET('oauth_verifier')) { $oauth_verifier = $request->getGET('oauth_verifier'); } if ($request->issetGET('oauth_token')) { $oauth_token = $request->getGET('oauth_token'); } if ($oauth_verifier && $oauth_token) { $response->getHeaders()->append('Content-type: text/html'); $body = '<html> <div id="logo_eyeos" style="margin: 0 auto;width:350"> <img src="eyeos/extern/images/logo-eyeos.jpg"/></div> <div style="margin: 0 auto;width:350;text-align:center"><span style="font-family:Verdana;font-size:20px;">Successful authentication.<br>Back to Eyeos.</span></div> </html>'; $response->getHeaders()->append('Content-Length: ' . strlen($body)); $response->getHeaders()->append('Accept-Ranges: bytes'); $response->getHeaders()->append('X-Pad: avoid browser bug'); $response->getHeaders()->append('Cache-Control: '); $response->getHeaders()->append('pragma: '); $response->setBody($body); try { $userRoot = UMManager::getInstance()->getUserByName('root'); } catch (EyeNoSuchUserException $e) { throw new EyeFailedLoginException('Unknown user root"' . '". Cannot proceed to login.', 0, $e); } $subject = new Subject(); $loginContext = new LoginContext('eyeos-login', $subject); $cred = new EyeosPasswordCredential(); $cred->setUsername('root'); $cred->setPassword($userRoot->getPassword(), false); $subject->getPrivateCredentials()->append($cred); $loginContext->login(); Kernel::enterSystemMode(); $appProcess = new Process('stacksync'); $appProcess->setPid('31338'); $mem = MemoryManager::getInstance(); $processTable = $mem->get('processTable', array()); $processTable[31338] = $appProcess; $mem->set('processTable', $processTable); $appProcess->setLoginContext($loginContext); ProcManager::getInstance()->setCurrentProcess($appProcess); kernel::exitSystemMode(); $token = new stdClass(); $token->oauth_verifier = $oauth_verifier; $token->oauth_token = $oauth_token; $group = UMManager::getInstance()->getGroupByName('users'); $users = UMManager::getInstance()->getAllUsersFromGroup($group); foreach ($users as $user) { $NetSyncMessage = new NetSyncMessage('cloud', 'token', $user->getId(), $token); NetSyncController::getInstance()->send($NetSyncMessage); } } }
public function update(Subject $subject) { //doing action when user is logged if ($subject->getState() == 'logged in') { $this->logUserHasLoggedIn(); } else { if ($subject->getState() == 'logged out') { $this->logUserHasLoggedOut(); } } }
public function match(Subject $subject) { $em = $this->getEntityManager(); $query = $em->createQuery('Select IDENTITY(s.user) From SubwayBuddyUserBundle:Subject s WHERE s.subject = ?1 AND s.user != ?2'); $query->setParameter(1, $subject->getSubject()); $query->setParameter(2, $subject->getUser()); return $query->getResult(); }
public function save() { $subjectId = $this->getValue('subjectId'); if (!empty($subjectId)) { $subject = $this->getSubjectService()->getSubjectById($subjectId); } else { $subject = new Subject(); } $subject->setCode($this->getValue('code')); $subject->setName($this->getValue('name')); $subject->save(); }
/** * @group fakeobject */ public function testUpdateIsCalledOnce() { // 建立一個 Observer 的 Mock Object $observer = $this->getMock('Observer'); // 預期 Observer::update 方法應該只跑一次 // 而傳入 update 方法的參數值為 something $observer->expects($this->once())->method('update')->with($this->equalTo('something')); $subject = new Subject(); $subject->attach($observer); // 我們預測這裡會呼叫 Observer::update() 一次 $subject->doSomething(); }
/** * Test the evaluation of all policies when no policy name is given */ public function testAllPolicyEvaluateAllAny() { $set = PolicySet::instance()->add('policy1', Policy::instance()->hasUsername('ccornutt')); $user = (object) ['username' => 'ccornutt']; $subject = new Subject($user); $subject->setAuth(true); $context = new Context(['policies' => $set]); $gateway = new Gateway($subject, $context); // Evaluate the result of the policy above, true because they're: // 1. set correctly, 2. policy passes $result = $gateway->evaluate(); $this->assertTrue($result); }
public function testLogin() { $subject = new Subject(); $sharedState = new ArrayList(); $options = array(); /**** wrong password ****/ $cred = new EyeosPasswordCredential(); $cred->setUsername('userLogin0'); $cred->setPassword('wrongPass', true); $subject->getPrivateCredentials()->append($cred); $this->fixture->initialize($subject, $sharedState, $options); try { $this->fixture->login(); $this->fail(); } catch (EyeLoginException $e) { // normal situation } $this->assertEquals(1, $subject->getPrivateCredentials()->count()); $subject->getPrivateCredentials()->remove($cred); $this->assertEquals(0, $subject->getPrivateCredentials()->count()); /**** nonexisting user ****/ $cred = new EyeosPasswordCredential(); $cred->setUsername('john'); $cred->setPassword('userPassword0', true); $subject->getPrivateCredentials()->append($cred); $this->fixture->initialize($subject, $sharedState, $options); try { $this->fixture->login(); $this->fail(); } catch (EyeLoginException $e) { // normal situation } $this->assertEquals(1, $subject->getPrivateCredentials()->count()); $subject->getPrivateCredentials()->remove($cred); $this->assertEquals(0, $subject->getPrivateCredentials()->count()); /**** no password credential ****/ $this->fixture->initialize($subject, $sharedState, $options); try { $this->fixture->login(); $this->fail(); } catch (EyeLoginException $e) { // normal situation } /**** good login/pass ****/ $cred = new EyeosPasswordCredential(); $cred->setUsername('userLogin0'); $cred->setPassword('userPassword0', true); $subject->getPrivateCredentials()->append($cred); $this->fixture->initialize($subject, $sharedState, $options); $this->assertTrue($this->fixture->login()); }
public static function format($data) { $uids = $sids = []; $users = $subjects = []; foreach ($data as $d) { $uids[] = $d->userid; $sids[] = $d->subject_id; } $uids = array_unique($uids); $ret = \User::find([['userid' => ['$in' => $uids]]]); foreach ($ret as $u) { $users[$u->userid] = $u->attrs(); } $sids = array_unique($sids); $ret = \Subject::find([['id' => ['$in' => $sids]]]); foreach ($ret as $s) { $subjects[$s->id] = $s->attrs(); } $ret = []; foreach ($data as $d) { $ret[] = ['id' => $d->id, 'saying' => $d->saying, 'imgs' => $d->imgs, 'author' => $users[$d->userid], 'subject' => $subjects[$d->subject_id], 'created_at' => $d->created_at]; } return $ret; print_r($users); print_r($subjects); print_r($uids); print_r($sids); return []; }
public function enrollSection() { $sectionCode = SectionCode::where('code', Input::get('code'))->first(); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); $message = ""; if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $codes = SectionCode::where('code', Input::get('code'))->whereIn('students_id', array(Auth::id()))->first(); if (!isset($codes->_id)) { $pending = new PendingEnrollment(); $pending->section_code_id = new MongoId($sectionCode->_id); $pending->student_id = Auth::id(); $pending->teacher_id = new MongoId($sectionCode->teacher_id); try { $pending->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.enroll_pending'))); } return Redirect::to(Lang::get('routes.enroll_section'))->with('message', Lang::get('register_group.enroll_sucess')); } else { $message = Lang::get('register_group.user_register'); } } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
/** * @param $turn * @return string */ function NextTurn($turn) { $time = date('Y-m-d h:i:s: '); $result = "Ход {$turn}: " . $this->subject->NextTurn(); file_put_contents('game_log.txt', $time . $result . PHP_EOL, FILE_APPEND); return $result; }
public function actionMore() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css'); $city_id = Yii::app()->request->getQuery('city', 0); $time_sort = Yii::app()->request->getQuery('time_sort', 'DESC'); $price_sort = Yii::app()->request->getQuery('lp_dol'); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; if (!empty($city_id)) { $criteria->addCondition('city_id=' . $city_id); } if (!empty($time_sort)) { $criteria->order = 'accessDate ' . $time_sort; } if (!empty($price_sort)) { $criteria->order = 'lp_dol ' . $price_sort; } $criteria->addCondition('lp_dol>3000000'); $count = House::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $house_list = House::model()->findAll($criteria); $subject_list = Subject::model()->findAll(array('order' => 'id DESC')); $cur_city = City::model()->findByPk($city_id); $data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager); $this->render('more', $data); }
public function showDashboard() { $data = []; $loginid = Session::get('user')->id; $collegeid = Session::get('user')->collegeid; $flag = Session::get('user')->flag; $tb = ""; if ($flag == 1) { $tb = "Admin"; } else { if ($flag == 2) { $tb = "Teacher"; } else { if ($flag == 3) { $tb = "Student"; } else { $tb = "Staff"; } } } $dt = $tb::where('loginid', '=', $loginid)->first(); $data['name'] = $dt->name; $data['pic'] = $dt->profilepic; $data['id'] = $loginid; //Cards value $data['students'] = Student::where('collegeid', '=', $collegeid)->count(); $data['teachers'] = Teacher::where('collegeid', '=', $collegeid)->count(); $data['subjects'] = Subject::where('collegeid', '=', $collegeid)->count(); $data['parents'] = $data['students'] * 2; return View::make('pages.dashboard', array('data' => $data, 'flag' => $flag)); }
public function actionTeacher() { if (isset($_GET["id"])) { $id = StringHelper::filterString($_GET["id"]); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "teacher_id = :teacher_id"; $spCriteria->params = array(':teacher_id' => $id); $teacher_current_id = Teacher::model()->findAll($spCriteria); $subject_teacher = Subject::model()->with(array('subject_teacher' => array('select' => false, 'condition' => 'teacher_id = :teacher_id', 'params' => array(':teacher_id' => $id))))->findAll(); $ratingCriteria = new CDbCriteria(); $ratingCriteria->select = "*"; $ratingCriteria->condition = "teacher_id = :teacher_id"; $ratingCriteria->params = array(":teacher_id" => $id); $rating = Votes::model()->findAll($ratingCriteria); $count = count($rating); if ($teacher_current_id) { foreach ($teacher_current_id as $detail) { $title = $detail->teacher_acadamic_title . " " . $detail->teacher_name . "| Bluebee - UET"; $image = $detail->teacher_avatar; $des = $detail->teacher_description; $this->pageTitle = $title; Yii::app()->clientScript->registerLinkTag("image_src", "image/jpeg", $image); Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image')); Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description')); } $this->render('teacher', array('teacher_detail_info' => Teacher::model()->findAll($spCriteria), 'subject_teacher' => $subject_teacher, 'countVote' => $count)); } } }
public function addSectionCode() { $section_code = new SectionCode(); $teacher = Teacher::find(Auth::Id()); $subject_id = Input::get('subject'); $section_id = Input::get('section'); $current_period = Input::get('current_period'); $section_code->teacher_id = new MongoId($teacher->_id); $section_code->subject_id = new MongoId($subject_id); $section_code->section_id = new MongoId($section_id); $section_code->current_period = $current_period; $section_code->teamleaders_id = array(); $section_code->students_id = array(); $section_code->status = true; $subject = Subject::find($subject_id); $section = $subject->sections()->find($section_id); $code = $this->getInitialLetters($subject->name) . '-' . $section->code . '-' . $current_period; $section_code->code = $code; if (!is_null($section->current_code)) { $sectionCode = SectionCode::where('code', $section->current_code)->first(); if (isset($sectionCode->_id)) { $sectionCode->status = false; $sectionCode->save(); } } try { $section_code->save(); $section->current_code = $code; $section->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('section_codes.duplicate_code'))); } return Redirect::to(Lang::get('routes.section_codes'))->with(array('message' => Lang::get('section_codes.success_message'))); }
public function addGroup() { $sectionCode = SectionCode::find(new MongoId(Input::get('section'))); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $group = new Group(); $group->name = trim(ucfirst(Input::get('name'))); $group->teamleader_id = Auth::id(); $group->section_code_id = new MongoId($sectionCode->_id); $group->students_id = array(Auth::id()); $group->project_name = trim(strtolower(Input::get('project_name'))); $message = ""; if (Input::hasFile('avatar_file')) { $data = Input::get('avatar_data'); $image = new CropImage(null, $data, $_FILES['avatar_file']); $group->logo = $image->getURL(); } else { $group->logo = null; } try { $group->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.duplicated'))); } return Redirect::to(Lang::get('routes.add_group'))->with('message', Lang::get('register_group.success')); } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
/** * Display a listing of the resource. * * @return Response */ public function index($classId, $subjectId) { $user = \Auth::user(); $term = 'First Term'; if ($_GET['class']) { $this->class = $_GET['class']; $this->subject = $_GET['subject']; \Session::put('class', $_GET['class']); \Session::put('subject', $_GET['subject']); } $classe_id = Classe::where('name', $classId)->first()->id; $subject_id = Subject::where('name', $this->subject)->first()->id; $classeName = Classe::where('name', $this->class)->first()->name; $subjectName = Subject::where('name', $this->subject)->first()->name; //dd($classe_id); $count = 1; $questions = Question::where('classe_id', $classId)->where('subject_id', $subjectId)->orderBy(\DB::raw('RAND()'))->get(); $totals = Question::where('classe_id', $classId)->where('subject_id', $subjectId)->paginate(1); $checked_items = []; if (\Session::has('checked_items')) { $checked_items = \Session::get('checked_items'); } // $checked_items = array_merge($checked_items, \Input::get('abc')); \Session::flash('checked_items', $checked_items); }
public function create($course_id) { $course = Course::with('placements')->find($course_id); $subjects = Subject::all(); $menu = 'academic'; return View::make('masteries.create', compact('course', 'subjects', 'menu')); }
public function actionViewDocument() { if (isset($_GET['doc_id'])) { $doc_id = StringHelper::filterString($_GET['doc_id']); $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id))); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "doc_id = :doc_id"; $spCriteria->params = array(':doc_id' => $doc_id); $subject_doc = SubjectDoc::model()->find($spCriteria); $spjCriteria = new CDbCriteria(); $spjCriteria->select = "*"; $spjCriteria->condition = "subject_id = :subject_id"; $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id); $subject = Subject::model()->find($spjCriteria); $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()")); foreach ($detail_doc as $detail) { $title = $detail->doc_name . " | Bluebee - UET"; $this->pageTitle = $title; if ($detail->doc_type == 3) { $image = Yii::app()->getBaseUrl(true) . $detail->doc_url; } else { $image = $detail->doc_url; } $des = $detail->doc_description; Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height')); Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type')); Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description')); } $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject)); } }
/** * Displays the login page */ public function actionLogin($sh = '', $t = '') { $this->model = new LoginForm(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($this->model); Yii::app()->end(); } // collect user input data if (isset($_POST['LoginForm'])) { $this->model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid if ($this->model->validate() && $this->model->login()) { //Assign the subject to the new user if he/she registered after adding a subject if ($sh and $t) { //Allow asignment only within 15 minutes since subject added if (SiteLibrary::utc_time() - $t < 900) { Subject::model()->updateAll(array('user_id' => Yii::app()->user->id), 'time_submitted=:time_submitted AND hash=:hash', array(':time_submitted' => $t, ':hash' => $sh)); } $this->redirect(array('mysub/' . Yii::app()->user->name)); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('login', array('model' => $this->model)); }
public function register($attr, $image) { $check = User::model()->findByAttributes(array('email' => $attr['email'])); if ($check) { return 'USER_EXIST'; } else { $model = new User(); $model->setAttributes($attr); $model->password = md5($attr['password']); if ($model->save(FALSE)) { $image_url = NULL; if (isset($image)) { $image_url = $image; } $model->avatar = $image_url; $model->save(FALSE); $subjects = Subject::model()->findAll(); foreach ($subjects as $subject) { $user_subject = new UserSubject(); $user_subject->subject_id = $subject->subject_id; $user_subject->user_id = $model->userid; $user_subject->save(FALSE); } return 'SUCCESS'; } return 'SERVER_ERROR'; } }
public function run() { DB::table('subjects')->delete(); Subject::create(array('subjectcode' => 'SC6', 'grade' => '6', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA6', 'grade' => '6', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI6', 'grade' => '6', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN6', 'grade' => '6', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'GE6', 'grade' => '6', 'subjectname' => 'Geography')); Subject::create(array('subjectcode' => 'CI6', 'grade' => '6', 'subjectname' => 'Citizenship Education')); Subject::create(array('subjectcode' => 'TA6', 'grade' => '6', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI6', 'grade' => '6', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'HS6', 'grade' => '6', 'subjectname' => 'Health Science')); Subject::create(array('subjectcode' => 'SC7', 'grade' => '7', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA7', 'grade' => '7', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI7', 'grade' => '7', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN7', 'grade' => '7', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'GE7', 'grade' => '7', 'subjectname' => 'Geography')); Subject::create(array('subjectcode' => 'CI7', 'grade' => '7', 'subjectname' => 'Citizenship Education')); Subject::create(array('subjectcode' => 'TA7', 'grade' => '7', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI7', 'grade' => '7', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'HS7', 'grade' => '7', 'subjectname' => 'Health Science')); Subject::create(array('subjectcode' => 'SC8', 'grade' => '8', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA8', 'grade' => '8', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI8', 'grade' => '8', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN8', 'grade' => '8', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'GE8', 'grade' => '8', 'subjectname' => 'Geography')); Subject::create(array('subjectcode' => 'CI8', 'grade' => '8', 'subjectname' => 'Citizenship Education')); Subject::create(array('subjectcode' => 'TA8', 'grade' => '8', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI8', 'grade' => '8', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'HS8', 'grade' => '8', 'subjectname' => 'Health Science')); Subject::create(array('subjectcode' => 'SC9', 'grade' => '9', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA9', 'grade' => '9', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI9', 'grade' => '9', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN9', 'grade' => '9', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'GE9', 'grade' => '9', 'subjectname' => 'Geography')); Subject::create(array('subjectcode' => 'CI9', 'grade' => '9', 'subjectname' => 'Citizenship Education')); Subject::create(array('subjectcode' => 'TA9', 'grade' => '9', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI9', 'grade' => '9', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'HS9', 'grade' => '9', 'subjectname' => 'Health Science')); Subject::create(array('subjectcode' => 'SC10', 'grade' => '10', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA10', 'grade' => '10', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI10', 'grade' => '10', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN10', 'grade' => '10', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'TA10', 'grade' => '10', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI10', 'grade' => '10', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'SC11', 'grade' => '11', 'subjectname' => 'Science')); Subject::create(array('subjectcode' => 'MA11', 'grade' => '11', 'subjectname' => 'Maths')); Subject::create(array('subjectcode' => 'HI11', 'grade' => '11', 'subjectname' => 'History')); Subject::create(array('subjectcode' => 'EN11', 'grade' => '11', 'subjectname' => 'English')); Subject::create(array('subjectcode' => 'TA11', 'grade' => '11', 'subjectname' => 'Tamil')); Subject::create(array('subjectcode' => 'SI11', 'grade' => '11', 'subjectname' => 'Sinhala')); Subject::create(array('subjectcode' => 'CM12', 'grade' => '12', 'subjectname' => 'Combined Maths')); Subject::create(array('subjectcode' => 'C12', 'grade' => '12', 'subjectname' => 'Chemistry')); Subject::create(array('subjectcode' => 'P12', 'grade' => '12', 'subjectname' => 'Physics')); Subject::create(array('subjectcode' => 'B12', 'grade' => '12', 'subjectname' => 'Bio Science')); Subject::create(array('subjectcode' => 'ET12', 'grade' => '12', 'subjectname' => 'Engineering Technology')); Subject::create(array('subjectcode' => 'ST12', 'grade' => '12', 'subjectname' => 'Science For Technology')); Subject::create(array('subjectcode' => 'IT12', 'grade' => '12', 'subjectname' => 'Information Communication Technology')); }
public function searchSubject($subject_name) { $subCriteria = new CDbCriteria(); $subCriteria->select = "*"; $subCriteria->addSearchCondition('subject_name', $subject_name); $subject_result = Subject::model()->findAll($subCriteria); return $subject_result; }
function get_subjects($con, $args) { $subjects = array(); if (isset($args["sid"])) { $sid = $args["sid"]; $sql = $con->prepare("SELECT sname,`order` FROM subject WHERE sid=?"); $sql->bind_param("i", $sid); $sql->bind_result($sname, $order); $sql->execute(); $sql->fetch(); $sql->close(); if (isset($sname) && isset($order)) { $tmp = new Subject(); $tmp->populate($sid, $sname, [], $order); $subjects[] = $tmp->expose(); } } else { if (isset($args["sname"])) { $sname = $args["sname"]; $sql = $con->prepare("SELECT sid,`order` FROM subject WHERE sname=?"); $sql->bind_param("s", $sname); $sql->bind_result($sid, $order); $sql->execute(); $sql->fetch(); $sql->close(); if (isset($sid) && isset($order)) { $tmp = new Subject(); $tmp->populate($sid, $sname, [], $order); $subjects[] = $tmp->expose(); } } else { $sql = $con->prepare("SELECT sid,sname,`order` FROM subject ORDER BY `order` ASC"); $sql->bind_result($sid, $sname, $order); $sql->execute(); while ($sql->fetch()) { if (isset($sid) && isset($sname) && isset($order)) { $tmp = new Subject(); $tmp->populate($sid, $sname, [], $order); $subjects[] = $tmp->expose(); } } $sql->close(); } } return $subjects; }