ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilExportOptions Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilExportOptions:

Public Member Functions

 getSubitemsForCreation (int $a_source_id)
 Get all subitems with mode ilExportOptions::EXPORT_BUILD More...
 
 getSubitemsForExport ()
 Get all subitems with mode != self::EXPORT_OMIT. More...
 
 getExportId ()
 
 addOption (int $a_keyword, int $a_ref_id, int $a_obj_id, $a_value)
 
 addOptions (int $parent_ref_id, ilObjectDefinition $object_definition, ilAccessHandler $il_access, array $child_nodes, array $cp_options)
 
 getOption (int $a_keyword)
 
 getOptionByObjId (int $a_obj_id, int $a_keyword)
 Get option by. More...
 
 getOptionByRefId (int $a_ref_id, int $a_keyword)
 Get option by. More...
 
 delete ()
 
 read ()
 

Static Public Member Functions

static getInstance ()
 
static newInstance (int $a_export_id)
 
static allocateExportId ()
 

Data Fields

const EXPORT_EXISTING = 1
 
const EXPORT_BUILD = 2
 
const EXPORT_OMIT = 3
 
const KEY_INIT = 1
 
const KEY_ITEM_MODE = 2
 
const KEY_ROOT = 3
 

Protected Attributes

ilDBInterface $db
 

Private Member Functions

 __construct (int $a_export_id)
 

Private Attributes

int $export_id = 0
 
array $ref_options = array()
 
array $obj_options = array()
 
array $options = array()
 

Static Private Attributes

static ilExportOptions $instance = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Export options

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 25 of file class.ilExportOptions.php.

Constructor & Destructor Documentation

◆ __construct()

ilExportOptions::__construct ( int  $a_export_id)
private

Definition at line 44 of file class.ilExportOptions.php.

45 {
46 global $DIC;
47
48 $this->db = $DIC->database();
49 $this->export_id = $a_export_id;
50 if ($this->export_id) {
51 $this->read();
52 }
53 }
global $DIC
Definition: shib_login.php:26

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ addOption()

ilExportOptions::addOption ( int  $a_keyword,
int  $a_ref_id,
int  $a_obj_id,
  $a_value 
)
Parameters
int$a_keyword
int$a_ref_id
int$a_obj_id
string | int$a_value

Definition at line 134 of file class.ilExportOptions.php.

134 : void
135 {
136 $query = "SELECT MAX(pos) position FROM export_options";
137 $res = $this->db->query($query);
138
139 $pos = 0;
140 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
141 $pos = (int) $row->position;
142 }
143 $pos++;
144
145 $query = 'INSERT INTO export_options (export_id,keyword,ref_id,obj_id,value,pos) ' .
146 'VALUES( ' .
147 $this->db->quote($this->getExportId(), ilDBConstants::T_INTEGER) . ', ' .
148 $this->db->quote($a_keyword, ilDBConstants::T_INTEGER) . ', ' .
149 $this->db->quote($a_ref_id, ilDBConstants::T_INTEGER) . ', ' .
150 $this->db->quote($a_obj_id, ilDBConstants::T_INTEGER) . ', ' .
151 $this->db->quote($a_value, ilDBConstants::T_INTEGER) . ', ' .
152 $this->db->quote($pos, ilDBConstants::T_INTEGER) . ' ' .
153 ')';
154 $this->db->manipulate($query);
155 }
$res
Definition: ltiservices.php:69

References $res, ilDBConstants\FETCHMODE_OBJECT, getExportId(), ILIAS\Repository\int(), and ilDBConstants\T_INTEGER.

Referenced by addOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addOptions()

ilExportOptions::addOptions ( int  $parent_ref_id,
ilObjectDefinition  $object_definition,
ilAccessHandler  $il_access,
array  $child_nodes,
array  $cp_options 
)

Definition at line 157 of file class.ilExportOptions.php.

