/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param BoardMember $value A BoardMember object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(BoardMember $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Create/Edit board member * CODE: board_member_create */ public function executeBoardMember(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('person_id')) { $this->person = PersonPeer::retrieveByPK($request->getParameter('person_id')); } if ($request->getParameter('id')) { $b_member = BoardMemberPeer::retrieveByPK($request->getParameter('id')); $this->person = PersonPeer::retrieveByPK($b_member->getPersonId()); $this->personID = $this->person->getId(); $this->title = 'Edit board member'; $query = "SELECT * FROM board_member "; $query .= "WHERE person_id =" . $this->personID . " order by id desc"; $con = Propel::getConnection(); $stmt = $con->prepare($query); $stmt->execute(); while ($rs = $stmt->fetch()) { $this->flag = $rs['startyear']; $this->setendyear = $rs['endyear']; $this->ID = $rs['id']; break; } $success = 'Board Member information successfully edited!'; $this->person = PersonPeer::retrieveByPK($b_member->getPersonId()); } else { $b_member = new BoardMember(); $this->title = 'Add new board member'; $success = 'New Board Member information successfully created!'; $this->title1 = 'Board member served history'; $this->person = PersonPeer::retrieveByPK($request->getParameter('person_id')); $this->personID = $this->person->getId(); $query = "SELECT * FROM board_member "; $query .= "WHERE person_id =" . $this->personID; $con = Propel::getConnection(); $stmt = $con->prepare($query); $stmt->execute(); $this->value = array(); while ($rs = $stmt->fetch(PDO::FETCH_OBJ)) { $this->value[] = $rs; } } $this->form = new BoardMemberForm($b_member); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('bmem')); if ($this->form->isValid() && $this->form->getValue('startyear') && $this->form->getValue('endyear') && $request->getParameter('person_id')) { if ($request->getParameter('person_id')) { $b_member->setPersonId($this->person->getId()); } if ($request->getParameter('id')) { $b_member->setId($request->getParameter('id')); } $b_member->setStartyear($this->form->getValue('startyear')); $b_member->setEndyear($this->form->getValue('endyear')); $b_member->save(); $this->getUser()->setFlash('success', $success); $this->redirect('@person_view?id=' . $this->person->getId()); } else { $this->getUser()->setFlash('warning', 'Please choise start year and end year!'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : 'member/index'; } $this->b_member = $b_member; }
/** * Declares an association between this object and a BoardMember object. * * @param BoardMember $v * @return BoardCommittee The current object (for fluent API support) * @throws PropelException */ public function setBoardMember(BoardMember $v = null) { if ($v === null) { $this->setBoardMemberId(NULL); } else { $this->setBoardMemberId($v->getId()); } $this->aBoardMember = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the BoardMember object, it will not be re-added. if ($v !== null) { $v->addBoardCommittee($this); } return $this; }
$boardMember->formReposts($smarty); } else { // If errors occur while trying to create board member, we need to return with errors. if ($boardMember->formProcessUpdate()) { handle_errors($boardMember->get_boardMemberFormErrors()); $boardMember->formReposts($smarty); } else { handle_success($boardMember->get_boardMemberFormSuccess()); } } } } } // if GET request to Delete board member if (isset($_GET['boardMemberID']) && $_GET['boardMemberID'] > 0 && $_GET['delete'] == 1) { $boardMember = new BoardMember($_GET['boardMemberID']); if ($boardMember->formProcessDelete()) { handle_errors($boardMember->get_boardMemberFormErrors()); $boardMember->formReposts($smarty); } else { handle_success($boardMember->get_boardMemberFormSuccess()); } } // Build list of board members $BoardMembers = new BoardMembers(); $BoardMembersArray = $BoardMembers->get_BoardMemberArray(0); if (count($BoardMembersArray) > 0) { $count = 0; $smarty->assign('boardMemberID', array()); $smarty->assign('boardMemberName', array()); $smarty->assign('boardMemberFirstName', array());