public function createChildren($children) { if (isset($children['new'])) { foreach (@$children['new'] as $nOption) { if (!empty($nOption)) { $opt = new CampaignChoice(); $opt->setCampaign($this->getCampaign()); $opt->setChoice(stripslashes($nOption)); $opt->setParent($this->getId()); $opt->save(); } } } if (isset($children['exist'])) { foreach (@$children['exist'] as $optId => $nOption) { $opt = new CampaignChoice($optId); if (!empty($nOption)) { $opt->setCampaign($this->getCampaign()); $opt->setChoice(stripslashes($nOption)); $opt->setParent($this->getId()); $opt->save(); } else { $opt->delete(); } } } }
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'); }