Beispiel #1
0
 function getUserInterface()
 {
     require_once SITE_ROOT . '/modules/Campaigns/include/Campaign.php';
     if (@$_REQUEST['hash'] == 'register') {
         $register = new CampaignRegister();
         $form = $register->getRegisterForm();
         $this->smarty->assign('form', $form);
         if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['register_submit'])) {
             return $this->smarty->fetch('registersucceed.tpl');
         }
         return $this->smarty->fetch('register.tpl');
     } else {
         if (@$_REQUEST['hash'] == 'Retrieve_Key') {
             $form = CampaignUser::getRetievalForm($err);
             if ($form->isSubmitted() && isset($_POST['submit']) && $form->validate()) {
                 if ($err) {
                     return "<h1>Failed</h1><br /><p>Your e-mail address was invalid.</p>";
                 }
                 return "<h1>Success</h1><br /><p>Hash key recovery has been sent.</p>";
             }
             $this->smarty->assign('form', $form);
             return $this->smarty->fetch('hashretrieve.tpl');
         } else {
             if (!is_null(@$_REQUEST['hash']) && !empty($_REQUEST['hash'])) {
                 $cData = Campaign::checkHash($_REQUEST['hash']);
                 if ($cData) {
                     $campaign = new Campaign($cData);
                     if (strpos($campaign->getStatus(), 'progress') > 0) {
                         $form = $campaign->getVoteForm($_REQUEST['hash']);
                         $this->smarty->assign('campaign', $campaign);
                         $this->smarty->assign('form', $form);
                         if ($form->validate() && $form->isSubmitted() && isset($_POST['vote_submit'])) {
                             foreach ($_POST['vote_choice'] as $selChoice) {
                                 $uChoice = new CampaignChoice($selChoice);
                                 $uChoice->setVote($_REQUEST['hash']);
                             }
                             return $this->smarty->fetch('votesucceed.tpl');
                         } else {
                             $this->parentSmarty->addJS('/modules/Campaigns/js/frontEnd.js');
                             return $this->smarty->fetch('vote.tpl');
                         }
                     }
                 }
                 return $this->smarty->fetch('votefail.tpl');
             }
         }
     }
     $form = Campaign::getHashForm();
     $this->smarty->assign('form', $form);
     return $this->smarty->fetch('voteinsert.tpl');
 }
Beispiel #2
0
 public static function parseCsv($csvfile)
 {
     $handle = fopen($csvfile, 'r');
     while (($data = fgetcsv($handle)) != false) {
         $newRecip = new CampaignUser();
         $newRecip->setName($data[0]);
         $newRecip->setEmail($data[1]);
         $newRecip->setGroup($_SESSION['authenticated_user']->getAuthGroup());
         $newRecip->save();
     }
 }
Beispiel #3
0
 public static function getRetievalForm(&$err = false, $target = '/Vote/Retrieve_Key')
 {
     $form = new Form('campaign_hash_retrieval', 'POST', $target);
     $form->addElement('text', 'email', 'Your E-mail Address');
     $form->addElement('submit', 'submit', 'Retrieve');
     $form->addRule('email', 'You must enter a valid e-mail address', 'required');
     if ($form->isSubmitted() && isset($_POST['submit'])) {
         if ($form->validate()) {
             $err = !CampaignUser::getByEmail($form->exportValue('email'));
         }
     }
     return $form;
 }