Esempio n. 1
0
function mailEvent()
{
    global $error;
    $color = DEFAULT_COLOR;
    $arr_submit = array(array('cal_id', 'int', true, ''), array('str_date_end', 'string', false, ''), array('str_date_start', 'string', false, ''), array('title', 'string', false, ''), array('location', 'string', false, ''), array('phone', 'phone', false, ''), array('myurl', 'string', false, ''), array('description', 'string', false, ''));
    $frm_submitted = validate_var($arr_submit);
    $frm_submitted['title'] = stripslashes($frm_submitted['title']);
    if (empty($frm_submitted['title'])) {
        echo json_encode(array('success' => false, 'error' => 'Title is required'));
        exit;
    }
    if (is_null($error) || empty($error)) {
        // get calendar admin mail
        $arr_calendar = Calendar::getCalendar($frm_submitted['cal_id']);
        $to_mail = '';
        if (isset($arr_calendar['calendar_admin_email']) && !empty($arr_calendar['calendar_admin_email'])) {
            if (Utils::checkEmail($arr_calendar['calendar_admin_email'])) {
                $bln_email_correct = true;
                $to_mail = $arr_calendar['calendar_admin_email'];
            }
        } else {
            if (defined('MAIL_EVENT_MAILADDRESS')) {
                $mailaddress = MAIL_EVENT_MAILADDRESS;
                if (!empty($mailaddress)) {
                    if (Utils::checkEmail($mailaddress)) {
                        $bln_email_correct = true;
                        $to_mail = $mailaddress;
                    } else {
                        echo json_encode(array('success' => false, 'error' => 'No correct emailaddress found'));
                        exit;
                    }
                } else {
                    echo json_encode(array('success' => false, 'error' => 'Emailaddress in config.php is empty'));
                    exit;
                }
            } else {
                echo json_encode(array('success' => false, 'error' => 'No emailaddress found'));
                exit;
            }
        }
        if (!empty($to_mail)) {
            $arr_user = array();
            if (User::isLoggedIn()) {
                $arr_user = User::getUser();
            }
            $bln_send = Utils::sendMail('mail_event', $to_mail, '', $frm_submitted, $arr_user);
            if ($bln_send) {
                echo json_encode(array('success' => true, 'msg' => 'Mail successfully send'));
                exit;
            } else {
                echo json_encode(array('success' => false, 'error' => 'Error while sending the email, contact the admin'));
                exit;
            }
        } else {
            // echo json_encode(array('success'=>false, 'error'=>'No calendar admin email found'));
            //  exit;
        }
    } else {
        echo json_encode(array('success' => false, 'error' => $error));
        exit;
    }
}
Esempio n. 2
0
function saveCalendar()
{
    global $error;
    global $obj_smarty;
    $arr_submit = array(array('calendar_id', 'int', false, -1), array('name', 'string', true, ''), array('dditems', 'string', false, ''), array('calendar_color', 'string', true, ''), array('can_add', 'bool', false, 0), array('can_edit', 'bool', false, 0), array('can_delete', 'bool', false, 0), array('can_change_color', 'bool', false, 0), array('checkbox_use_color_for_all_events', 'bool', false, 0), array('initial_show', 'bool', false, 0), array('share_type', 'string', false, 'private'), array('active', 'string', true, ''), array('cal_startdate', 'string', false, ''), array('cal_enddate', 'string', false, ''), array('alterable_startdate', 'string', false, ''), array('alterable_enddate', 'string', false, ''));
    $frm_submitted = validate_var($arr_submit);
    if (!$error) {
        $bln_success = Calendar::saveCalendar($frm_submitted);
        if (is_string($bln_success)) {
            echo json_encode(array('success' => false, 'save_calendar_error' => $bln_success));
            exit;
        }
    } else {
        $obj_smarty->assign('save_calendar_error', $error);
    }
    if (!is_null($error) && $error !== false) {
        // give feedback about the error
        $arr_calendar = Calendar::getCalendar($frm_submitted['calendar_id'], true);
        $obj_smarty->assign('active', 'calendar');
        $obj_smarty->assign('calendar', $arr_calendar);
        $obj_smarty->display(FULLCAL_DIR . '/view/user_panel.tpl');
        exit;
    } else {
        header('location: ' . FULLCAL_URL . '/user/calendars');
        exit;
    }
}
Esempio n. 3
0
 public static function canDelete($event_user = 0, $cal_id = 0)
 {
     $arr_calendar = array();
     if ($cal_id > 0) {
         $arr_calendar = Calendar::getCalendar($cal_id);
     }
     if (User::isLoggedIn()) {
         $arr_user = User::getUser();
         if (defined('ADMIN_HAS_FULL_CONTROL') && ADMIN_HAS_FULL_CONTROL && (User::isAdmin() || User::isSuperAdmin())) {
             return true;
         }
     }
     if (!empty($arr_calendar)) {
         if (User::isLoggedIn()) {
             if ($_SESSION['calendar-uid']['uid'] == $event_user) {
                 return true;
             }
         }
         if ($arr_calendar['share_type'] == 'private_group' && $arr_calendar['can_delete'] && Calendar::UserInGroup($arr_calendar, $arr_user['user_id'])) {
             return true;
         }
         if ($arr_calendar['share_type'] == 'public' && $arr_calendar['can_delete']) {
             return true;
         }
         if (!$arr_calendar['can_delete']) {
             return false;
         }
     }
     //        if(isset($_SESSION['calendar-uid']['uid']) && $_SESSION['calendar-uid']['uid'] > 0) {
     //            $bln_users_can_delete_items_from_others = Settings::getAdminSetting('users_can_delete_items_from_others', $_SESSION['calendar-uid']['uid']);
     //        } else {
     //            $bln_users_can_delete_items_from_others = USERS_CAN_DELETE_ITEMS_FROM_OTHERS;
     //        }
     //if($bln_users_can_delete_items_from_others || (isset($_SESSION['calendar-uid']) && $event_user == $_SESSION['calendar-uid']['uid'])) {
     if (isset($_SESSION['calendar-uid']) && $event_user == $_SESSION['calendar-uid']['uid']) {
         return true;
     } else {
         return false;
     }
     return false;
 }
