Beispiel #1
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Beispiel #2
0
 /**
  * The student inserts this initially once he/she accepts a project offer
  * @param unknown $props
  * @param unknown $proposal_id
  * @return boolean|unknown
  */
 static function insertAgreement($props)
 {
     if (!$props) {
         drupal_set_message(t('Insert requested with empty (filtered) data set'), 'error');
         return false;
     }
     if (!isset($props['proposal_id'])) {
         drupal_set_message(t('Insert requested with no proposal set'), 'error');
         return false;
     }
     global $user;
     $txn = db_transaction();
     try {
         $proposal = objectToArray(Proposal::getInstance()->getProposalById($props['proposal_id']));
         $project = objectToArray(Project::getProjectById($proposal['pid']));
         if (!isset($props['student_id'])) {
             $props['student_id'] = $user->uid;
         }
         if (!isset($props['supervisor_id'])) {
             $props['supervisor_id'] = $proposal['supervisor_id'];
         }
         if (!isset($props['mentor_id'])) {
             $props['mentor_id'] = $project['mentor_id'];
         }
         $props['project_id'] = $proposal['pid'];
         if (!isset($props['description'])) {
             $props['description'] = '';
         }
         if (!isset($props['student_signed'])) {
             $props['student_signed'] = 0;
         }
         if (!isset($props['supervisor_signed'])) {
             $props['supervisor_signed'] = 0;
         }
         if (!isset($props['mentor_signed'])) {
             $props['mentor_signed'] = 0;
         }
         /*
         if (! testInput($props, array('owner_id', 'org_id', 'inst_id', 'supervisor_id','pid', 'title'))){
         	return FALSE;
         }
         */
         try {
             $id = db_insert(tableName(_AGREEMENT_OBJ))->fields($props)->execute();
         } catch (Exception $e) {
             drupal_set_message($e->getMessage(), 'error');
         }
         if ($id) {
             drupal_set_message(t('You have created your agreement: you can continue editing it later.'));
             return $id;
         } else {
             drupal_set_message(t('We could not add your agreement. ') . (_DEBUG ? '<br/>' . getDrupalMessages() : ""), 'error');
         }
         return $result;
     } catch (Exception $ex) {
         $txn->rollback();
         drupal_set_message(t('We could not add your agreement.') . (_DEBUG ? $ex->__toString() : ''), 'error');
     }
     return FALSE;
 }
Beispiel #3
0
 public function loadModel($id)
 {
     $model = Proposal::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $filter = array_fill_keys($this->proposal->getAllColumnsNames(), "");
     $stop_fields = array('filter', 'user_id');
     $input = Input::all();
     if (isset($input['filter']) && $input['filter'] == 'apply') {
         $filter = array_merge($filter, $input);
         Session::put("PROPOSALS_FILTER", $filter);
     }
     if (isset($input['filter']) && $input['filter'] == 'reset') {
         Session::forget('PROPOSALS_FILTER');
     }
     if (isset($input['sort_value'])) {
         $sort = $input['sort_value'];
         $sort_dir = $input['sort_dir'];
         Session::put("PROPOSALS_SORT", array('value' => $sort, 'dir' => $sort_dir));
     }
     $sort = Session::get('PROPOSALS_SORT');
     if (isset($input['filter']) && $input['filter'] == 'reset') {
         Session::forget('PROPOSALS_FILTER');
     }
     if (Session::has('PROPOSALS_FILTER')) {
         $filter = Session::get('PROPOSALS_FILTER');
         $proposals = $this->proposal->where('id', '>', '0');
         foreach ($filter as $k => $v) {
             if (!in_array($k, $stop_fields) && $v != '') {
                 $proposals = $proposals->where($k, 'like', '%' . $v . '%');
             }
         }
         if ($filter['user_id']) {
             $users = User::where('username', 'like', '%' . $filter['user_id'] . '%')->get();
             $proposals = $proposals->whereIn('user_id', $users->pluck('id')->all());
         }
         if (Session::has('PROPOSALS_SORT') && $sort['value'] != '') {
             $proposals = $proposals->orderBy($sort['value'], $sort['dir'] == '1' ? 'desc' : '');
         }
         $proposals = $proposals->paginate(Settings::getValue('TABLE_ELEMENTS'));
     } else {
         if (Session::has('PROPOSALS_SORT') && $sort['value'] != '') {
             $proposals = $this->proposal->orderBy($sort['value'], $sort['dir'] == '1' ? 'desc' : 'asc');
         } else {
             $proposals = $this->proposal;
         }
         $proposals = $proposals->paginate(Settings::getValue('TABLE_ELEMENTS'));
     }
     $sort_options = Proposal::getSortOptions();
     return View::make('backend.proposals.index', compact("proposals", 'filter', 'sort_options', 'sort'));
 }
