/**
	 * Test that a MemberID was set on MultiFormSession if
	 * a member is logged in.
	 */
	function testMemberLogging() {
		$session = new MultiFormSession();
		$session->write();
		
		if($memberID = Member::currentUserID()) {
			$this->assertEquals($memberID, $session->SubmitterID);
		}
	}
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->form->getController()->getDateTime()->Event()->RegistrationTimeLimit) {
         return;
     }
     $isInDb = $this->getRegistration()->isInDB();
     $hasTickets = (bool) count($this->getRegistration()->Tickets());
     if ($isInDb || $hasTickets) {
         $this->getRegistration()->write();
     }
     $this->RegistrationID = $this->getRegistration()->ID;
 }
Example #3
0
 /**
  * Set up the session.
  * 
  * If MultiFormSessionID isn't set, we assume that this is a new
  * multiform that requires a new session record to be created.
  * 
  * @TODO Fix the fact you can continually refresh and create new records
  * if MultiFormSessionID isn't set.
  * 
  * @TODO Not sure if we should bake the session stuff directly into MultiForm.
  * Perhaps it would be best dealt with on a separate class?
  */
 protected function setSession()
 {
     $this->session = $this->getCurrentSession();
     // If there was no session found, create a new one instead
     if (!$this->session) {
         $this->session = new MultiFormSession();
         $this->session->write();
     }
     // Create encrypted identification to the session instance if it doesn't exist
     if (!$this->session->Hash) {
         $this->session->Hash = sha1($this->session->ID . '-' . microtime());
         $this->session->write();
     }
 }
Example #4
0
	/**
	 * Set up the session.
	 * 
	 * If MultiFormSessionID isn't set, we assume that this is a new
	 * multiform that requires a new session record to be created.
	 * 
	 * @TODO Fix the fact you can continually refresh and create new records
	 * if MultiFormSessionID isn't set.
	 * 
	 * @TODO Not sure if we should bake the session stuff directly into MultiForm.
	 * Perhaps it would be best dealt with on a separate class?
	 */
	protected function setSession() {
		// If there's a MultiFormSessionID variable set, find that, otherwise create a new session
		if(isset($_GET['MultiFormSessionID'])) {
			$this->session = $this->getSessionRecord($_GET['MultiFormSessionID']);
		}

		// If there was no session found, create a new one instead
		if(!$this->session) {
			$this->session = new MultiFormSession();
			$this->session->write();
		}
			
		// Create encrypted identification to the session instance if it doesn't exist
		if(!$this->session->Hash) {
			$this->session->Hash = sha1($this->session->ID . '-' . microtime());
			$this->session->write();
		}
	}
 /**
  * Return the currently used {@link MultiFormSession}
  * @return MultiFormSession|boolean FALSE
  */
 public function getCurrentSession()
 {
     if (!$this->currentSessionHash) {
         $this->currentSessionHash = $this->controller->request->getVar('MultiFormSessionID');
         if (!$this->currentSessionHash) {
             return false;
         }
     }
     $this->session = MultiFormSession::get()->filter(array("Hash" => $this->currentSessionHash, "IsComplete" => 0))->first();
     return $this->session;
 }