@link http://blog.idleman.fr @licence CC by nc sa @version 1.0.0 @description Plugin intégrant un serveur caldav et un calendrier mois/semaine/jour */ function caldav_menu(&$menuItems){ global $_; $menuItems[] = array('sort'=>10,'content'=>' Calendrier'); } function caldav_home($_){ if(!isset($_['module']) || $_['module']!='caldav') return; global $myUser; try{ $dbmanager = new Configuration(); $calendarsQuery = $dbmanager->customQuery("SELECT * FROM ".ENTITY_PREFIX."plugin_caldav_calendars WHERE principaluri ='principals/".$myUser->getLogin()."'"); $calendars =array(); while($calendar = $calendarsQuery->fetchArray()): $calendars[] = $calendar; endwhile; if(count($calendars)==0) throw new Exception('Aucun calendrier créé pour votre compte, veuillez créer un calendrier avant de le consulter.'); $_['calendar'] = isset($_['calendar']) ? $_['calendar']: $calendars[0]['uri']; $url = YANA_URL.'/plugins/caldav/calendars.php/calendars/'.$myUser->getLogin() .'/'.$_['calendar']; ?>
Calendrier :
getMessage(); ?>
host = YANA_URL.'/plugins/caldav/calendars.php/calendars'; $client->login = $myUser->getLogin(); $client->password = $myUser->getToken(); $client->user = $myUser->getLogin(); $client->calendar = $_['calendar']; $events = $client->get_events($_['calendar'],strtotime($_['start']),strtotime($_['end'])); $response = array(); foreach($events as $event): $response[] = array( 'id' => $event->ics, 'title' => $event->title, 'start' => date('Y-m-d\TH:i:s',$event->start), 'end' => date('Y-m-d\TH:i:s',$event->end), 'backgroundColor'=> '#94c655', 'borderColor' => '#78ab24', 'textColor' => '#ffffff' ); endforeach; }); break; case 'caldav_save_event': Action::write(function($_,&$response){ global $myUser; require_once('CalDavClient.class.php'); $client = new CaldavClient(); $client->host = YANA_URL.'/plugins/caldav/calendars.php/calendars'; $client->login = $myUser->getLogin(); $client->password = $myUser->getToken(); $client->user = $myUser->getLogin(); $client->calendar = $_['calendar']; list($startDay,$startMonth,$startYear) = explode('/',$_['startDay']); list($endDay,$endMonth,$endYear) = explode('/',$_['endDay']); $start = mktime ($_['startHour'], $_['startMinut'], 0, $startMonth,$startDay, $startYear); $end = mktime ($_['endHour'], $_['endMinut'], 0, $endMonth,$endDay, $endYear); $event = new IcalEvent(); $event->title = $_['label']; $event->description = $_['label']; $event->start = $start; $event->end = $end ; $event->categories = array('évenement'); if($_['alert']=='1') $event->alarms = array($_['alertNumber'].$_['alertUnity']); if($_['location']!='') $event->location = $_['location']; $ics = isset($_['ics']) && !empty($_['ics']) ? $_['ics'] : null; $ics = $client->create_event($event,$ics); $event->id = $ics; $event->start = date('Y-m-d\TH:i:s',$start); $event->end = date('Y-m-d\TH:i:s',$end); $response['event'] = $event; }); break; case 'caldav_delete_event': Action::write(function($_,&$response){ global $myUser; require_once('CalDavClient.class.php'); $client = new CaldavClient(); $client->host = YANA_URL.'/plugins/caldav/calendars.php/calendars'; $client->login = $myUser->getLogin(); $client->password = $myUser->getToken(); $client->user = $myUser->getLogin(); $client->calendar = $_['calendar']; foreach($_['events'] as $ics){ $ics = $client->delete_event($ics); } }); break; case 'caldav_add_calendar': global $myUser; $dbmanager = new Configuration(); $slug = Functions::slugify($_['label']); $principalQuery = $dbmanager->customQuery("SELECT * FROM ".ENTITY_PREFIX."plugin_caldav_principals WHERE uri='principalsr/".$myUser->getLogin()."' LIMIT 1"); $principal = $principalQuery->fetchArray(); if(!$principal){ $query = " INSERT INTO ".ENTITY_PREFIX."plugin_caldav_principals (uri,email,displayname) VALUES ('principals/".$myUser->getLogin()."','". $myUser->getMail()."','".$myUser->getLogin()."'); INSERT INTO ".ENTITY_PREFIX."plugin_caldav_principals (uri,email,displayname) VALUES ('principals/".$myUser->getLogin()."/calendar-proxy-read', null, null); INSERT INTO ".ENTITY_PREFIX."plugin_caldav_principals (uri,email,displayname) VALUES ('principals/".$myUser->getLogin()."/calendar-proxy-write', null, null);"; $dbmanager->customExecute($query); } $query = "INSERT INTO ".ENTITY_PREFIX."plugin_caldav_calendars (principaluri, displayname, uri, synctoken, description, calendarorder, calendarcolor, timezone, components, transparent) VALUES ('principals/".$myUser->getLogin()."','". $_['label']."','". $slug."', 1, NULL, NULL, NULL, NULL, 'VEVENT,VTODO', '0');"; $dbmanager->customExecute($query); header('location: setting.php?section=caldav'); break; } } function caldav_setting_menu(){ global $_; echo '
  • Calendriers
  • '; } function caldav_setting_page(){ global $_,$myUser,$conf; if(isset($_['section']) && $_['section']=='caldav' ){ if(!$myUser) throw new Exception('Vous devez être connecté pour effectuer cette action'); $dbmanager = new Configuration(); $calendars = $dbmanager->customQuery("SELECT * FROM ".ENTITY_PREFIX."plugin_caldav_calendars WHERE principaluri ='principals/".$myUser->getLogin()."'"); ?>

    Calendriers

    Gestion des calendriers

    Créer un nouveau calendrier


    Calendrier créés

    fetchArray()): $url = YANA_URL.'/plugins/caldav/calendars.php/calendars/'.str_replace('principals/','',$calendar['principaluri']) .'/'.$calendar['uri']; ?>
    Nom Adresse du synchronisation