function getContactEmails2($arrConf) { $pDBACL = new paloDB($arrConf['dsn_conn_database1']); $pACL = new paloACL($pDBACL); $id_user = $pACL->getIdUser($_SESSION["elastix_user"]); $tag = getParameter('name_startsWith'); $salida = array(); if (isset($id_user) && $id_user != "") { $pDB = new paloDB($arrConf['dsn_conn_database']); $pDBAddress = new paloDB($arrConf['dsn_conn_database3']); $pCalendar = new paloSantoCalendar($pDB); $salida = $pCalendar->getContactByTag($pDBAddress, $tag, $id_user); if (!$salida) { $salida = array(); } } header('Content-Type: application/json'); // se instancia a JSON $json = new Services_JSON(); return $json->encode($salida); }
/** * 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; }
/** * This function query the status of the ticket of a queue, if it is unsolved returns NULL, * but if it is solved it will get the data to be sync in the client. * * @return mixed returns an array with the data to be sync in the client, or NULL it the ticket * is unsolved or false if an error exists */ protected function getData() { global $arrConf; $dbCalendar = $this->_getDB($arrConf['dsn_conn_database']); $pCalendar = new paloSantoCalendar($dbCalendar); $data_ticket = $pCalendar->getDataTicket($this->_ticket, $this->_id_user); if (is_null($data_ticket)) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to write data - ' . $pCalendar->_DB->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } elseif (!$data_ticket) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Wrong ticket'; $this->errMsg["fd"] = "The ticket {$this->_ticket} does not exist or does not belong to you"; $this->errMsg["cn"] = get_class($pCalendar); return false; } else { if ($data_ticket["status"] != "OK") { return null; } else { $result["status"] = "OK"; $json = new Services_JSON(); $data = $json->decode($data_ticket["data"]); if (!isset($data->last_sync) || !isset($data->events)) { $remove_queue = $pCalendar->removeQueue($this->_ticket); if ($remove_queue === false) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to delete data - ' . $pCalendar->_DB->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Wrong data'; $this->errMsg["fd"] = "The data of the ticket {$this->_ticket} is wrong or corrupted. This data has to be a JSON string containing the keywords \"last_sync\" and \"contacts\". The ticket will be deleted"; $this->errMsg["cn"] = get_class($pCalendar); return false; } if (!is_array($data->events)) { $remove_queue = $pCalendar->removeQueue($this->_ticket); if ($remove_queue === false) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to delete data - ' . $pCalendar->_DB->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Wrong data'; $this->errMsg["fd"] = "The data of the contacts in ticket {$this->_ticket} is wrong or corrupted. It has to be an array. The ticket will be deleted"; $this->errMsg["cn"] = get_class($pCalendar); return false; } $last_sync = $data->last_sync; if (isset($data_ticket["response_data"]) && !empty($data_ticket["response_data"])) { $response_data = $json->decode($data_ticket["response_data"]); } else { $response_data = array(); } $events = $pCalendar->getEventsAfterSync($last_sync, $data->events, $this->_id_user, $response_data); if ($events === false) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to get data - ' . $pCalendar->_DB->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } else { $remove_queue = $pCalendar->removeQueue($this->_ticket); if ($remove_queue === false) { $this->errMsg["fc"] = 'DBERROR'; $this->errMsg["fm"] = 'Database operation failed'; $this->errMsg["fd"] = 'Unable to delete data - ' . $pCalendar->_DB->errMsg; $this->errMsg["cn"] = get_class($pCalendar); return false; } else { $result["last_sync"] = time(); $result["events"] = $events; return $result; } } } } }