0) { //This will also rollback the audit log process_sql_rollback (); return false; } process_sql_commit (); return true; } /** * Delete notes out the database. * * @param mixed $id_note An int or an array of ints to be deleted * @param bool $transact true if a transaction should be started, false if not * * @return bool True if note was succesfully deleted, false if not */ function delete_incidents_note ($id_note, $transact = true) { $id_note = (array) safe_int ($id_note, 1); //cast as array $errors = 0; //Start transaction if ($transact == true){ process_sql_begin (); process_sql_commit (); } //Delete notes foreach ($id_note as $id) { $ret = process_sql_delete ('tnota', array ('id_nota' => $id)); if ($ret === false) { $errors++; } } if ($transact == true && $errors > 0) { process_sql_rollback (); return false; } elseif ($transact == true) { process_sql_commit (); return true; } elseif ($errors > 0) { return false; } else { return true; } } /** * Delete attachments out the database and from the machine. * * @param mixed $id_attach An int or an array of ints to be deleted * @param bool $transact true if a transaction should be started, false if not * * @return bool True if attachment was succesfully deleted, false if not */ function delete_incidents_attach ($id_attach, $transact = true) { global $config; $id_attach = (array) safe_int ($id_attach, 1); //cast as array $errors = 0; //Start transaction if ($transact == true) { process_sql_begin (); } //Delete attachment foreach ($id_attach as $id) { $filename = get_db_value ("filename", "tattachment", "id_attachment", $id); $sql = sprintf ("DELETE FROM tattachment WHERE id_attachment = %d", $id); $ret = process_sql ($sql); if ($ret === false) { $errors++; } unlink ($config["attachment_store"]."/pand".$id."_".$filename); } if ($transact == true && $errors > 0) { process_sql_rollback (); return false; } elseif ($transact == true) { process_sql_commit (); return true; } elseif ($errors > 0) { return false; } else { return true; } } /** * Get notes based on the incident id. * * @param int $id_incident An int with the incident id * * @return array An array of all the notes for that incident */ function get_incidents_notes ($id_incident) { $return = get_db_all_rows_field_filter ("tnota", "id_incident", (int) $id_incident); if ($return === false) { $return = array (); } $notes = array (); foreach ($return as $row) { $notes[$row["id_nota"]] = $row; } return $notes; } /** * Get attachments based on the incident id. * * @param int $id_incident An int with the incident id * * @return array An array of all the notes for that incident */ function get_incidents_attach ($id_incident) { $return = get_db_all_rows_field_filter ("tattachment", "id_incidencia", (int) $id_incident); if ($return === false) { $return = array (); } $attach = array (); foreach ($return as $row) { $attach[$row["id_attachment"]] = $row; } return $attach; } /** * Get user id of a note. * * @param int $id_note Note id. * * @return string User id of the given note. */ function get_incidents_notes_author ($id_note) { return (string) get_db_value ('id_usuario', 'tnota', 'id_nota', (int) $id_note); } ?>