ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLTIProviderObjectSetting.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  private $log = null;
17 
21  private $db = null;
22 
23  private $ref_id = 0;
24  private $consumer_id = 0;
25  private $admin = false;
26  private $tutor = false;
27  private $member = false;
28 
33  public function __construct($a_ref_id, $a_ext_consumer_id)
34  {
35  global $DIC;
36 
37  $this->log = $DIC->logger()->lti();
38  $this->db = $DIC->database();
39 
40  $this->ref_id = $a_ref_id;
41  $this->consumer_id = $a_ext_consumer_id;
42 
43  $this->read();
44  }
45 
46 
47  public function setAdminRole($a_role)
48  {
49  $this->admin = $a_role;
50  }
51 
52  public function getAdminRole()
53  {
54  return $this->admin;
55  }
56 
57  public function setTutorRole($a_role)
58  {
59  $this->tutor = $a_role;
60  }
61 
62  public function getTutorRole()
63  {
64  return $this->tutor;
65  }
66 
67  public function setMemberRole($a_role)
68  {
69  $this->member = $a_role;
70  }
71 
72  public function getMemberRole()
73  {
74  return $this->member;
75  }
76 
81  public function setConsumerId($a_consumer_id)
82  {
83  $this->consumer_id = $a_consumer_id;
84  }
85 
86  public function getConsumerId()
87  {
88  return $this->consumer_id;
89  }
90 
91 
95  public function delete()
96  {
97  $query = 'DELETE FROM lti_int_provider_obj ' .
98  'WHERE ref_id = ' . $this->db->quote($this->ref_id, 'integer') . ' ' .
99  'AND ext_consumer_id = ' . $this->db->quote($this->getConsumerId(), 'integer');
100  $this->db->manipulate($query);
101  }
102 
103  public function save()
104  {
105  $this->delete();
106 
107  $query = 'INSERT INTO lti_int_provider_obj ' .
108  '(ref_id,ext_consumer_id,admin,tutor,member) VALUES( ' .
109  $this->db->quote($this->ref_id, 'integer') . ', ' .
110  $this->db->quote($this->getConsumerId(), 'integer') . ', ' .
111  $this->db->quote($this->getAdminRole(), 'integer') . ', ' .
112  $this->db->quote($this->getTutorRole(), 'integer') . ', ' .
113  $this->db->quote($this->getMemberRole(), 'integer') .
114  ' )';
115  $this->db->manipulate($query);
116  }
117 
122  protected function read()
123  {
124  if (!$this->ref_id) {
125  return false;
126  }
127 
128  $query = 'SELECT * FROM lti_int_provider_obj ' .
129  'WHERE ref_id = ' . $this->db->quote($this->ref_id, 'integer') . ' ' .
130  'AND ext_consumer_id = ' . $this->db->quote($this->getConsumerId(), 'integer');
131 
132  $res = $this->db->query($query);
133  while ($row = $res->fetchObject()) {
134  $this->ref_id = $row->ref_id;
135  $this->consumer_id = $row->ext_consumer_id;
136  $this->admin = $row->admin;
137  $this->tutor = $row->tutor;
138  $this->member = $row->member;
139  }
140  }
141 }
global $DIC
Definition: saml.php:7
setConsumerId($a_consumer_id)
Set consumer id.
foreach($_POST as $key=> $value) $res
$query
__construct($a_ref_id, $a_ext_consumer_id)
Constructor type $DIC.