Beispiel #5
0
function showMyProposals($proposals, $current_tab_propid = 0)
{
    $nr = 0;
    $apply_projects = $apply_projects = vals_soc_access_check('dashboard/projects/apply') ? 1 : 0;
    $rate_projects = Users::isSuperVisor();
    $tab_id_prefix = "proposal_page";
    $data = array();
    $activating_tabs = array();
    $current_tab = 1;
    $current_tab_id = "{$tab_id_prefix}{$current_tab}";
    $current_tab_content = '';
    foreach ($proposals as $proposal) {
        $nr++;
        if (!$current_tab_propid && $nr == 1 || $proposal->proposal_id == $current_tab_propid) {
            //$id = $proposal->pid;
            $current_tab = $nr;
            $current_tab_id = "{$tab_id_prefix}{$current_tab}";
            $current_tab_content = renderProposal(Proposal::getInstance()->getProposalById($proposal->proposal_id, TRUE), $current_tab_id, 'myproposal_page');
        }
        $activating_tabs[] = "'{$tab_id_prefix}{$nr}'";
        $data[] = array(0, $proposal->title, 'view', _PROPOSAL_OBJ, $proposal->proposal_id);
    }
    echo renderTabs($nr, 'Proposal', $tab_id_prefix, _PROPOSAL_OBJ, $data, 0, TRUE, $current_tab_content, $current_tab, _PROPOSAL_OBJ);
    ?>
	<script type="text/javascript">
		window.view_settings = {};
		window.view_settings.apply_projects = <?php 
    echo $apply_projects ? 1 : 0;
    ?>
;
		window.view_settings.rate_projects  = <?php 
    echo $rate_projects ? 1 : 0;
    ?>
;
		activatetabs('tab_', [<?php 
    echo implode(', ', $activating_tabs);
    ?>
], '<?php 
    echo $current_tab_id;
    ?>
');
	</script>
<?php 
}
Beispiel #6
0
/**
 * display supporters and offline voting demanders
 *
 * @param Proposal $proposal
 * @param array   $supporters
 * @param mixed   $is_supporter
 * @param boolean $is_valid
 */
function display_quorum(Proposal $proposal, array $supporters, $is_supporter, $is_valid) {
?>
<section class="quorum">
<h2 id="supporters"><?=_("Supporters")?>:</h2>
<div class="bargraph_container">
<?
	$proposal->bargraph_quorum($is_supporter, $is_valid);
?>
</div>
<?

	if (Login::$member or Login::$admin) {
?>
<?=join(", ", $supporters);
	} else {
?>
<span class="disabled"><?=_("The list of supporters is only visible for logged in users.")?></span>
<?
	}
	if ($proposal->allowed_change_supporters()) {
?>
<br class="clear">
<?
		$disabled = (Login::$member and Login::$member->entitled($_SESSION['ngroup'])) ? "" : " disabled";
		if ($is_supporter) {
			if ($is_valid) {
				?><div class="support">&#10003; <?
				if ($is_supporter==="anonymous") {
					echo _("You support this proposal anonymously.");
				} else {
					echo _("You support this proposal.");
				}
				?></div><?
			} else {
				?><div class="support_expired">&#10003; <?
				if ($is_supporter==="anonymous") {
					echo _("Your anonymous support for this proposal is expired.");
				} else {
					echo _("Your support for this proposal is expired.");
				}
				?></div><?
				form(URI::same()."#supporters");
?>
<input type="hidden" name="action" value="renew_support">
<input type="submit" value="<?=_("Renew your support for this proposal")?>"<?=$disabled?>>
<?
				form_end();
			}
			if (Login::$member and $proposal->is_proponent(Login::$member, false)) {
				$disabled = ' disabled title="'._("You can not remove your support while you are proponent.").'"';
			}
			form(URI::same()."#supporters");
?>
<input type="hidden" name="action" value="revoke_support">
<input type="submit" value="<?=_("Revoke your support for this proposal")?>"<?=$disabled?>>
<?
			form_end();
		} else {
			form(URI::same()."#supporters");
?>
<input type="hidden" name="action" value="add_support">
<input type="submit" value="<?=_("Support this proposal")?>"<?=$disabled?>>
<?
			form_end();
			form(URI::same()."#supporters");
?>
<input type="hidden" name="action" value="add_support_anonym">
<input type="submit" value="<?=_("Support this proposal anonymously")?>"<?=$disabled?>>
<?
			form_end();
		}
	}

?>
<div class="clearfix"></div>
<?

	// admission by decision
	if (Login::$admin) {
		if (!empty($_GET['edit_admission_decision'])) {
			form(URI::same()."#admission_decision", "", "admission_decision", "admission_decision", true);
			if ($proposal->admission_decision!==null) {
?>
<b><?=_("Admitted by decision")?>:</b>
<input type="text" name="admission_decision" value="<?=h($proposal->admission_decision)?>">
<input type="submit" value="<?=_("apply changes")?>">
<?
			} else {
?>
<b id="admission_decision"><?=_("Admit proposal due to a decision")?>:</b>
<input type="text" name="admission_decision">
<input type="submit" value="<?=_("admit proposal")?>">
<?
			}
?>
<input type="hidden" name="action" value="admission_decision">
<?
			form_end();
		} elseif ($proposal->admission_decision!==null) {
?>
<div id="admission_decision" class="admission_decision">
	<b><?=_("Admitted by decision")?>:</b>
	<?=content2html($proposal->admission_decision)?>
	&nbsp;
	<a href="<?=URI::append(['edit_admission_decision'=>1])?>#admission_decision" class="iconlink"><img src="img/edit.png" width="16" height="16" <?alt(_("edit"))?>></a>
</div>
<?
		} else {
?>
<div class="admission_decision">
	<a href="<?=URI::append(['edit_admission_decision'=>1])?>#admission_decision"><?=_("Admit proposal due to a decision")?></a>
</div>
<?
		}
	} elseif ($proposal->admission_decision!==null) {
?>
<div id="admission_decision" class="admission_decision">
	<b><?=_("Admitted by decision")?>:</b>
	<?=content2html($proposal->admission_decision)?>
</div>
<?
	}

?>
</section>
<?
}
Beispiel #7
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) );

