summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
blob: 5bceac3e1d0a4ceda33840257effad33a63fa4ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php

class CourseBackend_Dummy extends CourseBackend
{
	private $pw;

	/**
	 * uses json to setCredentials, the json must follow the form given in
	 * getCredentials
	 *
	 * @param array $data with the credentials
	 * @param string $url address of the server
	 * @param int $serverId ID of the server
	 * @returns bool if the credentials were in the correct format
	 */
	public function setCredentials($json, $location, $serverId)
	{
		$x = $json;
		$this->pw = $x['password'];

		if ($this->pw === "mfg") {
			$this->error = false;
			return true;
		} else {
			$this->error = "USE mfg as password!";
			return false;
		}
	}

	/**
	 * @return boolean true if the connection works, false otherwise
	 */
	public function checkConnection()
	{
		if ($this->pw == "mfg") {
			$this->error = false;
			return true;
		} else {
			$this->error = "USE mfg as password!";
			return false;
		}
	}

	/**
	 * @returns array with parameter name as key and and an array with type, help text and mask  as value
	 */
	public function getCredentials()
	{
		$options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"];
		$credentials = [
			"username" => "string",
			"password" => "password",
			"integer" => "int",
			"option" => $options,
			"CheckTheBox" => "bool",
			"CB2 t" => "bool"
		];
		return $credentials;
	}

	/**
	 * @return string return display name of backend
	 */
	public function getDisplayName()
	{
		return 'Dummy with array';
	}

	/**
	 * @return int desired caching time of results, in seconds. 0 = no caching
	 */
	public function getCacheTime()
	{
		return 0;
	}

	/**
	 * @return int age after which timetables are no longer refreshed should be
	 * greater then CacheTime
	 */
	public function getRefreshTime()
	{
		return 0;
	}

	/**
	 * Internal version of fetch, to be overridden by subclasses.
	 *
	 * @param $roomIds array with local ID as key and serverId as value
	 * @return array a recursive array that uses the roomID as key
	 * and has the schedule array as value. A shedule array contains an array in this format:
	 * ["start"=>'JJJJ-MM-DD HH:MM:SS',"end"=>'JJJJ-MM-DD HH:MM:SS',"title"=>string]
	 */
	public function fetchSchedulesInternal($roomId)
	{
		$a = array();
		foreach ($roomId as $id) {
			$x['id'] = $id;
			$calendar['title'] = "test exam";
			$calendar['start'] = "2017-3-08 13:00:00";
			$calendar['end'] = "2017-3-08 16:00:00";
			$calarray = array();
			$calarray[] = $calendar;
			$x['calendar'] = $calarray;
			$a[$id] = $calarray;
		}


		return $a;
	}

}

?>