public function json_RemoveCalendar() { $data = json_decode(file_get_contents('php://input'), true); $data['username'] = user_decrypt($data['username']); if (getUserUID($data['username'])) { if (removeCalendar($data['username'], $data['calname'])) { $return['error'] = 0; $return['value'] = "Successfully removed"; } else { $return['error'] = -2; $return['value'] = "Invalid calendar name"; } } else { $return['error'] = -1; $return['value'] = "Invalid username"; } $jsonString = json_encode($return); echo $jsonString; }
$ret['IsSuccess'] = true; $ret['Msg'] = 'Succefully'; return $ret; } header('Content-type:text/javascript;charset=UTF-8'); $method = $_GET["method"]; switch ($method) { case "add": $ret = addCalendar($_POST["CalendarStartTime"], $_POST["CalendarEndTime"], $_POST["CalendarTitle"], $_POST["IsAllDayEvent"]); break; case "list": $ret = listCalendar($_POST["showdate"], $_POST["viewtype"]); break; case "update": $ret = updateCalendar($_POST["calendarId"], $_POST["CalendarStartTime"], $_POST["CalendarEndTime"]); break; case "remove": $ret = removeCalendar($_POST["calendarId"]); break; case "adddetails": $id = $_GET["id"]; $st = $_POST["stpartdate"] . " " . $_POST["stparttime"]; $et = $_POST["etpartdate"] . " " . $_POST["etparttime"]; if ($id) { $ret = updateDetailedCalendar($id, $st, $et, $_POST["Subject"], $_POST["IsAllDayEvent"] ? 1 : 0, $_POST["Description"], $_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]); } else { $ret = addDetailedCalendar($st, $et, $_POST["Subject"], $_POST["IsAllDayEvent"] ? 1 : 0, $_POST["Description"], $_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]); } break; } echo json_encode($ret);
public function process() { if ("ajax_calendar" == $_REQUEST['_process'] && module_calendar::can_i('view', 'Calendar')) { // ajax functions from wdCalendar. copied from the datafeed.php sample files. header('Content-type: text/javascript'); $ret = array(); $method = isset($_REQUEST['method']) ? $_REQUEST['method'] : false; switch ($method) { case "quick_add": if (module_calendar::can_i('create', 'Calendar')) { $ret = addCalendar($_POST["CalendarStartTime"], $_POST["CalendarEndTime"], $_POST["CalendarTitle"], $_POST["IsAllDayEvent"]); } break; case "list": $ret = listCalendar($_POST["showdate"], $_POST["viewtype"]); break; case "quick_update": if (module_calendar::can_i('edit', 'Calendar')) { $ret = updateCalendar($_POST["calendarId"], $_POST["CalendarStartTime"], $_POST["CalendarEndTime"]); } break; case "quick_remove": if (module_calendar::can_i('delete', 'Calendar')) { $ret = removeCalendar($_POST["calendarId"]); } break; } echo json_encode($ret); exit; } if ("save_calendar_entry" == $_REQUEST['_process']) { header('Content-type: text/javascript'); $calendar_id = isset($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0; $response = array(); if ($calendar_id && module_calendar::can_i('edit', 'Calendar') || !$calendar_id && module_calendar::can_i('create', 'Calendar')) { $data = $_REQUEST; if (isset($data['start'])) { $start_time = $data['start']; if (isset($data['start_time']) && (!isset($data['is_all_day']) || !$data['is_all_day'])) { $data['is_all_day'] = 0; $time_hack = $data['start_time']; $time_hack = str_ireplace(_l("am"), '', $time_hack); $time_hack = str_ireplace(_l("pm"), '', $time_hack); $bits = explode(':', $time_hack); if (strpos($data['end_time'], _l("pm"))) { if ($bits[0] < 12) { $bits[0] += 12; } } // add the time if it exists $start_time .= ' ' . implode(':', $bits) . ':00'; $data['start'] = strtotime(input_date($start_time, true)); } else { $data['start'] = strtotime(input_date($start_time)); } } if (isset($data['end'])) { $end_time = $data['end']; if (isset($data['end_time']) && (!isset($data['is_all_day']) || !$data['is_all_day'])) { $data['is_all_day'] = 0; $time_hack = $data['end_time']; $time_hack = str_ireplace(_l("am"), '', $time_hack); $time_hack = str_ireplace(_l("pm"), '', $time_hack); $bits = explode(':', $time_hack); if (strpos($data['end_time'], _l("pm"))) { if ($bits[0] < 12) { $bits[0] += 12; } } // add the time if it exists $end_time .= ' ' . implode(':', $bits) . ':00'; //echo $end_time; $data['end'] = strtotime(input_date($end_time, true)); } else { $data['end'] = strtotime(input_date($end_time)); } } if (!$data['start'] || !$data['end']) { $response['message'] = 'Missing Date'; } else { //print_r($_REQUEST); print_r($data); exit; $calendar_id = update_insert('calendar_id', $calendar_id, 'calendar', $data); if ($calendar_id) { // save staff members. $staff_ids = isset($_REQUEST['staff_ids']) && is_array($_REQUEST['staff_ids']) ? $_REQUEST['staff_ids'] : array(); delete_from_db('calendar_user_rel', 'calendar_id', $calendar_id); foreach ($staff_ids as $staff_id) { if ((int) $staff_id > 0) { $sql = "INSERT INTO `" . _DB_PREFIX . "calendar_user_rel` SET calendar_id = " . (int) $calendar_id . ", user_id = " . (int) $staff_id; query($sql); } } $response['calendar_id'] = $calendar_id; $response['message'] = 'Success'; } else { $response['message'] = 'Error Saving'; } } } else { $response['message'] = 'Access Denied'; } echo json_encode($response); exit; } }
$ret['IsSuccess'] = false; $ret['Msg'] = $e->getMessage(); } return $ret; } header('Content-type:text/javascript;charset=UTF-8'); $method = $get["method"]; switch ($method) { case "add": $ret = addCalendar($post["CalendarStartTime"], $post["CalendarEndTime"], $post["CalendarTitle"], $post["IsAllDayEvent"]); break; case "list": $ret = listCalendar($post["showdate"], $post["viewtype"]); break; case "update": $ret = updateCalendar($post["calendarId"], $post["CalendarStartTime"], $post["CalendarEndTime"]); break; case "remove": $ret = removeCalendar($post["calendarId"]); break; case "adddetails": $st = $post["stpartdate"] . " " . $post["stparttime"]; $et = $post["etpartdate"] . " " . $post["etparttime"]; if (isset($get["id"])) { $ret = updateDetailedCalendar($get["id"], $st, $et, $post["Subject"], isset($post["IsAllDayEvent"]) ? 1 : 0, $post["Description"], $post["Location"], $post["colorvalue"], $post["timezone"]); } else { $ret = addDetailedCalendar($st, $et, $post["Subject"], isset($post["IsAllDayEvent"]) ? 1 : 0, $post["Description"], $post["Location"], $post["colorvalue"], $post["timezone"]); } break; } echo json_encode($ret);
switch ($method) { case "add": $ret = addCalendar($calid, JRequest::getVar("CalendarStartTime"), JRequest::getVar("CalendarEndTime"), JRequest::getVar("CalendarTitle"), JRequest::getVar("IsAllDayEvent"), JRequest::getVar("location")); break; case "list": $d1 = js2PhpTime(JRequest::getVar("startdate")); $d2 = js2PhpTime(JRequest::getVar("enddate")); $d1 = mktime(0, 0, 0, date("m", $d1), date("d", $d1), date("Y", $d1)); $d2 = mktime(0, 0, 0, date("m", $d2), date("d", $d2), date("Y", $d2)) + 24 * 60 * 60 - 1; $ret = listCalendarByRange($calid, $d1, $d2); break; case "update": $ret = updateCalendar(JRequest::getVar("calendarId"), JRequest::getVar("CalendarStartTime"), JRequest::getVar("CalendarEndTime")); break; case "remove": $ret = removeCalendar(JRequest::getVar("calendarId"), JRequest::getVar("rruleType")); break; case "adddetails": $st = JRequest::getVar("stpartdatelast") . " " . JRequest::getVar("stparttimelast"); $et = JRequest::getVar("etpartdatelast") . " " . JRequest::getVar("etparttimelast"); if (JRequest::getVar("id") != "") { $ret = updateDetailedCalendar(JRequest::getVar("id"), $st, $et, JRequest::getVar("Subject"), JRequest::getVar("IsAllDayEvent") == 1 ? 1 : 0, JRequest::getVar('Description', null, 'default', 'none', JREQUEST_ALLOWHTML), JRequest::getVar("Location"), JRequest::getVar("colorvalue"), JRequest::getVar("rrule"), JRequest::getVar("rruleType"), JRequest::getVar("timezone")); } else { $ret = addDetailedCalendar($calid, $st, $et, JRequest::getVar("Subject"), JRequest::getVar("IsAllDayEvent") == 1 ? 1 : 0, JRequest::getVar('Description', null, 'default', 'none', JREQUEST_ALLOWHTML), JRequest::getVar("Location"), JRequest::getVar("colorvalue"), JRequest::getVar("rrule"), 0, JRequest::getVar("timezone")); } break; } echo json_encode($ret); function addCalendar($calid, $st, $et, $sub, $ade, $loc) { eval(base64_decode('JHJldCA9IGFycmF5KCk7ICRkYiA9JiBKRmFjdG9yeTo6Z2V0REJPKCk7ICR1c2VyID0mIEpGYWN0b3J5OjpnZXRVc2VyKCk7IHRyeXsgJGEgPSBhcnJheSgic3QiPT4kc3QsImV0Ij0+JGV0LCJ0aXRsZSI9PiRzdWIsImFsbCI9PiRhZGUsImxvYyI9PiRsb2MsIm93bmVyIj0+JHVzZXItPmlkLCJwdWJsaXNoZWQiPT4xKTsgJGRhdGEgPSBzZXJp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