summaryrefslogblamecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
blob: 482ca09773798200c3c0211947dd3027f4ca7819 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13

                                                 
                
 








                                                                              
                                                               
                 
                                 








                                                 

     


                                                                        
                                      







                                                 

     


                                                                                                             

                                                                                  
                                                                                                                                                 


                          


                                                        


                                     


                                                                                  


                                   



                                                                                  



                                     







                                                                                                 
                                                    



                                         

                                                  


                                   
                            


       
                



     
<?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->errormsg = "USE mfg as password!";
        $this->error = true;
        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->errormsg = "USE mfg as password!";
        $this->error = true;
        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;
    }

}
?>