コード例 #1
0
ファイル: helper.php プロジェクト: raalzate/api-services
function _unadcalendar_add_events($v, $clientId, $events, $calendarId, $cs, $email)
{
    $response = array();
    $location = "UNAD - " . get_course_by_code(JSON_COUSER, $cs);
    $n = 0;
    foreach ($events as $data) {
        $inf = array();
        if (count($data) < 5) {
            continue;
        }
        for ($i = count($data) - 7 - 1; $i < count($data); $i++) {
            if ($i >= 0) {
                $inf[] = $data[$i];
            }
        }
        $summary = $cs . ' - ' . $inf[0] . ' Valor: ' . $inf[4];
        $description = $inf[1] . "\n";
        $description .= "Valor de la actividad: " . $inf[4];
        $dataTimeStart = date("Y-m-d", get_date_format($inf[2])) . "T12:00:00.000-05:00";
        $dataTimeEnd = date("Y-m-d", get_date_format($inf[3])) . "T23:55:55.000-05:00";
        //inserta un envento al calendario
        $rqEvent = google_calendar_add_event($v, $clientId, $calendarId, $summary, $description, $location, $dataTimeStart, $dataTimeEnd, $email)->body();
        $rqEvent = json_decode($rqEvent);
        if ($rqEvent->status) {
            //si el evento fue insertado con exito
            $response[$n]['description'] = $rqEvent->event->description;
            $response[$n]['htmlLink'] = $rqEvent->event->htmlLink;
            $response[$n]['summary'] = $rqEvent->event->summary;
            $response[$n]['start'] = $rqEvent->event->start;
            $response[$n]['end'] = $rqEvent->event->end;
            $response[$n]['id'] = $rqEvent->event->id;
            $n++;
        }
    }
    return $response;
}
コード例 #2
0
if (isset($_POST['submit'])) {
    if ($_POST['submit']) {
        $name = mysql_prep($_POST['name']);
        $code = mysql_prep($_POST['code']);
        $startdate = mysql_prep($_POST['startdate']);
        $enddate = mysql_prep($_POST['enddate']);
        $details = mysql_prep($_POST['details']);
        if (course_code_isExists($code)) {
            $msg = "Course Code Already Exists";
            goto error;
        }
        $query = "INSERT INTO course \n\t\t\t\t\t(Name, Code, StartDate, EndDate, Details) \n\t\t\t\t\tVALUES ('{$name}','{$code}','{$startdate}','{$enddate}','{$details}');";
        global $connection;
        $rs = mysql_query($query, $connection);
        confirm_query($rs);
        $course_row = mysql_fetch_array(get_course_by_code($code));
        redirect_to("view_course.php?id=" . $course_row['ID']);
    }
}
?>

<?php 
error:
require_once 'includes/header.php';
?>

<div class="row">
	<div class="col-md-4 col-md-offset-4">
		<div class="login-panel panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">Add A Course</h3>
コード例 #3
0
ファイル: hook.php プロジェクト: raalzate/api-services
function unadcalendar_find_calendar(Slim\Route $route)
{
    global $app, $info;
    $curso = $route->getParam('cs');
    $email = $route->getParam('em');
    $gcVersion = $info['google/calendar']['version'];
    $clientId = $info['unadcalendar']['client_id'];
    $rqCalendar = google_calendar_find($gcVersion, $clientId, $curso)->body();
    $rqCalendar = json_decode($rqCalendar);
    if ($rqCalendar->status) {
        //no existe problemas
        $calendarId = $rqCalendar->calendar->id;
        $rqEvents = google_calendar_get_events($gcVersion, $clientId, $calendarId)->body();
        $rqEvents = json_decode($rqEvents);
        if (!$rqEvents->status) {
            return;
        }
        $mpEvent = _unadcalendar_map_events($calendarId, $rqEvents->events, $email);
        if (is_null($mpEvent)) {
            //existe problemas con el calendario
            //no hay eventos, se elimina el calendario
            google_calendar_delete($gcVersion, $clientId, $calendarId);
            return;
        }
        $request['name'] = get_course_by_code(JSON_COUSER, $rqCalendar->calendar->summary);
        $request['code'] = $rqCalendar->calendar->summary;
        $request['status'] = true;
        $request['calendar_id'] = $calendarId;
        $request['events'] = $mpEvent;
        $app->response()->body(json_encode($request));
        $app->stop();
    }
}