Esempio n. 4
0
 public static function updateRepeatingEvent($arr_dates, $frm_submitted)
 {
     global $obj_db;
     if (IGNORE_TIMEZONE) {
         $str_startdate = $frm_submitted['str_date_start'];
         $str_enddate = $frm_submitted['str_date_end'];
         $str_starttime = substr($frm_submitted['str_date_start'], 10);
         $str_endtime = substr($frm_submitted['str_date_end'], 10);
     } else {
         $str_startdate = date('Y-m-d', $frm_submitted['date_start']);
         $str_enddate = date('Y-m-d', $frm_submitted['date_end']);
         $str_starttime = date('H:i:s', $frm_submitted['date_start']);
         $str_endtime = date('H:i:s', $frm_submitted['date_end']);
     }
     /*
      * check if interval or weekdays have changed
      */
     //TODO other intervals 2weeks
     // get the pattern
     $str_select_repeating_query = 'SELECT * FROM repeating_events WHERE rep_event_id = ' . $frm_submitted['rep_event_id'];
     $obj_result1 = mysqli_query($obj_db, $str_select_repeating_query);
     $arr_repeat_pattern = mysqli_fetch_array($obj_result1, MYSQLI_ASSOC);
     // update repeating_events table
     $str_update_query = 'UPDATE repeating_events SET rep_interval = "' . $frm_submitted['interval'] . '", ' . 'weekdays = "' . $frm_submitted['weekdays'] . '",' . 'monthday = "' . $frm_submitted['monthday'] . '",' . 'yearmonthday = "' . $frm_submitted['yearmonthday'] . '",' . 'yearmonth = "' . $frm_submitted['yearmonth'] . '",' . 'startdate = "' . $str_startdate . '",' . 'enddate = "' . $str_enddate . '" ' . 'WHERE rep_event_id = ' . $frm_submitted['rep_event_id'];
     $res = mysqli_query($obj_db, $str_update_query);
     // check if moved to another calendar
     $bln_change_cal_id = false;
     if (defined('MOVE_EVENT_TO_OTHER_CALENDAR_POSSIBLE') && MOVE_EVENT_TO_OTHER_CALENDAR_POSSIBLE === true) {
         if ($frm_submitted['calendar_id'] > 0 && $frm_submitted['calendar_id'] != $frm_submitted['cal_id']) {
             $bln_change_cal_id = true;
         }
     }
     // update events
     $str_update_events_query = 'UPDATE `events` SET title = "' . $frm_submitted['title'] . '", ' . '`color` = "' . $frm_submitted['color'] . '", ';
     if ($bln_change_cal_id) {
         $str_update_events_query .= '`calendar_id` = "' . $frm_submitted['calendar_id'] . '", ';
     }
     $str_update_events_query .= '`location` = "' . $frm_submitted['location'] . '", ' . '`description` = "' . $frm_submitted['description'] . '", ' . '`phone` = "' . $frm_submitted['phone'] . '", ' . '`myurl` = "' . $frm_submitted['myurl'] . '", ' . '`time_start` = "' . $str_starttime . '", ' . '`time_end` = "' . $str_endtime . '", ' . '`allDay` = ' . ($str_starttime == '00:00:00' && $str_endtime == '00:00:00' || $frm_submitted['allDay'] == 1 ? '1 ' : '0 ') . 'WHERE `repeating_event_id` = ' . $frm_submitted['rep_event_id'];
     $res2 = mysqli_query($obj_db, $str_update_events_query);
     /*
      * get all existing items in this pattern
      */
     $arr_events_from_this_pattern = array();
     $str_events_query = 'SELECT * FROM events WHERE repeating_event_id = ' . $frm_submitted['rep_event_id'];
     $obj_result1 = mysqli_query($obj_db, $str_events_query);
     while ($arr_line = mysqli_fetch_array($obj_result1, MYSQLI_ASSOC)) {
         $arr_events_from_this_pattern[] = $arr_line;
     }
     /*
      * find deleted weekdays
      */
     $current_user_id = '';
     foreach ($arr_events_from_this_pattern as $event) {
         if (!in_array($event['date_start'], $arr_dates)) {
             // delete
             $obj_result_del = mysqli_query($obj_db, 'DELETE FROM events WHERE event_id = ' . $event['event_id']);
         } else {
             $search = array_search($event['date_start'], $arr_dates);
             unset($arr_dates[$search]);
         }
         $time_start = $event['time_start'];
         $time_end = $event['time_end'];
         $current_user_id = $event['user_id'];
         $current_calendar_id = $event['calendar_id'];
     }
     /*
      * added/changed weekdays
      */
     if ($frm_submitted['repair_pattern'] || $arr_repeat_pattern['weekdays'] != $frm_submitted['weekdays'] || $arr_repeat_pattern['startdate'] != $str_startdate || $arr_repeat_pattern['enddate'] != $str_enddate) {
         // add new items to pattern
         foreach ($arr_dates as $day) {
             if (IGNORE_TIMEZONE) {
                 $frm_submitted['str_date_start'] = $day . ' ' . $time_start;
                 $frm_submitted['str_date_end'] = $day . ' ' . $time_end;
             } else {
                 $frm_submitted['date_start'] = strtotime($day . ' ' . $time_start);
                 $frm_submitted['date_end'] = strtotime($day . ' ' . $time_end);
             }
             self::insertEvent($frm_submitted, $current_user_id);
         }
     }
     if ($frm_submitted['repair_pattern']) {
         // set bln_broken to 0
         $str_update_query = 'UPDATE repeating_events SET bln_broken = 0 WHERE rep_event_id = ' . $frm_submitted['rep_event_id'];
         $res3 = mysqli_query($obj_db, $str_update_query);
     }
     $current_calendar_id = 0;
     if (!$frm_submitted['repair_pattern']) {
         // because then the mail is already send in the insertEevent function
         // notification mail to admin
         if ($current_calendar_id > 0 && !empty($current_user_id)) {
             $arr_calendar = Calendar::getCalendar($current_calendar_id);
             if (Calendar::calMailEventModsToAdmin($arr_calendar)) {
                 $arr_user = User::getUserById($current_user_id);
                 $to_mail = Calendar::getCalendarAdminEmail($arr_calendar);
                 if (!empty($to_mail)) {
                     $bln_send = Utils::sendMail('mail_event', $to_mail, '', $frm_submitted, $arr_user);
                 }
             }
         }
     }
 }
