1: <?php
2:
3: /*
4: projectGroupHandler.class.php
5: Copyright 2010 Mika Ristolainen/Bmm Solutions
6: */
7:
8: class projectGroupHandler {
9:
10: protected $group_id;
11: protected $group_name;
12:
13: public function __construct ( $group_id,$group_name){
14: $this->group_id = $group_id;
15: $this->group_name = $group_name;
16: }
17:
18: public function setDataSource(&$db){
19: $this->dbhandler = new projectGroupDbHandler($db);
20: }
21:
22: public function destructDbInstances(){
23: unset($this->dbhandler);
24: }
25:
26: public function initialize (){
27: $this->group_id = null;
28: $this->group_name = null;
29: }
30:
31: public function initializeById($id){
32: $this->group_id = $id;
33: $this->group_name = $this->dbhandler->getGroupName($id);
34: }
35:
36: public function syncStorageInsert($trans = true){
37:
38: if (!is_numeric($this->getGroupUserId())) return false;
39: try {
40: if ($trans == true) $this->dbhandler->db->transactionStart();
41: $this->group_id = $this->dbhandler->insertGroupData( $this->getGroupUserId());
42:
43: }catch (Exception $e){
44: $this->dbhandler->db->transactionRollback();
45: throw new Exception($e->getMessage());
46: }
47: if ($trans == true) $this->dbhandler->db->transactionEnd();
48: return true;
49: }
50:
51: public function getGroupId(){
52: return $this->group_id;
53: }
54:
55: public function getGroupName(){
56: return $this->group_name;
57: }
58: }
59: ?>
60: