1: <?php
2: /*
3: accessLevelHandler.class.php
4: Copyright 2007 Mika Ristolainen/Bmm Solutions
5: */
6:
7:
8: class permissionHandler extends accessLevelHandler {
9:
10: protected $id;
11:
12: function __construct (){
13: $this->initialize();
14: parent::__construct();
15: }
16:
17: function __destruct(){
18: }
19:
20: public function destructDbInstances(){
21: unset($this->dbhandler);
22: }
23:
24:
25: public function setDataSource(&$db){
26: $this->dbhandler = new permissionDbHandler($db);
27: }
28:
29: public function initialize($app_id,
30: $app_target_id,
31: $perm_target_id,
32: $perm_target_type,
33: $perm_target_section = "default"){
34:
35: }
36:
37: public function initializeById($id){
38: if (!is_numeric($id)) {
39: $this->id = null;
40: return false;
41: }
42:
43: $this->id = $id;
44: }
45:
46: public function syncStorage($transaction = true){
47: if ($this->getAccessId() > 0)
48: $this->syncStorageUpdate($transaction);
49: else
50: $this->syncStorageInsert($transaction);
51: }
52:
53: public function syncStorageUpdate($transaction){
54:
55: //if (!($this->getGroupId())) throw new Exception("Failed to Update data, missing Group ID. Please verify data values.");
56:
57: try {
58: if ($transaction == true) $this->dbhandler->db->transactionStart();
59: $this->dbhandler->updateAccessLevelData( $this->id);
60: }catch (Exception $e){
61: $this->dbhandler->db->transactionRollback();
62: return false;
63: }
64: if ($transaction == true) $this->dbhandler->db->transactionEnd();
65: }
66:
67: public function syncStorageInsert($transaction){
68:
69: //if (!($this->getGroupName())) throw new Exception("Failed to insert data, missing Group Name. Please verify data values.");
70: try {
71: if ($transaction == true) $this->dbhandler->db->transactionStart();
72: $this->id = $this->dbhandler->insertAccessLevelData(
73: );
74: }catch (Exception $e){
75: $this->dbhandler->db->transactionRollback();
76: return false;
77: }
78: if ($transaction == true) $this->dbhandler->db->transactionEnd();
79: return $this->id;
80: }
81:
82: }
83: ?>
84: