public function importMentee($email, $pid, $firstname, $lastname, $middle, $valid) { if ($this->exists($email) == false) { $us = new User(); if ($valid == true) { $us->activated = 1; $us->email = $email . "@fiu.edu"; $us->fiucs_id = $pid; $us->fname = ucfirst($firstname); $us->lname = ucfirst($lastname); $us->username = $email; $us->isMentee = 1; $randPassword = $this->passwordGenerator(); $hasher = new PasswordHash(8, false); $us->password = $hasher->HashPassword($randPassword); $us->save(false); $mentee = new Mentee(); $mentee->user_id = $us->id; $mentorid = User::model()->findBySql("select * from user where username = '******' "); $mentee->personal_mentor_user_id = $mentorid->id; //$mentee->project_id = 999; $mentee->save(false); } else { $us->disable = 1; $us->save(false); } } //$userfullName = $model->fname.' '.$model->lname; $error = ''; // $this->actionSendVerificationEmail($userfullName, $model->email); }
public static function getMentee($id) { $mentee = Mentee::model()->findBySql("SELECT * FROM mentee WHERE user_id=" . $id); return $mentee; }
<h4><?php echo ucfirst($model->fname) . "'s "; ?> Current Assigned Mentees</h4> <h5>***Max Mentees Already Assigned***</h5> <div id="container" class="my-box-container6" style="height: 200px; overflow-y: scroll "> <?php ?> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="#mytable" width="100%"> <thread> <tr> <th width="40%">Student Name</th> </tr> </thread> <?php $men = Mentee::model()->findAllBySql("SELECT * FROM mentee WHERE personal_mentor_user_id={$model->id}"); foreach ($men as $mentee) { $usr = User::model()->findBySql("SELECT * FROM user WHERE id={$mentee->user_id}"); ?> <tbody> <tr> <td><?php echo ucfirst($usr->fname) . " " . ucfirst($usr->lname); ?> </td> </tr> </tbody> <?php } ?>
public function actionpersonalMentorViewMeetings() { /** @var User $user */ $username = Yii::app()->user->name; $user = User::model()->find("username=:username", array(':username' => $username)); $pmentees = array(); // tito $allMentees = Mentee::model()->findAllBySql("SELECT * FROM mentee WHERE personal_mentor_user_id=:id", array(":id" => $user->id)); foreach ($allMentees as $i => $m) { //tito $pmentees[$pm->id][$m->user_id] = $m; $pmentees[4352][$m->user_id] = $m; } $pmentee = array(); foreach ($pmentees as $pment) { foreach ($pment as $pm) { $pmentee[$pm->user_id] = User::model()->findBySql("SELECT * FROM user WHERE id=:id", array(":id" => $pm->user_id)); } } /*Get all tickets for his mentees */ $tickets = array(); foreach ($pmentee as $id => $menteeTickets) { $myTickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE creator_user_id=:id and assign_user_id!=:id2", array(':id' => $menteeTickets->id, ':id2' => User::getCurrentUserId())); if (is_array($myTickets)) { $tickets = array_merge($tickets, $myTickets); } } function cmp($a, $b) { return $b["id"] - $a["id"]; } usort($tickets, "cmp"); /** @var User $usermentee */ /* End Return all the mentees for the project mentor */ $this->render('personalMentorViewMeetings', array('user' => $user, 'pmentee' => $pmentee, 'tickets' => $tickets)); }
public function returnUsersForApp($dataProvider) { $users = array(); foreach ($dataProvider->getData() as $user) { $temp = array(); $temp["id"] = $user->id; $temp["name"] = $user->getFullName(); if (isset($user->university_id) && $user->university_id > 0) { $temp["university"] = University::model()->universityById($user->university_id); } $temp["avatar"] = $user->pic_url; $temp["email"] = $user->email; $mentee = Mentee::model()->findByPk($user->id); $mentorTrim = array(); $mentorTrim["name"] = "None"; $mentorTrim["avatar"] = ""; if (count($mentee) == 0) { $temp["project"] = "None"; $temp["description"] = ""; $temp["mentor"] = $mentorTrim; } else { $project = Project::model()->findByPk($mentee->project_id); if (count($project) > 0) { $temp["project"] = $project->title; $temp["description"] = $project->getDescriptionOfSize(200); } else { $temp["project"] = "None"; $temp["description"] = ""; } $personalMentor = User::model()->findByPk($mentee->personal_mentor_user_id); if (count($personalMentor) > 0 && $mentee->personal_mentor_user_id != 999) { $mentorTrim = array(); $mentorTrim["name"] = $personalMentor->getFullName(); $mentorTrim["avatar"] = $personalMentor->pic_url; } $temp["mentor"] = $mentorTrim; } $users[] = $temp; } return $users; }
<div class="container" > <div class="column-center"> <?php if (User::isCurrentUserMentee()) { $pmentors = Mentee::model()->findBySql("SELECT * FROM mentee WHERE user_id={$user->id}"); $pmentor = null; $proj = null; if ($pmentors->personal_mentor_user_id != null) { $pmentor = PersonalMentor::model()->findBySql("SELECT * FROM personal_mentor WHERE user_id={$pmentors->personal_mentor_user_id}"); } $myproject = Mentee::model()->findBySql("SELECT project_id FROM mentee WHERE user_id={$user->id}"); if ($myproject->project_id != null) { $proj = Project::model()->findBySql("SELECT * FROM project WHERE id={$myproject->project_id}"); } ?> <div class="titlebox" style="width: auto" align="center"><h3>Mentee</h3></div> <br> <br> <div id="contain" class ="my-box-container6"> <h4> My Personal Mentor </h4> <div id="container" class="my-box-container6" style="<?php if (User::isCurrentUserMentee()) { echo 'display:block;'; } else { echo 'display:none;'; } ?> height: auto; overflow-y: scroll;width: 400px"> <?php
/** * 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 $id the ID of the model to be loaded * @return Mentee the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Mentee::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
if ($mentee->project_id != null) { $menteeProj = Project::model()->findBySql("select * from project where id = {$mentee->project_id}"); $projMentor = User::model()->findByPk($menteeProj->project_mentor_user_id); $title = $menteeProj->title; $projectdesc = $menteeProj->description; $mycustomer = null; if ($projMentor != null) { if ($projMentor->username == 'DEFAULT') { $mycustomer = Project::model()->findBySql("select * from project where id = {$menteeProj->id}"); $pmName = ucfirst($projMentor->fname) . ' ' . ucfirst($projMentor->fname); } } if ($mycustomer != null) { $CUSName = $mycustomer->customer_fname . ' ' . $mycustomer->customer_lname; } $mymenids = Mentee::model()->findAllBySql("select * from mentee where project_id ={$menteeProj->id} "); if ($mymenids != null) { $res = ''; foreach ($mymenids as $m) { $pid = $m->user_id; $t = User::model()->findBySql("select * from user where id = {$pid}"); $projmid = Project::model()->findBySql("select * from project where id = {$m->project_id}"); $pjm = null; if ($projmid != null) { if ($projmid->project_mentor_user_id != null) { $pjm = User::model()->findBySql("select * from user where id = {$projmid->project_mentor_user_id}"); } } $perm = User::model()->findBySql("select * from user where id = {$m->personal_mentor_user_id}"); if (isset($pjm)) { $PJMname = $pjm->fname . ' ' . $pjm->lname;
public function actionApprove() { //$this->layout = ''; $user = User::model()->getCurrentUser(); $perModel = new ApplicationPersonalMentorPick(); $proModel = new ApplicationProjectMentorPick(); $domModel = new ApplicationDomainMentorPick(); $subModel = new ApplicationSubdomainMentorPick(); if (Yii::app()->getRequest()->isPostRequest) { $projectFlag = false; $personalFlag = false; $domainFlag = false; $domApp = $this->loadDomainMentorForApproval($user->id); $persApp = $this->loadPersonalMentorForApproval($user->id); $projApp = $this->loadProjectMentorForApproval($user->id); // PERSONAL PICKS ACCEPT $mypicks = $_POST['personal_picks_accept']; // add entry to personal_mentor $personalEntry = $this->isNewEntry($user->id, 'personal_mentor'); // if it already exists do NOTHING . change here with else statement to perform update if ($personalEntry < 1) { // add entry to personal_mentor $pementor = new PersonalMentor('add_new'); $pementor->user_id = $user->id; $pementor->max_hours = $persApp->max_hours; $pementor->max_mentees = $persApp->max_amount; $pementor->save(); } // else UPDATE $personalFlag = true; //$loaduser->isPerMentor = 1; } if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadPersonalPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // create new entry $mentee = new PersonalMentorMentees('add_new'); $mentee->user_id = $actualPick->user_id; // mentee id $mentee->personal_mentor_id = $user->id; // mentor id $mentee->save(); $trans = Yii::app()->db->beginTransaction(); $menter = Mentee::model()->findByPk($actualPick->user_id); if (is_null($menter)) { $menter = new Mentee('add_new'); $menter->user_id = $actualPick->user_id; } $menter->personal_mentor_user_id = $user->id; $menter->save(); $trans->commit(); } // PERSONAL PICKS REJECT $mypicks = $_POST['personal_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadPersonalPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $personalFlag = true; } // PROJECT PICKS ACCEPT $mypicks = $_POST['project_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadProjectPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // update entry $project = $this->loadProject($actualPick->project_id); $project->project_mentor_user_id = $user->id; $project->save(); } // add entry to project_mentor $projectEntry = $this->isNewEntry($user->id, 'project_mentor'); // if it already exists do NOTHING . change here with else statement to perform update if ($projectEntry < 1) { // add entry to project_mentor $promentor = new ProjectMentor('add_new'); $promentor->user_id = $user->id; $promentor->max_hours = $projApp->max_hours; $promentor->max_projects = $projApp->max_amount; $promentor->save(); } // else UPDATE $projectFlag = true; //$loaduser->isProMentor = 1; } // PROJECT PICKS REJECT $mypicks = $_POST['project_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); foreach ($mypicks as $pick) { $actualPick = $this->loadProjectPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $projectFlag = true; } // DOMAIN PICKS ACCEPT $mypicks = $_POST['domain_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadDomainPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // create new entry $domain = new UserDomain('add_new'); $domain->user_id = $user > id; $domain->domain_id = $actualPick->domain_id; $domain->rate = $actualPick->proficiency; $domain->active = 1; $domain->tier_team = 1; $domain->save(); } $domainFlag = true; //$loaduser->isDomMentor = 1; } // DOMAIN PICKS REJECT $mypicks = $_POST['domain_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadDomainPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $domainFlag = true; } // SUBDOMAIN PICKS ACCEPT $mypicks = $_POST['subdomain_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadSubDomainPick($pick); $this->updatePickStatus($actualPick, 'Approved'); //create new entry $subdomain = new UserDomain('add_new'); $subdomain->user_id = $user->id; $subdomain->domain_id = $actualPick->subdomain->domain->id; $subdomain->subdomain_id = $actualPick->subdomain_id; $subdomain->rate = $actualPick->proficiency; $subdomain->active = 1; $subdomain->tier_team = 1; $subdomain->save(); } $domainFlag = true; //$loaduser->isDomMentor = 1; } // SUBDOMAIN PICKS REJECT $mypicks = $_POST['subdomain_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadSubDomainPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $domainFlag = true; } $closed = new ApplicationClosed(); $closedOne = false; if ($domainFlag) { // add entry to domain_mentor $domEntry = $this->isNewEntry($user->id, 'domain_mentor'); $user->isDomMentor = 1; // add entry to domain_mentor // if it already exists do NOTHING . change here with else statement to perform update if ($domEntry < 1) { $dmentor = new DomainMentor('add_new'); $dmentor->user_id = $user->id; $dmentor->max_tickets = $domApp->max_amount; $dmentor->save(); } // else UPDATE $this->updateAppStatus($domApp, 'Closed'); $closed->app_domain_mentor_id = $domApp->id; $closedOne = true; } if ($personalFlag) { $user->isPerMentor = 1; $this->updateAppStatus($persApp, 'Closed'); $closed->app_personal_mentor_id = $persApp->id; $closedOne = true; } if ($projectFlag) { $user->isProMentor = 1; $this->updateAppStatus($projApp, 'Closed'); $closed->app_project_mentor_id = $projApp->id; $closedOne = true; } $user->save(); if ($closedOne) { $closed->user_id = $user->id; $closed->date = new CDbExpression('NOW()'); $closed->save(); } $this->redirect("/coplat/index.php/application/portal"); } // on initial load // application personal mentor // load application sent by admin $personalMentor = $this->loadPersonalMentorForApproval($user->id); $personalMentorHistory = null; $personalMentorChanges = null; $personalCount = 0; if ($personalMentor != null) { $personalMentorHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.user_id, t.approval_status, u.fname, u.lname FROM application_personal_mentor_pick t, user u WHERE t.user_id = u.id AND (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.app_id = ' . $personalMentor->id . ''); $personalMentorChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.user_id, t.approval_status, u.fname, u.lname FROM application_personal_mentor_pick t, user u WHERE t.user_id = u.id AND (t.approval_status = "Proposed by Admin") AND t.app_id = ' . $personalMentor->id . ''); $personalCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_personal_mentor_pick')->where('app_id =:id', array(':id' => $personalMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } // application project mentor $projectMentor = $this->loadProjectMentorForApproval($user->id); $projectMentorHistory = null; $projectMentorChanges = null; $projectCount = 0; if ($projectMentor != null) { $projectMentorHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.project_id, t.approval_status, p.title FROM application_project_mentor_pick t, project p WHERE t.project_id = p.id AND (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.app_id = ' . $projectMentor->id . ''); $projectMentorChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.project_id, t.approval_status, p.title FROM application_project_mentor_pick t, project p WHERE t.project_id = p.id AND (t.approval_status = "Proposed by Admin") AND t.app_id = ' . $projectMentor->id . ''); $projectCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_project_mentor_pick')->where('app_id =:id', array(':id' => $projectMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } // application domain mentor $domainMentor = $this->loadDomainMentorForApproval($user->id); $domainHistory = null; $domainChanges = null; $domainCount = 0; $subdomainHistory = null; $subdomainChanges = null; $subdomainCount = 0; if ($domainMentor != null) { $domainHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.domain_id, t.proficiency, t.approval_status, d.name FROM application_domain_mentor_pick t, domain d WHERE (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.domain_id = d.id AND t.app_id = ' . $domainMentor->id . ''); $domainChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.domain_id, t.proficiency, t.approval_status, d.name FROM application_domain_mentor_pick t, domain d WHERE (t.approval_status = "Proposed by Admin") AND t.domain_id = d.id AND t.app_id= ' . $domainMentor->id . ''); $domainCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_domain_mentor_pick')->where('app_id =:id', array(':id' => $domainMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); $subdomainHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.subdomain_id, t.proficiency, t.approval_status, d.name as "dname", s.name as "sname" FROM application_subdomain_mentor_pick t, subdomain s, domain d WHERE (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND s.domain_id = d.id AND s.id = t.subdomain_id AND t.app_id = ' . $domainMentor->id . ''); $subdomainChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.subdomain_id, t.proficiency, t.approval_status, d.name as "dname", s.name as "sname" FROM application_subdomain_mentor_pick t, subdomain s, domain d WHERE (t.approval_status = "Proposed by Admin") AND s.domain_id = d.id AND s.id = t.subdomain_id AND t.app_id = ' . $domainMentor->id . ''); $subdomainCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_subdomain_mentor_pick')->where('app_id =:id', array(':id' => $domainMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } $userInfo = $this->loadUserInfoByUser($user->id); $newCount = $personalCount + $projectCount + $domainCount + $subdomainCount; // render view $this->render('approve', array('user_id' => $user->id, 'personalMentor' => $personalMentor, 'personalMentorHistory' => $personalMentorHistory, 'personalMentorChanges' => $personalMentorChanges, 'projectMentor' => $projectMentor, 'projectMentorHistory' => $projectMentorHistory, 'projectMentorChanges' => $projectMentorChanges, 'domainMentor' => $domainMentor, 'domainHistory' => $domainHistory, 'domainChanges' => $domainChanges, 'subdomainHistory' => $subdomainHistory, 'subdomainChanges' => $subdomainChanges, 'newCount' => $newCount, 'perModel' => $perModel, 'proModel' => $proModel, 'domModel' => $domModel, 'subModel' => $subModel, 'userInfo' => $userInfo)); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = $this->loadModel($id); $deleteMessage = ""; if ($model->isAdmin == 1 || isset($model->administrator)) { $deleteMessage = "You can not delete administrators. Try disable the user."; } elseif (count($model->tickets) > 0) { $deleteMessage = "You can not delete this user because is assigned to a ticket. Try disable the user."; } elseif (count($model->tickets1) > 0) { $deleteMessage = "You can not delete this user because it is the owner of tickets. Try disable the user."; } if ($deleteMessage != "") { throw new CHttpException(400, $deleteMessage); } //TODO: implement transaction here //we can proceed with the deletion (put transactions here) if (isset($model->projectMentor)) { $model->projectMentor->delete(); } if (isset($model->personalMentor)) { $model->personalMentor->delete(); } if (isset($model->domainMentor)) { $model->domainMentor->delete(); } if (isset($model->user_info)) { $model->user_info->delete(); } $mentee = Mentee::getMentee($id); if (isset($mentee)) { $mentee->delete(); } $model->delete(); ////soft delete //$model->disable = 1; //$model->save(false); //Hard delete //$this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } }
public function actioneditProfile() { /** @var User $username */ $username = Yii::app()->user->name; $user = User::model()->find("username=:username", array(':username' => $username)); $projects = Project::model()->findAllBySql("SELECT title FROM project WHERE project_mentor_user_id IS NULL"); $userdoms = UserDomain::model()->findAllBySql("SELECT domain_id FROM user_domain WHERE user_id={$user->id}"); $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id IS NULL"); $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $user->id)); $this->render('editProfile', array('Tickets' => $Tickets, 'user' => $user, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects)); }
public function getProjectsForApp($dataProvider, $currentUser) { $projects = array(); foreach ($dataProvider->getData() as $project) { $temp = array(); $temp["id"] = $project->id; $temp["title"] = $project->title; $temp["customer"] = $project->getCustomerFullName(); $temp["description"] = $project->getDescriptionOfSize(750); // get project mentors for this project $pmToP = new ProjectMentorProjects(); $pmToP->project_id = $project->id; $temp["mentors"] = $pmToP->getProjectMentors($pmToP->search(), $currentUser); // get mentees for this project $mentees = new Mentee(); $mentees->project_id = $project->id; $temp["mentees"] = $mentees->getMenteesOnProject($mentees->search()); // Only add if user is not on this project $projects[] = $temp; } return $projects; }
?> <?php echo $form->dropDownList($model, 'assign_user_id', $data, array('prompt' => 'Select')); ?> <?php echo $form->error($model, 'assign_user_id'); ?> <?php } ?> <?php /* If the user if project mentor. He has the option of assign the ticket to another project mentor */ if (User::isCurrentUserMentee()) { // find project mentor $mentee = Mentee::model()->findByPk(User::getCurrentUserId()); $mentor = null; $projectmentor = Project::model()->findByPk($mentee->project_id); if ($projectmentor != null) { $mentor = User::model()->find("id=:id", array(':id' => $projectmentor->project_mentor_user_id)); } else { } //Tito: Find perssonnal mentor $personalMentor = null; if ($mentee->personal_mentor_user_id != null) { $personalMentorID = $mentee->personal_mentor_user_id; $personalMentor = User::model()->find("id=:id", array(':id' => $personalMentorID)); } $data = array(); // foreach ($mentor as $mod) { if ($mentor != null) {