163 : bool {
164 global $DIC;
165 $items_selected = false;
166 foreach ($child_nodes as $node) {
167 if ($node['type'] === 'rolf') {
168 continue;
169 }
170 if ((int) $node['ref_id'] === $parent_ref_id) {
171 $this->addOption(
173 (int) $node['ref_id'],
174 (int) $node['obj_id'],
176 );
177 continue;
178 }
179 // no export available or no access
180 if (!$object_definition->allowExport($node['type']) || !$il_access->checkAccess(
181 'write',
182 '',
183 (int) $node['ref_id']
184 )) {
185 $this->addOption(
187 (int) $node['ref_id'],
188 (int) $node['obj_id'],
190 );
191 continue;
192 }
193
194 $mode = $cp_options[$node['ref_id']]['type'] ?? ilExportOptions::EXPORT_OMIT;
195 $this->addOption(
197 (int) $node['ref_id'],
198 (int) $node['obj_id'],
199 $mode
200 );
201 if ($mode != ilExportOptions::EXPORT_OMIT) {
202 $items_selected = true;
203 }
204 }
205 return $items_selected;
206 }
addOption(int $a_keyword, int $a_ref_id, int $a_obj_id, $a_value)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)

References addOption(), ilObjectDefinition\allowExport(), ilRBACAccessHandler\checkAccess(), EXPORT_BUILD, EXPORT_OMIT, and KEY_ITEM_MODE.

+ Here is the call graph for this function:

◆ allocateExportId()

static ilExportOptions::allocateExportId ( )
static

Definition at line 68 of file class.ilExportOptions.php.

68 : int
69 {
70 global $DIC;
71
72 $ilDB = $DIC->database();
73
74 // get last export id
75 $query = 'SELECT MAX(export_id) exp FROM export_options ' .
76 'GROUP BY export_id ';
77 $res = $ilDB->query($query);
78 $exp_id = 1;
79 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
80 $exp_id = $row->exp + 1;
81 }
82 $query = 'INSERT INTO export_options (export_id,keyword,ref_id,obj_id,value) ' .
83 'VALUES( ' .
84 $ilDB->quote($exp_id, 'integer') . ', ' .
85 $ilDB->quote(self::KEY_INIT, 'integer') . ', ' .
86 $ilDB->quote(0, 'integer') . ', ' .
87 $ilDB->quote(0, 'integer') . ', ' .
88 $ilDB->quote(0, 'integer') . ' ' .
89 ')';
90 $ilDB->manipulate($query);
91 return (int) $exp_id;
92 }

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilExportGUI\createXMLContainerExport(), and ilObjRoleGUI\executeCommand().

+ Here is the caller graph for this function:

◆ delete()

ilExportOptions::delete ( )

Definition at line 239 of file class.ilExportOptions.php.

239 : void
240 {
241 $query = "DELETE FROM export_options " .
242 "WHERE export_id = " . $this->db->quote($this->getExportId(), ilDBConstants::T_INTEGER);
243 $this->db->manipulate($query);
244 }

References ilDBConstants\T_INTEGER.

◆ getExportId()

ilExportOptions::getExportId ( )

Definition at line 123 of file class.ilExportOptions.php.

123 : int
124 {
125 return $this->export_id;
126 }

References $export_id.

Referenced by addOption().

+ Here is the caller graph for this function:

◆ getInstance()

static ilExportOptions::getInstance ( )
static

Definition at line 55 of file class.ilExportOptions.php.

