コード例 #1
0
 public function executeDelete()
 {
     $role = RolePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($role);
     $role->delete();
     return $this->redirect('role/list');
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: RolePeer.php プロジェクト: lejacome/hospital-mgt
 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;
 }
コード例 #5
0
ファイル: RolePeer.php プロジェクト: Ayaan123/alumnisangam
 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;
 }
コード例 #6
0
ファイル: BaseRoleQuery.php プロジェクト: raulito1500/mdokeos
 /**
  * Find object by primary key
  * Use instance pooling to avoid a database query if the object exists
  * <code>
  * $obj  = $c->findPk(12, $con);
  * </code>
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con an optional connection object
  *
  * @return    Role|array|mixed the result, formatted by the current formatter
  */
 public function findPk($key, $con = null)
 {
     if (null !== ($obj = RolePeer::getInstanceFromPool((string) $key)) && $this->getFormatter()->isObjectFormatter()) {
         // the object is alredy in the instance pool
         return $obj;
     } else {
         // the object has not been requested yet, or the formatter is not an object formatter
         $criteria = $this->isKeepQuery() ? clone $this : $this;
         $stmt = $criteria->filterByPrimaryKey($key)->getSelectStatement($con);
         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
     }
 }
コード例 #7
0
 public function executeLogin()
 {
     $c = new Criteria();
     $c->add(UsersPeer::USER_NAME, $this->getRequestParameter('login'));
     $c->add(UsersPeer::USER_PWD, $this->getRequestParameter('password'));
     $user_record = UsersPeer::doSelectOne($c);
     if ($user_record) {
         $this->getUser()->setAuthenticated(true);
         $c = new Criteria();
         $c->add(RolePeer::ID, $user_record->getRoleId());
         $user_role = RolePeer::doSelectOne($c);
         $this->getUser()->addCredential($user_role->getRoleName());
         return $this->redirect('users');
     } else {
         $this->getRequest()->setError('login', 'incorrect entry');
         return $this->forward('security', 'index');
     }
 }
コード例 #8
0
ファイル: components.class.php プロジェクト: yasirgit/afids
 public function executeTeamNotepad(sfWebRequest $request)
 {
     $this->person_role = PersonRolePeer::getByPersonIdOne($this->getUser()->getId());
     $s_role = RolePeer::getByTitle('Staff');
     $a_role = RolePeer::getByTitle('Administrator');
     $role_ids = array();
     //    foreach ($person_roles as $person_role){
     //      $roleId = $person_role->getRoleId();
     //      $s_role_id = $s_role->getId();
     //      if($roleId==$s_role_id){
     //        $role_ids[] = $a_role->getId();
     //      }else{
     //        $role_ids[] = $roleId;
     //      }
     //    }
     $team_notes = "";
     if ($this->person_role) {
         $team_notes = TeamNotePeer::getTeamNote();
     }
     $this->team_notes = $team_notes;
     $this->allowed_tags = $this->getAllowedTags();
 }
コード例 #9
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * 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));
     }
 }
コード例 #10
0
ファイル: BaseUserPeer.php プロジェクト: rapila/cms-base
 /**
  * Method to invalidate the instance pool of all tables related to users
  * by a foreign key with ON DELETE CASCADE
  */
 public static function clearRelatedInstancePool()
 {
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in PagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePeer::clearInstancePool();
     // Invalidate objects in PagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePeer::clearInstancePool();
     // Invalidate objects in PagePropertyPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePropertyPeer::clearInstancePool();
     // Invalidate objects in PagePropertyPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePropertyPeer::clearInstancePool();
     // Invalidate objects in PageStringPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PageStringPeer::clearInstancePool();
     // Invalidate objects in PageStringPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PageStringPeer::clearInstancePool();
     // Invalidate objects in ContentObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ContentObjectPeer::clearInstancePool();
     // Invalidate objects in ContentObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ContentObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectHistoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectHistoryPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectHistoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectHistoryPeer::clearInstancePool();
     // Invalidate objects in LanguagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguagePeer::clearInstancePool();
     // Invalidate objects in LanguagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguagePeer::clearInstancePool();
     // Invalidate objects in TranslationPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TranslationPeer::clearInstancePool();
     // Invalidate objects in TranslationPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TranslationPeer::clearInstancePool();
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in GroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupPeer::clearInstancePool();
     // Invalidate objects in GroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupPeer::clearInstancePool();
     // Invalidate objects in GroupRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupRolePeer::clearInstancePool();
     // Invalidate objects in GroupRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupRolePeer::clearInstancePool();
     // Invalidate objects in RolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RolePeer::clearInstancePool();
     // Invalidate objects in RolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RolePeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in RightPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RightPeer::clearInstancePool();
     // Invalidate objects in RightPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RightPeer::clearInstancePool();
     // Invalidate objects in DocumentPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentPeer::clearInstancePool();
     // Invalidate objects in DocumentPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentPeer::clearInstancePool();
     // Invalidate objects in DocumentDataPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentDataPeer::clearInstancePool();
     // Invalidate objects in DocumentDataPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentDataPeer::clearInstancePool();
     // Invalidate objects in DocumentTypePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentTypePeer::clearInstancePool();
     // Invalidate objects in DocumentTypePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentTypePeer::clearInstancePool();
     // Invalidate objects in DocumentCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentCategoryPeer::clearInstancePool();
     // Invalidate objects in DocumentCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentCategoryPeer::clearInstancePool();
     // Invalidate objects in TagPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagPeer::clearInstancePool();
     // Invalidate objects in TagPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagPeer::clearInstancePool();
     // Invalidate objects in TagInstancePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagInstancePeer::clearInstancePool();
     // Invalidate objects in TagInstancePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagInstancePeer::clearInstancePool();
     // Invalidate objects in LinkPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkPeer::clearInstancePool();
     // Invalidate objects in LinkPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkPeer::clearInstancePool();
     // Invalidate objects in LinkCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkCategoryPeer::clearInstancePool();
     // Invalidate objects in LinkCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkCategoryPeer::clearInstancePool();
     // Invalidate objects in ReferencePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ReferencePeer::clearInstancePool();
     // Invalidate objects in ReferencePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ReferencePeer::clearInstancePool();
 }
コード例 #11
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 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);
     //////////////////////////////////////////
 }
コード例 #12
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
    /**
     * Displays a person information
     * CODE: person_view
     * @param sfWebRequest $request
     * @return unknown_type
     */
    public function executeView(sfWebRequest $request)
    {
        #security
        if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
            $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
            $this->redirect('dashboard/index');
        }
        $this->person = PersonPeer::retrieveByPK($request->getParameter('id'));
        $this->forward404Unless($this->person);
        $this->requester = RequesterPeer::getByPersonId($this->person->getId());
        $this->camp_id = $request->getParameter('camp_id');
        if ($this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
            # get all roles
            $roles = RolePeer::getForSelect();
            # get assigned roles
            $person_roles = PersonRolePeer::getByPersonId($this->person->getId());
            $assoc_roles = array();
            foreach ($person_roles as $person_role) {
                $assoc_roles[] = $person_role->getRoleId();
            }
            $this->assoc_roles = $assoc_roles;
            # prepare widget
            $this->widget = new sfWidgetFormSelectDoubleList(array('choices' => $roles, 'label_unassociated' => 'Full List', 'label_associated' => 'Assigned Roles', 'associate' => 'lt;', 'associate_class' => 'btn-right', 'unassociate' => 'gt;', 'unassociate_class' => 'btn-left', 'template' => <<<EOF
<div class="%class%" style="padding-top: 0px;">
  <div class="holder">
    <h4>%label_unassociated%</h4>
    %unassociated%
  </div>
  <ul class="btn-switch">
    <li>%associate%</li>
    <li>%unassociate%</li>
  </ul>
  <div class="holder">
    <h4>%label_associated%</h4>
    %associated%
  </div>
    
  <br style="clear: both" />
  <script type="text/javascript">
    sfDoubleList.init(document.getElementById('%id%'), '%class_select%');
  </script>
</div>
EOF
));
            $this->form = new PersonForm();
        }
        # email lists associated to the person
        $this->email_lists = EmailListPeer::doSelect(new Criteria());
        $this->subscribed_list = EmailListPersonPeer::getEmailListIdsByPersonId($this->person->getId());
    }
コード例 #13
0
ファイル: BaseRole.php プロジェクト: rapila/cms-base
 public function mayOperate($sOperation, $oUser = false)
 {
     $oUser = RolePeer::getRightsUser($oUser);
     $bIsAllowed = false;
     if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && RolePeer::mayOperateOnOwn($oUser, $this, $sOperation)) {
         $bIsAllowed = true;
     } else {
         if (RolePeer::mayOperateOn($oUser, $this, $sOperation)) {
             $bIsAllowed = true;
         }
     }
     FilterModule::getFilters()->handleRoleOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed));
     return $bIsAllowed;
 }
コード例 #14
0
ファイル: BaseTeamNotePeer.php プロジェクト: yasirgit/afids
 /**
  * Selects a collection of TeamNote objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of TeamNote objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseTeamNotePeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseTeamNotePeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     TeamNotePeer::addSelectColumns($c);
     $startcol2 = TeamNotePeer::NUM_COLUMNS - TeamNotePeer::NUM_LAZY_LOAD_COLUMNS;
     RolePeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (RolePeer::NUM_COLUMNS - RolePeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(TeamNotePeer::ROLE_ID), array(RolePeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = TeamNotePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = TeamNotePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = TeamNotePeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             TeamNotePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Role rows
         $key2 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = RolePeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = RolePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 RolePeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (TeamNote) to the collection in $obj2 (Role)
             $obj1->setRole($obj2);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #15
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 public function executeSaveTeamNote(sfWebRequest $request)
 {
     $note = $request->getParameter('note');
     $a_role = RolePeer::getByTitle('Admin');
     $id = $a_role->getId();
     # validate
     //$c = new Criteria();
     //$c->add(PersonRolePeer::PERSON_ID, $this->getUser()->getId());
     //$c->add(PersonRolePeer::ROLE_ID, $id);
     //if (PersonRolePeer::doCount($c) == 0) $this->forward404();
     # save
     $team_note = TeamNotePeer::retrieveByPK($id);
     if (!$team_note) {
         $team_note = new TeamNote();
     }
     $team_note->setRoleId($id);
     $team_note->setNote(strip_tags($note, sfConfig::get('app_allowed_note_tags')));
     $team_note->save();
     return sfView::NONE;
 }
コード例 #16
0
ファイル: BaseUser.php プロジェクト: lejacome/hospital-mgt
 /**
  * Get the associated Role object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Role The associated Role object.
  * @throws     PropelException
  */
 public function getRole(PropelPDO $con = null)
 {
     if ($this->aRole === null && $this->role_id !== null) {
         $c = new Criteria(RolePeer::DATABASE_NAME);
         $c->add(RolePeer::ID, $this->role_id);
         $this->aRole = RolePeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aRole->addUsers($this);
         		 */
     }
     return $this->aRole;
 }
コード例 #17
0
ファイル: BaseRole.php プロジェクト: yasirgit/afids
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = RolePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTitle($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
 }
