function add()
 {
     // Somebody input an email because they want to be notified
     if ($this->RequestHandler->isGet()) {
         return;
     }
     // Parse input
     $data = array();
     $data['email'] = $this->data['Invite']['email'];
     // Sanitize
     $methods = array('email' => 'email');
     $data = arraySanitize($data, $methods);
     // Validation
     $this->Invite =& ClassRegistry::init('Invite');
     $this->Invite->set($data);
     if (!$this->Invite->validates()) {
         $this->set('vErrors', $this->Invite->invalidFields());
         return;
     }
     // Save
     $this->Invite->create();
     if (!$this->Invite->save($data)) {
         $this->_Flash('There were errors saving your Invitation Request, please try again', 'mean', null);
         $this->set('vErrors', $this->Invite->invalidFields());
         return;
     }
     // Redirect to thank you page
     $this->redirect('/pages/thank_you');
 }
 function add($project_id = null)
 {
     // Add a State
     $project_id = intval($project_id);
     // Get Project
     $this->Project =& ClassRegistry::init('Project');
     $this->Project->contain(array('State'));
     $conditions = array('Project.id' => $project_id, 'Project.live' => 1);
     $project = $this->Project->find('first', compact('conditions'));
     if (empty($project)) {
         $this->_Flash('Did not find Project', 'mean', $this->referer('/'));
     }
     // Must be my Project
     if ($project['Project']['user_id'] != $this->DarkAuth->id) {
         $this->_Flash('Not your Project', 'mean', $this->referer('/'));
     }
     if ($this->RequestHandler->isGet()) {
         return;
     }
     // Parse input
     $data = array();
     $data['project_id'] = $project['Project']['id'];
     $data['live'] = 1;
     $data['key'] = Inflector::slug($this->data['State']['key']);
     // Sanitize
     $methods = array('key' => array('paranoid', array('_')));
     $data = arraySanitize($data, $methods);
     // Validate
     $this->State =& ClassRegistry::init('State');
     $this->State->set($data);
     if (!$this->State->validates()) {
         return false;
     }
     // Must be only key
     $conditions = array('State.key' => $data['key'], 'State.project_id' => $project['Project']['id'], 'State.live' => 1);
     $state = $this->State->find('first', compact('conditions'));
     if (!empty($state)) {
         $this->State->invalidate('key', 'Key already used');
         return false;
     }
     // Save
     $this->State->create();
     if (!$this->State->save($data)) {
         $this->_Flash('Failed saving new State', 'mean', $this->referer('/'));
     }
     $data['id'] = $this->State->id;
     $pData = array();
     $pData = $data;
     $pData['Step'] = array('Condition' => array(), 'Action' => array());
     // Nicely saved
     echo json_encode($pData);
     exit;
     //$this->_Flash('Added new Step','nice',$this->referer('/'));
 }
 function edit($team_id = null)
 {
     // NOT DONE
     // Edit the info for your Team(s)
     $team_id = intval($team_id);
     // Get Team
     $this->Team =& ClassRegistry::init('Team');
     $this->Team->contain(array('Attendee'));
     $conditions = array('Team.id' => $team_id, 'Team.event_id' => $this->EAuth->event_id, 'Team.live' => 1);
     $team = $this->Team->find('first', compact('conditions'));
     // No Team?
     if (empty($team)) {
         $this->_Flash('Unable to find Team', 'mean', '/teams');
     }
     // I am on Team?
     // - could also check my EA['Team']
     // - I bet this causes an error later
     $user_ids = Set::extract($team['Attendee'], '{n}.user_id');
     if (!in_array($this->DarkAuth->id, $user_ids)) {
         $this->_Flash('You are not on that Team', 'mean', '/teams/view/' . $team_id);
     }
     // Set Values
     $this->set(compact('team'));
     if ($this->RequestHandler->isGet()) {
         // Insert as defaults
         $this->data = $team;
         return;
     }
     // Parse input
     // - same as create()
     $data = array();
     $data['id'] = $team['Team']['id'];
     $data['name'] = $this->data['Team']['name'];
     $data['bio'] = $this->data['Team']['bio'];
     $data['public_message'] = $this->data['Team']['public_message'];
     // Sanitize
     $methods = array('name' => 'escape', 'bio' => 'escape', 'public_message' => 'escape');
     $data = arraySanitize($data, $methods);
     // Validation
     $this->Team->set($data);
     if (!$this->Team->validates()) {
         $this->_Flash('Please fix errors', 'mean', null);
         return;
     }
     // Save
     $this->Team->create();
     if (!$this->Team->save($data)) {
         $this->_Flash('There were errors saving your Team, please try again', 'mean', null);
         return;
     }
     // Redirect
     $this->_Flash('Changes have been saved', 'nice', '/teams/view/' . $team['Team']['id']);
 }
 function register_not_allowed_yet()
 {
     // Basic signup
     exit;
     $this->User =& ClassRegistry::init('User');
     if ($this->RequestHandler->isGet()) {
         return;
     }
     // Parse input
     $data = array();
     $data['email'] = trim($this->data['User']['email']);
     $data['pswd'] = $this->data['User']['pswd'];
     // Sanitize
     $methods = array('email' => 'email');
     $data = arraySanitize($data, $methods);
     // Already registered with that Email?
     // - support other services as well
     $conditions = array('User.email' => $data['email']);
     $user = $this->User->find('first', compact('conditions'));
     if (!empty($user)) {
         $this->_Flash('Email already in use', 'mean', null);
         return;
     }
     // Validation
     $this->User->set($data);
     if (!$this->User->validates()) {
         return;
     }
     // Save
     if (!$this->User->save($data)) {
         return false;
     }
     // Add as an Attendee
     $user_id = $this->User->id;
     // Already an Attendee
     // - default is as a participant/member
     $this->Attendee =& ClassRegistry::init('Attendee');
     $conditions = array('Attendee.user_id' => $user_id, 'Attendee.event_id' => EVENT_ID);
     $attendee = $this->Attendee->find('first', compact('conditions'));
     if (!empty($attendee)) {
     }
 }