56 {
57 if (self::$instance) {
58 return self::$instance;
59 }
60 return null;
61 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilExportOptions $instance

References $instance.

Referenced by ilContainerXmlWriter\__construct(), ilContainerReferenceExporter\getXmlExportHeadDependencies(), ilAccessControlExporter\getXmlRepresentation(), and ilExportOptionsTest\testConstruct().

+ Here is the caller graph for this function:

◆ getOption()

ilExportOptions::getOption ( int  $a_keyword)
Parameters
$a_keyword
Returns
mixed|null

Definition at line 212 of file class.ilExportOptions.php.

213 {
214 return $this->options[$a_keyword] ?? null;
215 }

◆ getOptionByObjId()

ilExportOptions::getOptionByObjId ( int  $a_obj_id,
int  $a_keyword 
)

Get option by.

Parameters
int$a_obj_id
int$a_keyword
Returns
mixed|null

Definition at line 223 of file class.ilExportOptions.php.

224 {
225 return $this->obj_options[$a_keyword][$a_obj_id] ?? null;
226 }

◆ getOptionByRefId()

ilExportOptions::getOptionByRefId ( int  $a_ref_id,
int  $a_keyword 
)

Get option by.

Parameters
int$a_obj_id
int$a_keyword
Returns
mixed|null

Definition at line 234 of file class.ilExportOptions.php.

235 {
236 return $this->ref_options[$a_keyword][$a_ref_id] ?? null;
237 }

◆ getSubitemsForCreation()

ilExportOptions::getSubitemsForCreation ( int  $a_source_id)

Get all subitems with mode ilExportOptions::EXPORT_BUILD

Definition at line 97 of file class.ilExportOptions.php.

97 : array
98 {
99 $refs = array();
100 foreach ((array) $this->ref_options[self::KEY_ITEM_MODE] as $ref_id => $mode) {
101 if ($mode == self::EXPORT_BUILD) {
102 $refs[] = $ref_id;
103 }
104 }
105 return $refs;
106 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

◆ getSubitemsForExport()

ilExportOptions::getSubitemsForExport ( )

Get all subitems with mode != self::EXPORT_OMIT.

Returns
int[] ref ids

Definition at line 112 of file class.ilExportOptions.php.

113 {
114 $refs = array();
115 foreach ((array) $this->ref_options[self::KEY_ITEM_MODE] as $ref_id => $mode) {
116 if ($mode != self::EXPORT_OMIT) {
117 $refs[] = (int) $ref_id;
118 }
119 }
120 return $refs;
121 }

References $ref_id, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ newInstance()

static ilExportOptions::newInstance ( int  $a_export_id)
static

Definition at line 63 of file class.ilExportOptions.php.

64 {
65 return self::$instance = new ilExportOptions($a_export_id);
66 }

Referenced by ilExportGUI\createXMLContainerExport(), ilObjRoleGUI\executeCommand(), and ilExportOptionsTest\testConstruct().

+ Here is the caller graph for this function:

◆ read()

ilExportOptions::read ( )

Definition at line 246 of file class.ilExportOptions.php.

246 : void
247 {
248 $this->options = array();
249 $this->obj_options = array();
250 $this->ref_options = array();
251
252 $query = "SELECT * FROM export_options " .
253 "WHERE export_id = " . $this->db->quote($this->getExportId(), ilDBConstants::T_INTEGER) . ' ' .
254 "ORDER BY pos";
255 $res = $this->db->query($query);
256 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
257 if ($row->ref_id) {
258 $this->ref_options[(int) $row->keyword][(int) $row->ref_id] = $row->value;
259 }
260 if ($row->obj_id) {
261 $this->obj_options[(int) $row->keyword][(int) $row->obj_id] = $row->value;
262 }
263 if (!$row->ref_id and !$row->obj_id) {
264 $this->options[(int) $row->keyword] = $row->value;
265 }
266 }
267 }

References $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\Repository\int(), and ilDBConstants\T_INTEGER.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilExportOptions::$db
protected

Definition at line 42 of file class.ilExportOptions.php.

◆ $export_id

int ilExportOptions::$export_id = 0
private

Definition at line 37 of file class.ilExportOptions.php.

Referenced by getExportId().

◆ $instance

ilExportOptions ilExportOptions::$instance = null
staticprivate

Definition at line 27 of file class.ilExportOptions.php.

Referenced by getInstance().

◆ $obj_options

array ilExportOptions::$obj_options = array()
private

Definition at line 39 of file class.ilExportOptions.php.

◆ $options

array ilExportOptions::$options = array()
private

Definition at line 40 of file class.ilExportOptions.php.

◆ $ref_options

array ilExportOptions::$ref_options = array()
private

Definition at line 38 of file class.ilExportOptions.php.

◆ EXPORT_BUILD

const ilExportOptions::EXPORT_BUILD = 2

◆ EXPORT_EXISTING

const ilExportOptions::EXPORT_EXISTING = 1

◆ EXPORT_OMIT

◆ KEY_INIT

const ilExportOptions::KEY_INIT = 1

Definition at line 33 of file class.ilExportOptions.php.

◆ KEY_ITEM_MODE

const ilExportOptions::KEY_ITEM_MODE = 2

Definition at line 34 of file class.ilExportOptions.php.

Referenced by addOptions(), and ilContainerXmlWriter\writeSubitems().

◆ KEY_ROOT


The documentation for this class was generated from the following file: