univ-pau-ics/build/router/controller/ics.php

95 lines
1.6 KiB
PHP
Raw Normal View History

<?php
namespace router\controller;
2017-09-13 13:03:36 +00:00
use \lightdb\core\lightdb;
class ics{
private $diplome_id;
/* PRE-CALL
*
* @url<String> Calling URI
*
*/
public function __construct($url){
$this->diplome_id = $url['diplome_id'];
2017-09-13 13:03:36 +00:00
}
/* CALL
*
*/
public function download(){
/* [1] Check .ics file
=========================================================*/
/* (1) Set file name */
$file_name = __ROOT__."/tmp/".$this->diplome_id.".ics";
/* (2) Check if exists */
if( !file_exists($file_name) )
die("An error occured. Please contact the developers.\n");
/* [2] Display file
=========================================================*/
/* (1) Headers */
header('Content-Type: text/calendar; charset=utf-8');
2017-09-12 17:11:39 +00:00
header('Content-Disposition: attachment; filename='.$this->diplome_id.'.ics');
/* (2) Body */
readfile($file_name);
}
2017-09-13 13:03:36 +00:00
public function info(){
/* [1] Get database colors
=========================================================*/
/* (1) Open instance */
try{
$ldb = new lightdb('config');
}catch(\Exception $e){
die("An error occured. Please contact the developers.\n");
}
/* (2) Fetch diplome data */
$d_cols = $ldb->fetch($this->diplome_id);
/* (3) Error */
if( $d_cols == false )
die("No color found for this diplome");
foreach($d_cols as $col=>$name){
echo "<span style='background-color: #".str_pad(substr($col,1), 6, "0", STR_PAD_LEFT).";'>PLANNING COLOR</span> => ";
if( $col == $name )
echo "no name<br>";
else
echo "$name<br>";
}
}
/* POST-CALL
*
*/
public function __destruct(){
}
}