示例#1
0
 public function executeShow()
 {
     $c = new Criteria();
     $c->add(UserPeer::USERNAME, $this->getUser()->getAttribute('username'));
     $user = UserPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PersonalPeer::USER_ID, $user->getId());
     $this->personal = PersonalPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(LoruserPeer::USER_ID, $user->getId());
     $c->addJoin(LoruserPeer::LORVALUES_ID, LorvaluesPeer::ID);
     $c->add(LorvaluesPeer::LORFIELDS_ID, sfConfig::get('app_lor_linkedin'));
     $this->lors = LorvaluesPeer::doSelect($c);
     $c = new Criteria();
     $c->add(LoruserPeer::USER_ID, $user->getId());
     $c->addJoin(LoruserPeer::LORVALUES_ID, LorvaluesPeer::ID);
     $c->add(LorvaluesPeer::LORFIELDS_ID, sfConfig::get('app_lor_general'));
     $this->glors = LorvaluesPeer::doSelect($c);
     // display the checkbox
     $userid = $this->getUser()->getAttribute('userid');
     $c = new Criteria();
     $c->add(PersonalPeer::USER_ID, $userid);
     $this->personal = PersonalPeer::doSelectOne($c);
     //$this->personalid= $this->personal->getId();
     //$c = new Criteria();
     //$c->add(PersonalPeer::USER_ID,$this->userid );
     //$personal = PersonalPeer::doSelectOne($c);
     //$this->senderemail=$personal->getId();
     $c = new Criteria();
     $c->addJoin(WorktypePeer::ID, PersonalWorktypePeer::ID);
     $c->add(PersonalWorktypePeer::PERSONAL_ID, $this->personal->getId());
     $c->addAscendingOrderByColumn(WorktypePeer::ID);
     $this->worktypes = WorktypePeer::doSelect($c);
     $this->forward404Unless($this->personal);
 }
 public static function doSelectJoinAllExceptPersonal(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     PersonalWorktypePeer::addSelectColumns($c);
     $startcol2 = PersonalWorktypePeer::NUM_COLUMNS - PersonalWorktypePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     WorktypePeer::addSelectColumns($c);
     $startcol3 = $startcol2 + WorktypePeer::NUM_COLUMNS;
     $c->addJoin(PersonalWorktypePeer::WORKTYPE_ID, WorktypePeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = PersonalWorktypePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = WorktypePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getWorktype();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addPersonalWorktype($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initPersonalWorktypes();
             $obj2->addPersonalWorktype($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
示例#3
0
 public function executeResult()
 {
     $this->myid = $this->getUser()->getAttribute('userid');
     //Changes in the next 3 lines are to cater the issue # 72
     $orgflag = 1;
     /*if($this->getUser()->getAttribute('userid')){
      		$orgflag = 1;
      	}*/
     $sortcriteria = $this->getRequestParameter('sort');
     if (!$sortcriteria) {
         $sortcriteria = $this->getUser()->getAttribute('lastsortparam');
     } else {
         //$this->getUser()->setAttribute('assort', $sortcriteria);
         if ($this->getUser()->getAttribute('lastsortparam') == $sortcriteria) {
             if ($this->getUser()->getAttribute('lastsortact') == 123) {
                 $sorttype = 321;
             } else {
                 $sorttype = 123;
             }
         }
         $this->getUser()->setAttribute('lastsortparam', $sortcriteria);
         $this->getUser()->setAttribute('lastsortact', $sorttype);
     }
     $this->fname = $firstname = $this->getsets('firstname');
     $this->lname = $lastname = $this->getsets('lastname');
     $this->br = $branchid = $this->getsetd('branch');
     $this->yr = $yearid = $this->getsetd('year');
     $this->chap = $chapterid = $this->getsetd('chapter');
     $this->usertypeid = $usertypeid = $this->getsetd('usertype');
     $this->loc = $location = $this->getsets('location');
     $this->cn = $countryid = $this->getsetd('country');
     $chjoin = 0;
     $c = new Criteria();
     $c->addJoin(UserPeer::ID, PersonalPeer::USER_ID);
     if ($firstname) {
         $c->add(PersonalPeer::FIRSTNAME, $firstname);
     }
     if ($lastname) {
         $c->add(PersonalPeer::LASTNAME, $lastname);
     }
     $this->privacyfilter($branchid, $orgflag, $c, 'user.BRANCH_ID', 'user.BRANCHFLAG');
     $this->privacyfilter($yearid, $orgflag, $c, 'user.GRADUATIONYEAR', 'user.GRADUATIONYEARFLAG');
     if ($chapterid != 0) {
         $c->addJoin(UserPeer::ID, UserchapterregionPeer::USER_ID);
         $c->addJoin(UserchapterregionPeer::CHAPTERREGION_ID, ChapterregionPeer::ID);
         $c->add(ChapterregionPeer::CHAPTER_ID, $chapterid);
         $chjoin = 1;
     }
     $c->add(UserPeer::USERTYPE, $usertypeid);
     if ($location) {
         $c->add(UserPeer::CURRENTLYAT, $location);
         if ($orgflag) {
             $c->add(UserPeer::CURRENTLYATFLAG, sfConfig::get('app_privacycode_me'), Criteria::NOT_EQUAL);
         } else {
             $c->add(UserPeer::CURRENTLYATFLAG, sfConfig::get('app_privacycode_world'), Criteria::EQUAL);
         }
     }
     //$this->privacyfilter($countryid, $orgflag, $c, 'address.COUNTRY', 'address.COUNTRYFLAG');
     if ($countryid != 0) {
         $c->add(AddressPeer::COUNTRY, $countryid);
         if ($orgflag) {
             $c->add(AddressPeer::COUNTRYFLAG, sfConfig::get('app_privacycode_me'), Criteria::NOT_EQUAL);
         } else {
             $c->add(AddressPeer::COUNTRYFLAG, sfConfig::get('app_privacycode_world'), Criteria::EQUAL);
         }
     }
     if ($sortcriteria) {
         switch ($sortcriteria) {
             case "name":
                 $this->ascdesc($sorttype, 'personal.FIRSTNAME', $c);
                 break;
             case "roll":
                 $this->ascdesc($sorttype, 'user.ROLL', $c);
                 break;
             case "year":
                 $this->ascdesc($sorttype, 'user.GRADUATIONYEAR', $c);
                 break;
             case "branch":
                 $this->ascdesc($sorttype, 'user.BRANCH_ID', $c);
                 break;
             case "degree":
                 $this->ascdesc($sorttype, 'user.DEGREE_ID', $c);
                 break;
             case "chapter":
                 if (!$chjoin) {
                     $c->addJoin(UserPeer::ID, UserchapterregionPeer::USER_ID);
                     $c->addJoin(UserchapterregionPeer::CHAPTERREGION_ID, ChapterregionPeer::ID);
                     $c->addJoin(ChapterregionPeer::CHAPTER_ID, ChapterPeer::ID);
                 }
                 $this->ascdesc($sorttype, 'chapter.NAME', $c);
                 break;
             case "reg":
                 $this->ascdesc($sorttype, 'user.ISLOCKED', $c);
                 break;
             case "lastlogin":
                 $this->ascdesc($sorttype, 'user.LASTLOGIN', $c);
                 break;
         }
     }
     $pageoptions = array();
     for ($i = sfConfig::get('app_pager_min'); $i <= sfConfig::get('app_pager_max'); $i += sfConfig::get('app_pager_step')) {
         $pageoptions[$i] = "View " . $i . " Results";
     }
     $this->pageoptions = $pageoptions;
     $maxresult = $this->getRequestParameter('maxresult');
     if (!$maxresult) {
         $maxresult = $this->getUser()->getAttribute('maxresult');
     } else {
         $this->getUser()->setAttribute('maxresult', $maxresult);
     }
     if ($maxresult) {
         $pager = new sfPropelPager('User', $maxresult);
         $this->maxresult = $maxresult;
     } else {
         $pager = new sfPropelPager('User', sfConfig::get('app_pager_min'));
     }
     $cr = new Criteria();
     $cr->add(RolePeer::ASSIGNABLE, '1');
     $cr->addAscendingOrderByColumn(RolePeer::DISPLAYNAME);
     $roles = RolePeer::doSelect($cr);
     $rolelist = array();
     foreach ($roles as $role) {
         $rolelist[$role->getId()] = $role->getDisplayname();
     }
     $this->rolelist = $rolelist;
     $cx = new Criteria();
     $this->worktypes = WorktypePeer::doSelect($cx);
     //$c->addJoin(PersonalPeer::ID, PersonalWorktypePeer::PERSONAL_ID);
     $c->setDistinct();
     foreach ($this->worktypes as $worktype) {
         if ($this->getRequestParameter($worktype->getId())) {
             $c->addJoin(PersonalPeer::ID, PersonalWorktypePeer::PERSONAL_ID);
             $c->add(PersonalWorktypePeer::WORKTYPE_ID, $worktype->getId());
         }
     }
     //$c->addGroupByColumn(PersonalWorktypePeer::PERSONAL_ID);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
     $this->getUser()->setAttribute('srpage', $this->getRequestParameter('page', 1));
     if (!$this->getUser()->getAttribute('resultcount')) {
         $this->count = UserPeer::doCount($c);
         $this->getUser()->setAttribute('resultcount', $this->count);
     } else {
         $this->count = $this->getUser()->getAttribute('resultcount');
     }
 }
 public function getWorktype($con = null)
 {
     include_once 'lib/model/om/BaseWorktypePeer.php';
     if ($this->aWorktype === null && $this->worktype_id !== null) {
         $this->aWorktype = WorktypePeer::retrieveByPK($this->worktype_id, $con);
     }
     return $this->aWorktype;
 }
示例#5
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = WorktypePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
 }
示例#6
0
    public function executeRegistration()
    {
        $userid = $this->getRequestParameter('userid');
        $this->getUser()->getAttributeHolder()->remove('claimerid');
        $roll = $this->getRequestParameter('roll');
        $hawa = $this->getRequestParameter('hawa');
        $city = $this->getRequestParameter('city');
        $hod = $this->getRequestParameter('hod');
        $director = $this->getRequestParameter('director');
        $teacher = $this->getRequestParameter('favteacher');
        $lanka = $this->getRequestParameter('favlankashop');
        $email = $this->getRequestParameter('email');
        $other = $this->getRequestParameter('otherinfo');
        $dusername = $this->getRequestParameter('dusername');
        $mob = $this->getRequestParameter('mob');
        if (!$userid) {
            $fname = $this->getRequestParameter('fname');
            $mname = $this->getRequestParameter('mname');
            $lname = $this->getRequestParameter('lname');
            $year = $this->getRequestParameter('year');
            $dusername = $this->getRequestParameter('dusername');
            $formerrors1 = array();
            if (!$fname) {
                $formerrors1[] = 'Please enter first name';
            }
            if (!$lname) {
                $formerrors1[] = 'Please enter last name';
            }
            if (!$dusername) {
                $formerrors1[] = 'Please enter username';
            }
            if ($formerrors1) {
                $this->getRequest()->setErrors($formerrors1);
                $this->forward('home', 'getmyaccount');
            }
            $branchn = BranchPeer::retrieveByPK($this->getRequestParameter('branchid'));
            $degreen = DegreePeer::retrieveByPK($this->getRequestParameter('degreeid'));
            if (!$dusername) {
                $newusername = $fname . "." . $lname . "@" . $branchn->getCode() . substr($year, -2);
            } else {
                $newusername = $dusername;
            }
            $currentyear = date('Y');
            if ($currentyear <= $year) {
                $usertype = '0';
            } else {
                $usertype = '1';
            }
            $user = new User();
            $user->setUsername($newusername);
            $user->setRoll($roll);
            $user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
            $user->setGraduationyear($year);
            $user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
            $user->setBranchId($branchn->getId());
            $user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
            $user->setDegreeId($degreen->getId());
            $user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
            $user->setUsertype($usertype);
            $user->setTempemail($email);
            $user->setIslocked(sfConfig::get('app_islocked_newreg'));
            $user->save();
            $personal = new Personal();
            $personal->setUserId($user->getId());
            $personal->setFirstname($fname);
            $personal->setMiddlename($mname);
            $personal->setLastname($lname);
            $personal->setEmail($email);
            $personal->setMobile($mob);
            $personal->save();
            $userid = $user->getId();
        } else {
            $user = UserPeer::retrieveByPK($userid);
            $user->setIslocked(sfConfig::get('app_islocked_claimed'));
            $user->save();
        }
        $c = new Criteria();
        $c->add(ClaiminfoPeer::USER_ID, $userid);
        $claiminfo = ClaiminfoPeer::doSelectOne($c);
        if ($claiminfo) {
            $this->user = $claiminfo->getUser();
            $this->claiminfo = $claiminfo;
        } else {
            $claiminfo = new Claiminfo();
            $claiminfo->setUserId($userid);
            $claiminfo->setRoll($roll);
            $claiminfo->setHawa($hawa);
            $claiminfo->setCity($city);
            $claiminfo->setHod($hod);
            $claiminfo->setDirector($director);
            $claiminfo->setTeacher($teacher);
            $claiminfo->setLankashop($lanka);
            $claiminfo->setOther($other);
            $claiminfo->setDusername($dusername);
            $claiminfo->save();
            $this->claiminfo = $claiminfo;
            $this->user = $user;
            if ($user) {
                $username = $user->getUsername();
                $personal = $user->getPersonal();
                $personal->setEmail($email);
                $personal->save();
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = sfConfig::get('app_to_adminmail');
                $subject = "Registration request for ITBHU Global Org";
                $body = '
	  Hi,
	 
	  I want to connect to ITBHU Global. My verification information is: 
	
	';
                $body = $body . 'Roll Number           : ' . $roll . '
	';
                $body = $body . 'HAWA                  :  ' . $hawa . '
	';
                $body = $body . 'City                  :  ' . $city . '
	';
                $body = $body . 'HoD                   :  ' . $hod . '
	';
                $body = $body . 'Director              :  ' . $director . '
	';
                $body = $body . 'Favourite Teacher     :  ' . $teacher . '
	';
                $body = $body . 'Favuorite Lanka Shop  :  ' . $lanka . '
	';
                $body = $body . 'My Email              :  ' . $email . '
	';
                $body = $body . 'Username I am claiming: ' . $username . '
	';
                $body = $body . 'Desired Username      : '******'
	';
                $body = $body . 'Thanks,';
                $body = $body . '
	' . $user->getFullname();
                //send mail to admin
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
                //send mail to class authorizer
                $ca = new Criteria();
                $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear());
                $ca->add(UserPeer::BRANCH_ID, $user->getBranchId());
                $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                $authusers = UserPeer::doSelect($ca);
                //if class authorizers are available.
                if ($authusers) {
                    foreach ($authusers as $authuser) {
                        $toauth = $authuser->getEmail();
                        $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                    }
                    $user->setAuthcode(sfConfig::get('app_authcode_classauth'));
                    $user->save();
                } else {
                    //get other authorizers
                    $ugyear = $user->getGraduationyear() - 2;
                    $lgyear = $user->getGraduationyear() + 2;
                    $oa = new Criteria();
                    $oa->add(UserPeer::GRADUATIONYEAR, $ugyear, Criteria::GREATER_EQUAL);
                    $oa->add(UserPeer::GRADUATIONYEAR, $lgyear, Criteria::LESS_EQUAL);
                    $oa->add(UserPeer::BRANCH_ID, $user->getBranchId());
                    $oa->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                    $oa->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                    $authuserspm = UserPeer::doSelect($oa);
                    //if other authorizers are available
                    if ($authuserspm) {
                        foreach ($authuserspm as $authuserpm) {
                            $toauth = $authuserpm->getEmail();
                            $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                            $user->setAuthcode(sfConfig::get('app_authcode_otherauth'));
                            $user->save();
                        }
                    } else {
                        // no authorizers were available, send to master list of authorizers
                        $ma = new Criteria();
                        $ma->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                        $ma->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_masterauth'));
                        $mauths = UserPeer::doSelect($ma);
                        if ($mauths) {
                            foreach ($mauths as $mauth) {
                                $toauth = $mauth->getEmail();
                                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                                $user->setAuthcode(sfConfig::get('app_authcode_masterauth'));
                                $user->save();
                            }
                        } else {
                            $user->setAuthcode(sfConfig::get('app_authcode_none'));
                            $user->save();
                        }
                    }
                }
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = $email;
                $subject = "Registration request for ITBHU Global Org";
                $body = '
				Dear ' . $user->getFullname() . ',
				
				Thank you for your connect request. We\'ll get back to you shortly.	
				
				
				Admin,
				ITBHU Global
				';
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
            }
        }
        // saving the checkbox data in db
        $c = new Criteria();
        $c->add(PersonalPeer::USER_ID, $user->getId());
        $this->personal = PersonalPeer::doSelectOne($c);
        $c = new Criteria();
        $worktypes = WorktypePeer::doSelect($c);
        foreach ($worktypes as $worktype) {
            if ($this->getRequestParameter($worktype->getId())) {
                $personalWorktype = new PersonalWorktype();
                $personalWorktype->setPersonalId($this->personal->getId());
                $personalWorktype->setWorktypeId($worktype->getId());
                $personalWorktype->save();
            }
        }
    }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(WorktypePeer::ID, $pks, Criteria::IN);
         $objs = WorktypePeer::doSelect($criteria, $con);
     }
     return $objs;
 }