public function execute(&$value, &$error) { $id = $this->getContext()->getRequest()->getParameter('id'); $name = $value; $c = new Criteria(); $c->add(UserPeer::USERNAME, $name); $user = UserPeer::doSelectOne($c); $condition = true; if ($user) { if ($id && $id == $user->getId()) { $condition = true; } else { $error = 'User ' . $user->getUsername() . ' already Exist.'; $condition = false; } } $roles = RolePeer::doSelect(new Criteria()); $found = false; foreach ($roles as $role) { if ($this->getContext()->getRequest()->getParameter($role->getName(), 0) == 1) { $found = true; } } if (!$found) { $error = 'Please select atleast one role'; $condition = false; } return $condition; }
public static function GetRole() { $c = new Criteria(); $c->add(RolePeer::STATUS, Constant::RECORD_STATUS_ACTIVE); $c->addAscendingOrderByColumn(RolePeer::TITLE); $roles = RolePeer::doSelect($c); return $roles; }
public function executeShow() { $this->users = UsersPeer::retrieveByPk($this->getRequestParameter('id')); $c = new Criteria(); $c->add(RolePeer::ID, $this->users->getRoleId()); $this->roles = RolePeer::doSelect($c); $this->forward404Unless($this->users); }
public static function retrieveByName($pk, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(RolePeer::DATABASE_NAME); $criteria->add(RolePeer::NAME, $pk); $v = RolePeer::doSelect($criteria, $con); return !empty($v) > 0 ? $v[0] : null; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(RolePeer::DATABASE_NAME); $criteria->add(RolePeer::ID, $pks, Criteria::IN); $objs = RolePeer::doSelect($criteria, $con); } return $objs; }
public function allRoles() { $oCriteria = new Criteria(); $oCriteria->addAscendingOrderByColumn(RolePeer::ROLE_KEY); return WidgetJsonFileModule::jsonBaseObjects(RolePeer::doSelect($oCriteria), array('role_key', 'description')); }
function executeNotification(sfWebRequest $request) { $c = new Criteria(); $c->addAscendingOrderByColumn(RolePeer::TITLE); $this->role_list = RolePeer::doSelect($c); ///////////////////////////////////////// $c = new Criteria(); $c->addAscendingOrderByColumn(RoleNotificationPeer::MID); $this->notification_list = RoleNotificationPeer::doSelectJoinAll($c); ////////////////////////////////////////// }
public function executeList() { $this->roles = RolePeer::doSelect(new Criteria()); }
/** * Fixes default roles for the Application * If must have roles don't exist it tries to create them */ protected function fixDefaultRoles() { $role_names = sfConfig::get('app_default_roles', array()); $c = new Criteria(); $c->add(RolePeer::TITLE, $role_names, Criteria::IN); $roles = RolePeer::doSelect($c); $lower_names = array_map('strtolower', $role_names); foreach ($roles as $role) { $key = array_search(strtolower($role->getTitle()), $lower_names); if ($key !== false) { unset($role_names[$key]); } } unset($roles); if (count($role_names)) { foreach ($role_names as $name) { $role = new Role(); $role->setTitle($name); $role->save(); } $this->getUser()->setFlash('warning', 'Roles have recovered: ' . implode(', ', $role_names)); } }
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'); } }
<?php $c = new Criteria(); $c->add(RolePeer::ACTIVE, array('active' => 1)); $roles = RolePeer::doSelect($c); $roles_array = array(); for ($index = 0; $index < sizeof($roles); $index++) { $id = $roles[$index]->getId(); $label = $roles[$index]->getRoleLable(); $roles_array[$id] = $label; } $selected_id = $users->getRoleId(); $selected_id ? $selected_id = $selected_id : ($selected_id = '2'); echo select_tag('role_id', options_for_select($roles_array, $selected_id));
public function executeLogin() { $username = $this->getRequestParameter('username'); $password = $this->getRequestParameter('password'); if ($username) { $c = new Criteria(); $c->add(UserPeer::USERNAME, $username); $user = UserPeer::doSelectOne($c); if ($user) { $islocked = $user->getIslocked(); if ($islocked == "0") { $salt = md5(sfConfig::get('app_salt_password')); if (sha1($salt . $password) == $user->getPassword()) { $c = new Criteria(); $c->addJoin(UserPeer::ID, UserrolePeer::USER_ID); $c->addJoin(UserrolePeer::ROLE_ID, RolePeer::ID); $c->add(UserPeer::USERNAME, $username); $roles = RolePeer::doSelect($c); foreach ($roles as $role) { $this->getUser()->addCredential($role->getName()); } $this->getUser()->setAuthenticated(true); $this->getUser()->setAttribute('username', $user->getUsername()); $this->getUser()->setAttribute('userid', $user->getId()); date_default_timezone_set('Asia/Kolkata'); $user->setLastlogin(time()); $user->save(); //initiate phpBB session $ch = curl_init(); $timeout = 20; curl_setopt($ch, CURLOPT_URL, "http://192.168.1.209:80/phpBB3/init_session.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); if (sfConfig::get('app_proxy_hasproxy')) { curl_setopt($ch, CURLOPT_PROXY, sfConfig::get('app_proxy_proxyhost') . ':' . sfConfig::get('app_proxy_proxyport')); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_POST, 1); $sid = trim(curl_exec($ch)); curl_close($ch); $this->getUser()->setAttribute('bbsid', trim($sid)); //phpBB sign in $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $personal = PersonalPeer::doSelectOne($c); $email = $personal->getEmail(); $browserdetail = $_SERVER['HTTP_USER_AGENT']; $con = sfContext::getInstance()->getDatabaseConnection('v2bb'); $mapQr = "select user_id as id from phpbb_users where user_email = '" . $email . "'"; $mapRslt = $con->executeQuery($mapQr); $bbuid = ""; while ($mapRslt->next()) { $bbuid = $mapRslt->getString('id'); } if ($bbuid) { $upQr = "update phpbb_sessions set session_user_id = '" . $bbuid . "', session_browser='" . $browserdetail . "', session_admin='1' where session_id = '" . $sid . "'"; $upRslt = $con->executeQuery($upQr); } else { $insQr = "insert into phpbb_users(user_type, user_email, username, username_clean, user_regdate, group_id, user_ip, user_lang, user_dateformat, user_topic_sortby_type, user_topic_sortby_dir, user_post_sortby_type, user_post_sortby_dir) values('0', '" . $email . "', '" . $user->getUsername() . "', '" . $user->getUsername() . "', '" . time() . "', '2', '::1', 'en', 'D M d, Y g:i a', 't', 'd', 't', 'a')"; $con->executeQuery($insQr); $bbuid = mysql_insert_id(); $upQr = "update phpbb_sessions set session_user_id = '" . $bbuid . "', session_browser='assssdddd', session_admin='1' where session_id = '" . $sid . "'"; $rslt = $con->executeQuery($upQr); } return $this->redirect('user/welcome'); } else { $this->setFlash('login', 'Invalid username / password.'); return $this->redirect('/'); } } else { $this->setFlash('login', 'Username is not Enabled.'); return $this->redirect('/'); } } else { $this->setFlash('login', 'Username doesn\'t Exist.'); return $this->redirect('/'); } } }