97 lines
1.7 KiB
PHP
97 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace router\controller;
|
|
|
|
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'];
|
|
|
|
}
|
|
|
|
|
|
/* 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');
|
|
// header('Content-Disposition: attachment; filename='.$this->diplome_id.'.ics');
|
|
|
|
/* (2) Body */
|
|
echo "<pre>";
|
|
readfile($file_name);
|
|
echo "</pre>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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(){
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|