Beispiel #1
0
	/**
	 * display a timestamp
	 *
	 * @param string  $content
	 */
	public function dbtableadmin_print_timestamp($content) {
		echo datetimeformat($content);
	}
Beispiel #2
0
	/**
	 * display the list item with one comment and its children
	 *
	 * @param Comment $comment
	 * @param integer $position position on this level, first comment has position 1
	 * @param integer $level    folding level, top level is 0
	 * @param boolean $full     allow showing full text
	 */
	private function display_comment(Comment $comment, $position, $level, $full) {

		// on show restart rules
		if ( in_array($comment->id, self::$show) ) {
			$level = 0;
			$full = true;
			$show = true;
		} else {
			$show = false;
		}

?>
<li id="comment<?php 
echo $comment->id;
?>
">
	<div class="comment<?
		if (Login::$member) {
			if (!$comment->seen) {
				?> new<?
			} elseif (
				!self::comments_head($level+1) and
				$this->has_new_children($comment->id)
			) {
				?> new_children<?
			}
		}
		?>">
<?
		if ($comment->member) {
			$author = new Member($comment->member);
			$author_link = $author->link();
		} else {
			$author_link = "";
		}
		if (
			$comment->is_author() and
			isset($_GET['comment_edit']) and $_GET['comment_edit']==$comment->id and
			!$comment->removed
		) {
			// edit existing comment
?>
		<div class="author"><?php 
echo $author_link;
?>
 <?php 
echo datetimeformat($comment->created);
?>
</div>
<?
			if (strtotime($comment->created) > Comment::edit_limit()) {
?>
		<div class="time"><?printf(_("This comment can be updated until %s."), datetimeformat($comment->created." + ".COMMENT_EDIT_INTERVAL))?></div>
<?
				form(URI::append(['comment_edit'=>$comment->id]), "", "comment", "comment", true);
?>
<input id="comment<?php 
echo $comment->id;
?>
" name="title" type="text" maxlength="<?php 
echo Comment::title_length;
?>
" value="<?php 
echo h(!empty($_POST['title']) ? $_POST['title'] : $comment->title);
?>
" required><br>
<textarea name="content" rows="5" maxlength="<?php 
echo Comment::content_length;
?>
" required><?php 
echo h(!empty($_POST['content']) ? $_POST['content'] : $comment->content);
?>
</textarea><br>
<input type="hidden" name="action" value="update_comment">
<input type="hidden" name="id" value="<?php 
echo $comment->id;
?>
">
<input type="submit" value="<?php 
echo _("apply changes");
?>
">
<?
				form_end();
				$display_content = false;
			} else {
?>
		<div class="time"><?php 
echo _("This comment may not be updated any longer!");
?>
</div>
<?
				$display_content = true;
			}
		} else {
?>
		<div class="author<?php 
echo $comment->removed ? ' removed' : '';
?>
"><?
			// edit link
			if (
				$comment->is_author() and
				strtotime($comment->created) > Comment::edit_limit() and
				!$comment->removed and
				Login::access_allowed("comment") and
				self::$proposal->allowed_add_comments($this->rubric)
			) {
				?><a href="<?php 
echo URI::append(['comment_edit' => $comment->id]);
?>
#comment<?php 
echo $comment->id;
?>
" class="iconlink"><img src="img/edit.png" width="16" height="16" <?alt(_("edit"))?>></a> <?
			}
			// author and time
			echo $author_link?> <?php 
echo datetimeformat($comment->created);
?>
</div>
<?
			$display_content = true;
		}

		// title and content
		if ($display_content) {
			if ($comment->removed) {
?>
		<h3 class="removed">&mdash; <?php 
echo _("comment removed by admin");
?>
 &mdash;</h3>
<?
			} elseif (
				// show because title was clicked
				$show or
				// show because of position
				( defined('COMMENTS_FULL_'.$level) and $position <= constant('COMMENTS_FULL_'.$level) and $full )
			) {
				// display full text
				if ($comment->updated) {
?>
		<div class="author"><?php 
echo _("updated");
?>
 <?php 
echo datetimeformat($comment->updated);
?>
</div>
<?
				}
?>
		<h3><?php 
echo h($comment->title);
?>
</h3>
<?
				$this->display_comment_content($comment);

				// don't show the comment as new next time
				if (Login::$member and !$comment->seen) {
					// simulate INSERT IGNORE
					DB::query_ignore("INSERT INTO seen (comment, member) VALUES (".intval($comment->id).", ".intval(Login::$member->id).")");
				}

			} else {
				// display only head
				$open = self::$open;
				$show = self::$show;
				$show[] = $comment->id;
				$show = array_unique($show);
?>
		<h3><a href="<?php 
echo URI::append(['open' => $open, 'show' => $show]);
?>
#comment<?php 
echo $comment->id;
?>
" title="<?php 
echo _("show text and replys");
?>
"><?php 
echo h($comment->title);
?>
</a></h3>
<?
				// display all children without full text
				$full = false;
			}
		}

?>
		<div class="clearfix"></div>
	</div>
<?
		// display children
		$level++;
		if (
			self::comments_head($level) or
			in_array($comment->id, self::$open_ids)
		) $this->display_comments($comment->id, $level, $full);
?>
</li>
<?
	}
<?
Issue::display_proposals_th(true);
list($proposals, $submitted) = $issue->proposals_list(true);
$issue->display_proposals($proposals, $submitted, count($proposals), true);
?>
</table>

<h2><?php 
echo _("Votes");
?>
</h2>
<?

if ($issue->cleared) {
?>
<p><? printf(_("Raw data has been cleared at %s."), datetimeformat($issue->cleared)); ?></p>
<?
} else {
	// display list of votes
	$sql = "SELECT token, vote, votetime FROM vote_token
 		LEFT JOIN vote_vote USING (token)
 		WHERE issue=".intval($issue->id)."
 		ORDER BY token ASC, votetime DESC";
	$result = DB::query($sql);
	if (Login::$member) $token = $issue->vote_token(); else $token = null;
	Issue::display_votes($proposals, $result, $token);
}

?>
<div class="clearfix"></div>
<?
	/**
	 * 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);
	}
Beispiel #5
0
	/**
	 * start online voting
	 *
	 * @param array   $issues
	 */
	public function start_voting(array $issues) {

		// entitled members of the ngroup
		$sql = "SELECT member.* FROM member
			JOIN member_ngroup ON member.id = member_ngroup.member AND member_ngroup.ngroup=".intval($this->ngroup)."
			WHERE activated IS NOT NULL AND eligible=TRUE AND verified=TRUE";
		$members = DB::fetchobjectarray($sql, "Member");

		$personal_tokens = array();
		$all_tokens      = array();
		foreach ($issues as $issue) {
			/** @var $issue Issue */

			// generate vote tokens
			$all_tokens[$issue->id] = array();
			foreach ( $members as $member ) {
				DB::transaction_start();
				do {
					$token = Login::generate_token(8);
					$sql = "SELECT token FROM vote_token WHERE token=".DB::esc($token);
				} while ( DB::numrows($sql) );
				$sql = "INSERT INTO vote_token (member, issue, token) VALUES (".intval($member->id).", ".intval($issue->id).", ".DB::esc($token).")";
				DB::query($sql);
				DB::transaction_commit();
				$personal_tokens[$member->id][$issue->id] = $token;
				$all_tokens[$issue->id][]                 = $token;
			}

			$issue->state = "voting";
			$issue->update(["state"], 'voting_started=now()');

		}

		// notification mails
		$subject = sprintf(_("Voting started in period %d"), $this->id);
		$body_top = _("Group").": ".$this->ngroup()->name."\n\n"
			._("Online voting has started on the following proposals").":\n";
		$body_lists = "\n"._("Voting end").": ".datetimeformat($this->counting)
			."\n\n===== "._("Lists of all vote tokens")." =====\n";
		$issues_blocks = array();
		foreach ( $issues as $issue ) {
			$body_lists .= "\n"
				._("Issue")." ".$issue->id.":\n"
				.join(", ", $all_tokens[$issue->id])."\n";
			$issues_blocks[$issue->id] = "\n"._("Issue")." ".$issue->id."\n";
			foreach ( $issue->proposals(true) as $proposal ) {
				$issues_blocks[$issue->id] .= _("Proposal")." ".$proposal->id.": ".$proposal->title."\n"
					.BASE_URL."proposal.php?id=".$proposal->id."\n";
			}
		}
		foreach ( $members as $member ) {
			if (!$member->mail) continue;
			$body = $body_top;
			foreach ( $issues as $issue ) {
				$body .= $issues_blocks[$issue->id]
					._("Vote").": ".BASE_URL."vote.php?issue=".$issue->id."\n"
					._("Your vote token").": ".$personal_tokens[$member->id][$issue->id]."\n";
			}
			$body .= $body_lists;
			send_mail($member->mail, $subject, $body, array(), $member->fingerprint);
		}

	}
Beispiel #6
0
		$issue->vote($token, $_POST['vote']);
		//redirect("proposals.php?ngroup=".$ngroup->id."&filter=voting");
		redirect();
		break;
	default:
		warning(_("Unknown action"));
		redirect();
	}
}


html_head(_("Vote"), true);

?>
<p><?php 
echo sprintf(_("Voting goes until %s."), datetimeformat($issue->period()->counting));
?>
</p>
<?

list($proposals, $submitted) = $issue->proposals_list(true);

$sql = "SELECT token, vote, votetime FROM vote_vote
	WHERE token=".DB::esc($token)."
	ORDER BY votetime DESC";
$result = DB::query($sql);
// get only the first record, which is the last submitted vote
if ( $row = DB::fetch_assoc($result) ) {
	$vote = unserialize($row['vote']);
} else {
	// default
$sql = "SELECT * FROM `tasks` WHERE `userid` = " . $_GET['id'] . " AND `taskstatus` != 3";
$result = mysqli_query($con, $sql);
$output = "BEGIN:VCALENDAR\n";
$output .= "PRODID:PHP\n";
$output .= "VERSION:2.0\n";
$output .= "METHOD:PUBLISH\n";
while ($row = mysqli_fetch_array($result)) {
    if ($row['startdate'] != "0000-00-00" && $row['enddate'] != "0000-00-00") {
        $output .= "BEGIN:VEVENT\n";
        $output .= "SUMMARY:" . $row['taskname'] . "\n";
        $output .= "UID:" . $row['taskid'] . "@task.com\n";
        $output .= "STATUS:CONFIRMED\n";
        $output .= "DESCRIPTION:" . $row['tasksummary'] . "\n";
        $output .= "CREATED:" . creationdateformat($row['creationdate']) . "\n";
        $output .= "DTSTART:" . datetimeformat($row['startdate']) . "\n";
        if ($row['is_recurring'] == "1") {
            $output .= "RRULE:FREQ=WEEKLY;UNTIL=" . datetimeformat($row['recuruntil']) . ";WKST=MO;BYDAY=" . $row['recday'] . "\n";
        }
        $output .= "DTEND:" . datetimeformat($row['enddate']) . "\n";
        if ($row['alarm'] != 0) {
            $output .= "BEGIN:VALARM\n";
            $output .= "ACTION:DISPLAY\n";
            $output .= "DESCRIPTION:DISPLAY\n";
            $output .= "TRIGGER:-P" . $row['alarm'] . "D\n";
            $output .= "END:VALARM\n";
        }
        $output .= "END:VEVENT\n";
    }
}
$output .= "END:VCALENDAR";
echo $output;
Beispiel #8
0
}

$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(_("Proposal %d, draft from %s"), $proposal->id, datetimeformat($draft->created)));

?>

<section class="proposal_info">
<? $proposal->display_proposal_info($issue, $proponents, $is_proponent); ?>
</section>

<section class="proposal_content">
<h2><?php 
echo _("Title");
?>
</h2>
<p class="proposal proposal_title"><?php 
echo h($draft->title);
?>