?>
Beispiel #8
0
   /**
     * testPropalOther
     * 
     * @param	Proposal	$localobject	Proposal
     * @return	int
     * 
     * @depends testPropalValid
     * The depends says test is run only if previous is ok
     */
    public function testPropalOther($localobject)
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

        /*$result=$localobject->setstatus(0);
        print __METHOD__." id=".$localobject->id." result=".$result."\n";
        $this->assertLessThan($result, 0);
        */

        $localobject->info($localobject->id);
        print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
        $this->assertNotEquals($localobject->date_creation, '');

        return $localobject->id;
    }
        }
        unset($_POST);
        $form = drupal_get_form("vals_soc_project_form", $obj, $target);
        if ($originalPath) {
            $form['#action'] = url($originalPath);
        }
        // Process the submit button which uses ajax
        //$form['submit'] = ajax_pre_render_element($form['submit']);
        // Build renderable array
        // 		$build = array(
        // 				'form' => $form,
        // 				'#attached' => $form['submit']['#attached'], // This will attach all needed JS behaviors onto the page
        // 		);
        renderForm($form, $target);
        break;
    case 'delete':
        $type = altSubValue($_POST, 'type', '');
        $id = altSubValue($_POST, 'id', '');
        if (!isValidOrganisationType($type)) {
            echo jsonBadResult(t('There is no such type we can delete'));
        } elseif (count(Proposal::getProposalsPerProject($id))) {
            echo jsonBadResult(t('You cannot delte the project; there are already students working on a proposal for this project. You can still edit it though.'));
        } else {
            $result = Groups::removeGroup($type, $id);
            ThreadedComments::getInstance()->removethreadsForEntity($id, $type);
            echo $result ? jsonGoodResult(true, '', array('extra' => $mine ? array('mine' => 1) : '')) : jsonBadResult();
        }
        break;
    default:
        echo "No such action: " . $_GET['action'];
}
	/**
	 * 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);
	}
 $entity_id = altSubValue($_POST, 'entity_id', '');
 $target = altSubValue($_POST, 'target', '');
 $properties = ThreadedComments::getInstance()->filterPostLite(ThreadedComments::getInstance()->getKeylessFields(), $_POST);
 $properties['author'] = $user->uid;
 $result = ThreadedComments::getInstance()->addComment($properties);
 $new = false;
 if ($result) {
     // get all the threads
     $thread_details = ThreadedComments::getInstance()->getThreadsForEntity($entity_id, $type);
     // decide which entity it is and get the owner details & description etc
     if ($type == _PROJECT_OBJ) {
         $entity_details = Project::getInstance()->getProjectById($entity_id, true);
         $fire_emails = true;
     } else {
         if ($type == _PROPOSAL_OBJ) {
             $entity_details = objectToArray(Proposal::getInstance()->getProposalById($entity_id, true));
             $fire_emails = true;
         } else {
             // for now nothing - only have projects & proposal comments
             $fire_emails = false;
         }
     }
     // send emails out...
     if ($fire_emails) {
         $properties['name'] = $user->name;
         $properties['mail'] = $user->mail;
         module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail');
         notify_all_of_new_comment($entity_details, $thread_details, $properties);
     }
     echo json_encode(array('result' => TRUE, 'id' => $result, 'type' => $type, 'entity_id' => $entity_id, 'msg' => tt('You succesfully added a comment to this %1$s', t_type($type)) . (_DEBUG ? showDrupalMessages() : '')));
 } else {
Beispiel #12
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];
}
Beispiel #13
0
	/**
	 * column "state"
	 *
	 * @param Proposal $proposal
	 * @param array   $proposals
	 * @param boolean $first
	 * @param boolean $first_admitted
	 * @param integer $num_rows
	 */
	private function display_column_state(Proposal $proposal, array $proposals, $first, &$first_admitted, $num_rows) {
		if ($this->state=="entry" or $this->state=="cancelled") {
			// individual proposal states
			if ($proposal->state=="admitted") {
				if ($first_admitted) {
					// count admitted proposals for rowspan
					$num_admitted_rows = 0;
					foreach ($proposals as $p) {
						if ($p->state=="admitted") $num_admitted_rows++;
					}
?>
		<td rowspan="<?=$num_admitted_rows?>" class="center"><?=$proposal->state_name();
					if ($this->period) {
						?><br><span class="stateinfo"><?
						printf(
							_("Debate starts at %s"),
							'<span class="datetime">'.datetimeformat_smart($this->period()->debate).'</span>'
						);
						?></span><?
					}
					?></td>
<?
					$first_admitted = false;
				}
			} else {
				// submitted, cancelled
?>
		<td class="center"><?=$proposal->state_name()?></td>
<?
			}
		} else {
			// issue states
			if ($first) {
?>
		<td rowspan="<?=$num_rows?>" class="center"><?
				if ($this->state=="voting") $this->display_voting(); else echo $this->state_name();
				if ( $state_info = $this->state_info() ) {
					?><br><span class="stateinfo"><?=$state_info?></span><?
				}
				if (Login::$admin and $this->votingmode_offline() and BN!="admin_vote_result.php") {
					if ($this->state=="preparation") {
						?><br><a href="admin_vote_result.php?issue=<?=$this->id?>"><?=_("enter result")?></a><?
					} elseif ($this->state=="finished") {
						?><br><a href="admin_vote_result.php?issue=<?=$this->id?>"><?=_("edit result")?></a><?
					}
				}
				?></td>
<?
			}
		}
	}
Beispiel #14
0
 public function contactAction()
 {
     $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     if ($this->session->has('auth') && $this->request->hasPost('offer_id')) {
         $offer = Offers::findFirst($this->request->getPost('offer_id'));
         $user = $offer->user;
         $this->view->setVars(array('user_id' => $id = $user->id, 'first_name' => $name = isset($user->first_name) ? $user->first_name : false, 'organization' => $org = isset($user->organization) ? $user->organization : false, 'profession' => $profession = isset($user->profession) ? $user->profession : false, 'phone' => $phone = isset($user->phone) ? $user->phone : false, 'email' => $email = isset($user->email) ? $user->email : false, 'country' => $country = isset($user->country) ? $user->country : false, 'adress' => $adress = isset($user->adress) ? $user->adress : false));
     }
     if ($this->session->has('auth') && $this->request->hasPost('order_id')) {
         $prop = Proposal::findFirst($this->request->getPost('order_id'));
         $user = $prop->user;
         $this->view->setVars(array('user_id' => $id = $user->id, 'first_name' => $name = isset($user->first_name) ? $user->first_name : false, 'organization' => $org = isset($user->organization) ? $user->organization : false, 'profession' => $profession = isset($user->profession) ? $user->profession : false, 'phone' => $phone = isset($user->phone) ? $user->phone : false, 'email' => $email = isset($user->email) ? $user->email : false, 'country' => $country = isset($user->country) ? $user->country : false, 'adress' => $adress = isset($user->adress) ? $user->adress : false));
     }
     if ($this->session->has('auth') && $this->request->hasPost('di_id')) {
         $dial = Dialogs::findFirst($this->request->getPost('di_id'));
         foreach ($dial->user as $users) {
             if ($users->id != $this->session->get('user_id')) {
                 $user = User::findFirst($users->id);
             }
         }
         $this->view->setVars(array('user_id' => $id = $user->id, 'first_name' => $name = isset($user->first_name) ? $user->first_name : false, 'organization' => $org = isset($user->organization) ? $user->organization : false, 'profession' => $profession = isset($user->profession) ? $user->profession : false, 'phone' => $phone = isset($user->phone) ? $user->phone : false, 'email' => $email = isset($user->email) ? $user->email : false, 'country' => $country = isset($user->country) ? $user->country : false, 'adress' => $adress = isset($user->adress) ? $user->adress : false));
     }
     if ($this->session->has('auth') && $this->request->hasPost('user_id')) {
         $user = User::findFirst($this->request->getPost('user_id'));
         $this->view->setVars(array('user_id' => $id = $user->id, 'first_name' => $name = isset($user->first_name) ? $user->first_name : false, 'organization' => $org = isset($user->organization) ? $user->organization : false, 'profession' => $profession = isset($user->profession) ? $user->profession : false, 'phone' => $phone = isset($user->phone) ? $user->phone : false, 'email' => $email = isset($user->email) ? $user->email : false, 'country' => $country = isset($user->country) ? $user->country : false, 'adress' => $adress = isset($user->adress) ? $user->adress : false));
     }
 }
 public function delorderAction()
 {
     $this->view->disable();
     if ($this->request->hasPost('order') && $this->request->isAjax()) {
         $prop = Proposal::findFirst($this->request->getPost('order'));
         foreach ($prop->dannproposal as $dann) {
             $dann->delete();
         }
         foreach ($prop->favorites as $fav) {
             foreach (ProposalHasFavorites::find(array("proposal_id = {$prop->id}")) as $favs) {
                 $favs->delete();
             }
             $fav->delete();
         }
         foreach ($prop->comments as $comm) {
             $comm->delete();
         }
         $prop->delete();
     }
 }
/**
 * 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();
}
                 Proposal::getInstance()->updateProposal($props, $single_proposal_for_accepted_project->proposal_id);
                 //uncomment to set this after testing **************
             }
         }
     }
 } else {
     // this.proposal =!= accepted proposal // any other proposals by this student not accepted
     if ($my_proposal->state != 'rejected') {
         $props = array();
         $props['state'] = 'archived';
         // set these to archived in case we need to separate later between auto rejected & manually rejected
         Proposal::getInstance()->updateProposal($props, $my_proposal->proposal_id);
         //uncomment to set this after testing **************
     }
     $project_id = $my_proposal->pid;
     $all_proposals_for_this_project = Proposal::getInstance()->getProposalsPerProject($project_id, '', true);
     // TODO - may need to set details flag here
     foreach ($all_proposals_for_this_project as $single_proposal_for_unaccepted_project) {
         if ($single_proposal_for_unaccepted_project->owner_id == $student && $single_proposal_for_unaccepted_project->proposal_id == $single_proposal_for_unaccepted_project->pr_proposal_id) {
             $update_props = array();
             $update_props['proposal_id'] = NULL;
             if ($single_proposal_for_unaccepted_project->selected == "0") {
                 //(means its an interim)
                 // email mentor only - withdrawn PREFERRED INTERIM
                 notify_all_of_project_offer_rejection($single_proposal_for_unaccepted_project, $proposal_id, true);
             } else {
                 // (means its an offer)
                 $update_props['selected'] = 0;
                 // email (mentor) - rejected OFFER - project is therefore reopened and he should choose another proposal
                 // email this proposal (student & supervisor) to say that the project has reopended and the mentor can choose another, possibly theirs
                 notify_all_of_project_offer_rejection($single_proposal_for_unaccepted_project, $proposal_id, false);
 public function commentsAction()
 {
     $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     if ($this->request->hasPost('comm') && $this->request->hasPost('order') && $this->request->isAjax()) {
         $comments = new Comments();
         $comments->proposal_id = $this->request->getPost('order');
         $comments->reciever_id = $this->session->get('user_id');
         $comments->text = $this->request->getPost('comm');
         $comments->creation_date = date("Y-m-d-H-i-s");
         $comments->save();
         $prop = Proposal::findFirst($this->request->getPost('order'));
         foreach ($prop->comments as $comm) {
             $com[$comm->id] = array($comm->user->first_name, $comm->text, $comm->creation_date);
         }
         $this->view->setVars(array('comm' => $com));
     }
 }
 /**
  * Prints the result of the search for attribute <code>attribute</code> to
  * <code>$wgOut</code>
  *
  * @param $attribute String: attribute
  */
 private function printSearchResult($attribute)
 {
     global $wgOut;
     if (strlen($attribute)) {
         try {
             $searchResult = new TagCloud($attribute);
         } catch (InvalidAttributeException $e) {
             if ($attribute) {
                 $proposal = new Proposal($attribute);
                 // Attribute not found -> show attributes that are related
                 try {
                     // Only if suggestions found
                     if ($proposal->getProposal()) {
                         $wgOut->addHTML(wfMsg('fptc-suggestion'));
                         $wgOut->addHTML(' ');
                     }
                     $w = 1;
                     foreach ($proposal->getProposal() as $possibleAttribute) {
                         $wgOut->addHTML('<a href=' . $possibleAttribute . '>' . $possibleAttribute . '</a>');
                         if ($w < count($proposal->getProposal())) {
                             $wgOut->addHTML(', ');
                         }
                         $w++;
                     }
                 } catch (InvalidAttributeException $e) {
                     $wgOut->addHTML(wfMsg('fptc-no-suggestion'));
                 }
                 if ($proposal->getProposal()) {
                     $wgOut->addHTML('<br /><br />');
                 }
             }
         }
     }
 }
Beispiel #20
0
function showOrganisationOverviewPage($organisations)
{
    include_once _VALS_SOC_ROOT . '/includes/classes/Proposal.php';
    if ($organisations->rowCount() == 1) {
        $org_id = $organisations->fetchObject()->org_id;
        $nr_proposals_draft = count(Proposal::getProposalsPerOrganisation($org_id));
        $nr_proposals_final = count(Proposal::getProposalsPerOrganisation($org_id, '', 'published'));
        echo "<b>" . t("Proposals in draft:") . "</b>&nbsp; {$nr_proposals_draft}<br>";
        echo "<b>" . t("Proposals submitted:") . "</b>&nbsp; {$nr_proposals_final}<br>";
    } else {
        foreach ($organisations->fetchAll() as $org) {
            echo "<h2>" . $org->name . "</h2>";
            $org_id = $org->org_id;
            $nr_proposals_draft = count(Proposal::getProposalsPerOrganisation($org_id));
            $nr_proposals_final = count(Proposal::getProposalsPerOrganisation($org_id, '', 'published'));
            echo "<b>" . t("Proposals in draft:") . "</b>&nbsp; {$nr_proposals_draft}<br>";
            echo "<b>" . t("Proposals submitted:") . "</b>&nbsp; {$nr_proposals_final}<br>";
        }
    }
}
 private function getTelOrderAndTelVisit(Proposal $proposal)
 {/*{{{*/
     $telOrder = current($proposal->getExecutions());
     if (empty($telOrder))
     {
         $telOrder = new NullEntity();
     }
     $telVisit = new NullEntity();
     if (false == $telOrder->isNull())
     {
         $telVisit = DAL::get()->find_by_orderid('TelVisit', $telOrder->id);
     }
     return array($telOrder, $telVisit);
 }/*}}}*/
Beispiel #22
0
	/**
	 * content area of one comment
	 *
	 * @param Comment $comment
	 */
	private function display_comment_content(Comment $comment) {
?>
		<p><?php 
echo content2html($comment->content);
?>
</p>
<?

		// reply
		if (
			self::$proposal->allowed_add_comments($this->rubric) and
			self::$parent!=$comment->id and
			!$comment->removed
		) {
			if (Login::access_allowed("comment")) {
				$open = self::$open;
				$open[] = $comment->id;
				$open = array_unique($open);
?>
		<div class="reply"><a href="<?php 
echo URI::append(['open' => $open, 'parent' => $comment->id]);
?>
#form" class="iconlink"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></a></div>
<?
			} else {
?>
		<div class="reply iconlink disabled"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></div>
<?
			}
		}

		// rating and remove/restore
		if ($comment->rating) {
			?><span class="rating" title="<?php 
echo _("sum of ratings");
?>
">+<?php 
echo $comment->rating;
?>
</span> <?
		}
		if (Login::$admin) {
			form(URI::same(), 'class="button"');
?>
<input type="hidden" name="id" value="<?php 
echo $comment->id;
?>
">
<?
			if ($comment->removed) {
?>
<input type="hidden" name="action" value="restore_comment">
<input type="submit" value="<?php 
echo _("restore");
?>
">
<?
			} else {
?>
<input type="hidden" name="action" value="remove_comment">
<input type="submit" value="<?php 
echo _("remove");
?>
">
<?
			}
			form_end();
		} elseif (
			self::$proposal->allowed_add_comments($this->rubric) and
			// don't allow to rate ones own comments
			!$comment->is_author() and
			// don't allow to rate removed comments
			!$comment->removed
		) {
			if (Login::access_allowed("rate")) {
				$disabled = "";
				$uri = URI::same()."#comment".$comment->id;
			} else {
				$disabled = " disabled";
				$uri = "";
			}
			if ($comment->score) {
				form($uri, 'class="button rating reset"');
?>
<input type="hidden" name="comment" value="<?php 
echo $comment->id;
?>
">
<input type="hidden" name="action" value="reset_rating">
<input type="submit" value="0"<?php 
echo $disabled;
?>
>
<?
				form_end();
			}
			for ($score=1; $score <= Comment::rating_score_max; $score++) {
				form($uri, 'class="button rating'.($score <= $comment->score?' selected':'').'"');
?>
<input type="hidden" name="comment" value="<?php 
echo $comment->id;
?>
">
<input type="hidden" name="action" value="set_rating">
<input type="hidden" name="rating" value="<?php 
echo $score;
?>
">
<input type="submit" value="+<?php 
echo $score;
?>
"<?php 
echo $disabled;
?>
>
<?
				form_end();
			}
		}

	}
