From: Verdon V. <ve...@us...> - 2009-03-03 15:18:37
|
Update of /cvsroot/phpwebsite-comm/modules/elections/class In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6393/class Modified Files: ELEC_Ballot.php ELEC_Candidate.php ELEC_Forms.php Election.php Log Message: final tweaks for 2.0.1 Index: ELEC_Candidate.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Candidate.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ELEC_Candidate.php 2 Mar 2009 19:59:11 -0000 1.2 --- ELEC_Candidate.php 3 Mar 2009 15:18:26 -0000 1.3 *************** *** 360,364 **** ! public function viewTpl() { $tpl = $this->getCustoms(); --- 360,364 ---- ! public function viewTpl($votebox=false) { $tpl = $this->getCustoms(); *************** *** 371,375 **** $tpl['CANDIDATE_THUMBNAIL'] = null; } ! $tpl['VOTE_BOX'] = $this->getVoteBox(); return $tpl; --- 371,377 ---- $tpl['CANDIDATE_THUMBNAIL'] = null; } ! if ($votebox) { ! $tpl['VOTE_BOX'] = $this->getVoteBox(); ! } return $tpl; *************** *** 377,392 **** - /* not used - public function viewTplVote() - { - $tpl['CANDIDATE_TITLE'] = $this->viewLink(); - $tpl['DESCRIPTION'] = $this->getDescription(true); - $tpl['LINKS'] = $this->candidateLinks(); - $tpl['VOTE_BOX'] = $this->getVoteBox(); - - return $tpl; - } - */ - public function save() { --- 379,382 ---- *************** *** 461,465 **** PHPWS_Core::initModClass('elections', 'ELEC_Ballot.php'); $ballot = new Elections_Ballot($this->ballot_id); - // echo $ballot->can_vote(); if (isset($_REQUEST['Candidate_Vote'][$this->id])) { $match = $_REQUEST['Candidate_Vote'][$this->id]; --- 451,454 ---- *************** *** 467,481 **** $match = null; } ! if ($ballot->can_vote() == '1') { ! if ($ballot->ranking) { ! $tpl = null; $tpl .= '<input type="button" name="-" onclick=\'javascript: subtractQty("Candidate_Vote['.$this->id.']");\' value="-" />'; ! $tpl .= '<input type="text" name="Candidate_Vote['.$this->id.']" id="Candidate_Vote['.$this->id.']" size="3" value="'.$match.'" />'; $tpl .= '<input type="button" name="+" onclick=\'javascript: document.getElementById("Candidate_Vote['.$this->id.']").value++;\' value="+" />'; - } else { - $tpl = PHPWS_Form::formCheckBox("Candidate_Vote[".$this->id."]", 1, $match, $this->id); } } else { ! $tpl = null; } --- 456,471 ---- $match = null; } ! ! if ($ballot->ranking) { ! $tpl = null; ! if (javascriptEnabled()) { $tpl .= '<input type="button" name="-" onclick=\'javascript: subtractQty("Candidate_Vote['.$this->id.']");\' value="-" />'; ! } ! $tpl .= '<input type="text" name="Candidate_Vote['.$this->id.']" id="Candidate_Vote['.$this->id.']" size="3" value="'.$match.'" />'; ! if (javascriptEnabled()) { $tpl .= '<input type="button" name="+" onclick=\'javascript: document.getElementById("Candidate_Vote['.$this->id.']").value++;\' value="+" />'; } } else { ! $tpl = PHPWS_Form::formCheckBox("Candidate_Vote[".$this->id."]", 1, $match, $this->id); } Index: ELEC_Ballot.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Ballot.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ELEC_Ballot.php 2 Mar 2009 19:59:11 -0000 1.2 --- ELEC_Ballot.php 3 Mar 2009 15:18:26 -0000 1.3 *************** *** 291,298 **** } ! if ($this->can_vote() == '1') { ! javascript('modules/elections/utilities'); ! // javascript('modules/elections/checkvotes'); $form = new PHPWS_Form('elections_vote'); --- 291,301 ---- } + $voteable = $this->can_vote(); ! if ($voteable == '1') { ! if (javascriptEnabled()) { ! javascript('modules/elections/utilities'); ! // javascript('modules/elections/checkvotes'); ! } $form = new PHPWS_Form('elections_vote'); *************** *** 300,304 **** $form->addHidden('uop', 'post_vote'); $form->addHidden('ballot_id', $this->id); ! // $form->addSubmit(dgettext('elections', 'Vote')); $tpl = $form->getTemplate(); --- 303,309 ---- $form->addHidden('uop', 'post_vote'); $form->addHidden('ballot_id', $this->id); ! if (!javascriptEnabled()) { ! $form->addSubmit(dgettext('elections', 'Vote')); ! } $tpl = $form->getTemplate(); *************** *** 308,313 **** $type = 'check'; } ! $submit_vars = array("MIN"=>$this->minchoice, 'MAX'=>$this->maxchoice, 'SUBMIT_LABEL'=>dgettext('elections', 'Vote'), 'TYPE'=>$type); ! $tpl['VOTE_BUTTON'] = javascript('modules/elections/checkvotes', $submit_vars); $tpl['MSG'] = '<b>' . dgettext('elections', 'Voting is open for this election.') . '</b>'; if ($this->maxchoice > 1) { --- 313,320 ---- $type = 'check'; } ! if (javascriptEnabled()) { ! $submit_vars = array("MIN"=>$this->minchoice, 'MAX'=>$this->maxchoice, 'SUBMIT_LABEL'=>dgettext('elections', 'Vote'), 'TYPE'=>$type); ! $tpl['VOTE_BUTTON'] = javascript('modules/elections/checkvotes', $submit_vars); ! } $tpl['MSG'] = '<b>' . dgettext('elections', 'Voting is open for this election.') . '</b>'; if ($this->maxchoice > 1) { *************** *** 317,321 **** } } else { ! $tpl['MSG'] = '<b>' . $this->can_vote() . '</b>'; } --- 324,328 ---- } } else { ! $tpl['MSG'] = '<b>' . $voteable . '</b>'; } *************** *** 394,402 **** if ($candidates) { foreach ($candidates as $candidate) { ! // if ($this->can_vote()) { ! // $tpl['candidates'][] = $candidate->viewTplVote(); ! // } else { $tpl['candidates'][] = $candidate->viewTpl(); ! // } } } else { --- 401,409 ---- if ($candidates) { foreach ($candidates as $candidate) { ! if ($voteable == '1') { ! $tpl['candidates'][] = $candidate->viewTpl(true); ! } else { $tpl['candidates'][] = $candidate->viewTpl(); ! } } } else { *************** *** 608,612 **** function can_vote() { - // old $now = date("Y-m-d H:i:s"); $now = mktime(); $msg = NULL; --- 615,618 ---- *************** *** 621,638 **** $msg = '1'; /* if it's not are they logged in */ - // } elseif (isset(Current_User::getId())) { } elseif (isset($_SESSION['User']->username)) { /* is there a group restriction */ if (isset($this->votegroups)){ $votegroups = explode(":", $this->votegroups); - // $votegroups_array = array_intersect($votegroups, $this->listGroupsID()); $votegroups_array = array_intersect($votegroups, $_SESSION['User']->_groups); // test print_r($votegroups_array); exit; /* if they're in the group */ - // old if(count($votegroups_array) > 0 or $_SESSION['OBJ_user']->isDeity()) { if(count($votegroups_array) > 0 or Current_User::isUnrestricted('elections')) { $msg = '1'; } else { ! $msg = dgettext('elections', 'You are not a member of an authorized voting group for this election'); } /* no group restriction */ --- 627,641 ---- $msg = '1'; /* if it's not are they logged in */ } elseif (isset($_SESSION['User']->username)) { /* is there a group restriction */ if (isset($this->votegroups)){ $votegroups = explode(":", $this->votegroups); $votegroups_array = array_intersect($votegroups, $_SESSION['User']->_groups); // test print_r($votegroups_array); exit; /* if they're in the group */ if(count($votegroups_array) > 0 or Current_User::isUnrestricted('elections')) { $msg = '1'; } else { ! $msg = dgettext('elections', 'You are not a member of an authorized voting group for this ballot.'); } /* no group restriction */ *************** *** 642,658 **** /* no public and not logged in */ } else { ! $msg = dgettext('elections', 'Public voting is not allowed for this election'); } /* they've already voted */ } else { ! $msg = dgettext('elections', 'You have already voted in this election'); } /* voting is closed */ } else { ! $msg = dgettext('elections', 'Voting has closed for this election'); } /* voting isn't open yet */ } else { ! $msg = dgettext('elections', 'Voting has not opened yet for this election'); } --- 645,661 ---- /* no public and not logged in */ } else { ! $msg = dgettext('elections', 'Public voting is not allowed for this ballot. You must log in first.'); } /* they've already voted */ } else { ! $msg = dgettext('elections', 'You have already voted in this ballot.'); } /* voting is closed */ } else { ! $msg = dgettext('elections', 'Voting has closed for this ballot.'); } /* voting isn't open yet */ } else { ! $msg = dgettext('elections', 'Voting has not opened yet for this ballot.'); } *************** *** 686,708 **** - /* not used, old example - function listGroupsID() - { - if (!(list($row) = $GLOBALS["core"]->sqlSelect("mod_users", "user_id", $_SESSION["OBJ_user"]->user_id))) - exit("Error listGroups: Unable to load user"); - - $groups = $row["groups"]; - - if ($groups) { - $groupList = explode(":", $groups); - } else { - $groupList = array(); - } - return $groupList; - } - */ - - - --- 689,692 ---- Index: ELEC_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Forms.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ELEC_Forms.php 2 Mar 2009 19:59:11 -0000 1.2 --- ELEC_Forms.php 3 Mar 2009 15:18:26 -0000 1.3 *************** *** 131,137 **** $pager = new DBPager('elections_candidates', 'Elections_Candidate'); $pager->setModule('elections'); ! if (!Current_User::isUnrestricted('elections')) { ! // $pager->addWhere('active', 1); ! } if ($ballot_id > 0) { $pager->addWhere('ballot_id', $ballot_id); --- 131,135 ---- $pager = new DBPager('elections_candidates', 'Elections_Candidate'); $pager->setModule('elections'); ! if ($ballot_id > 0) { $pager->addWhere('ballot_id', $ballot_id); *************** *** 315,319 **** $candidate = & $this->election->candidate; $ballot = & $this->election->ballot; ! //print_r($candidate); print_r($ballot); $form->addHidden('module', 'elections'); $form->addHidden('aop', 'post_candidate'); --- 313,317 ---- $candidate = & $this->election->candidate; $ballot = & $this->election->ballot; ! $form->addHidden('module', 'elections'); $form->addHidden('aop', 'post_candidate'); *************** *** 496,504 **** $form->addHidden('aop', 'edit_candidate'); - // PHPWS_Core::initModClass('elections', 'ELEC_Ballot.php'); - // $db = new PHPWS_DB('elections_ballots'); - // $db->addColumn('id'); - // $db->addColumn('title'); - // $result = $db->getObjects('Elections_Ballot'); $result = $this->getAllBallots(); --- 494,497 ---- *************** *** 641,651 **** $text = dgettext('elections', 'Purge voting log'); $extra = true; - // $js['QUESTION'] = 'Are you sure you want to delete these records?'; - // $js['ADDRESS'] = PHPWS_Text::linkAddress('elections', array('aop'=>'get_report', 'purge_votes'=>1), true); - // $js['LINK'] = 'Purge voting log'; - // $js['TITLE'] = 'Purge voting log'; - // $js['CLASS'] = 'confirm-link'; - // $js['type'] = 'button'; - // return Layout::getJavascript('confirm', $js); } else { $text = dgettext('elections', 'Submit'); --- 634,637 ---- *************** *** 655,659 **** if ($extra) { $question = dgettext('elections', 'Are you sure you wish to purge the selected logs'); - // $form->setExtra($type, 'onclick="confirmAction(\'' . $question . '\', this.form)"'); this.value='Saving...'; return performPrePostChecks(); $form->setExtra($type, 'onclick="this.value=\'' . $text . '\'; return confirmAction(\'' . $question . '\', this.form)"'); } --- 641,644 ---- Index: Election.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/Election.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Election.php 2 Mar 2009 19:59:11 -0000 1.8 --- Election.php 3 Mar 2009 15:18:26 -0000 1.9 *************** *** 482,488 **** public function postCandidate() { - //print_r($_POST); exit; $this->loadCandidate(); - //print_r($this->candidate); exit; if (empty($_POST['title'])) { --- 482,486 ---- |