Project

General

Profile

Feature #4655 » eph_settings.php

Yannick Warnier, 25/04/2012 18:07

 
1
<?php
2
	$language_file = array('ephorus');
3
	require_once('settings.inc.php');
4
	require('../inc/global.inc.php');
5

    
6
api_protect_admin_script();
7

    
8
?>
9
<html>
10
<head>
11
	<style>
12
		.text{
13
			font-family: Arial;
14
			font-size: 9pt;
15
		}
16
		.errMessage{
17
			color: red;
18
		}
19
	</style>
20
</head>
21
<body style="padding: 5px;">
22
<?php
23
	$showresult = false;
24
	$HISrv = "";
25
	$ISrv = "";
26
	$UCode = "";
27
	$errorMessage = "";
28
	if($_SERVER['REQUEST_METHOD'] == 'POST' && ISSET($_POST['save_config']))
29
	{
30
		$HISrv = trim($_POST["hisrv"]);
31
		$ISrv = trim($_POST["isrv"]);
32
		$UCode = trim($_POST["ucode"]);
33
		if($HISrv==""){
34
			$errorMessage.=get_lang('EphorusHISValidation')."<br>";
35
		}
36
		if($ISrv==""){
37
			$errorMessage.=get_lang('EphorusISValidation')."<br>";
38
		}
39
		if($UCode==""){
40
			$errorMessage.=get_lang('EphorusUCValidation')."<br>";
41
		}
42

    
43
		if($errorMessage==""){
44
			//save
45
			get_saved_value("HandInService", $HISrv);
46
			get_saved_value("IndexService", $ISrv);
47
			get_saved_value("UploadCode", $UCode);
48
		}
49
	}
50
	else if($_SERVER['REQUEST_METHOD'] == 'POST' && ISSET($_POST['update_courses']))
51
	{
52
		$i = 0;
53
		$j = 0;
54

    
55
		// get all courses, for every course, make sure 'ephorus_student_publications' tool is present in the tools list
56
		$sql_query = "SELECT code FROM course";
57
		$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
58

    
59
		while ($crs = mysql_fetch_array($sql_result))
60
		{
61
			// only add if not present
62
			$sql_query2 = "SELECT id FROM crs_".$crs['code']."_tool WHERE name = 'ephorus_student_publications'";
63

    
64
			echo "Q: '".$sql_query2."'<br/>";
65

    
66
			$sql_result2 = api_sql_query($sql_query2,__FILE__,__LINE__);
67

    
68
			$i++;
69

    
70
			if (mysql_num_rows($sql_result2) == 0)
71
			{
72
				$sql_ins_query = "INSERT INTO `crs_".$crs['code']."_tool` VALUES ('', 'ephorus_student_publications','ephorus/work.php','works.gif','1','0','squaregrey.gif','NO','_self','interaction')";
73
				api_sql_query($sql_ins_query,__FILE__,__LINE__);
74
				$j++;
75
			}
76
		}
77

    
78
		$showresult = true;
79

    
80
		$HISrv = get_saved_value("HandInService", null);
81
		$ISrv = get_saved_value("IndexService", null);
82
		$UCode = get_saved_value("UploadCode", null);
83
	}
84
	else{
85
		$HISrv = get_saved_value("HandInService", null);
86
		$ISrv = get_saved_value("IndexService", null);
87
		$UCode = get_saved_value("UploadCode", null);
88
	}
89
?>
90
	<img src="http://www1.ephorus.com/images/ephorus_logo.gif">
91
	<table style="width: 650px;">
92
		<form id="form1" method="POST" action="eph_settings.php">
93
		<tr>
94
			<td style="width: 100px;">&nbsp;</td>
95
			<td style="width: 100px;">&nbsp;</td>
96
			<td style="width: 450px;" class="text"><?php echo get_lang('EphorusSettingsText') ?></td>
97
		</tr>
98
		<tr>
99
			<td style="width: 100px;">&nbsp;</td>
100
			<td style="width: 100px;" class="text"><?php echo get_lang('EphorusHIS') ?></td>
101
			<td style="width: 450px;"><input type="text" name="hisrv" style="width: 400px;" value="<?php echo $HISrv; ?>"></td>
102
		</tr>
103
		<tr>
104
			<td style="width: 100px;">&nbsp;</td>
105
			<td style="width: 100px;" class="text"><?php echo get_lang('EphorusIS') ?></td>
106
			<td style="width: 450px;"><input type="text" name="isrv" style="width: 400px;" value="<?php echo $ISrv; ?>"></td>
107
		</tr>
108
		<tr>
109
			<td style="width: 100px;">&nbsp;</td>
110
			<td style="width: 100px;" class="text"><?php echo get_lang('EphorusUC') ?></td>
111
			<td style="width: 450px;"><input type="text" name="ucode" style="width: 400px;" value="<?php echo $UCode; ?>"></td>
112
		</tr>
113
<?php
114
	if($errorMessage!=""){
115
?>
116
		<tr>
117
			<td style="width: 100px;">&nbsp;</td>
118
			<td style="width: 100px;">&nbsp;</td>
119
			<td style="width: 450px;" class="text errMessage"><?php echo $errorMessage ?></td>
120
		</tr>
121
<?php
122
	}
123
?>
124
		<tr>
125
			<td style="width: 100px;">&nbsp;</td>
126
			<td style="width: 100px;">&nbsp;</td>
127
			<td style="width: 450px;"><input type="submit" name="save_config" style="width: 150px" value="<?php echo get_lang('EphorusSC') ?>"/></td>
128
		</tr>
129
		</form>
130
		<form id="form2" method="POST" action="eph_settings.php">
131
		<tr>
132
			<td style="width: 100px;">&nbsp;</td>
133
			<td style="width: 100px;">&nbsp;</td>
134
			<td style="width: 450px;">&nbsp;</td>
135
		</tr>
136
		<tr>
137
			<td style="width: 100px;">&nbsp;</td>
138
			<td style="width: 100px;">&nbsp;</td>
139
			<td style="width: 430px;">
140
<?php
141
	if($showresult){
142
		echo $j.get_lang('EphorusUpdCrsConf').$i.".";
143
	}else{
144
?>
145
		<input type="submit" name="update_courses" style="width: 150px" value="<?php echo get_lang('EphorusUpdCrs') ?>"/>
146
<?
147
	}
148
?>
149
			</td>
150
		</tr>
151
		</form>
152
	<table>
153
</body>
154
</html>
(3-3/4)