コード例 #18
0
 public static function doSelectJoinAllExceptUser(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserrolePeer::addSelectColumns($c);
     $startcol2 = UserrolePeer::NUM_COLUMNS - UserrolePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     RolePeer::addSelectColumns($c);
     $startcol3 = $startcol2 + RolePeer::NUM_COLUMNS;
     $c->addJoin(UserrolePeer::ROLE_ID, RolePeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = UserrolePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = RolePeer::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->getRole();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addUserrole($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initUserroles();
             $obj2->addUserrole($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
コード例 #19
0
 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('/');
         }
     }
 }
コード例 #20
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 public function executeIndex(sfWebRequest $request)
 {
     $text = $request->getParameter('search_by');
     $this->results = array();
     $this->messages = array();
     $this->uris = array();
     //person search
     if ($this->getUser()->hasRights('person_index')) {
         $c = new Criteria();
         $c1 = $c->getNewCriterion(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $c2 = $c->getNewCriterion(PersonPeer::LAST_NAME, $text . '%', Criteria::LIKE);
         //$c->setDistinct(PersonPeer::FIRST_NAME);
         //$c->setDistinct(PersonPeer::LAST_NAME);
         $c->add($c1->addOr($c2));
         $this->results['person'] = PersonPeer::doCount($c);
         $this->messages['person'] = ' person results';
         $this->uris['person'] = 'person/index?filter=1&findperson=1&firstname=' . $text;
     }
     //passenger search
     if ($this->getUser()->hasRights('passenger_index')) {
         $c = new Criteria();
         $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['passenger'] = PassengerPeer::doCount($c);
         $this->messages['passenger'] = ' passenger results';
         $this->uris['passenger'] = 'passenger/index?filter=1&firstname=' . $text;
     }
     //companion search
     if ($this->getUser()->hasRights('companion_index')) {
         $c = new Criteria();
         $c->add(CompanionPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['companion'] = CompanionPeer::doCount($c);
         $this->messages['companion'] = ' companion results';
         $this->uris['companion'] = 'companion/index?filter=1&name=' . $text;
     }
     //mission search
     if ($this->getUser()->hasRights('mission_index')) {
         $c = new Criteria();
         if (is_numeric($text)) {
             $c->add(MissionPeer::ID, $text . '%', Criteria::LIKE);
             $this->results['mission'] = MissionPeer::doCount($c);
             $this->uris['mission'] = 'mission/index?filter=1&miss_id=' . $text;
         } else {
             $c->addJoin(MissionPeer::PASSENGER_ID, PassengerPeer::ID, Criteria::LEFT_JOIN);
             $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
             $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
             $this->results['mission'] = MissionPeer::doCount($c);
             $this->uris['mission'] = 'mission/index?filter=1&pass_fname=' . $text;
         }
         $this->messages['mission'] = ' mission results';
     }
     //leg search
     if ($this->getUser()->hasRights('leg_index')) {
         $c = new Criteria();
         $c->addJoin(MissionLegPeer::MISSION_ID, MissionPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(MissionPeer::PASSENGER_ID, PassengerPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['leg'] = MissionLegPeer::doCount($c);
         $this->messages['leg'] = ' mission leg results';
         $this->uris['leg'] = 'missionLeg/index?filter=1&pass_fname=' . $text;
     }
     //requester search
     if ($this->getUser()->hasRights('requester_index')) {
         $c = new Criteria();
         $c->addJoin(RequesterPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['requester'] = RequesterPeer::doCount($c);
         $this->messages['requester'] = ' requester results';
         $this->uris['requester'] = 'requester/index?filter=1&firstname=' . $text;
     }
     //agency search
     if ($this->getUser()->hasRights('agency_index')) {
         $c = new Criteria();
         $c->add(AgencyPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['agency'] = AgencyPeer::doCount($c);
         $this->messages['agency'] = ' agency results';
         $this->uris['agency'] = 'agency/index?filter=1&name=' . $text;
     }
     //coordinator search
     if ($this->getUser()->hasRights('coordinator_index')) {
         $c = new Criteria();
         $c->addJoin(CoordinatorPeer::MEMBER_ID, MemberPeer::ID);
         $c->addJoin(PersonPeer::ID, MemberPeer::PERSON_ID);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['coordinator'] = CoordinatorPeer::doCount($c);
         $this->messages['coordinator'] = ' coordinator results';
         $this->uris['coordinator'] = 'coordinator/index?filter=1&firstname=' . $text;
     }
     //camp search
     if ($this->getUser()->hasRights('camp_index')) {
         $c = new Criteria();
         $c->add(CampPeer::CAMP_NAME, $text . '%', Criteria::LIKE);
         $this->results['camp'] = CampPeer::doCount($c);
         $this->messages['camp'] = ' camp results';
         $this->uris['camp'] = 'camp/index?filter=1&camp_name=' . $text;
     }
     //airport search
     if ($this->getUser()->hasRights('airport_index')) {
         $c = new Criteria();
         $c->add(AirportPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['airport'] = AirportPeer::doCount($c);
         $this->messages['airport'] = ' airport results';
         $this->uris['airport'] = 'airport/index?filter=1&name=' . $text;
     }
     //member search
     if ($this->getUser()->hasRights('member_index')) {
         $c = new Criteria();
         if (is_numeric($text)) {
             $c->add(MemberPeer::ID, $text . '%', Criteria::LIKE);
             $this->results['member'] = MemberPeer::doCount($c);
             $this->uris['member'] = 'member/index?filter=1&member_id=' . $text;
         } else {
             $c->addJoin(MemberPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
             $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
             $this->results['member'] = MemberPeer::doCount($c);
             $this->uris['member'] = 'member/index?filter=1&firstname=' . $text;
         }
         $this->messages['member'] = ' member results';
     }
     //pilot search
     if ($this->getUser()->hasRights('pilot_index')) {
         $c = new Criteria();
         $c->addJoin(PilotPeer::MEMBER_ID, MemberPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(MemberPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['pilot'] = PilotPeer::doCount($c);
         $this->messages['pilot'] = ' pilot results';
         $this->uris['pilot'] = 'pilot/index?filter=1&firstname=' . $text;
     }
     //pilot request search
     if ($this->getUser()->hasRights('mission_available_list')) {
         $c = new Criteria();
         if ($text) {
             $c->add(PilotRequestPeer::DATE, date('Y-m-d', strtotime($text)), Criteria::GREATER_EQUAL);
         }
         $this->results['pilotRequest'] = PilotRequestPeer::doCount($c);
         $this->messages['pilotRequest'] = ' pilot request results';
         $this->uris['pilotRequest'] = 'pilotRequest/index?filter=1&req_date2=' . $text;
     }
     //mission request search
     if ($this->getUser()->hasRights('mission_request_index')) {
         $c = new Criteria();
         if ($text) {
             $c->add(MissionRequestPeer::REQUESTER_DATE, date('Y-m-d', strtotime($text)), Criteria::GREATER_EQUAL);
         }
         $this->results['missionRequest'] = MissionRequestPeer::doCount($c);
         $this->messages['missionRequest'] = ' missionRequest results';
         $this->uris['missionRequest'] = 'missionRequest/index?filter=1&request_date2=' . $text;
     }
     //mission report search
     if ($this->getUser()->hasRights('mission_report_review')) {
         $c = new Criteria();
         $c->add(MissionReportPeer::COPILOT_NAME, $text . '%', Criteria::LIKE);
         $this->results['missionReport'] = MissionReportPeer::doCount($c);
         $this->messages['missionReport'] = ' missionReport results';
         $this->uris['missionReport'] = 'mission_report/review?filter=1&pilot_name=' . $text;
     }
     //role search
     if (1 == 1) {
         $c = new Criteria();
         if (isset($text)) {
             $c->add(RolePeer::TITLE, $text . '%', Criteria::LIKE);
         }
         $this->results['role'] = RolePeer::doCount($c);
         $this->messages['role'] = ' role results';
         $this->uris['role'] = 'role_permission/index?search_by=' . $text;
     }
     $this->text = $text;
 }
コード例 #21
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');
     }
 }
コード例 #22
0
<?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));
コード例 #23
0
 /**
  * Selects a collection of User objects pre-filled with all related objects except Employee.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of User objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptEmployee(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserPeer::addSelectColumns($c);
     $startcol2 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS;
     RolePeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (RolePeer::NUM_COLUMNS - RolePeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(UserPeer::ROLE_ID), array(RolePeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = UserPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = UserPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = UserPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             UserPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Role rows
         $key2 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = RolePeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = RolePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 RolePeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (User) to the collection in $obj2 (Role)
             $obj2->addUser($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #24
0
 /**
  * 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;
 }
コード例 #25
0
 public function allRoles()
 {
     $oCriteria = new Criteria();
     $oCriteria->addAscendingOrderByColumn(RolePeer::ROLE_KEY);
     return WidgetJsonFileModule::jsonBaseObjects(RolePeer::doSelect($oCriteria), array('role_key', 'description'));
 }
コード例 #26
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * Member add or edit
  * CODE: member_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     $new_pilot = false;
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Member'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     //FROM PERSON VIEW
     if ($request->getParameter('id')) {
         $member = MemberPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($member);
         $this->title = 'Edit member';
         $success = 'Member information has been successfully changed!';
         $this->person = $member->getPerson();
     } else {
         $this->person = PersonPeer::retrieveByPK($request->getParameter('person_id'));
         $this->forward404Unless($this->person);
         $member = new Member();
         $this->title = 'Add new member';
         $success = 'Member information has been successfully created!';
     }
     $this->form = new MemberForm($member);
     $this->back = $request->getReferer();
     $this->member = $member;
     if (strstr($request->getReferer(), 'person/view')) {
         $this->f_back = 1;
     } elseif (strstr($request->getReferer(), '/member/view/id')) {
         $this->f_back = 3;
     } elseif (strstr($request->getReferer(), '/member')) {
         $this->f_back = 2;
     }
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('mem'));
         if ($this->form->isValid() && $this->form->getValue('member_class_id') != 0 && $this->form->getValue('flight_status')) {
             if ($request->getParameter('person_id')) {
                 $member->setPersonId($request->getParameter('person_id'));
             }
             $person = PersonPeer::retrieveByPK($request->getParameter('person_id'));
             $member->setDateOfBirth($this->form->getValue('date_of_birth'));
             $member->setWeight($this->form->getValue('weight'));
             $member->setLanguages($this->form->getValue('languages'));
             if ($this->form->getValue('wing_id') == 0) {
                 $member->setWingId(null);
             } else {
                 $member->setWingId($this->form->getValue('wing_id'));
             }
             if ($this->form->getValue('secondary_wing_id') == 0) {
                 $member->setSecondaryWingId(null);
             } else {
                 $member->setSecondaryWingId($this->form->getValue('secondary_wing_id'));
             }
             // setting external_id
             $c = new Criteria();
             $c->add(MemberPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
             $c->addDescendingOrderByColumn(MemberPeer::ID);
             $external_member = MemberPeer::doSelectOne($c);
             $external_id = $external_member->getExternalId();
             $currentExternalId = $external_id + 1;
             $member->setExternalId($currentExternalId);
             $member->setJoinDate($this->form->getValue('join_date'));
             $member->setMemberClassId($this->form->getValue('member_class_id'));
             $member->setSpouseName($this->form->getValue('spouse_name'));
             $member->setCoordinatorNotes($this->form->getValue('coordinator_notes'));
             $member->setFlightStatus($this->form->getValue('flight_status'));
             if ($this->form->getValue('co_pilot') == null) {
                 $member->setCoPilot(0);
             } else {
                 $member->setCoPilot($this->form->getValue('co_pilot'));
             }
             $new_member = $member->isNew();
             if ($new_member) {
                 $content = $this->getUser()->getName() . ' added new Member: ' . $person->getFirstName();
                 ActivityPeer::log($content);
             }
             $member->save();
             //
             $wing_jobs = $request->getParameter('wing_job1[]');
             if ($request->getParameter('wing_job1')) {
                 $old_mem_wing_jobs = MemberWingJobPeer::getWingJob($member->getId());
                 foreach ($old_mem_wing_jobs as $old_mem_wing_job) {
                     $old_mem_wing_job->delete();
                 }
                 foreach ($wing_jobs as $wing_job) {
                     $member_wing_job = new MemberWingJob();
                     $member_wing_job->setMemberId($member->getId());
                     $member_wing_job->setWingJobId($wing_job);
                     $member_wing_job->save();
                 }
             }
             if (strtolower($member->getFlightStatus()) == 'command pilot') {
                 // if command-pilot then make pilot
                 $pilot = new Pilot();
                 $pilot->setMemberId($member->getId());
                 $pilot->setLicenseType('Default');
                 $pilot->setIfr(0);
                 $pilot->setMultiEngine(0);
                 $pilot->save();
                 $new_pilot = true;
             } else {
                 $new_pilot = false;
             }
             $this->getUser()->setFlash('success', $success);
             $last = $request->getParameter('back');
             $back_url = 'member/index';
             if (strstr($last, 'member/edit')) {
                 $back_url = 'member/index';
             } elseif (strstr($last, 'person/view')) {
                 if (isset($this->person)) {
                     $back_url = '@person_view?id=' . $this->person->getId();
                 }
             } elseif (strstr($last, 'member/view')) {
                 $back_url = '@member_view?id=' . $member->getId();
             }
             //with error validation back url
             if (strstr($request->getReferer(), 'last/1')) {
                 $back_url = '@person_view?id=' . $this->person->getId();
             } elseif (strstr($request->getReferer(), 'last/2')) {
                 $back_url = 'member/index';
             } elseif (strstr($request->getReferer(), 'last/3')) {
                 $back_url = '@member_view?id=' . $member->getId();
             }
             // role for new member
             if ($new_member) {
                 $role = '@Member';
                 $member_role = RolePeer::getByTitle($role);
                 if ($member_role) {
                     $person_role = new PersonRole();
                     $person_role->setPersonId($this->person->getId());
                     $person_role->setRoleId($member_role->getId());
                     $person_role->save();
                 } else {
                     $url = $this->generateUrl('default_index', array('module' => 'role'), true);
                     $this->getUser()->setFlash('warning', '"' . $role . '" role not found! Please navigate ' . $url . ' and fix.');
                 }
             }
             // role for new pilot
             if ($new_pilot) {
                 $role = '@Pilot';
                 $pilot_role = RolePeer::getByTitle($role);
                 $is_true = PersonRolePeer::getIsTrue($this->person->getId(), $pilot_role->getId());
                 if (!$is_true) {
                     $person_role = new PersonRole();
                     $person_role->setPersonId($this->person->getId());
                     $person_role->setRoleId($pilot_role->getId());
                     $person_role->save();
                 } else {
                     $url = $this->generateUrl('default_index', array('module' => 'role'), true);
                     //$this->getUser()->setFlash('warning', '"'.$role.'" role not found! Please navigate '.$url.' and fix');
                 }
             }
             $this->redirect($back_url);
         } else {
             $this->getUser()->setFlash('warning', 'Please confirm flight status and choose the member class!');
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : 'member/index';
     }
     $this->member = $member;
 }
コード例 #27
0
ファイル: BaseGroupRolePeer.php プロジェクト: rapila/cms-base
 /**
  * Selects a collection of GroupRole objects pre-filled with all related objects except UserRelatedByUpdatedBy.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of GroupRole objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(GroupRolePeer::DATABASE_NAME);
     }
     GroupRolePeer::addSelectColumns($criteria);
     $startcol2 = GroupRolePeer::NUM_HYDRATE_COLUMNS;
     GroupPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
     RolePeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(GroupRolePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
     $criteria->addJoin(GroupRolePeer::ROLE_KEY, RolePeer::ROLE_KEY, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = GroupRolePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = GroupRolePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = GroupRolePeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             GroupRolePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Group rows
         $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = GroupPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = GroupPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 GroupPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (GroupRole) to the collection in $obj2 (Group)
             $obj2->addGroupRole($obj1);
         }
         // if joined row is not null
         // Add objects for joined Role rows
         $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = RolePeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = RolePeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 RolePeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (GroupRole) to the collection in $obj3 (Role)
             $obj3->addGroupRole($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #28
0
ファイル: BaseRole.php プロジェクト: raulito1500/mdokeos
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = RolePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setRoleId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setRoleName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setRoleComment($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDefaultRole($arr[$keys[3]]);
     }
 }
コード例 #29
0
ファイル: BaseTeamNote.php プロジェクト: yasirgit/afids
 /**
  * Get the associated Role object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Role The associated Role object.
  * @throws     PropelException
  */
 public function getRole(PropelPDO $con = null)
 {
     if ($this->aRole === null && $this->role_id !== null) {
         $c = new Criteria(RolePeer::DATABASE_NAME);
         $c->add(RolePeer::ID, $this->role_id);
         $this->aRole = RolePeer::doSelectOne($c, $con);
         // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
         $this->aRole->setTeamNote($this);
     }
     return $this->aRole;
 }
コード例 #30
0
ファイル: viewSuccess.php プロジェクト: yasirgit/afids
  <?php 
    }
    ?>
 <?php 
} else {
    ?>
    <div class="person-table-data">
    <h3>Security Role</h3>
    <table style="width: 100px">
    <?php 
    foreach ($assoc_roles as $assoc_role) {
        ?>
    <tr class="alt">
      <td class="cell-1">
    <?php 
        $ro = RolePeer::retrieveByPK($assoc_role);
        echo $ro->getTitle();
        echo "<br/>";
        ?>
      </td>
    </tr>
    <?php 
    }
    ?>
    </table>
  </div>
 <?php 
}
?>
    <?php 
if ($sf_user->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {