/** * Functional point that deletes an existing event in the calendar of the authenticated user * * @param integer $id ID of the event to be deleted * @return boolean True if the event was successfully deleted, or false if an error exists */ function delCalendarEvent($id) { global $arrConf; if (!$this->_checkUserAuthorized('calendar')) { return false; } // Identificar el usuario para averiguar el ID de usuario en calendario $id_user = $this->_leerIdUser(); if (is_null($id_user)) { return false; } // Verificar presencia de ID del evento if (!isset($id) || !preg_match('/^\\d+$/', $id)) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Invalid ID'; $this->errMsg["fd"] = 'Event ID must be nonnegative integer'; $this->errMsg["cn"] = get_class($this); return false; } $id = (int) $id; // Leer los datos del evento del usuario $pCalendar = new paloSantoCalendar($this->_getDB($arrConf['dsn_conn_database'])); $infoEvento = $pCalendar->getEventById($id, $id_user); if (!is_array($infoEvento) && $pCalendar->errMsg != '') { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to read event in calendar - ' . $pCalendar->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } if (count($infoEvento) <= 0 || $infoEvento['uid'] != $id_user) { $this->errMsg["fc"] = 'CALENDAR'; $this->errMsg["fm"] = 'Event lookup failed'; $this->errMsg["fd"] = 'No event was found for user ' . $_SERVER['PHP_AUTH_USER']; $this->errMsg["cn"] = get_class($pCalendar); return false; } // Borrar los archivos de audio para el ID indicado array_map('unlink', glob($arrConf['output_callfile_base'] . "/event_{$id}_*.call")); // Si había notificación de correo, se envía mensaje a lista de usuarios if ($infoEvento['emails_notification'] != '') { $r = (object) $infoEvento; // subject description emails_notification $r->emails_notification = array_filter(preg_split('/[\\s,]+/', $infoEvento['emails_notification']), array($this, '_rechazar_correo_vacio')); $this->_enviarCorreosNotificacionEvento($id, $infoEvento['starttime'] . ':00', $infoEvento['endtime'] . ':00', $r->subject, $r->emails_notification, $r->description, 'Delete_Event'); } // Borrar el evento if (!$pCalendar->deleteEvent($id, $id_user)) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to delete event in calendar - ' . $pCalendar->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } return true; }
function setDataCalendar($arrLang, $pDB, $arrConf) { $pDBACL = new paloDB($arrConf['dsn_conn_database1']); $pACL = new paloACL($pDBACL); $id_user = $pACL->getIdUser($_SESSION["elastix_user"]); $action = getParameter('action'); $days = getParameter('days'); $minutes = getParameter('minutes'); $dateIni = getParameter('dateIni'); $dateEnd = getParameter('dateEnd'); $dateIni = str_replace("|mas|", "+", $dateIni); $dateIni = str_replace("|menos|", "-", $dateIni); $dateEnd = str_replace("|mas|", "+", $dateEnd); $dateEnd = str_replace("|menos|", "-", $dateEnd); $id = getParameter('id'); // id_event $pCalendar = new paloSantoCalendar($pDB); $Initial = explode(" ", $dateIni); $Finally = explode(" ", $dateEnd); $hour_ini = date("H:i", strtotime($Initial[4])); $hour_end = date("H:i", strtotime($Finally[4])); $event = $pCalendar->getEventById($id, $id_user); $start = $event['startdate']; $end = $event['enddate']; $checkbox_days = ""; $startdate = date("Y-m-d", strtotime("{$dateIni}")); $enddate = date("Y-m-d", strtotime("{$dateEnd}")); $starttime = $startdate . " " . $hour_ini; $endtime = $enddate . " " . $hour_end; if (!ctype_digit($id)) { $id = NULL; } // obtain data to create audio files $arrResult = $pCalendar->getEventById($id, $id_user); if (!isset($arrResult) || $arrResult == "") { return $arrLang['error_Noevent']; } $uid = $arrResult['uid']; $pDB3 = new paloDB($arrConf['dsn_conn_database1']); $ext = $pCalendar->obtainExtension($pDB3, $uid); $each_repeat = $arrResult['each_repeat']; $day_repeat = explode(',', $arrResult['days_repeat']); if ($arrResult['eventtype'] == 1) { $num_frec = 0; } else { if ($arrResult['eventtype'] == 5) { $num_frec = 7; } else { $num_frec = 30; } } if ($arrResult['eventtype'] == 1) { $startdateTime = strtotime($startdate); $checkbox_days = getConvertDay($startdateTime); $day_repeat = explode(',', $checkbox_days); } $asterisk_calls = $arrResult['asterisk_call']; $call_to = $arrResult['call_to']; $recording = $arrResult['recording']; $remainerTime = $arrResult['reminderTimer']; $val = $pCalendar->updateDateEvent($id, $startdate, $enddate, $starttime, $endtime, $checkbox_days); if ($val) { if (isset($arrResult['call_to']) && $arrResult['call_to'] != "") { createRepeatAudioFile($each_repeat, $day_repeat, $starttime, $endtime, $num_frec, $asterisk_calls, $ext, $call_to, $pDB, $id, $arrLang, $arrConf, $recording, $remainerTime); } return $arrLang['update_successful']; } else { return $arrLang['error_update']; } }