Exemple #1
1
            $tail = " AND we.cal_create_by = '{$username}' {$tail}";
        } else {
            $tail = '';
            $ALL = 1;
            // Need this to tell get_ids to ignore participant check
        }
        $E_ids = get_ids('SELECT we.cal_id FROM webcal_entry we, webcal_entry_user weu ' . "WHERE cal_type = 'E' AND cal_date < '{$end_date}' {$tail}", $ALL);
        $M_ids = get_ids('SELECT DISTINCT(we.cal_id) FROM webcal_entry we,
      webcal_entry_user weu, webcal_entry_repeats wer
      WHERE we.cal_type = \'M\'
      AND we.cal_id = wer.cal_id AND we.cal_id = wer.cal_id ' . "AND cal_end IS NOT NULL AND cal_end < '{$end_date}' {$tail}", $ALL);
        $ids = array_merge($E_ids, $M_ids);
    }
    //echo "event ids: <ul><li>" . implode ( "</li><li>", $ids ) . "</li></ul>\n";
    if (count($ids) > 0) {
        purge_events($ids);
    } else {
        echo translate('None');
    }
    echo '<h2>...' . translate('Finished') . ".</h2>\n";
    ?>
  <form><input type="button" value="<?php 
    etranslate('Back');
    ?>
"
onclick="history.back()" /></form
><?php 
    if ($purgeDebug) {
        echo '<div style="border: 1px solid #000;background-color: #ffffff;"><tt>' . $sqlLog . '</tt></div>' . "\n";
    }
} else {
Exemple #2
0
function updateRessources($db, $ressources, $startdate = null, $enddate = null, $GMT = "+1 hour")
{
    if ($startdate == null) {
        $startdate = date("Y-m-d");
    }
    if ($enddate == null) {
        $enddate = date("Y-m-d", strtotime("+30 days"));
    }
    $nb = array();
    foreach ($ressources as $ressource) {
        $ical = new ICal('https://planning.univ-rennes1.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=' . $ressource . '&projectId=1&calType=ical&firstDate=' . $startdate . '&lastDate=' . $enddate);
        $events = $ical->events();
        $insertNb = 0;
        purge_events($db, $ressource);
        if ($events) {
            foreach ($events as $event) {
                $export_d = date("Y/m/d H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTAMP'])));
                $start_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $start_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $end_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $end_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $description = desc2json($event['DESCRIPTION']);
                $req = $db->prepare('insert into events (UID,ressource, StartDate, StartTime, EndDate, EndTime, Title, Location, Description,Export) VALUES (?,?,?,?,?,?,?,?,?,?)');
                $res = $req->execute(array(issetor($event['UID']), $ressource, $start_d, $start_t, $end_d, $end_t, $event['SUMMARY'], issetor($event['LOCATION']), $description, $export_d));
                $insertNb += $res;
            }
        }
        $nb[$ressource] = $insertNb;
    }
    $req = $db->prepare("UPDATE ressources r inner join events e on r.number = e.ressource set r.last_sync = e.Export");
    $req->execute();
    return $nb;
}