X-Git-Url: https://git.llucax.com/z.facultad/75.43/tp1.git/blobdiff_plain/6554fc774c6458cfb1fa451b260047dbcd7ec282..refs/heads/master:/src/lib/Info.php?ds=sidebyside
diff --git a/src/lib/Info.php b/src/lib/Info.php
index 4579ed5..a6d2baa 100644
--- a/src/lib/Info.php
+++ b/src/lib/Info.php
@@ -1,15 +1,14 @@
infoCSVConst, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));
+ }
+
+ function saveExisting() {
+ if (($f = fopen($this->infoCSVConst, 'r+')) == false) return false; // error
+ $index = 0;
+ while (!feof($f))
+ {
+ $index = ftell($f);
+ $d = fgetcsv($f, 4096);
+ if ($d[0] == $this->id)
+ {
+ fseek($f,$index);
+ fputcsv($f, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));
+ fclose($f);
+ return true;
+ }
+ }
+ fclose($f);
+ return false;
+ }
+
+ function saveLoadThis( $pId, $pTema, $pURL, $pAutor, $pComentario ) {
$this->id = $pId;
$this->tema = $pTema;
$this->url = $pURL;
$this->autor = $pAutor;
- $this->comentario = $pComentario;
+ $this->comentario = preg_replace('[\n|\r\n]','
',$pComentario);
$this->ranking = 0;
$this->fecha = time();
$this->texto = '';
+ }
+ function ingresar( $pId, $pTema, $pURL, $pAutor, $pComentario ) {
+ $this->saveLoadThis( $pId, $pTema, $pURL, $pAutor, $pComentario );
$resultado = "";
- if (!fappendcsv($this->infoCSVConst, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha))) {
+ if (!$this->saveNew()) {
$resultado = "ERROR al agregar la informacion. Revise que los parametros sean los adecuados";
- }
+ file_log_add($pAutor,$resultado);
+ } else {
+ file_log_add($pAutor,"Se agregó la información");
+ }
return $resultado;
}
@@ -89,32 +117,15 @@ class Info extends Item