Example #1
0
	/**
	 * assign a member to this ballot
	 *
	 * @param Member  $member
	 * @param boolean $agent
	 */
	public function assign_member(Member $member, $agent=false) {
		$fields_values = array(
			'member' => $member->id,
			'period' => $this->period,
			'ballot' => $this->id,
			'agent'  => $agent
		);
		$keys = array("member", "period");
		DB::insert_or_update("offlinevoter", $fields_values, $keys);
	}
 */


require "inc/common_http.php";

Login::access("member");

if ($action) {
	switch ($action) {
	case "save":
		foreach ( Notification::$default_settings as $interest => $types ) {
			$fields_values = array('member'=>Login::$member->id, 'interest'=>$interest);
			foreach ( $types as $type => $value ) {
				$fields_values[$type] = !empty($_POST['notify'][$interest][$type]);
			}
			DB::insert_or_update("notify", $fields_values, array('member', 'interest'));
		}
		success(_("The email notification settings have been saved."));
		redirect();
	default:
		warning(_("Unknown action"));
		redirect();
	}
}


html_head(_("Member settings"));

display_nav_settings();

form(BN, "", "", "settings_notifications", true);
Example #3
0
	/**
	 * add the logged in member as proponent
	 *
	 * @param string  $proponent           display name of the proponent
	 * @param boolean $proponent_confirmed (optional)
	 * @return boolean
	 */
	public function add_proponent($proponent, $proponent_confirmed=false) {
		if (!$this->check_proponent($proponent)) return false;

		DB::transaction_start();
		$this->read();
		if (!$this->allowed_change_proponents()) {
			warning(_("You can not become proponent anymore once voting preparation has started or the proposal has been closed!"));
			DB::transaction_rollback();
			return false;
		}
		if (mb_strlen($proponent) > Proposal::proponent_length) {
			$proponent = limitstr($proponent, Proposal::proponent_length);
			warning(sprintf(_("The input has been truncated to the maximum allowed length of %d characters!"), self::proponent_length));
		}
		// the first proponent is already confirmed
		if (!$proponent_confirmed and !$this->proponents_count()) $proponent_confirmed = true;
		$fields_values = array(
			'proposal' => $this->id,
			'member' => Login::$member->id,
			'proponent' => $proponent,
			'proponent_confirmed' => $proponent_confirmed
		);
		$keys = array('proposal', 'member');
		DB::insert_or_update("supporter", $fields_values, $keys);
		DB::transaction_commit();

		if ($proponent_confirmed) {
			$this->check_required_proponents();
		} else {

			// notification to the other proponents
			$notification = new Notification("apply_proponent");
			$notification->proposal = $this;
			$notification->proponent = $proponent;
			$notification->send($this->proponents());

			notice(_("Your application to become proponent has been submitted to the current proponents to confirm your request."));
		}

		$this->update_supporters_cache();
		$this->issue()->area()->activate_participation();
		return true;
	}
Example #4
0
/**
 * create a member once
 *
 * @param string  $username
 */
function create_member($username) {
	global $password, $ngroup;

	// make usernames unique
	$username .= " ".$ngroup->id;

	static $members = array();
	if (isset($members[$username])) {
		Login::$member = $members[$username];
		return;
	}

	Login::$member = new Member;
	Login::$member->invite = Login::generate_token(24);
	Login::$member->eligible = true;
	Login::$member->verified = true;
	Login::$member->create();
	Login::$member->username = $username;
	Login::$member->password = $password;
	$update_fields = array('username', 'password', 'eligible');

	// Enable this only in local development environment, because it will lead to extremely many notification mails!
	//Login::$member->mail = ERROR_MAIL;
	//$update_fields[] = "mail";

	Login::$member->update($update_fields, 'activated=now()');
	DB::insert("member_ngroup", array('member'=>Login::$member->id, 'ngroup'=>$ngroup->id));

	// activate all notifications
	foreach ( Notification::$default_settings as $interest => $types ) {
		$fields_values = array('member'=>Login::$member->id, 'interest'=>$interest);
		foreach ( $types as $type => $value ) {
			$fields_values[$type] = true;
		}
		DB::insert_or_update("notify", $fields_values, array('member', 'interest'));
	}

	$members[$username] = Login::$member;

}
Example #5
0
	/**
	 * member selects postal voting
	 */
	public function select_postal() {
		$fields_values = array(
			'member' => Login::$member->id,
			'period' => $this->id,
			'ballot' => null,
			'agent'  => false
		);
		$keys = array("member", "period");
		DB::insert_or_update("offlinevoter", $fields_values, $keys);
	}
Example #6
0
	/**
	 * set or update a rating score
	 *
	 * @param integer $score
	 * @return boolean
	 */
	function set_rating($score) {
		if ($this->removed) {
			warning(_("The comment has been removed."));
			return false;
		}
		if ($this->is_author()) {
			warning(_("Rating your own comments is not allowed."));
			return false;
		}
		$fields_values = array(
			'comment' => $this->id,
			'score'   => min(max($score, 1), self::rating_score_max),
			'session' => self::session_id()
		);
		if (Login::$member) {
			$fields_values['member'] = Login::$member->id;
			$keys = array("comment", "member");
		} else {
			$keys = array("comment", "session");
		}
		DB::insert_or_update("rating", $fields_values, $keys);
		$this->update_ratings_cache();
		return true;
	}