ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLearningSequenceSettingsDB Class Reference

Persistence for Settings (like abstract, extro) More...

+ Collaboration diagram for ilLearningSequenceSettingsDB:

Public Member Functions

 __construct (ilDBInterface $database, ilLearningSequenceFilesystem $ls_filesystem)
 
 store (ilLearningSequenceSettings $settings)
 
 delete (int $obj_id)
 
 getSettingsFor (int $lso_obj_id)
 

Data Fields

const TABLE_NAME = 'lso_settings'
 

Protected Member Functions

 select (int $obj_id)
 
 buildSettings (int $obj_id, string $abstract='', string $extro='', ?string $abstract_image=null, ?string $extro_image=null, bool $gallery=false)
 
 insert (ilLearningSequenceSettings $settings)
 

Protected Attributes

ilDBInterface $database
 
ilLearningSequenceFilesystem $ls_filesystem
 

Detailed Description

Persistence for Settings (like abstract, extro)

Definition at line 24 of file class.ilLearningSequenceSettingsDB.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningSequenceSettingsDB::__construct ( ilDBInterface  $database,
ilLearningSequenceFilesystem  $ls_filesystem 
)

Definition at line 31 of file class.ilLearningSequenceSettingsDB.php.

References $database, and $ls_filesystem.

32  {
33  $this->database = $database;
34  $this->ls_filesystem = $ls_filesystem;
35  }

Member Function Documentation

◆ buildSettings()

ilLearningSequenceSettingsDB::buildSettings ( int  $obj_id,
string  $abstract = '',
string  $extro = '',
?string  $abstract_image = null,
?string  $extro_image = null,
bool  $gallery = false 
)
protected

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

Referenced by getSettingsFor().

131  return new ilLearningSequenceSettings(
132  $obj_id,
133  $abstract,
134  $extro,
135  $abstract_image,
136  $extro_image,
137  $gallery
138  );
139  }
Settings for an LSO (like abstract, extro)
+ Here is the caller graph for this function:

◆ delete()

ilLearningSequenceSettingsDB::delete ( int  $obj_id)

Definition at line 64 of file class.ilLearningSequenceSettingsDB.php.

References getSettingsFor(), ilLearningSequenceFilesystem\IMG_ABSTRACT, and ilLearningSequenceFilesystem\IMG_EXTRO.

64  : void
65  {
66  $settings = $this->getSettingsFor($obj_id);
67 
69  $settings = $this->ls_filesystem->delete_image($pre, $settings);
70  }
71 
72  $query =
73  "DELETE FROM " . static::TABLE_NAME . PHP_EOL
74  . "WHERE obj_id = " . $this->database->quote($obj_id, "integer") . PHP_EOL
75  ;
76 
77  $this->database->manipulate($query);
78  }
+ Here is the call graph for this function:

◆ getSettingsFor()

ilLearningSequenceSettingsDB::getSettingsFor ( int  $lso_obj_id)

Definition at line 80 of file class.ilLearningSequenceSettingsDB.php.

References $data, buildSettings(), insert(), and select().

Referenced by delete().

81  {
82  $data = $this->select($lso_obj_id);
83 
84  if (count($data) == 0) {
85  $settings = $this->buildSettings($lso_obj_id);
86  $this->insert($settings);
87  } else {
88  $settings = $this->buildSettings(
89  $lso_obj_id,
90  $data['abstract'],
91  $data['extro'],
92  $data['abstract_image'],
93  $data['extro_image'],
94  (bool) $data['gallery']
95  );
96  }
97 
98  return $settings;
99  }
Settings for an LSO (like abstract, extro)
insert(ilLearningSequenceSettings $settings)
buildSettings(int $obj_id, string $abstract='', string $extro='', ?string $abstract_image=null, ?string $extro_image=null, bool $gallery=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilLearningSequenceSettingsDB::insert ( ilLearningSequenceSettings  $settings)
protected

Definition at line 141 of file class.ilLearningSequenceSettingsDB.php.

References ilLearningSequenceSettings\getAbstract(), ilLearningSequenceSettings\getExtro(), ilLearningSequenceSettings\getMembersGallery(), and ilLearningSequenceSettings\getObjId().

Referenced by getSettingsFor().

141  : void
142  {
143  $values = [
144  "obj_id" => ["integer", $settings->getObjId()],
145  "abstract" => ["text", $settings->getAbstract()],
146  "extro" => ["text", $settings->getExtro()],
147  "gallery" => ["integer", $settings->getMembersGallery()]
148  ];
149  $this->database->insert(static::TABLE_NAME, $values);
150  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select()

ilLearningSequenceSettingsDB::select ( int  $obj_id)
protected
Returns
array<string, mixed>

Definition at line 104 of file class.ilLearningSequenceSettingsDB.php.

Referenced by getSettingsFor().

104  : array
105  {
106  $ret = [];
107  $query =
108  "SELECT abstract, extro, abstract_image, extro_image, gallery" . PHP_EOL
109  . "FROM " . static::TABLE_NAME . PHP_EOL
110  . "WHERE obj_id = " . $this->database->quote($obj_id, "integer") . PHP_EOL
111  ;
112 
113  $result = $this->database->query($query);
114 
115  if ($this->database->numRows($result) !== 0) {
116  // TODO PHP8 Review: Check array building, should be $ret[] = ... IMO
117  $ret = $this->database->fetchAssoc($result);
118  }
119 
120  return $ret;
121  }
+ Here is the caller graph for this function:

◆ store()

ilLearningSequenceSettingsDB::store ( ilLearningSequenceSettings  $settings)

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

References ilLearningSequenceSettings\getAbstract(), ilLearningSequenceSettings\getAbstractImage(), ilLearningSequenceSettings\getDeletions(), ilLearningSequenceSettings\getExtro(), ilLearningSequenceSettings\getExtroImage(), ilLearningSequenceSettings\getMembersGallery(), ilLearningSequenceSettings\getObjId(), and ilLearningSequenceSettings\getUploads().

37  : void
38  {
39  $uploads = $settings->getUploads();
40  foreach ($uploads as $pre => $info) {
41  $settings = $this->ls_filesystem->moveUploaded($pre, $info, $settings);
42  }
43 
44  $deletions = $settings->getDeletions();
45  foreach ($deletions as $pre) {
46  $settings = $this->ls_filesystem->delete_image($pre, $settings);
47  }
48 
49  $where = [
50  "obj_id" => ["integer", $settings->getObjId()]
51  ];
52 
53  $values = [
54  "abstract" => ["text", $settings->getAbstract()],
55  "extro" => ["text", $settings->getExtro()],
56  "abstract_image" => ["text", $settings->getAbstractImage()],
57  "extro_image" => ["text", $settings->getExtroImage()],
58  "gallery" => ["integer", $settings->getMembersGallery()]
59  ];
60 
61  $this->database->update(static::TABLE_NAME, $values, $where);
62  }
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ilLearningSequenceSettingsDB::$database
protected

Definition at line 28 of file class.ilLearningSequenceSettingsDB.php.

Referenced by __construct().

◆ $ls_filesystem

ilLearningSequenceFilesystem ilLearningSequenceSettingsDB::$ls_filesystem
protected

Definition at line 29 of file class.ilLearningSequenceSettingsDB.php.

Referenced by __construct().

◆ TABLE_NAME

const ilLearningSequenceSettingsDB::TABLE_NAME = 'lso_settings'

Definition at line 26 of file class.ilLearningSequenceSettingsDB.php.


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