Example #1
0
 public function executeDelete()
 {
     $userrole = UserrolePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($userrole);
     $userrole->delete();
     return $this->redirect('userrole/list');
 }
Example #2
0
 public static function retrieveByPKUser($pk, $user, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria(UserrolePeer::DATABASE_NAME);
     $criteria->add(UserrolePeer::ROLE_ID, $pk);
     $criteria->add(UserrolePeer::USER_ID, $user);
     $v = UserrolePeer::doSelect($criteria, $con);
     return !empty($v) > 0 ? $v[0] : null;
 }
Example #3
0
 public function getPrivacyenabledvalue($flag, $value, $thisid)
 {
     $visitorid = sfContext::getInstance()->getUser()->getAttribute('userid');
     $visitor = UserPeer::retrieveByPK($visitorid);
     $c = new Criteria();
     $c->add(UserrolePeer::USER_ID, $visitorid);
     $c->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_admin'));
     $isadmin = UserrolePeer::doSelectOne($c);
     if ($visitorid == $thisid || $isadmin) {
         return $value;
     } else {
         switch ($flag) {
             case 1:
                 return sfConfig::get('app_privacy_message');
                 break;
             case 2:
                 $c = new Criteria();
                 $c->add(UserPeer::ID, $thisid);
                 $c->addJoin(UserPeer::ID, UserfriendPeer::USER_ID);
                 $c->addJoin(UserfriendPeer::FRIEND_ID, FriendPeer::ID);
                 $c->add(FriendPeer::USER_ID, $visitorid);
                 $frienduser = UserPeer::doSelectOne($c);
                 if ($frienduser) {
                     return $value;
                 } else {
                     return sfConfig::get('app_privacy_message');
                 }
                 break;
             case 3:
                 if ($visitorid) {
                     return $value;
                 } else {
                     return sfConfig::get('app_privacy_message');
                 }
                 break;
             case 4:
                 return $value;
                 break;
             default:
                 return $value;
         }
     }
 }
Example #4
0
 public function executeAssignrole()
 {
     $roleid = $this->getRequestParameter('role');
     $userid = $this->getRequestParameter('assignee');
     $user = UserPeer::retrieveByPK($userid);
     $c = new Criteria();
     $c->add(UserrolePeer::USER_ID, $userid);
     $c->add(UserrolePeer::ROLE_ID, $roleid);
     $userrole = UserrolePeer::doSelectOne($c);
     if ($userrole) {
         $this->setFlash('notice', 'This role is already assigned for <b>' . $user->getFullname() . '</b>');
         $this->redirect('/search/result');
     }
     $userrole = new Userrole();
     $userrole->setUserId($userid);
     $userrole->setRoleId($roleid);
     $userrole->save();
     $this->setFlash('notice', 'Role assigned successfully for <b>' . $user->getFullname() . '</b>');
     $this->redirect('/search/result');
 }
 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(UserrolePeer::ID, $pks, Criteria::IN);
         $objs = UserrolePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #6
0
 public function getUserrolesJoinUser($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseUserrolePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUserroles === null) {
         if ($this->isNew()) {
             $this->collUserroles = array();
         } else {
             $criteria->add(UserrolePeer::ROLE_ID, $this->getId());
             $this->collUserroles = UserrolePeer::doSelectJoinUser($criteria, $con);
         }
     } else {
         $criteria->add(UserrolePeer::ROLE_ID, $this->getId());
         if (!isset($this->lastUserroleCriteria) || !$this->lastUserroleCriteria->equals($criteria)) {
             $this->collUserroles = UserrolePeer::doSelectJoinUser($criteria, $con);
         }
     }
     $this->lastUserroleCriteria = $criteria;
     return $this->collUserroles;
 }
Example #7
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = UserrolePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setRoleId($arr[$keys[2]]);
     }
 }