Ejemplo n.º 1
0
	/**
	 * save fingerprint
	 *
	 * @param string  $fingerprint
	 */
	public function set_fingerprint($fingerprint) {
		$this->fingerprint = limitstr($fingerprint, self::fingerprint_length);
	}
Ejemplo n.º 2
0
	/**
	 * display the list of drafts for the right column
	 *
	 * @param array   $proponents
	 */
	public function display_drafts_without_form(array $proponents) {
?>
<h2><?php 
echo _("Drafts");
?>
</h2>
<table class="drafts">
<?
		$sql = "SELECT * FROM draft WHERE proposal=".intval($this->id)." ORDER BY created DESC";
		$result = DB::query($sql);
		$i = DB::num_rows($result);
		$j = 0;
		while ( $draft = DB::fetch_object($result, "Draft") ) {
			// get the author's proponent name
			$author = new Member($draft->author);
			$proponent_name = "("._("proponent revoked").")";
			foreach ($proponents as $proponent) {
				if ($proponent->id == $author->id) {
					$proponent_name = $proponent->proponent_name;
					break;
				}
			}
			if ($j==0) {
				$link = "proposal.php?id=".$this->id;
			} else {
				$link = "draft.php?id=".$draft->id;
			}
?>
<tr>
	<td class="content" onClick="location.href='<?php 
echo $link;
?>
'"><?php 
echo $i;
?>
 <a href="<?php 
echo $link;
?>
"><?php 
echo datetimeformat_smart($draft->created);
?>
</a> <?php 
echo limitstr($proponent_name, 30);
?>
</td>
</tr>
<?
			$i--;
			$j++;
		}
?>
</table>
<?
	}
Ejemplo n.º 3
0
/**
 * wrapper for mail()
 *
 * @param string  $to
 * @param string  $subject
 * @param string  $body
 * @param array   $headers     (optional)
 * @param string  $fingerprint (optional) encrypt mail with the public key with this fingerprint
 * @return bool
 */
function send_mail($to, $subject, $body, array $headers=array(), $fingerprint="") {

	$subject = mb_encode_mimeheader( limitstr(MAIL_SUBJECT_PREFIX.$subject, 125) );

	$headers[] = "Content-Type: text/plain; charset=UTF-8";
	$headers[] = "Content-Transfer-Encoding: 8bit";
	if (MAIL_FROM) $headers[] = "From: ".MAIL_FROM;

	$body = mb_wordwrap($body);

	if (GNUPG_SIGN_KEY) {
		$gnupg = new_gnupg();
		if ( $gnupg->addsignkey(GNUPG_SIGN_KEY) ) {
			if ($fingerprint) {
				if ( gnupg_keyinfo_matches_email($gnupg->keyinfo($fingerprint), $to) and $gnupg->addencryptkey($fingerprint) ) {
					$body = $gnupg->encryptsign($body);
				} else {
					$body .= "\n\n".mb_wordwrap(_("This email should be encrypted, but no available key matching your fingerprint and email address was found! Please check your settings:")." ".BASE_URL."settings_encryption.php");
					$body = $gnupg->sign($body);
				}
			} else {
				$body = $gnupg->sign($body);
			}
		} else {
			trigger_error("Gnupg sign key cound not be added", E_USER_WARNING);
		}
	}

	return mail($to, $subject, $body, join("\r\n", $headers));
}
Ejemplo n.º 4
0
	/**
	 * wrapper for create()
	 *
	 * @param Proposal $proposal
	 */
	function add(Proposal $proposal) {

		if (mb_strlen($this->title) > self::title_length) {
			$this->title = limitstr($this->title, self::title_length);
			warning(sprintf(_("The title has been truncated to the maximum allowed length of %d characters!"), self::title_length));
		}
		if (mb_strlen($this->content) > self::content_length) {
			$this->content = limitstr($this->content, self::content_length);
			warning(sprintf(_("The content has been truncated to the maximum allowed length of %d characters!"), self::content_length));
		}

		if (Login::$member) $this->member = Login::$member->id;
		$this->session = self::session_id();
		$this->create();

		// notification to authors of all parent comments
		$recipients = array();
		$parent = $this->parent;
		while ( $parent > 0 ) { // "pro"/"contra"/"discussion" will be converted to 0
			$comment = new Comment($parent);
			if ($comment->member) $recipients[] = $comment->member;
			$parent = $comment->parent;
		}
		$notification = new Notification("reply");
		$notification->proposal = $proposal;
		$notification->comment = $this;
		$notification->send($recipients);

		// notification according to notify settings
		$notification = new Notification("comment");
		$notification->proposal = $proposal;
		$notification->comment = $this;
		$notification->send([], $recipients);

	}