.

VotingController Class Reference

Controller for Voting related actions. More...

Inheritance diagram for VotingController:
ControllerBase IController IEventSink

List of all members.

Public Member Functions

  action_voting_vote (PageData $page_data, $instance)
  Process a vote.
  get_routes ()
  Return array of IRoute this controller takes responsability.

Detailed Description

Controller for Voting related actions.

Definition at line 5 of file voting.controller.php.


Member Function Documentation

VotingController::action_voting_vote ( PageData page_data,
instance  
)

Process a vote.

Definition at line 19 of file voting.controller.php.

00019                                                                            {
00020                 Session::start();
00021                 Load::components('referer');
00022                 $referer = Referer::current();
00023                 if ($referer->is_internal()) {
00024                         History::push($referer->build());
00025                 }
00026                 $instance = InstanceReferenceSerializier::string_to_instance($instance);
00027                 if (empty($instance)) {
00028                         History::go_to(0, new Status(tr('Instance you voted for not found', 'voting')));
00029                         exit;
00030                 }
00031                 
00032                 if (!$page_data->has_post_data()) {
00033                         History::go_to(0, new Status(tr('No vote submitted', 'voting')));
00034                         exit;                   
00035                 }
00036                 
00037                 $created = false;
00038                 Load::models('votes');
00039                 $status = Votes::create($page_data->get_post()->get_array(), $instance, $created);
00040                 if ($status->is_ok()) {
00041                         $status = new Message(tr('Your vote has been counted', 'voting'));
00042                 }
00043                 History::go_to(0, $status);
00044         }
VotingController::get_routes (  ) 

Return array of IRoute this controller takes responsability.

Reimplemented from ControllerBase.

Definition at line 9 of file voting.controller.php.

00009                                      {
00010                 $ret = array(
00011                         new InstanceReferenceRoute('http://voting/vote/{instance:inst}%', $this, 'voting_vote', new NoCacheCacheManager()),
00012                 );
00013                 return $ret;
00014         }

The documentation for this class was generated from the following file: