/**
  * 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 DomainMentor the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = DomainMentor::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
    <div id="container" class="my-box-container3"
         style="<?php 
        if ($model->isDomMentor || $model->isProMentor || $model->isPerMentor) {
            echo 'display:block; ';
        } else {
            echo 'dispaly:none; ';
        }
        ?>
height: 100%;">
        <div class="contactlinks">
            <h4>Availability</h4>
            <?php 
        if ($model->isDomMentor) {
            ?>
<h6>Domain Mentor Availability</h6><?php 
            $dommentor = DomainMentor::model()->findBySql("SELECT max_tickets FROM domain_mentor WHERE user_id={$model->id}");
            $userdom = UserDomain::model()->findBySql("SELECT tier_team FROM user_domain WHERE user_id={$model->id}");
            if (is_null($dommentor->max_tickets)) {
                $dommentor->max_tickets = 0;
                $dommentor->save();
            }
            if ($dommentor->max_tickets == null) {
                echo "Max tickets: ";
                ?>
                    <select name="numTickets" style="width:60px;">
                        <option selected value="<?php 
                echo $dommentor->max_tickets;
                ?>
"><?php 
                echo $dommentor->max_tickets;
                ?>
Пример #3
0
 public static function escalateTicket($domain_id, $sub)
 {
     if ($sub) {
         $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE subdomain_id =:id", array(":id" => $domain_id));
         $subdomain = Subdomain::model()->findByPk($domain_id);
         $validator = $subdomain->validator;
     } else {
         $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE domain_id =:id", array(":id" => $domain_id));
         $domain = Domain::model()->findByPk($domain_id);
         $validator = $domain->validator;
     }
     if ($userDomain != null && is_array($userDomain)) {
         foreach ($userDomain as $auserDomain) {
             /** @var UserDomain $auserDomain */
             if ($auserDomain->tier_team == 2) {
                 if ($auserDomain->rate >= $validator) {
                     /*Query to the domain mentor to see how many tickets is allowed to be assigned */
                     $domainMentor = DomainMentor::model()->findAllBySql("SELECT * FROM domain_mentor WHERE user_id =:id", array(":id" => $auserDomain->user_id));
                     /** @var Ticket $count */
                     if (is_array($domainMentor)) {
                         foreach ($domainMentor as $adomainMentor) {
                             /** @var DomainMentor $adomainMentor */
                             $count = Ticket::model()->findBySql("SELECT COUNT(id) as `id` FROM ticket WHERE assign_user_id =:id", array(":id" => $adomainMentor->user_id));
                             if ($count->id < $adomainMentor->max_tickets) {
                                 /*return the first available domain mentor on queue */
                                 return $auserDomain->user_id;
                             }
                         }
                     }
                 }
             }
         }
     }
     return self::$admin;
     /* Assign the ticket to the admin for reassign */
 }
    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));
    }
 public function actionAdmin_Create_User()
 {
     $model = new User();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $error = '';
     if (isset($_POST['User'])) {
         /*if ($this->actionVerifyRegistrationOld() != "") {
         		$this->render('create', array('model'=>$model));
         		 }*/
         $model->attributes = $_POST['User'];
         $model->pic_url = '/coplat/images/profileimages/default_pic.jpg';
         $model->biography = "Tell us something about yourself...";
         $model->activation_chain = $this->genRandomString(10);
         $model->activated = 1;
         $error = $this->verifyRegistrationOld();
         if (!$model->isProMentor && !$model->isDomMentor && !$model->isPerMentor && !$model->isMentee) {
             $error = "Please select at least one user role.";
         }
         if ($error == null) {
             $model->save(false);
             if ($model->isProMentor) {
                 $proMentor = new ProjectMentor();
                 $proMentor->user_id = $model->id;
                 $proMentor->max_hours = 0;
                 $proMentor->max_projects = 0;
                 $proMentor->save(false);
             }
             if ($model->isDomMentor) {
                 $domMentor = new DomainMentor();
                 $domMentor->user_id = $model->id;
                 $domMentor->max_tickets = 0;
                 $domMentor->save();
             }
             if ($model->isPerMentor) {
                 $perMentor = new PersonalMentor();
                 $perMentor->user_id = $model->id;
                 $perMentor->max_hours = 0;
                 $perMentor->max_mentees = 0;
                 $perMentor->save();
             }
             if ($model->isMentee()) {
                 $mentee = new Mentee();
                 $mentee->user_id = $model->id;
                 $mentee->personal_mentor_user_id = null;
                 $mentee->project_id = null;
                 $mentee->save();
             }
         }
     }
     if (isset($_POST['Roles'])) {
         $proMentor = ProjectMentor::model()->getProMentor($_COOKIE['UserID']);
         $perMentor = PersonalMentor::model()->getPerMentor($_COOKIE['UserID']);
         $domMentor = DomainMentor::model()->getDomMentor($_COOKIE['UserID']);
         $mentee = Mentee::model()->getMentee($_COOKIE['UserID']);
         //$model->save(false);
         $user = User::model()->findByPk($_COOKIE['UserID']);
         if ($user->isProMentor == 1) {
             //$proMentor = new ProjectMentor;
             $proMentor->user_id = $user->id;
             $proMentor->max_hours = $_POST['pjmhours'];
             $all = Project::model()->findAll();
             $proMentor->save();
             $count = 0;
             foreach ($all as $each) {
                 if (isset($_POST[$each->id . 'pjm'])) {
                     $p = Project::model()->findByPk($each->id);
                     $p->project_mentor_user_id = $_COOKIE['UserID'];
                     $p->save(false);
                     $count++;
                 }
             }
             $proMentor->max_projects = $count;
             $proMentor->save();
         }
         if ($user->isDomMentor == 1) {
             //UserDomain::model()->deleteAll("user_id = ".$user->id);
             $domMentor->max_tickets = $_POST['dmmaxtickets'];
             $domMentor->save();
             $all = Domain::model()->findAll();
             foreach ($all as $each) {
                 if (isset($_POST[$each->id])) {
                     $user_domain = new UserDomain();
                     $user_domain->user_id = $domMentor->user_id;
                     $user_domain->domain_id = $each->id;
                     $user_domain->active = 1;
                     $user_domain->save(false);
                     $allsubs = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$each->id}");
                     if ($allsubs != null) {
                         foreach ($allsubs as $onesub) {
                             $temp = $onesub->id . 'ddmsub';
                             if (isset($_POST[$temp])) {
                                 $user_domain = new UserDomain();
                                 $user_domain->user_id = $domMentor->user_id;
                                 $user_domain->domain_id = $each->id;
                                 $user_domain->active = 1;
                                 $rate = $each->id . '-' . $onesub->id . 'dmrate';
                                 $tier = $each->id . '-' . $onesub->id . 'dmtier';
                                 $user_domain->rate = $_POST[$rate];
                                 $user_domain->tier_team = $_POST[$tier];
                                 $user_domain->subdomain_id = $onesub->id;
                                 $user_domain->save(false);
                             }
                         }
                     } else {
                         $user_domain = new UserDomain();
                         $user_domain->user_id = $domMentor->user_id;
                         $user_domain->domain_id = $each->id;
                         $user_domain->active = 1;
                         $user_domain->save(false);
                     }
                 }
             }
         }
         if ($user->isPerMentor) {
             //$perMentor = new PersonalMentor();
             $perMentor->user_id = $user->id;
             $perMentor->max_hours = $_POST['pmhours'];
             $all = Mentee::model()->findAll();
             $perMentor->save();
             $count = 0;
             foreach ($all as $each) {
                 if (isset($_POST[$each->user_id . 'pm'])) {
                     $p = Mentee::model()->findByPk($each->user_id);
                     $p->personal_mentor_user_id = $_COOKIE['UserID'];
                     $p->save(false);
                     $count++;
                 }
             }
             $perMentor->max_mentees = $count;
             $perMentor->save();
         }
         if ($user->isMentee) {
             $changed = false;
             $menteePersonalMentor = $_POST['mentePersonalMentor'];
             if (isset($menteePersonalMentor) && $menteePersonalMentor > 0) {
                 $mentee->personal_mentor_user_id = $menteePersonalMentor;
                 $changed = true;
             }
             $menteeProject = $_POST['menteeProject'];
             if (isset($menteeProject) && $menteeProject > 0) {
                 $mentee->project_id = $menteeProject;
                 $changed = true;
             }
             if ($changed) {
                 $mentee->save();
             }
         }
         $hasher = new PasswordHash(8, false);
         $pw = $this->genRandomString(8);
         $user->password = $hasher->HashPassword($pw);
         $user->save(false);
         $userfullName = $user->fname . ' ' . $user->lname;
         $adminName = User::getCurrentUser();
         User::sendConfirmationEmail($userfullName, $user->email, $user->username, $pw, $adminName->fname . ' ' . $adminName->lname);
     }
     //$error = '';
     $this->render('admin_create_user', array('model' => $model, 'error' => $error));
     return;
     //$this->render('add',array('model'=>$model, 'error' => $error));
 }
 public function actionuserProfile()
 {
     $model = User::getCurrentUser();
     $promentor = ProjectMentor::getCurrentUser();
     $permentor = PersonalMentor::getCurrentUser();
     $dommentor = DomainMentor::getCurrentUser();
     if (isset($_POST['submit'])) {
         $model->biography = $_POST['biography'];
         $uploadedFile = CUploadedFile::getInstance($model, 'pic_url');
         /*Attach file */
         $fileName = "{$uploadedFile}";
         if ($fileName != null) {
             /*Save file uploaded in the Uploads folder */
             $model->pic_url = '/coplat/images/profileimages/' . $fileName;
             $uploadedFile->saveAs(Yii::getPathOfAlias('webroot') . '/images/profileimages/' . $fileName);
         }
         $model->save(false);
         if ($model->isProMentor == 1) {
             echo $_POST['proHours'];
             $promentor->max_hours = $_POST['proHours'];
             //$promentor->max_projects = $_POST['numProjects'];
             $promentor->save();
             if (isset($_POST['proj'])) {
                 $projs = $_POST['proj'];
                 if (empty($projs)) {
                     echo " No projects selected ";
                 } else {
                     $pro = $_POST['proj'];
                     $curr = Project::model()->findallbysql("SELECT * FROM project WHERE project_mentor_user_id={$model->id}");
                     for ($i = 0; $i < $promentor->max_projects - count($curr); $i++) {
                         $p = Project::model()->findBySql("SELECT * FROM project WHERE title='{$pro[$i]}'");
                         $p->project_mentor_user_id = $model->id;
                         $p->save();
                     }
                 }
             }
         }
         if ($model->isPerMentor == 1) {
             $permentor->max_hours = $_POST['pmenHours'];
             // $permentor->max_mentees = $_POST['numMentees'];
             $permentor->save();
             if (isset($_POST['mentees'])) {
                 $men = $_POST['mentees'];
                 $curr = Mentee::model()->findallbysql("SELECT * FROM mentee WHERE personal_mentor_user_id={$model->id}");
                 for ($i = 0; $i < $permentor->max_mentees - count($curr); $i++) {
                     $m = Mentee::model()->findBySql("SELECT * FROM mentee WHERE user_id={$men[$i]}");
                     $m->personal_mentor_user_id = $model->id;
                     $m->save();
                 }
             }
         }
         if ($model->isDomMentor == 1) {
             $dommentor->max_tickets = $_POST['numTickets'];
             $dommentor->save();
             if (isset($_POST['domainName'])) {
                 $d = new Domain();
                 $d->name = $_POST['domainName'];
                 if (Domain::model()->domainExists($d->name)) {
                     //do nothing
                 } else {
                     $d = new Domain();
                     $ud = new UserDomain();
                     $d->name = $_POST['domainName'];
                     $d->save();
                     $ud->domain_id = $d->id;
                     $ud->user_id = $model->id;
                     $ud->rate = $_POST['ratings'];
                     $ud->save();
                 }
             }
             if (isset($_POST['existDoms'])) {
                 $doms = $_POST['existDoms'];
                 for ($i = 0; $i < count($doms); $i++) {
                     $d = Domain::model()->findBySql("SELECT id FROM domain WHERE name='{$doms[$i]}'");
                     $ud = new UserDomain();
                     $ud->domain_id = $d->id;
                     $ud->user_id = $model->id;
                     $ud->rate = $_POST['ratings'];
                     $ud->save();
                 }
             }
             if (isset($_POST['unrated'])) {
                 $ud = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE rate IS NULL AND user_id={$model->id} ");
                 $ur = $_POST['unrated'];
                 for ($i = 0; $i < count($ur); $i++) {
                     $ud[$i]->rate = $ur[$i];
                     $ud[$i]->save();
                 }
             }
         }
     }
     /** @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={$user->id}");
     $userdoms = UserDomain::model()->findAllBySql("SELECT distinct domain_id FROM user_domain WHERE user_id={$user->id}");
     $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id={$user->id}");
     $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $user->id));
     $this->render('userProfile', array('Tickets' => $Tickets, 'user' => $user, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects));
 }
 public static function getDomMentor($id)
 {
     $dommentor = DomainMentor::model()->findBySql("SELECT * FROM domain_mentor WHERE user_id={$id}");
     return $dommentor;
 }