public function getUniversityList() { // $u1[]='Select university'; // $u2[0]='Select university'; $u2 = Chtml::listData(University::model()->findAll(), 'uid', 'uname'); //$u=array_merge($u1,$u2); return $u2; }
public function actionSetSessionVar() { if (isset($_POST['uid'])) { $university = new University(); if (!is_numeric($_POST['uid'])) { $max_id = University::model()->find(array('order' => 'did DESC')); $university->name = $_POST['uid']; $university->did = $max_id->did + 1; $university->validate(); $university->save(); } else { $university->did = $_POST['uid']; } $_SESSION['uid'] = $university->did; } if (isset($_POST['did'])) { $degree = new Degree(); if (!is_numeric($_POST['did'])) { $max_id = Degree::model()->find(array('order' => 'did DESC')); $degree->name = $_POST['did']; $degree->did = $max_id->did + 1; $degree->university_id = $_SESSION['uid']; $degree->validate(); $degree->save(); } else { $degree->did = $_POST['did']; } $_SESSION['did'] = $degree->did; } }
/** * @var string the default layout for the views. Defaults to '//layouts/column2', meaning * using two-column layout. See 'protected/views/layouts/column2.php'. */ public function loadUniversity($uid) { if ($this->_university === null) { $this->_university = University::model()->findbyPk($uid); if ($this->_university === null) { throw new CHttpException(404, 'The requested university does not exist.'); } } return $this->_university; }
public function actionSearch($q) { $result = array(); $term = trim(addcslashes($q, '%_')); // escape LIKE's special characters if (!empty($term)) { $param = new CDbCriteria(array('condition' => "name LIKE :match", 'params' => array(':match' => "%{$term}%"))); $cursor = University::model()->findAll($param); if (!empty($cursor)) { foreach ($cursor as $id => $value) { $result[] = array('id' => $value['did'], 'name' => $value['name']); } } } echo json_encode($result); Yii::app()->end(); }
/** * Returns the collection to which the user belongs * * @param $user User * @return Object */ public static function getUser($user) { if (strcmp($user->rank, 'university') === 0) { return University::find($user->_id); } else { if (strcmp($user->rank, 'teacher') === 0) { return Teacher::find($user->_id); } else { if (strcmp($user->rank, 'student') === 0) { return Student::find($user->_id); } else { return null; } } } }
/** * @return \yii\db\ActiveQuery */ public function getUniversity() { return $this->hasOne(University::className(), ['id' => 'university_id']); }
profiling_end('deal with tags and procd_descr'); profiling_start('wrap up processing and package data for the view'); $args['pagetitle'] = "{$icrs->title} ({$icrs->code})"; $args['pageurl'] = $_SERVER['REQUEST_URI']; $args['course'] = array('id' => (int) $icrs->id, 'title' => $icrs->title, 'code' => $icrs->code, 'descr' => $icrs->descr); $args['searchresults'] = $search_results; $args['comment_id'] = $icrs->cid; $args['comments'] = array_map(function ($a) { return $a['id']; }, Comment::ListAll($icrs->cid)); $args['actions'] = $ACTIONS; $_SESSION['lastargs'] = $args; preg_match('/^[a-zA-Z]+/', $icrs->code, $matches); $args['code'] = $matches[0]; $args['university'] = array('id' => $icrs->university, 'name' => University::GetName($icrs->university)); $args['area'] = array('id' => $areaid = University::GetAreaID($args['university']['id']), 'name' => Area::GetName($areaid)); $args['country'] = array('id' => $countryid = Area::GetCountryID($args['area']), 'name' => Country::GetName($countryid)); reset_loading_screen_counter(); profiling_end('wrap up processing and package data for the view'); include "views/search.view.php"; } } else { if ($action == 'list') { $args = array('pagetitle' => 'List', 'pageurl' => $_SERVER['REQUEST_URI'], 'courses' => CourseDefn::ListAll(), 'actions' => $ACTIONS); $_SESSION['lastargs'] = $args; include "views/list.view.php"; } else { if (isset($_GET['action']) && $_GET['action'] != '') { // Action with no params $action = $_GET['action']; $args = array('pagetitle' => ucfirst($action), 'pageurl' => $_SERVER['REQUEST_URI'], 'actions' => $ACTIONS);
/** * 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 = University::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function delete(University $university) { $q = $this->db->prepare('DELETE FROM universities WHERE id = :id'); $q->execute(array('id' => $university->getId())); }
/** * Register University * * @return View */ public function registerUniversity() { if (!is_null(Input::get('g-recaptcha-response'))) { $recaptcha = new \ReCaptcha\ReCaptcha(Config::get('recaptcha.private_key')); $resp = $recaptcha->verify(Input::get('g-recaptcha-response'), Request::server('REMOTE_ADDR')); if ($resp->isSuccess()) { $user = new User(); $user->user = trim(strtolower(Input::get('university_email'))); $user->password = Hash::make(Input::get('university_password')); $user->rank = "university"; $user->last_activity = null; try { $user->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_university.email_duplicated'))); } $user = User::first(['user' => $user->user]); $university = new University(); $university->_id = $user->_id; $university->name = trim(Input::get('university_name')); $university->email = trim(strtolower(Input::get('university_email'))); $university->acronym = strtoupper(trim(Input::get('university_acronym'))); $university->profile_image = null; $university->save(); return Redirect::to('/')->with('message', Lang::get('register_university.register_true')); } else { $errors = $resp->getErrorCodes(); return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [' . $errors[0] . ']')); } } else { return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [ 99 ]')); } }
public function setFirstLevelCategory($degree_id) { $degree = Degree::model()->findByPk($degree_id); $university = University::model()->findByPk($degree->university_id); $category_id = qa_db_category_slug_to_id(null, $university->name); if (!isset($category_id)) { $category_id = qa_db_category_create(null, $university->name, $university->name); } return $category_id; }
public function getUniversityName() { $uni = University::model()->findByPk($this->university_id); if ($uni == NULL) { return "FIU"; } return $uni->name; }
function getMenteColumns($model) { //get or initialize the current column order $columnArrayOrder = getColumnArrayOrder(); //only if make a cache of the columns if needed if (isset($_GET['sourceColumn']) && isset($_GET['destinationColumn'])) { $source = $_GET['sourceColumn']; $destination = $_GET['destinationColumn']; $sourceIndex = $source[0]; $destIndex = $destination[0]; ReportUtils::moveColumnsByIndex($sourceIndex, $destIndex, $columnArrayOrder); Yii::app()->session['MenteeColumnOrder'] = $columnArrayOrder; } //Now render the columns $columns = array(); for ($i = 0; $i < count($columnArrayOrder); $i++) { switch ($columnArrayOrder[$i]) { case MenteeColumns::userId: $menteeUserID = array('name' => 'UserID', 'header' => 'Mentee User ID', 'filter' => CHtml::activeNumberField($model, 'UserID'), 'headerHtmlOptions' => array('width' => '75')); $columns[] = $menteeUserID; break; case MenteeColumns::menteeName: $menteeName = array('name' => 'Name', 'header' => 'Mentee Name', 'filter' => CHtml::activeTextField($model, 'Name'), 'headerHtmlOptions' => array('width' => '200')); $columns[] = $menteeName; break; case MenteeColumns::menteeEmail: $menteeEmail = array('name' => 'Email', 'header' => 'Mentee Email', 'filter' => CHtml::activeEmailField($model, 'Email'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $menteeEmail; break; case MenteeColumns::menteeUserName: $menteeUserName = array('name' => 'UserName', 'header' => 'Mentee User Name', 'filter' => CHtml::activeTextField($model, 'UserName'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $menteeUserName; break; case MenteeColumns::menteeDisabled: $menteeDisabled = array('name' => 'Disabled', 'header' => 'Mentee Disabled', 'value' => 'ReportUtils::getZeroOneToYesNo($data->Disabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $menteeDisabled; break; case MenteeColumns::menteeUniversityName: $universityName = array('name' => 'UniversityName', 'header' => 'Mentee University', 'filter' => CHtml::activeDropDownList($model, 'UniversityID', CHtml::listData(University::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '220')); $columns[] = $universityName; break; case MenteeColumns::menteePersonalMentorID: $PersonalMentorID = array('name' => 'PersonalMentorID', 'header' => 'Personal Mentor (ID)', 'filter' => CHtml::activeNumberField($model, 'PersonalMentorID'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $PersonalMentorID; break; case MenteeColumns::menteePersonalMentorName: $PersonalMentorName = array('name' => 'PersonalMentorName', 'header' => 'Personal Mentor (Name)', 'filter' => CHtml::activeTextField($model, 'PersonalMentorName'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorName; break; case MenteeColumns::menteePersonalMentorEmail: $PersonalMentorEmail = array('name' => 'PersonalMentorEmail', 'header' => 'Personal Mentor (Email)', 'filter' => CHtml::activeEmailField($model, 'PersonalMentorEmail'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorEmail; break; case MenteeColumns::menteePersonalMentorDisabled: $PersonalMentorDisabled = array('name' => 'PersonalMentorDisabled', 'header' => 'Personal Mentor (Disabled)', 'value' => 'ReportUtils::getZeroOneToYesNo($data->PersonalMentorDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorDisabled; break; case MenteeColumns::menteeProjectTitle: $menteeProjectTitle = array('name' => 'menteeProjectTitle', 'header' => 'Project Title', 'filter' => CHtml::activeDropDownList($model, 'menteeProjectID', CHtml::listData(Project::model()->findAll(), 'id', 'title'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '300')); $columns[] = $menteeProjectTitle; break; case MenteeColumns::menteeProjectStartDate: $menteeProjectTitle = array('name' => 'menteeProjectStartDate', 'header' => 'Project Start Date', 'value' => 'ReportUtils::dateformat($data->menteeProjectStartDate)', 'filter' => CHtml::activeDateField($model, 'menteeProjectStartDate'), 'headerHtmlOptions' => array('width' => '160')); $columns[] = $menteeProjectTitle; break; case MenteeColumns::menteeProjectDueDate: $menteeProjectDueDate = array('name' => 'menteeProjectDueDate', 'header' => 'Project Due Date', 'value' => 'ReportUtils::dateformat($data->menteeProjectDueDate)', 'filter' => CHtml::activeDateField($model, 'menteeProjectDueDate'), 'headerHtmlOptions' => array('width' => '160')); $columns[] = $menteeProjectDueDate; break; case MenteeColumns::menteeProjectCustomerName: $menteeProjectCustomerName = array('name' => 'menteeProjectCustomerName', 'header' => 'Project Customer', 'filter' => CHtml::activeTextField($model, 'menteeProjectCustomerName'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $menteeProjectCustomerName; break; } } return $columns; }
public static function universityById($id) { $uni = University::model()->findBySql("SELECT * from university WHERE id = " . $id); return $uni->name; }
public function actionPersonal() { $model = new ApplicationPersonalMentor(); $students = new User(); $unis = array(); if (Yii::app()->getRequest()->isPostRequest) { // on application submit $user = User::model()->getCurrentUser(); // pull application data and save $model->attributes = $_POST['ApplicationPersonalMentor']; $model->status = 'Admin'; $model->user_id = $user->id; $model->date_created = new CDbExpression('NOW()'); if (!isset($model->university_id) || $model->university_id == 0) { $model->university_id = NULL; } $model->save(false); // save user picks $mypicks = $_POST['picks']; $mypicks = explode(',', $mypicks); foreach ($mypicks as $pick) { if ($pick > 0) { $dbpick = new ApplicationPersonalMentorPick(); $dbpick->app_id = $model->id; $dbpick->user_id = $pick; $dbpick->approval_status = 'Proposed by Mentor'; $dbpick->save(false); } } // save system picks $systempicks = $_POST['systempicks']; $systempicks = explode(',', $systempicks); foreach ($systempicks as $pick) { if ($pick > 0) { $dbpick = new ApplicationPersonalMentorPick(); $dbpick->app_id = $model->id; $dbpick->user_id = $pick; $dbpick->approval_status = 'Proposed by System'; $dbpick->save(false); } } // redirect to application portal $this->redirect("/coplat/index.php/application/portal"); } else { // on initial load $students->unsetAttributes(); $students->isMentee = 1; $student = User::model()->returnUsersForApp($students->searchNoPagination()); $universities = University::model()->getUniversities(); $unis[0] = 'Any'; foreach ($universities as $uni) { $unis[$uni->id] = $uni->name; } $model->system_pick_amount = 0; } $error = ''; $this->render('personal', array('model' => $model, 'user' => $students, 'universities' => $unis, 'students' => $student, 'error' => $error)); }
$country_id = Country::GetID('Canada'); profiling_start('create regions'); foreach ($areas['Canada'] as $a) { Area::Create($a, $country_id); } profiling_end('create regions'); $area_id = Area::GetID('Ontario', $country_id); profiling_start('create universities'); foreach ($universities['Canada']['Ontario'] as $uni) { University::Create($uni, $area_id); } profiling_end('create universities'); $code = ""; $title = ""; $descr = ""; $uni_id = University::GetID('University of Waterloo'); profiling_start('create courses'); foreach ($xml as $a) { if ($a['tag'] == "CODE") { $code = $a['value']; } else { if ($a['tag'] == "TITLE") { $title = $a['value']; } else { if ($a['tag'] == "DESCRIPTION") { $descr = $a['value']; $code = ltrim(rtrim($code)); $title = ltrim(rtrim($title)); $descr = ltrim(rtrim($descr)); $cid = Comment::Create(array('subject' => $code, 'id' => 1)); $cd = new CourseDefn(mysql_real_escape_string(htmlspecialchars($code)));