예제 #1
0
require "inc/common_http.php";
require "inc/libs/PHP-FineDiff/finediff.php";

$draft = new Draft(@$_GET['draft1']);
if (!$draft->id) {
	error(_("The requested draft does not exist."));
}

$draft2 = new Draft(@$_GET['draft2']);
if (!$draft2->id) {
	error(_("The requested draft does not exist."));
}

$proposal = new Proposal($draft->proposal);

$issue = $proposal->issue();

$_SESSION['ngroup'] = $issue->area()->ngroup;

list($supporters, $proponents, $is_supporter, $is_proponent) = $proposal->supporters();

if (!$is_proponent and !Login::$admin) {
	error(_("You are not a proponent of this proposal!"));
}


html_head( sprintf(_("<a%s>Proposal %d</a>, version differences"), ' href="proposal.php?id='.$proposal->id.'"', $proposal->id) );

?>

<section class="proposal_info">
예제 #2
0
	/**
	 * compose subject and body
	 *
	 * @return array
	 */
	private function content() {

		// ngroup
		if ($this->period) {
			$ngroup = $this->period->ngroup();
		} elseif ($this->issue) {
			$ngroup = $this->issue->area()->ngroup();
		} elseif ($this->proposal) {
			$ngroup = $this->proposal->issue()->area()->ngroup();
		} else {
			trigger_error("ngroup could not be determined", E_USER_WARNING);
			$ngroup = null;
		}
		$body = _("Group").": ".$ngroup->name."\n\n";

		$separator = "-----8<--------------------------------------------------------------------\n"; // 75 characters

		switch ($this->type) {
		case "comment":

			$subject = sprintf(_("New comment in proposal %d - %s"), $this->proposal->id, $this->comment->title);

			$uri = BASE_URL."proposal.php?id=".$this->proposal->id;
			if ($this->comment->rubric == "discussion") $uri .= "&discussion=1";

			$body .= _("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n\n";
			if (Login::$member) {
				$body .= sprintf(_("Member '%s' posted this comment:"), Login::$member->username());
			} else {
				$body .= _("Someone not logged in posted this comment:");
			}
			$body .= "\n"
				.$uri."&comment=".$this->comment->id."\n"
				.$separator
				.$this->comment->title."\n\n"
				.$this->comment->content."\n"
				.$separator
				._("Reply:")."\n"
				.$uri."&reply=".$this->comment->id;

			break;
		case "reply":

			$subject = sprintf(_("New reply to your comment in proposal %d - %s"), $this->proposal->id, $this->comment->title);

			$uri = BASE_URL."proposal.php?id=".$this->proposal->id;
			if ($this->comment->rubric == "discussion") $uri .= "&discussion=1";

			$body .= _("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n\n";
			if (Login::$member) {
				$body .= sprintf(_("Member '%s' replied to your comment:"), Login::$member->username());
			} else {
				$body .= _("Someone not logged in replied to your comment:");
			}
			$body .= "\n"
				.$uri."&comment=".$this->comment->id."\n"
				.$separator
				.$this->comment->title."\n\n"
				.$this->comment->content."\n"
				.$separator
				._("Reply:")."\n"
				.$uri."&reply=".$this->comment->id;

			break;
		case "new_proposal":

			$subject = sprintf(_("New proposal %d in area %s - %s"), $this->proposal->id, $this->proposal->issue()->area()->name, $this->proposal->title);

			$body .= sprintf(_("Proponent '%s' added a new proposal:"), $this->proponent)."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				."===== "._("Title")." =====\n"
				.$this->proposal->title."\n\n"
				."===== "._("Content")." =====\n"
				.$this->proposal->content."\n\n"
				."===== "._("Reason")." =====\n"
				.$this->proposal->reason."\n";

			break;
		case "new_draft":

			$subject = sprintf(_("New draft for proposal %d - %s"), $this->proposal->id, $this->proposal->title);

			if ($this->proponent !== false) {
				$body .= sprintf(_("Proponent '%s' added a new draft:"), $this->proponent);
			} else {
				$body .= _("An admin added a new draft:");
			}
			$body .= "\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				."===== "._("Title")." =====\n"
				.$this->proposal->title."\n\n"
				."===== "._("Content")." =====\n"
				.$this->proposal->content."\n\n"
				."===== "._("Reason")." =====\n"
				.$this->proposal->reason."\n";

			break;
		case "submitted":

			$subject = sprintf(_("Proposal %d submitted - %s"), $this->proposal->id, $this->proposal->title);

			$body .= sprintf(_("Proponent '%s' submitted this proposal:"), $this->proponent)."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				."===== "._("Title")." =====\n"
				.$this->proposal->title."\n\n"
				."===== "._("Content")." =====\n"
				.$this->proposal->content."\n\n"
				."===== "._("Reason")." =====\n"
				.$this->proposal->reason."\n";

			break;
		case "apply_proponent":

			$subject = sprintf(_("New proponent for proposal %d"), $this->proposal->id);

			$body .= _("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				._("The following member asks to become proponent:")."\n\n"
				.$this->proponent."\n"
				.Login::$member->identity()."\n";

			break;
		case "confirmed_proponent":

			$subject = sprintf(_("Proponent confirmed for proposal %d"), $this->proposal->id);

			$body .= _("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				._("The proponent ...")."\n\n"
				.$this->proponent_confirmed."\n\n"
				._("... has been confirmed by:")."\n\n"
				.$this->proponent_confirming;

			break;
		case "removed_proponent":

			$subject = sprintf(_("Proponent removed himself from proposal %d"), $this->proposal->id);

			$body .= _("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				._("The following proponent removed himself:")."\n\n"
				.$this->proponent."\n";

			break;
		case "admitted":

			if (count($this->proposals) > 1) {
				$body .= _("The following proposals have been admitted").":\n\n";
			} else {
				$body .= _("The following proposal has been admitted").":\n\n";
			}

			$ids = array();
			foreach ( $this->proposals as $proposal ) {
				$ids[] = $proposal->id;
				$body .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
					.BASE_URL."proposal.php?id=".$proposal->id."\n";
			}

			if (count($ids) > 1) {
				$subject = sprintf(_("Proposals %s admitted"), join(", ", $ids));
			} else {
				$subject = sprintf(_("Proposal %d admitted"), $ids[0]);
			}

			$body .= "\n"._("All admitted proposals in this group").":\n"
				.BASE_URL."proposals.php?ngroup=".$ngroup->id."&filter=admitted\n";

			break;
		case "debate":

			$subject = sprintf(_("Debate started in period %d"), $this->period->id);

			$body .= _("Debate has started on the following proposals").":\n";

			foreach ( $this->issues as $issue ) {
				/** @var $issue Issue */
				$body .= "\n";
				foreach ( $issue->proposals() as $proposal ) {
					$body .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
						.BASE_URL."proposal.php?id=".$proposal->id."\n";
				}
			}

			$body .= "\n"._("All proposals in debate in this group").":\n"
				.BASE_URL."proposals.php?ngroup=".$ngroup->id."&filter=debate\n\n"
				._("Voting preparation").": ".datetimeformat($this->period->preparation)."\n"
				._("Voting").": ".datetimeformat($this->period->voting)."\n";

			break;
		case "finished":

			$subject = sprintf(_("Voting finished in period %d"), $this->period->id);

			$body .= _("Voting has finished on the following proposals").":\n";

			foreach ( $this->issues as $issue ) {
				/** @var $issue Issue */
				$body .= "\n";
				$proposals = $issue->proposals(true);
				foreach ( $proposals as $proposal ) {
					$body .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
						.BASE_URL."proposal.php?id=".$proposal->id."\n".
						_("Yes").": ".$proposal->yes.", "._("No").": ".$proposal->no.", "._("Abstention").": ".$proposal->abstention;
					if (count($proposals) > 1) {
						$body .= ", "._("Score").": ".$proposal->score;
					}
					$body .= "\n";
				}
				$body .= _("Vote result").": ".BASE_URL."vote_result.php?issue=".$issue->id."\n";
			}

			$body .= "\n"._("All finished proposals in this group").":\n"
				.BASE_URL."proposals.php?ngroup=".$ngroup->id."&filter=closed\n";

			break;
		case "proposal_moved":

			$subject = sprintf(_("Proposal %d moved to a different issue"), $this->proposal->id);

			$body .= sprintf(_("An administrator moved the following proposal from issue %d to issue %d:"), $this->issue_old->id, $this->issue->id)."\n"
				._("Proposal")." ".$this->proposal->id.": ".$this->proposal->title."\n"
				.BASE_URL."proposal.php?id=".$this->proposal->id."\n\n"
				.sprintf(_("Proposals in the old issue %d:"), $this->issue_old->id)."\n";
			foreach ( $this->issue_old->proposals() as $proposal ) {
				$body .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
					.BASE_URL."proposal.php?id=".$proposal->id."\n";
			}
			$body .= "\n"
				.sprintf(_("Other proposals in the new issue %d:"), $this->issue->id)."\n";
			foreach ( $this->issue->proposals() as $proposal ) {
				if ($proposal->id == $this->proposal->id) continue; // skip the moved proposal
				$body .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
					.BASE_URL."proposal.php?id=".$proposal->id."\n";
			}
			$body .= "\n"._("Notice that if you demanded offline voting for the old issue, this was not automatically transferred to the new issue. If you still want offline voting, you should demand it again on the new issue!")."\n";

			break;
		case "ballot_approved":

			$subject = sprintf(_("Ballot approved in period %d"), $this->period->id);

			$body .= _("Your ballot application has been approved:")."\n\n"
				.$this->ballot->description_for_mail();

			break;
		case "ballot_not_approved":

			$subject = sprintf(_("Ballot not approved in period %d"), $this->period->id);

			$body .= _("Your ballot application has NOT been approved:")."\n\n"
				.$this->ballot->description_for_mail();

			break;
		case "ballot_assigned":

			$subject = sprintf(_("Ballot assigned in period %d"), $this->period->id);

			$body .= _("Ballot assignment has been started. You have been assigned to the following ballot:")."\n\n"
				.$this->ballot->description_for_mail()."\n"
				.sprintf(_("This ballot has been selected, either because you selected it yourself and it was approved or because it looks like it's the nearest one to where you live. You can change the selected ballot here until ballot preparation starts at %s:"), datetimeformat($this->period->ballot_preparation))."\n"
				.BASE_URL."ballots.php?period=".$this->period->id;

			break;
		default:
			trigger_error("unknown notification type", E_USER_WARNING);
			$subject = null;
		}

		// remove HTML line break hints
		$body = strtr($body, array("&shy;"=>""));

		return array($subject, $body);
	}
예제 #3
0
/**
 * create a new member and let it demand offline voting for the supplied proposal
 *
 * @param Proposal $proposal
 * @param string  $i
 */
function add_votingmode_demander(Proposal $proposal, $i) {
	create_member("user".$i);
	$proposal->issue()->demand_votingmode();
}
예제 #4
0
/**
 *
 * @param integer $period
 * @return array
 */
function create_vote_proposals($period) {
	global $area, $lorem_ipsum;


	// single proposal
	login(1);
	$proposal1 = new Proposal;
	$proposal1->title = "einzelner Beispielantrag";
	$proposal1->content = $lorem_ipsum;
	$proposal1->reason = $lorem_ipsum;
	$proposal1->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal1->add_proponent(Login::$member->username, true);
	}

	$issue1 = $proposal1->issue();
	// assign issue to period
	$issue1->period = $period;
	/** @var $issue Issue */
	$issue1->update(['period']);

	time_warp($issue1);
	$proposal1->submit();
	time_warp($issue1);
	$proposal1->read();
	for ( $i=6; $i<=23; $i++ ) {
		login($i);
		$proposal1->add_support();
	}
	time_warp($issue1);


	// 4 proposals
	login(1);
	$proposal2 = new Proposal;
	$proposal2->title = "Beispielantrag";
	$proposal2->content = $lorem_ipsum;
	$proposal2->reason = $lorem_ipsum;
	$proposal2->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal2->add_proponent(Login::$member->username, true);
	}

	$issue2 = $proposal2->issue();
	// assign issue to period
	$issue2->period = $period;
	/** @var $issue Issue */
	$issue2->update(['period']);

	login(1);
	$proposal3 = new Proposal;
	$proposal3->title = "Alternativantrag";
	$proposal3->content = $lorem_ipsum;
	$proposal3->reason = $lorem_ipsum;
	$proposal3->issue = $proposal2->issue;
	$proposal3->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal3->add_proponent(Login::$member->username, true);
	}

	login(1);
	$proposal4 = new Proposal;
	$proposal4->title = "nicht zugelassener Alternativantrag";
	$proposal4->content = $lorem_ipsum;
	$proposal4->reason = $lorem_ipsum;
	$proposal4->issue = $proposal2->issue;
	$proposal4->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal4->add_proponent(Login::$member->username, true);
	}

	login(1);
	$proposal5 = new Proposal;
	$proposal5->title = "zurückgezogener Antrag";
	$proposal5->content = $lorem_ipsum;
	$proposal5->reason = $lorem_ipsum;
	$proposal5->issue = $proposal2->issue;
	$proposal5->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal5->add_proponent(Login::$member->username, true);
	}

	time_warp($issue2);

	login(1);
	$proposal2->submit();
	$proposal3->submit();
	$proposal4->submit();
	$proposal5->submit();

	time_warp($issue2);

	$proposal2->read();
	for ( $i=6; $i<=24; $i++ ) {
		login($i);
		$proposal2->add_support();
	}

	$proposal3->read();
	for ( $i=6; $i<=15; $i++ ) {
		login($i);
		$proposal3->add_support();
	}

	$proposal4->read();
	for ( $i=6; $i<=8; $i++ ) {
		login($i);
		$proposal4->add_support();
	}

	$proposal5->read();
	for ( $i=6; $i<=15; $i++ ) {
		login($i);
		$proposal5->add_support();
	}
	// revoke by removing all proponents
	for ( $i=1; $i<=5; $i++ ) {
		login($i);
		$proposal5->remove_proponent(Login::$member);
	}

	time_warp($issue2);


	// single proposal for offline voting
	login(1);
	$proposal6 = new Proposal;
	$proposal6->title = "einzelner Beispielantrag";
	$proposal6->content = $lorem_ipsum;
	$proposal6->reason = $lorem_ipsum;
	$proposal6->create(Login::$member->username, $area->id);
	for ( $i=2; $i<=5; $i++ ) {
		login($i);
		$proposal6->add_proponent(Login::$member->username, true);
	}

	$issue3 = $proposal6->issue();
	// assign issue to period
	$issue3->period = $period;
	/** @var $issue Issue */
	$issue3->update(['period']);

	time_warp($issue3);
	$proposal6->submit();
	time_warp($issue3);
	$proposal6->read();
	for ( $i=6; $i<=23; $i++ ) {
		login($i);
		$proposal6->add_support();
	}

	for ( $i=1; $i<=23; $i++ ) {
		login($i);
		$issue3->demand_votingmode();
	}

	time_warp($issue3);


	return [$issue1, $issue2, $issue3];
}