Esempio n. 5
0
<?php

/*
 * Contrôleur de notre page de maps
 * gère la dynamique de l'application. Elle fait le lien entre l'utilisateur et le reste de l'application
 */
include_once "model/BDD.php";
include_once "model/Calendar.php";
include_once "model/Debug.php";
$calendar = new Calendar();
try {
    $infos = $calendar->getCalendar();
    $count = $calendar->getCountCalendar();
    $id = $count['count(*)'];
    $json = "{";
    foreach ($infos as $info) {
        $id--;
        $rdvDate = $info->rdv_date;
        $rdvIdDate = $info->rdv_iddate;
        if ($id == 0) {
            $json .= "'" . $rdvDate . "':'<a class=\"fancybox fancybox.iframe\" href=\"jour.php?rdvIdDate={$rdvIdDate}\" >Voir les èvènements</a>'";
        } else {
            $json .= "'" . $rdvDate . "':'<a class=\"fancybox fancybox.iframe\" href=\"jour.php?rdvIdDate={$rdvIdDate}\" >Voir les èvènements</a>',";
        }
    }
    $json .= "}";
    require_once "view/vueIndex.php";
} catch (Exception $e) {
    $msgErreur = $e->getMessage();
    require_once "view/vueErreur.php";
}
Esempio n. 6
0
 $first_default_calendar = array();
 if (isset($arr_calendars[0])) {
     $obj_smarty->assign('default_calendar_color', $arr_calendars[0]['calendar_color']);
     $first_default_calendar = $arr_calendars[0];
     $arr_permissions = Calendar::getPermissions($first_default_calendar['calendar_id']);
 } else {
     $obj_smarty->assign('default_calendar_color', '#3366CC');
     $arr_permissions = array('can_edit' => false, 'can_delete' => false, 'can_see_dditems' => false, 'can_add' => false);
 }
 $obj_smarty->assign('my_active_calendars', $arr_calendars);
 $obj_smarty->assign('movable_to', $arr_movable_to);
 if (!empty($str_default_calendars)) {
     // one or more calendars have initial_show set to true
     $obj_smarty->assign('default_calendars', $str_default_calendars);
     if (!strstr($str_default_calendars, ',')) {
         $arr_cal = Calendar::getCalendar($str_default_calendars);
         $obj_smarty->assign('default_calendar_color', $arr_cal['calendar_color']);
     }
 } else {
     if (!empty($first_default_calendar)) {
         // no calendars have initial_show set to true, so use first calendar as default
         $first_default_calendar['initial_show'] = true;
         $obj_smarty->assign('default_calendars', $first_default_calendar['calendar_id']);
         $obj_smarty->assign('default_calendar_color', $first_default_calendar['calendar_color']);
     }
 }
 $obj_smarty->assign('default_calendar', $first_default_calendar);
 $arr_cal = $first_default_calendar;
 if (!empty($arr_cal)) {
     if (User::isLoggedIn()) {
         $arr_cal['isOwner'] = Calendar::isOwner($arr_cal['calendar_id']);
Esempio n. 7
0
function getCalendar()
{
    $arr_submit = array(array('cid', 'int', true, ''));
    $frm_submitted = validate_var($arr_submit);
    global $obj_smarty;
    //if(User::isAdminUser($frm_submitted['cid'])) {
    $arr_calendar = Calendar::getCalendar($frm_submitted['cid'], true);
    //$arr_birthdate = explode('-', $arr_calendar['birth_date']);
    $obj_smarty->assign('active', 'public_calendar');
    $obj_smarty->assign('calendar', $arr_calendar);
    $obj_smarty->display(FULLCAL_DIR . '/view/user_panel.tpl');
    exit;
    //	} else {
    //		$obj_smarty->assign('active', 'calendars');
    //		$obj_smarty->assign('error', 'NO rights to change this calendar');
    //
    //		$obj_smarty->display(FULLCAL_DIR.'/view/user_panel.tpl');
    //		exit;
    //	}
}
Esempio n. 8
0
function saveCalendar()
{
    global $error;
    global $obj_smarty;
    $arr_submit = array(array('calendar_id', 'int', false, -1), array('name', 'string', true, ''), array('dditems', 'string', false, ''), array('calendar_color', 'string', true, ''), array('can_add', 'bool', false, 0), array('can_edit', 'bool', false, 0), array('can_delete', 'bool', false, 0), array('can_change_color', 'bool', false, 0), array('can_dd_drag', 'string', false, ''), array('checkbox_use_color_for_all_events', 'bool', false, 0), array('initial_show', 'bool', false, 0), array('users_can_email_event', 'bool', false, 0), array('all_event_mods_to_admin', 'bool', false, 0), array('active', 'string', true, ''), array('cal_startdate', 'string', false, ''), array('cal_enddate', 'string', false, ''), array('alterable_startdate', 'string', false, ''), array('alterable_enddate', 'string', false, ''), array('share_type', 'string', true, 'private_group'), array('calendar_admin_email', 'email', false, ''));
    $frm_submitted = validate_var($arr_submit);
    //if(User::isAdminUser($frm_submitted['user_id'])) {
    if (!$error || is_null($error)) {
        $bln_success = Calendar::saveCalendar($frm_submitted);
        if (is_string($bln_success)) {
            echo json_encode(array('success' => false, 'save_calendar_error' => $bln_success));
            exit;
        }
    } else {
        $obj_smarty->assign('save_calendar_error', $error);
    }
    //} else {
    //	$obj_smarty->assign('error', 'NO rights to change this user');
    //}
    if (!is_null($error) && $error !== false) {
        // give feedback about the error
        $arr_calendar = Calendar::getCalendar($frm_submitted['calendar_id'], true);
        //$arr_birthdate = explode('-', $arr_calendar['birth_date']);
        $obj_smarty->assign('active', 'calendar');
        $obj_smarty->assign('calendar', $arr_calendar);
        $obj_smarty->display(FULLCAL_DIR . '/view/admin_panel.tpl');
        exit;
    } else {
        header('location: ' . FULLCAL_URL . '/admin/calendars');
        exit;
    }
}
Esempio n. 9
0
require "../main_Lib.php";
require "../smartyLib/Smarty.class.php";
require_once "../phpLib/Calendar/Calendar.php";
include_once '../phpLib/calc.php';
validarAcceso(AuthUser::TIPO_SECRETARIA);
$smarty = new Smarty();
smartyTemplate($smarty, "../");
setHistoryGoBack(PATH_HTTP . "secretaria/SEC-calendario.php");
$smarty->assign("PATH_HTTP", PATH_HTTP);
//ob_end_clean();
$ano = isset($_GET['ano']) ? $_GET['ano'] : date("Y");
$mes = isset($_GET['mes']) ? $_GET['mes'] : date("m");
$dia = isset($_GET['dia']) ? $_GET['dia'] : date("d");
$fecha_hoy = $dia . "/" . $mes . "/" . $ano;
$ingresos_totales_mes = calc_total_ingreso($ano, $mes);
$salida_mes = calc_salida_mes($mes);
$total_dia = calc_total_ingreso($ano, $mes, $dia);
$salida_dia = calc_salida_dia($dia, $mes, $ano);
$nombre_mes = Calendar::getNombreMes($mes);
$smarty->assign("ingresos_totales_mes", $ingresos_totales_mes);
$smarty->assign("salida_mes", $salida_mes);
$smarty->assign("total_dia", $total_dia);
$smarty->assign("salida_dia", $salida_dia);
$smarty->assign("fecha_hoy", $fecha_hoy);
$smarty->assign("dia", $dia);
$smarty->assign("anio", $anio);
$smarty->assign("mes", $mes);
$smarty->assign("nombre_mes", $nombre_mes);
$smarty->assign("file_content", "SEC-calendario.tpl");
$smarty->assign("calendario", Calendar::getCalendar());
$smarty->display('LAYOUT-SEC-main.tpl');
Esempio n. 10
0
 /**
  * 
  * @param type $int_cal_id
  * @return type
  */
 public static function getPermissions($int_cal_id)
 {
     $arr_cal = Calendar::getCalendar($int_cal_id);
     $can_view = (bool) $arr_cal['can_view'];
     // can view detail
     $can_add = (bool) $arr_cal['can_add'];
     $can_edit = (bool) $arr_cal['can_edit'];
     $can_delete = (bool) $arr_cal['can_delete'];
     $can_change_color = (bool) $arr_cal['can_change_color'];
     $can_see_dditems = $can_add && !ONLY_ADMIN_CAN_SEE_DRAG_DROP_ITEMS;
     // only_owner , only_loggedin_users of everyone
     /*
      * IF LOGGED IN
      */
     if (User::isLoggedIn()) {
         $arr_user = User::getUser();
         if (ONLY_ADMIN_CAN_SEE_DRAG_DROP_ITEMS) {
             if (User::isAdmin() || User::isSuperAdmin()) {
                 $can_see_dditems = true;
             } else {
                 $can_see_dditems = false;
             }
         } else {
             if (Calendar::isOwner($arr_cal['calendar_id']) || $arr_cal['can_dd_drag'] == 'everyone' || $arr_cal['can_dd_drag'] == 'only_loggedin_users') {
                 $can_see_dditems = true;
             } else {
                 if ($arr_cal['can_dd_drag'] == 'only_owner' && !Calendar::isOwner($arr_cal['calendar_id'])) {
                     $can_see_dditems = false;
                 }
             }
         }
         // if admin with fullcontrol OR calendar owner (creator)
         if (ADMIN_HAS_FULL_CONTROL && (User::isAdmin() || User::isSuperAdmin()) || Calendar::isOwner($arr_cal['calendar_id'])) {
             $can_view = false;
             // not neccesary because admin can edit
             $can_add = true;
             $can_edit = true;
             $can_delete = true;
             $can_see_dditems = true;
         } else {
             if ($arr_cal['share_type'] == 'private_group' && !Calendar::UserInGroup($arr_cal, $arr_user['user_id'])) {
                 // if share_type is private_group and user is not in that group (admingroup)
                 $can_add = false;
                 $can_edit = false;
                 $can_delete = false;
                 $can_see_dditems = false;
             }
         }
     } else {
         /*
          * IF NOT LOGGED IN
          */
         if (ONLY_ADMIN_CAN_SEE_DRAG_DROP_ITEMS) {
             $can_see_dditems = false;
         } else {
             if ($arr_cal['can_dd_drag'] == 'everyone') {
                 $can_see_dditems = true;
             } else {
                 $can_see_dditems = false;
             }
         }
         // if public
         if ($arr_cal['share_type'] == 'public') {
             // use the defaults from the calendar
         }
         // if access allowed by IP and IP mathces with IP in config.php
         if (ALLOW_ACCESS_BY == 'ip' && User::ipAllowed()) {
             // use the defaults from the calendar
         }
     }
     return array('can_view' => $can_view, 'can_add' => $can_add, 'can_edit' => $can_edit, 'can_delete' => $can_delete, 'can_change_color' => $can_change_color, 'can_see_dditems' => $can_see_dditems);
 }