function saveSettings() { global $error; global $obj_smarty; // add the checkbox fields here $arr_submit = array(array('show_description_field', 'string', false, 'off'), array('show_location_field', 'string', false, 'off'), array('show_phone_field', 'string', false, 'off'), array('show_url_field', 'string', false, 'off'), array('show_am_pm', 'string', false, 'off'), array('show_delete_confirm_dialog', 'string', false, 'off'), array('truncate_title', 'string', false, 'off'), array('show_notallowed_messages', 'string', false, 'off'), array('show_weeknumbers', 'string', false, 'off'), array('show_public_and_private_separately', 'string', false, 'off')); $int_user_id = $_POST['user_id']; foreach ($_POST as $key => $param) { if (!empty($key) && $key != 'save-settings' && $key != 'user_id') { $arr_submit[] = array($key, 'string', false, $param); $_REQUEST[$key] = $param; } } unset($_REQUEST['params']); $frm_submitted = validate_var($arr_submit); $arr_user = User::getUser(); if (!$error) { if ($int_user_id == $arr_user['user_id']) { unset($frm_submitted['user_id']); Settings::saveSettings($frm_submitted, '', $arr_user['user_id']); $obj_smarty->assign('save_settings_success', 'Saved succesfully'); //header('location: '.FULLCAL_URL.'/admin/settings'); //exit; } else { $obj_smarty->assign('save_settings_error', 'NO rights to do that'); } } else { $obj_smarty->assign('save_settings_error', $error); } $obj_smarty->assign('active', 'settings'); $obj_smarty->assign('settings', Settings::getSettings($arr_user['user_id'])); $obj_smarty->display(FULLCAL_DIR . '/view/user_panel.tpl'); exit; }
function changePassword() { global $error; $use_captcha = true; $arr_submit = array(array('passw1', 'string', true, ''), array('passw2', 'string', true, ''), array('uid', 'int', true, '')); $frm_submitted = validate_var($arr_submit); if (!$error) { $bln_success = User::changePassword($frm_submitted); } }
function search() { global $error; global $obj_smarty; global $obj_db; $arr_submit = array(array('keyword', 'string', true, '')); $frm_submitted = validate_var($arr_submit); $str_query = 'SELECT e.* FROM events e WHERE title LIKE "%' . $frm_submitted['keyword'] . '%" '; // $str_query .= ' ORDER BY date_start'; $obj_result = mysqli_query($obj_db, $str_query); while ($arr_line = mysqli_fetch_array($obj_result, MYSQLI_ASSOC)) { $arr_events[] = $arr_line; } $obj_smarty->assign('keyword', $frm_submitted['keyword']); if (count($arr_events) == 1) { // no need to show the results, go to form right away $obj_smarty->assign('events', $arr_events[0]); $obj_smarty->display(FULLCAL_DIR . '/view/new.tpl'); } else { // show the search results $obj_smarty->assign('events', $arr_events); $obj_smarty->display(FULLCAL_DIR . '/view/found.tpl'); } }
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; } }
function undeleteCalendar() { global $error; global $obj_smarty; $arr_submit = array(array('cid', 'int', true, '')); $frm_submitted = validate_var($arr_submit); if (User::isUser() || User::isAdmin() || User::isSuperAdmin()) { $arr_user = User::getUser(); $bln_success = Calendar::undeleteCalendar($frm_submitted['cid']); if ($bln_success) { $obj_smarty->assign('msg', 'Calendar is back again'); } $language = Settings::getSetting('language', $arr_user['user_id']); $obj_smarty->assign('language', $language); $arr_calendars = Calendar::getCalendarsOfUser($arr_user['user_id']); $obj_smarty->assign('calendars', $arr_calendars); $obj_smarty->assign('active', 'calendars'); } else { $obj_smarty->assign('error', 'NO rights to undelete this calendar'); } $obj_smarty->display(FULLCAL_DIR . '/view/user_panel.tpl'); exit; }
function showExampleAgendaWidget($bln_google_like = false) { global $error; global $current_languages; $arr_submit = array(array('from', 'string', false, ''), array('to', 'string', false, ''), array('uid', 'int', false, ''), array('c', 'string', false, ''), array('w', 'int', false, 200), array('hrs', 'int', false, 24), array('ebc', 'string', false, 'FFFFCC'), array('bc', 'string', false, 'FFFFCC'), array('showec', 'string', false, 'no'), array('lang', 'string', false, ''), array('ics', 'string', false, 'no'), array('period', 'int', false, ''), array('google_calid', 'string', false, ''), array('google_privatekey', 'string', false, '')); $frm_submitted = validate_var($arr_submit); $obj_smarty = new Smarty(); $obj_smarty->compile_dir = 'templates_c/'; if (!empty($frm_submitted['lang'])) { $frm_submitted['lang'] = strtolower($frm_submitted['lang']); $bln_found = false; foreach ($current_languages as $code => $lang) { if (strtoupper($frm_submitted['lang']) == $code) { $bln_found = true; } } if ($bln_found) { Utils::setLocaleLanguage($frm_submitted['lang']); } } header("Content-Type: text/html;charset=UTF-8"); $obj_smarty->assign('iframewidth', $frm_submitted['w']); $obj_smarty->assign('showeventcolor', $frm_submitted['showec']); $obj_smarty->assign('hrs', $frm_submitted['hrs']); $arr_res = array(); $arr_res['results'] = array(date('Y-m-d', strtotime('+2DAY')) => array(array('event_id' => 102, 'title' => 'Walking in the Belgian hills near Spa', 'date_start' => date('Y-m-d', strtotime('+2DAY')), 'time_start' => '12:16:58', 'date_end' => date('Y-m-d', strtotime('+2DAY')), 'time_end' => '17:27:45', 'allDay' => '1', 'calendartype' => '', 'user_id' => '2', 'color' => '#FFBB00')), date('Y-m-d', strtotime('+3DAY')) => array(array('event_id' => 102, 'title' => 'Luxembourg', 'date_start' => date('Y-m-d', strtotime('+3DAY')), 'time_start' => '12:16:58', 'date_end' => date('Y-m-d', strtotime('+3DAY')), 'time_end' => '17:27:45', 'allDay' => '1', 'calendartype' => '', 'user_id' => '2', 'color' => '#FFBB00')), date('Y-m-d', strtotime('+4DAY')) => array(array('event_id' => 102, 'title' => 'Stayed at the campingsite', 'date_start' => date('Y-m-d', strtotime('+4DAY')), 'time_start' => '12:16:58', 'date_end' => date('Y-m-d', strtotime('+4DAY')), 'time_end' => '17:27:45', 'allDay' => '1', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc')), date('Y-m-d', strtotime('+5DAY')) => array(array('event_id' => 104, 'title' => 'another event', 'date_start' => date('Y-m-d', strtotime('+5DAY')), 'time_start' => '6:59:52', 'date_end' => date('Y-m-d', strtotime('+5DAY')), 'time_end' => '14:50:36', 'allDay' => '1', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc')), date('Y-m-d', strtotime('+6DAY')) => array(array('event_id' => 105, 'title' => 'yet another event', 'date_start' => date('Y-m-d', strtotime('+6DAY')), 'time_start' => '10:58:21', 'date_end' => date('Y-m-d', strtotime('+6DAY')), 'time_end' => '14:21:26', 'allDay' => '1', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc'), array('event_id' => 106, 'title' => 'Back home', 'date_start' => date('Y-m-d', strtotime('+6DAY')), 'time_start' => '11:35:28', 'date_end' => date('Y-m-d', strtotime('+6DAY')), 'time_end' => '18:15:41', 'allDay' => '0', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc'))); $arr_return['hide_from'] = false; $arr_return['hide_to'] = false; if (defined('AGENDA_VIEW_AMOUNT_DAYS_TO_SHOW') && AGENDA_VIEW_AMOUNT_DAYS_TO_SHOW > 0) { $amount_days_to_show = AGENDA_VIEW_AMOUNT_DAYS_TO_SHOW; } else { $amount_days_to_show = 5; } if (!empty($frm_submitted['from'])) { $arr_res['hide_from'] = true; } if (!empty($frm_submitted['to'])) { $arr_res['results'] = array(date('Y-m-d', strtotime('-4DAY')) => array(array('event_id' => 99, 'title' => 'felisc', 'date_start' => date('Y-m-d', strtotime('-4DAY')), 'time_start' => '9:21:48', 'date_end' => date('Y-m-d', strtotime('-4DAY')), 'time_end' => '13:54:41', 'allDay' => '0', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc')), date('Y-m-d', strtotime('-1DAY')) => array(array('event_id' => 100, 'title' => 'felisc', 'date_start' => date('Y-m-d', strtotime('-1DAY')), 'time_start' => '9:21:48', 'date_end' => date('Y-m-d', strtotime('-1DAY')), 'time_end' => '13:54:41', 'allDay' => '0', 'calendartype' => '', 'user_id' => '2', 'color' => '#3366cc'))); if (count($arr_res['results']) < $amount_days_to_show) { $arr_res['hide_to'] = true; } } if (empty($frm_submitted['from']) && empty($frm_submitted['to'])) { $arr_res['hide_from'] = true; } $obj_smarty->assign('items', $arr_res['results']); $obj_smarty->assign('from', current(array_keys($arr_res['results']))); $obj_smarty->assign('to', end(array_keys($arr_res['results']))); $obj_smarty->assign('hide_from', $arr_res['hide_from']); $obj_smarty->assign('hide_to', $arr_res['hide_to']); if ($bln_google_like) { $obj_smarty->display(FULLCAL_DIR . '/view/examples/agenda_widget_google_like.html'); } else { // $frm_submitted['from'] = date('Y-m-d'); // unset($frm_submitted['to']); // $frm_submitted['combine_moreday_events'] = false; // // $arr_res = Events::getListviewEvents($frm_submitted); // // if(isset($arr_res)) { // $obj_smarty->assign('items', $arr_res['results']); // $obj_smarty->assign('from', $arr_res['results']); // $obj_smarty->assign('to', $arr_res['results']); // } $obj_smarty->display(FULLCAL_DIR . '/view/examples/agenda_widget_justtext.html'); } }
function getEvents() { global $error; $arr_submit = array(array('start', 'int', true, ''), array('end', 'int', true, '')); $frm_submitted = validate_var($arr_submit); if (!$error) { $arr_content = Events::getEvents($frm_submitted); } else { $arr_content = array(); } echo json_encode($arr_content); }
function undeleteUser() { global $error; global $obj_smarty; $arr_submit = array(array('uid', 'int', true, '')); $frm_submitted = validate_var($arr_submit); $bln_admin = User::isAdmin(); $bln_superadmin = User::isSuperAdmin(); if ($bln_superadmin) { if (User::isAdmin($frm_submitted['uid'])) { $bln_success = User::undeleteAdmin($frm_submitted['uid']); if ($bln_success) { $obj_smarty->assign('msg', 'Admin is back again'); } $arr_users = User::getAdmins(true, true); // admins of this superadmin $obj_smarty->assign('users', $arr_users); } else { $obj_smarty->assign('error', 'NO rights to undelete this user'); } } else { if ($bln_admin) { if (User::isAdminUser($frm_submitted['uid'])) { $bln_success = User::undeleteUser($frm_submitted['uid']); if ($bln_success) { $obj_smarty->assign('msg', 'User is back again'); } //$arr_users = getUsers(); $arr_users = User::getAdminUsers(true, true); // users of this admin $obj_smarty->assign('users', $arr_users); } else { $obj_smarty->assign('error', 'NO rights to undelete this user'); } } } $obj_smarty->assign('active', 'users'); $obj_smarty->display(FULLCAL_DIR . '/view/admin_panel.tpl'); exit; }