Пример #1
0
    /**
     * 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());
    }