function renderProposal($proposal, $target = 'none', $follow_action = 'show')
{
    //A proposal consists of: fields = array('proposal_id', 'owner_id', 'org_id', 'inst_id',
    //'supervisor_id', 'pid', 'solution_short', 'solution_long', 'state',);
    $propid = $proposal->proposal_id;
    $buttons = '';
    if (Users::isStudent() && Groups::isOwner(_PROPOSAL_OBJ, $propid) && $proposal->state != 'published') {
        $delete_action = "onclick='if(confirm(\"" . t('Are you sure you want to delete this proposal?') . "\")){ajaxCall(\"proposal\", \"delete\", " . "{type: \"proposal\", proposal_id: {$propid}, target: \"{$target}\"}, \"refreshTabs\", \"json\", " . "[\"proposal\", \"{$target}\", \"proposal\", \"\", \"{$follow_action}\"]);}'";
        $edit_action = "onclick='ajaxCall(\"proposal\", \"edit\", {type: \"proposal\", proposal_id: {$propid}, target: " . "\"{$target}\", format:\"html\"}, \"formResult\", \"html\", [\"{$target}\", \"proposal\"]);'";
        $buttons .= "<div class='totheright' id='proposal_buttons'><input type='button' value='" . t('edit') . "' {$edit_action}/>";
        $buttons .= "<input type='button' value='" . t('delete') . "' {$delete_action}/></div>";
    }
    $content = "<div id='msg_{$target}'></div>\r\n\t{$buttons}" . "<h1>" . ($proposal->title ? $proposal->title : Proposal::getDefaultName('', $proposal)) . " (" . renderDefaultField('state', $proposal) . ")</h1>\r\n\r\n\t<div id='personalia'>\r\n\t<h3>Parties involved</h3>\r\n\t<ul>\r\n\t<li>" . t('Supervisor') . ": " . renderDefaultField('supervisor_name', $proposal, 'supervisor_user_name') . "</i>" . "<li>" . t('Mentor') . ": " . renderDefaultField('mentor_name', $proposal, 'mentor_user_name') . "</i>" . "<li>" . t('Student') . ": " . renderDefaultField('student_name', $proposal, 'name') . "</i>" . "<li>" . t('Institute') . ": " . renderDefaultField('i_name', $proposal) . "</i>" . "<li>" . t('Organisation') . ": " . renderDefaultField('o_name', $proposal) . "</i>" . "</ul>\r\n\t\t\t</div>" . "<div id='project'>\r\n\t\t\t" . t('Project') . ": " . $proposal->pr_title . "\r\n\t\t\t</div>" . "<div id='proposal_text'>\r\n\t\t\t<h3>" . t('Solution Summary') . "</h3>\r\n\t\t\t" . renderDefaultField('solution_short', $proposal) . "<br/>" . "<a href='javascript:void(0)' data='off' onclick='makeVisible(\"solution_{$propid}\");'>" . t('more') . "</a>" . "\r\n\t\t\t<div id='solution_{$propid}' class='invisible'>\r\n\t\t\t<h3>Solution</h3>\r\n\t\t\t" . renderDefaultField('solution_long', $proposal) . "\r\n\t\t\t</div>\r\n\t\t\t</div>";
    module_load_include('inc', 'vals_soc', 'includes/ui/comments/threaded_comments');
    $content .= initComments($propid, _PROPOSAL_OBJ);
    return $content;
}
 private function isAllowedToDispatch(Space $space, Proposal $proposal)
 {/*{{{*/
     $allow = $space->ensureToAnswer();
     if ($proposal->isComplicatedToPickup())
     {
         $cnt = DAL::get()->querySpacePickupCnt('proposal', $space);
         if($cnt >= self::MAX_ALLOW_PICKUP_CNT)
         {
             return 833;
         }
     }
     if($proposal->hasPickedUp())
     {
         return 834;
     }
     if(false == $space->isDoctor())
     {
         return 835;
     }
     return $this->ensureToAnswerByRecommendCategory($space, $proposal);
 }/*}}}*/