1 | <?php |
---|
2 | /************************************************************************************************\ |
---|
3 | * Gerencia de projetos ageis * |
---|
4 | * by Rafael Raymundo da Silva (rafael2000@gmail.com) * |
---|
5 | * ----------------------------------------------------------------------------------------------* |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \***********************************************************************************************/ |
---|
11 | include_once('../header.inc.php'); |
---|
12 | |
---|
13 | class sosaveElement{ |
---|
14 | |
---|
15 | var $db; |
---|
16 | var $save_projects; |
---|
17 | var $save_partic; |
---|
18 | var $save_admin; |
---|
19 | var $delOldies; |
---|
20 | |
---|
21 | public function sosaveElement($projId,$name,$description,$particArray,$adminArray){ |
---|
22 | include_once('../phpgwapi/inc/class.db.inc.php'); |
---|
23 | |
---|
24 | $particArray = unserialize($particArray); |
---|
25 | $adminArray = unserialize($adminArray); |
---|
26 | |
---|
27 | $numPartic = count($particArray); |
---|
28 | $numAdmin = count($adminArray); |
---|
29 | |
---|
30 | $this->save_projects = $GLOBALS['phpgw']->db; |
---|
31 | $this->save_partic = $GLOBALS['phpgw']->db; |
---|
32 | $this->save_admin = $GLOBALS['phpgw']->db; |
---|
33 | $this->delOldies = $GLOBALS['phpgw']->db; |
---|
34 | |
---|
35 | //Insere o projeto guardando seu ID |
---|
36 | //TODO: Fazer como UPDATE |
---|
37 | $delete = $this->delOldies->query('DELETE from phpgw_agile_users_projects WHERE uprojects_id_project=\''.$projId.'\'',__LINE__,__FILE__); |
---|
38 | |
---|
39 | //Realizando UPDATE da table phpgw_agile_projects |
---|
40 | $update_projects = $this->save_projects->query('UPDATE phpgw_agile_projects SET proj_name = \''.$name.'\', proj_description = \''.$description.'\' WHERE proj_id=\''.$projId.'\'',__LINE__,__FILE__); |
---|
41 | |
---|
42 | //Insere os usuarios participantes e posteriormente os administradores |
---|
43 | for($i=0;$i<$numPartic;$i++){ |
---|
44 | $this->save_partic->query('INSERT INTO phpgw_agile_users_projects(uprojects_id_user, uprojects_id_project,uprojects_user_admin,uprojects_active) VALUES(\''.$particArray[$i].'\',\''.$projId.'\',FALSE,FALSE)',__LINE__,__FILE__); |
---|
45 | } |
---|
46 | for($i=0;$i<$numAdmin;$i++){ |
---|
47 | $this->save_admin->query('INSERT INTO phpgw_agile_users_projects(uprojects_id_user, uprojects_id_project,uprojects_user_admin,uprojects_active) VALUES(\''.$adminArray[$i].'\',\''.$projId.'\',TRUE,FALSE)',__LINE__,__FILE__); |
---|
48 | } |
---|
49 | |
---|
50 | } |
---|
51 | } |
---|
52 | ?> |
---|