예제 #1
0
function renderOrganisation($type, $organisation = '', $organisation_owner = '', $target = '', $show_buttons = true)
{
    if (!$organisation) {
        $organisation = Groups::getGroup($type, '', $organisation_owner);
    }
    $key_name = Groups::keyField($type);
    $id = $organisation->{$key_name};
    if ($organisation) {
        $s = '';
        if ($show_buttons && user_access('vals admin register')) {
            $pPath = request_path();
            $edit_action = "onclick='ajaxCall(\"administration\", \"edit\", {type: \"{$type}\", id: {$id}, path: \"{$pPath}\", target: \"{$target}\"}, " . ($type == _STUDENT_GROUP ? "\"{$target}\");'" : "\"formResult\", \"html\", \"{$target}\");'");
            $s .= "<div class='totheright'>";
            $s .= "\t<input type='button' value='" . t('edit') . "' {$edit_action}/>";
            // has the org signup period ended if so user cant add/delete entries, only edit
            if (vals_soc_access_check("dashboard/{$type}/administer/add_or_delete")) {
                $delete_action = "onclick='if(confirm(\"" . tt('Are you sure you want to delete this %1$s?', t_type($type)) . "\")){ajaxCall(\"administration\", \"delete\", {type: \"{$type}\", id: {$id}, path: \"{$pPath}\", target: \"{$target}\"}, \"refreshTabs\", \"json\", [\"{$type}\", \"{$target}\", \"administration\"]);}'";
                $s .= "\t<input type='button' value='" . t('delete') . "' {$delete_action}/>";
            }
            $s .= "</div>";
            //$sub_type_user = '';
        }
        $s .= formatMemberRecordNice($organisation, $type, $target);
        if ($type == _STUDENT_GROUP) {
            $s .= "<h2>" . t('Members') . "</h2>";
            $students = Users::getStudents($id);
            $s .= renderStudents('', $students);
        }
        return $s;
    } else {
        return tt('You have no %1$s registered yet', $type);
    }
}
예제 #2
0
     echo "<div id='admin_container' class='tabs_container'>";
     echo showMyProposalPage();
     echo "</div>";
     break;
 case 'render_proposals_for_id':
     if (isset($_POST['mine_only']) && $_POST['mine_only']) {
         $mine_only = $_POST['mine_only'] === 'true' ? true : false;
     }
     if (isset($_POST['id']) && $_POST['id']) {
         echo showProposalsForProject($_POST['id'], $mine_only);
     } else {
         echo "Unable to find proposals without project identifier";
     }
     break;
 case 'proposal_form':
     if (!vals_soc_access_check('dashboard/projects/apply')) {
         echo errorDiv(t('You cannot apply for projects'));
         break;
     }
     $target = altSubValue($_POST, 'target');
     $project_id = altSubValue($_POST, 'id');
     $proposal_id = altSubValue($_POST, 'proposalid', 0);
     if (!Users::isOfType(_STUDENT_TYPE, $GLOBALS['user']->uid)) {
         if (_VALS_TEST_UI_ONLY) {
             //TODO: this kind of testing should go soon
             echo "!! Since you are an admin, you can test a bit. We test with user 31 under the condition that _VALS_TEST_UI_ONLY is true.";
             $owner_id = 31;
         } else {
             echo errorDiv(t('Only students can submit proposals'));
             return;
         }
예제 #3
0
function initBrowseProposalsLayout()
{
    $org_id = 0;
    $apply_projects = vals_soc_access_check('dashboard/projects/apply') ? 1 : 0;
    $rate_projects = Users::isSuperVisor();
    $browse_proposals = vals_soc_access_check('dashboard/proposals/browse') ? 1 : 0;
    $proposal_tabs = array();
    if (isset($_GET['organisation'])) {
        $org_id = $_GET['organisation'];
    }
    if ($apply_projects && !$browse_proposals) {
        //A student may only browse their own proposals
        $student_id = $GLOBALS['user']->uid;
        $student = Users::getStudentDetails($student_id);
        $inst_id = $student->inst_id;
        $student_section_class = 'invisible';
    } else {
        $student_section_class = '';
        $student_id = 0;
        if (isset($_GET[_STUDENT_TYPE])) {
            $student_id = $_GET[_STUDENT_TYPE];
        }
        $inst_id = 0;
        if (isset($_GET['institute'])) {
            $inst_id = $_GET['institute'];
        }
    }
    ?>
<div class="filtering" style="width: 800px;">
	<span id="infotext" style="margin-left: 34px"></span>
	<form id="proposal_filter">
        <?php 
    echo t('Select the proposals');
    ?>
:
        <?php 
    // echo t('Organisations');
    ?>
        <select id="organisation" name="organisation">
			<option <?php 
    echo !$org_id ? 'selected="selected"' : '';
    ?>
				value="0"><?php 
    echo t('All Organisations');
    ?>
</option><?php 
    $result = Organisations::getInstance()->getOrganisationsLite();
    foreach ($result as $record) {
        $selected = $record->org_id == $org_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->org_id . '">' . $record->name . '</option>';
    }
    ?>
        </select> <span id='student_section'
			class='<?php 
    echo $student_section_class;
    ?>
'> <select id="institute"
			name="institute">
				<option <?php 
    echo !$inst_id ? 'selected="selected"' : '';
    ?>
					value="0"><?php 
    echo t('All Institutes');
    ?>
</option><?php 
    $result = Groups::getGroups(_INSTITUTE_GROUP, 'all');
    foreach ($result as $record) {
        $selected = $record->inst_id == $inst_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->inst_id . '">' . $record->name . '</option>';
    }
    ?>
	        </select> <select id="student" name="student">
				<option <?php 
    echo !$student_id ? 'selected="selected"' : '';
    ?>
					value="0"><?php 
    echo t('All Students');
    ?>
</option><?php 
    $result = Users::getUsers(_STUDENT_TYPE, $inst_id ? _INSTITUTE_GROUP : 'all', $inst_id);
    foreach ($result as $record) {
        $selected = $record->uid == $student_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->uid . '">' . $record->name . ':' . $record->mail . '</option>';
    }
    ?>
	        </select>
		</span>
	</form>
</div>
<div id="TableContainer" style="width: 800px;"></div>
<script type="text/javascript">

		jQuery(document).ready(function($){

			//We make the ajax script path absolute as the language module might add a language code
			//to the path
			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;
    ?>
;

			function loadFilteredProposals(){
				$("#TableContainer").jtable("load", {
        			student: $("#student").val(),
                                organisation: $("#organisation").val(),
        			institute: $("#institute").val()
        		});
			}

		    //Prepare jTable
			$("#TableContainer").jtable({
				//title: "Table of proposals",
				paging: true,
				pageSize: 10,
				sorting: true,
				defaultSorting: "pid ASC",
				actions: {
					listAction: moduleUrl + "actions/proposal_actions.php?action=list_proposals"
				},
				fields: {
					proposal_id: {
						key: true,
						create: false,
						edit: false,
						list: false
					},
					pid: {
						width: "2%",
    					title: "Project",
						sorting: true,
    					display: function (data) {
							return "<a title=\"View project details\" href=\"javascript:void(0);\" onclick=\"getProjectDetail("+data.record.pid+");\">"+
									"<span class=\"ui-icon ui-icon-info\"></span></a>";
    					},
    					create: false,
    					edit: false
					},
					owner_id: {
						title: "Student",
						width: "30%",
						display: function (data){
							if(data.record.name){
								return data.record.name;
							}else{
								return data.record.u_name;
							}
						}
					},
					inst_id: {
						title: "Institute",
						width: "26%",
						create: false,
						edit: false,
						display: function (data){return data.record.i_name;}
					},
					org_id: {
						title: "Organisation",
						width: "20%",
						display: function (data){return data.record.o_name;}
					},

					solution_short : {//the key of the object is misused to show this column
						//width: "2%",
    					title: "Proposal details",
						sorting: false,
    					display: function (data) {
							return "<a title=\"See this Proposal\" href=\"javascript:void(0);\" "+
								"onclick=\"getProposalDetail("+data.record.proposal_id+")\">"+
									"<span class=\"ui-icon ui-icon-info\">See details</span></a>";
    					},

    					create: false,
    					edit: false
					},

				},
			});

			//Load proposal list from server on initial page load
			loadFilteredProposals();

			$("#organisation").change(function(e) {
           		e.preventDefault();
           		loadFilteredProposals();
        	});

			$("#institute").change(function(e) {
           		e.preventDefault();
           		loadFilteredProposals();
        	});

			$("#student").change(function(e) {
				e.preventDefault();
				loadFilteredProposals();
			});

			$("#proposal_filter").submit(function(e){
				e.preventDefault();
				loadFilteredProposals()
			});

			// define these at the window level so that they can still be called once loaded in the modal
			//window.getProposalFormForProject = getProposalFormForProject;
			//window.getProjectDetail = getProjectDetail;
			//window.getProposalDetail = getProposalDetail;

		});
	</script><?php 
}
예제 #4
0
function initBrowseProjectLayout($pid = '')
{
    $org_id = 0;
    if (isset($_GET['organisation'])) {
        $org_id = $_GET['organisation'];
    }
    $state = null;
    if (isset($_GET['state'])) {
        $state = $_GET['state'];
    }
    $apply_projects = vals_soc_access_check('dashboard/projects/apply') ? 1 : 0;
    $rate_projects = Users::isSuperVisor();
    $is_student = Users::isStudent();
    ?>
	<div class="filtering" id="browse_projects">
		<span id="infotext" style="margin-left: 34px"></span>
		<form id="project_filter">
		<?php 
    echo t('Tags');
    ?>
: <input type="text" name="tags" id="tags" />
		<?php 
    echo t('Organisations');
    ?>
:
			<select id="organisation" name="organisation">
			<option <?php 
    echo !$org_id ? 'selected="selected"' : '';
    ?>
 value="0"><?php 
    echo t('All Organisations');
    ?>
</option><?php 
    $result = Organisations::getInstance()->getOrganisationsLite();
    foreach ($result as $record) {
        $selected = $record->org_id == $org_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->org_id . '">' . $record->name . '</option>';
    }
    ?>
			</select>
			<?php 
    if ($is_student) {
        ?>
			<input type='button' value='<?php 
        echo t('Filter on Favourites');
        ?>
' id='favourite_filter'/>
			<?php 
    }
    ?>
			
			<?php 
    echo "<BR/>";
    echo t('Status');
    ?>
:
			<select id="state" name="state">
				<option <?php 
    echo !$state ? 'selected="selected"' : '';
    ?>
 value="0"><?php 
    echo t('NA');
    ?>
</option><?php 
    $states = array('draft' => 'draft', 'pending' => 'pending', 'open' => 'open', 'preselected' => 'preselected', 'active' => 'active', 'ended' => 'ended', 'archived' => 'archived');
    if (!Users::isAdmin()) {
        if (Users::isMentor()) {
            unset($states['archived']);
        } else {
            unset($states['draft']);
            if ($is_student) {
                unset($states['pending'], $states['archived']);
            } elseif (Users::isUser()) {
                unset($states['archived']);
            } else {
                $states = array();
            }
        }
    }
    foreach ($states as $key => $stat) {
        $selected = $key == $state ? 'selected="selected" ' : '';
        echo "<option {$selected} value='{$key}'>{$stat}</option>";
    }
    ?>
			</select>
			
		</form>
	</div>
	<div id="ProjectTableContainer" style="width: 700px;"></div>

<script type="text/javascript">
	jQuery(document).ready(function($){

		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;
    ?>
;
	
		//Prepare jTable
		$("#ProjectTableContainer").jtable({
			//title: "Table of projects",
			paging: true,
			pageSize: 10,
			sorting: true,
			defaultSorting: "title ASC",
			actions: {
				listAction: moduleUrl + "actions/project_actions.php?action=list_search"
			},
			fields: {
				pid: {
					key: true,
					create: false,
					edit: false,
					list: false
				},
				title: {
					title: "Project title",
					width: "40%",
					display: function (data) {
						return "<a title=\"View project details\" href=\"javascript:void(0);\" onclick=\"getProjectDetail("+
							data.record.pid+")\">" + data.record.title + "</a>";
						},
						create: false,
						edit: false
				},
				name: {
					title: "Organisation",
					width: "20%"
				},
				tags: {
					title: "Tags",
					width: "26%",
					create: false,
					edit: false
				},
				proposal_count: {
					title: "Proposals",
					width: "12%",
					create: false,
					edit: false
				},
				state: {
					title: "Status",
					//width: "12%",
					create: false,
					edit: false
				}
				/*
				,
				Detail: {
					width: "2%",
					title: "",
					sorting: false,
					display: function (data) {
						return "<a title=\"View project details\" href=\"#\" onclick=\"getProjectDetail("+
							data.record.pid+")\"><span class=\"ui-icon ui-icon-info\"></span></a>";
						},
					create: false,
					edit: false
				}
				*/
				<?php 
    if ($apply_projects) {
        ?>
					,
					Propose: {
						width: "2%",
						title: "",
						sorting: false,
						display: function (data) {
							return "<a title=\"Propose a project for this idea\" href=\"#\" onclick=\"getProposalFormForProject("+data.record.pid+")\">"+
							"<span class=\"ui-icon ui-icon-script\"></span></a>";
							},
						create: false,
						edit: false
					}<?php 
    }
    ?>
			}
			/*
//this makes of each row a filter for that project
			,recordsLoaded: function(event, data) {
				var browse_url = baseUrl + "dashboard/projects/browse?pid=";
				
				$(".jtable-data-row").each(function(){
					var $parent = $(this);
					
					var row_id = $parent.attr("data-record-key");
					$parent.children('td:first-child').click(function() {
						document.location.href=browse_url + row_id;
					});
				});
			}
			*/
		});
	
	//Load project list from server on initial page load
	$("#ProjectTableContainer").jtable("load", {
		tags: $("#tags").val(),
		state: $("#state").val(),
		organisation: $("#organisation").val()<?php 
    if ($pid) {
        echo ", pid: {$pid}";
    }
    ?>
	});
		
	$("#tags").keyup(function(e) {
		e.preventDefault();
		// only auto clear when there is no tag info
		if(testTagInput() && $("#tags").val()==""){
			$("#ProjectTableContainer").jtable("load", {
			tags: $("#tags").val(),
			state: $("#state").val(),
			organisation: $("#organisation").val()
			});
		}
	});
		
	$("#organisation").change(function(e) {
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});
	$("#state").change(function(e) {
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});
	<?php 
    if ($is_student) {
        ?>
	$("#favourite_filter").click(function(e) {
		e.preventDefault();
		//if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {favourites :true});
		//}
	});
	<?php 
    }
    ?>
	$("#project_filter").submit(function(e){
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});

	
	
					
	// define these at the window level so that they can still be called once loaded
	window.getProposalFormForProject = getProposalFormForProject;
	window.getProjectDetail = getProjectDetail;
	
	});
	</script>
<?php 
}
예제 #5
0
function showOrganisationAdminPage($organisations, $action = 'administer', $show_last = FALSE)
{
    $nr = 0;
    $data = array();
    $tabs = array();
    $id = 0;
    $tab_id_prefix = 'organisation_page-';
    $nr_orgs = $organisations->rowCount();
    $current_tab = $show_last ? $nr_orgs : 1;
    $current_tab_content = t('You have no organisation yet.');
    foreach ($organisations as $org) {
        $nr++;
        if ($nr == $current_tab) {
            $id = $org->org_id;
            $my_organisation = $org;
            $current_tab_content = renderOrganisation(_ORGANISATION_GROUP, $my_organisation, null, "{$tab_id_prefix}{$current_tab}", $action == 'administer');
        }
        $tabs[] = "'{$tab_id_prefix}{$nr}'";
        $data[] = array(2, $org->name, 'view', _ORGANISATION_GROUP, $org->org_id);
    }
    // check for org admin editing rights
    if ($action == 'administer' && vals_soc_access_check('dashboard/organisation/administer/add_or_delete')) {
        //To remove the add tab: comment the three lines below
        $nr++;
        $data[] = array(1, 'Add', 'add', _ORGANISATION_GROUP, null, "target={$tab_id_prefix}{$nr}&show_action=administer", true, 'adding_to_the right');
        $tabs[] = "'{$tab_id_prefix}{$nr}'";
    }
    echo sprintf('<h3>%1$s</h3>', t('Organisations you are involved in'));
    if ($nr) {
        echo renderTabs($nr, 'Org', $tab_id_prefix, _ORGANISATION_GROUP, $data, $id, TRUE, $current_tab_content, $current_tab);
        ?>
		<script type="text/javascript">
			activatetabs('tab_', [<?php 
        echo implode(',', $tabs);
        ?>
], '<?php 
        echo "{$tab_id_prefix}{$current_tab}";
        ?>
');
			</script>
		<?php 
    } else {
        echo $current_tab_content;
    }
}