/**
  * Allows a user to set the attendance status of a user
  *
  */
 public function takeRollAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
     } else {
         $this->_helper->pageTitle('workshop-instructor-takeRoll:title');
     }
     $get = Zend_Registry::get('getFilter');
     $messages = array();
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $eventId = $get->eventId;
     $event = new Event();
     $status = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $eventId);
     if ($status != 'instructor' && !$this->_helper->hasAccess('view-all-instructor-pages')) {
         throw new Ot_Exception_Access('msg-error-notInstructor');
     }
     $attendee = new Event_Attendee();
     $where = $attendee->getAdapter()->quoteInto('eventId = ?', $eventId);
     $attendees = $attendee->fetchAll($where);
     $hasAttendedList = array();
     $attendeeList = array();
     foreach ($attendees as $a) {
         $attendeeList[] = $a->accountId;
         if ($a->attended) {
             $hasAttendedList[] = $a->accountId;
         }
     }
     if (count($attendeeList) == 0) {
         throw new Ot_Exception_Data('msg-error-noAttendees');
     }
     $form = $event->rollForm(array('eventId' => $eventId, 'attendees' => $hasAttendedList));
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $attendees = $form->getValue('attendees');
             if (!is_array($attendees)) {
                 $attendees = array($attendees);
             }
             // make checked people as attended
             $where = $attendee->getAdapter()->quoteInto("accountId IN (?)", $attendees) . ' AND ' . $attendee->getAdapter()->quoteInto('eventId = ?', $eventId);
             $data = array('attended' => 1);
             $attendee->update($data, $where);
             // make everyone else as not attended
             $where = $attendee->getAdapter()->quoteInto("accountId NOT IN (?)", $attendees) . ' AND ' . $attendee->getAdapter()->quoteInto('eventId = ?', $eventId);
             $data = array('attended' => 0);
             $attendee->update($data, $where);
             $this->_helper->flashMessenger->addMessage('msg-info-attendanceRecorded');
             $this->_redirect('/workshop/instructor/?eventId=' . $eventId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->form = $form;
 }