public function getPersonal() { $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->getUserId()); $personal = PersonalPeer::doSelectOne($c); return $personal; }
public function executeChangepassword() { $oldpass = $this->getRequestParameter('oldpassword'); $newpass = $this->getRequestParameter('newpassword'); if ($oldpass) { $user = UserPeer::retrieveByPK($this->getUser()->getAttribute('userid')); $salt = md5(sfConfig::get('app_salt_password')); if (sha1($salt . $oldpass) == $user->getPassword()) { $user->setPassword($newpass); $user->save(); $this->setFlash('changepassword', 'Password changed successfully.'); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $personal = PersonalPeer::doSelectOne($c); $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname(); $sendermail = sfConfig::get('app_from_mail'); $sendername = sfConfig::get('app_from_name'); $to = $personal->getEmail(); $subject = "Password change request for ITBHU Global Org"; $body = ' Dear ' . $name . ', Someone, probably you have changed the password. If its not you, please contact admin as soon as practical. Admin, ITBHU Global '; $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body); } else { $this->setFlash('changepasswordErr', 'Incorrect Old Password'); } } }
public function executeLoraccept() { $lor = LorvaluesPeer::retrieveByPK($this->getRequestParameter('lorid')); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->getUser()->getAttribute('userid')); $personal = PersonalPeer::doSelectOne($c); $personal->setLinkedin($lor->getData()); $personal->save(); $c = new Criteria(); $c->add(LoruserPeer::USER_ID, $this->getUser()->getAttribute('userid')); $c->addJoin(LoruserPeer::LORVALUES_ID, LorvaluesPeer::ID); $c->add(LorvaluesPeer::LORFIELDS_ID, sfConfig::get('app_lor_linkedin')); $lors = LorvaluesPeer::doSelect($c); foreach ($lors as $lor) { $c = new Criteria(); $c->add(LoruserPeer::LORVALUES_ID, $lor->getId()); $loruser = LoruserPeer::doSelectOne($c); $loruser->delete(); $lor->delete(); } $this->redirect('/personal/show'); }
public static function retrievePreceptorBySfGuardUserId($sf_guard_user_id) { $criteria = new Criteria(); $criteria->add(PersonPeer::USER_ID, $sf_guard_user_id); $criteria->addJoin(PersonPeer::ID, PersonalPeer::PERSON_ID); $criteria->add(PersonalPeer::PERSONAL_TYPE, PersonalType::PRECEPTOR); return PersonalPeer::doSelectOne($criteria); }
/** * This method returns the personals ids related in head_personal_personal of the head_personal. The User must be headPreceptor * * @return array //with the Ids of the personal related */ public function getPersonalIds() { if ($this->isHeadPreceptor()) { $c = new Criteria(); $c->add(PersonPeer::USER_ID, $this->getGuardUser()->getId()); $c->addJoin(PersonPeer::ID, PersonalPeer::PERSON_ID); $c->addJoin(HeadPersonalPersonalPeer::HEAD_PERSONAL_ID, PersonalPeer::ID); $head_personal = PersonalPeer::doSelectOne($c); $personal_in = array(); if (!is_null($head_personal)) { foreach ($head_personal->getHeadPersonalPersonals() as $head_personal_personal) { $personal_in[] = $head_personal_personal->getPersonalId(); } } return $personal_in; } }
public function executeInvite() { $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->getRequestParameter('id')); $this->personal = PersonalPeer::doSelectOne($c); $this->email = $this->personal->getEmail(); if ($this->getUser()->getAttribute('userid')) { $this->userid = $this->getUser()->getAttribute('userid'); $user = UserPeer::retrieveByPK($this->userid); $this->fullname = $user->getFullname(); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->userid); $personal = PersonalPeer::doSelectOne($c); $this->senderemail = $personal->getEmail(); } else { $this->fullname = ""; $this->senderemail = ""; } $g = new Captcha(); $this->getUser()->setAttribute('captcha', $g->generate()); }
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 function executeManagenewuser() { $ids = $this->getRequestParameter('ids'); $action = $this->getRequestParameter('action1'); $value = 5; if ($action == 'approve') { $value = 0; } elseif ($action == 'reject') { $value = 1; } $idlist = split(',', $ids); $count = 0; foreach ($idlist as $id) { $user = UserPeer::retrieveByPK($id); $previslocked = 5; if ($user) { $previslocked = $user->getIslocked(); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $personal = PersonalPeer::doSelectOne($c); $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname(); $newmail = $personal->getEmail(); $newpassword = $this->generatePassword(); $user->setIslocked($value); $user->setPassword($newpassword); $count++; $sendermail = sfConfig::get('app_from_mail'); $sendername = sfConfig::get('app_from_name'); $to = $newmail; $subject = "Registration request for ITBHU Global Org"; if ($action == 'approve') { $userrole = new Userrole(); $userrole->setRoleId(sfConfig::get('app_role_user')); $userrole->setUserId($id); $userrole->save(); $academic = new Academic(); $academic->setDegree($user->getDegree()->getName()); $academic->setDegreeflag($user->getDegreeflag()); $academic->setYear($user->getGraduationyear()); $academic->setYearflag($user->getGraduationyearflag()); $academic->setDepartment($user->getBranchname()); $academic->setDepartmentflag($user->getBranchflag()); $academic->setUserId($id); $academic->save(); $c->clear(); $c->add(ClaiminfoPeer::USER_ID, $id); $claiminfo = ClaiminfoPeer::doSelectOne($c); $user->setUsername($claiminfo->getDusername()); $user->save(); $body = ' Dear ' . $name . ', Congrats!! You are now connected to ITBHU GLOBAL. Your Login Details are: Username: '******' Password: '******' Admin, ITBHU Global '; //check if there is any authorizer for the batch.. $ca = new Criteria(); $ca->add(UserPeer::BRANCH_ID, $user->getBranchId()); $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear()); $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID); $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth')); $authuser = UserPeer::doSelectOne($ca); if (!$authuser) { $body1 = ' Dear ' . $name . ', Currently there are no authorizers for your batch. You are invited for the role of Authorizer for your batch. To accept/reject the invitation, login to http://itbhuglobal.org and go to settings->invitations. On accepting the role, you\'ll recieve approval requests from y- our batchmates. Admin, ITBHU Global '; } } elseif ($action == 'reject') { if ($previslocked == 2) { $user->setIslocked('1'); $user->save(); } else { $user->delete(); $personal->delete(); } $body = ' Dear ' . $name . ', Your connect request to ITBHU GLOBAL is not approved as your details couldn\'t be verified. Admin, ITBHU Global '; } $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body); if ($body1) { $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body1); $body1 = ''; $user->setIsinvited('4'); $user->save(); } } } if ($action == 'approve') { if ($count == 0) { $this->setFlash('newuseraction', 'No user(s) selected to approve'); } else { $this->setFlash('newuseraction', 'You have successfuly approved ' . $count . ' users'); } } elseif ($action == 'reject') { if ($count == 0) { $this->setFlash('newuseraction', 'No user(s) selected to reject'); } else { $this->setFlash('newuseraction', 'You have successfuly rejected ' . $count . ' users'); } } if ($this->getRequestParameter('from') == 'new') { return $this->redirect('auth/newregister'); } else { return $this->redirect('auth/pendinglist'); } }