1: <?php
2:
3: /*
4: projectMemberHandler.class.php
5: Copyright 2007 Mika Ristolainen/Bmm Solutions
6: */
7:
8: class projectMemberHandler {
9:
10: protected $member_id;
11: protected $role;
12: protected $desc;
13: protected $user_id;
14:
15: public function __construct ( $member_id,$role,$desc,$user_id){
16: $this->member_id = $member_id;
17: $this->role = $role;
18: $this->desc = $desc;
19: $this->user_id = $user_id;
20: $this->userhandler = new userHandler();
21:
22: }
23:
24: public function setDataSource(&$db){
25: $this->dbhandler = new projectMemberDbHandler($db);
26: $this->userhandler->setDataSource($db);
27: }
28:
29: public function destructDbInstances(){
30: unset($this->dbhandler);
31: $this->userhandler->destructDbInstances();
32: }
33:
34: public function initialize (){
35: $this->member_id = null;
36: $this->role = null;
37: $this->desc = null;
38: $this->user_id = null;
39: $this->userhandler->initialize();
40: }
41:
42: public function initializeById($id){
43: $this->member_id = $id;
44: $this->role = $this->dbhandler->getMemberRole($id);
45: $this->desc = $this->dbhandler->getMemberDescription($id);
46: $this->user_id = $this->dbhandler->getMemberUserId($id);
47:
48: $this->userhandler->initializeById($this->user_id);
49: }
50:
51: public function initializeUserData($id){
52: $this->userhandler->initializeById($id);
53: }
54:
55:
56:
57: public function syncStorageInsert($trans = true){
58:
59: if (!is_numeric($this->getMemberUserId())) return false;
60: try {
61: if ($trans == true) $this->dbhandler->db->transactionStart();
62: $this->member_id = $this->dbhandler->insertMemberData(
63: $this->getMemberRole(),
64: $this->getMemberDescription(),
65: $this->getMemberUserId());
66:
67: }catch (Exception $e){
68: $this->dbhandler->db->transactionRollback();
69: throw new Exception($e->getMessage());
70: }
71: if ($trans == true) $this->dbhandler->db->transactionEnd();
72: return true;
73: }
74:
75:
76: public function getMemberUserId(){
77: return $this->user_id;
78: }
79:
80: public function getMemberId(){
81: return $this->member_id;
82: }
83:
84: public function getMemberUserName(){
85: return $this->userhandler->getUserName();
86: }
87:
88: public function getMemberUserEmail(){
89: return $this->userhandler->getUserEmail();
90: }
91:
92: public function getMemberRole(){
93: return $this->role;
94: }
95:
96: public function getMemberDescription(){
97: return $this->desc;
98: }
99: }
100: ?>
101: