Skip to content

Commit

Permalink
cambios en el xml export
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel Osorio authored and Abel Osorio committed Jan 11, 2013
1 parent b9e55e5 commit 3deee7c
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 12 deletions.
2 changes: 1 addition & 1 deletion application/controllers/upload.php
Expand Up @@ -50,7 +50,7 @@ function index() {
*/
function do_upload() {
$config['upload_path'] = './subidos/';
$config['allowed_types'] = 'gif|jpg|png|zip|avi';
$config['allowed_types'] = 'gif|jpg|png|zip|avi|xml';

$this->load->library('upload', $config);

Expand Down
16 changes: 16 additions & 0 deletions application/controllers/usuario.php
Expand Up @@ -92,6 +92,9 @@ function index($username, $opcion) {
case 'ExportXMLFIle':
$this->ExportXMLFIle($username);
break;
case 'ImportXMLFIle':
$this->ImportXMLFIle($username);
break;
};
}

Expand Down Expand Up @@ -186,6 +189,19 @@ function ExportXMLFIle($username) {
echo "esta repedito";
}

function ImportXMLFIle($username) {

$booleano = $this->usuario_model->SetUserInfoFromxml($username) ;

if ($booleano != null) {
// si el cambio fue exitoso se redirecciona
// redirect('/homeuser/index');
echo $booleano;
} else
// caso de gente repetido
echo "esta repedito";
}




Expand Down
52 changes: 42 additions & 10 deletions application/models/usuario_model.php
Expand Up @@ -181,7 +181,7 @@ public function getUserInfoxml($username) {
$sql = "select * from usuario where username = '$username'";
$query = $this->db->query($sql);
$config = array(
'root' => 'root',
'root' => 'infousuario',
'element' => 'usuario',
'newline' => "\n",
'tab' => "\t"
Expand All @@ -199,35 +199,67 @@ public function getUserInfoxml($username) {
);
$xml2 = $this->dbutil->xml_from_result($query2, $config2);
$xml3 = $xml . $xml2;


// notas
$sql3 = "select l.id_libreta,l.nombre,l.descripcion,l.fecha from libreta l, usuario u where u.username = '$username' and u.id_usuario = l.fk_usuario";
$query3 = $this->db->query($sql2);
$sql3 = "select n.id_nota,n.titulo,n.texto,n.fecha_creacion,n.id_libreta from nota n,libreta l, usuario u where u.id_usuario = l.fk_usuario and n.id_libreta = l.id_libreta and u.username = '$username' ";
$query3 = $this->db->query($sql3);
$config3 = array(
'root' => 'libretas',
'element' => 'libreta',
'root' => 'notas',
'element' => 'nota',
'newline' => "\n",
'tab' => "\t"
);
$xml4 = $this->dbutil->xml_from_result($query3, $config3);


$xml5 = $xml3 . $xml4;



// adjuntos
$sql4 = "select a.id_adjunto,a.link,a.nombre from nota n,libreta l, usuario u , adjunto a , nota_adjunto na where u.id_usuario = l.fk_usuario and n.id_libreta = l.id_libreta and na.fk_nota = n.id_nota and na.fk_adjunto = a.id_adjunto
and u.username = '$username'";
$query4 = $this->db->query($sql4);
$config4 = array(
'root' => 'adjuntos',
'element' => 'adjunto',
'newline' => "\n",
'tab' => "\t"
);
$xml6 = $this->dbutil->xml_from_result($query4, $config4);


$xml7 = $xml5 . $xml6;


$this->load->helper('download');
force_download('myfile.xml', $xml3);
force_download($username . '.xml', $xml7);

return true;
} else {
return false;
}
}

public function SetUserInfoFromxml($username) {

$doc = new DOMDocument();
$doc->load("subidos/usuariox.xml");//xml file loading here

$employees = $doc->getElementsByTagName("infousuario");
foreach ($employees as $employee) {
$names = $employee->getElementsByTagName("id_usuario");
$name = $names->item(0)->nodeValue;

$ages = $employee->getElementsByTagName("nombre");
$age = $ages->item(0)->nodeValue;

$salaries = $employee->getElementsByTagName("apellido");
$salary = $salaries->item(0)->nodeValue;

return $name . $salary . $age;
}
}

/**
*
*
Expand Down
3 changes: 2 additions & 1 deletion application/views/includes/headnormal.php
Expand Up @@ -30,7 +30,8 @@
<li><?php echo anchor('usuario/index/' . $username . '/modify', 'Modify User Data', array('title' => 'Modify')); ?></li>
<li><?php echo anchor('usuario/index/' . $username . '/changePassword', 'Change Password', array('title' => 'Change Password')); ?></li>
<li><?php echo anchor('upload/request_dropbox/', 'Configure Dropbox Account', array('title' => 'Configurate Dropbox Account')); ?></li>
<li><?php echo anchor('usuario/index/' . $username . '/ExportXMLFIle', 'Export User Info to XML FIle', array('title' => 'Export to XML')); ?></li>
<li><?php echo anchor('usuario/index/' . $username . '/ExportXMLFIle', 'Export User Info to Xml', array('title' => 'Export to XML')); ?></li>
<li><?php echo anchor('usuario/index/' . $username . '/ImportXMLFIle', 'Import User Info From Xml', array('title' => 'Import From XML')); ?></li>
<li><?php echo anchor('home', 'Logout', array('title' => 'Home')); ?></li>

</ul>
Expand Down
12 changes: 12 additions & 0 deletions subidos/usuariox.xml
@@ -0,0 +1,12 @@
<infousuario>
<usuario>
<id_usuario>32</id_usuario>
<nombre>usuariox</nombre>
<apellido>usuariox</apellido>
<username>usuariox</username>
<email>usuariox@gmail.com</email>
<password>12345678</password>
<oauth_token></oauth_token>
<oauth_token_secret></oauth_token_secret>
</usuario>
</infousuario>
18 changes: 18 additions & 0 deletions usuariox.xml
@@ -0,0 +1,18 @@
<infousuario>
<usuario>
<id_usuario>32</id_usuario>
<nombre>usuariox</nombre>
<apellido>usuariox</apellido>
<username>usuariox</username>
<email>usuariox@gmail.com</email>
<password>12345678</password>
<oauth_token></oauth_token>
<oauth_token_secret></oauth_token_secret>
</usuario>
</infousuario>
<libretas>
</libretas>
<notas>
</notas>
<adjuntos>
</adjuntos>

0 comments on commit 3deee7c

Please sign in to comment.