ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

 $database
 
 $ls_filesystem
 

Detailed Description

Persistence for Settings (like abstract, extro)

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $database, and $ls_filesystem.

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 116 of file class.ilLearningSequenceSettingsDB.php.

Referenced by getSettingsFor().

124  return new ilLearningSequenceSettings(
125  $obj_id,
126  $abstract,
127  $extro,
128  $abstract_image,
129  $extro_image,
130  $gallery
131  );
132  }
Settings for an LSO (like abstract, extro)
+ Here is the caller graph for this function:

◆ delete()

ilLearningSequenceSettingsDB::delete ( int  $obj_id)

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

References $query, getSettingsFor(), ilLearningSequenceFilesystem\IMG_ABSTRACT, ilLearningSequenceFilesystem\IMG_EXTRO, and PHP_EOL.

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

◆ getSettingsFor()

ilLearningSequenceSettingsDB::getSettingsFor ( int  $lso_obj_id)

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

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

Referenced by delete().

78  {
79  $data = $this->select($lso_obj_id);
80 
81  if (count($data) == 0) {
82  $settings = $this->buildSettings($lso_obj_id);
83  $this->insert($settings);
84  } else {
85  $settings = $this->buildSettings(
86  $lso_obj_id,
87  $data['abstract'],
88  $data['extro'],
89  $data['abstract_image'],
90  $data['extro_image'],
91  (bool) $data['gallery']
92  );
93  }
94 
95  return $settings;
96  }
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)
$data
Definition: bench.php:6
+ 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 134 of file class.ilLearningSequenceSettingsDB.php.

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

Referenced by getSettingsFor().

135  {
136  $values = array(
137  "obj_id" => array("integer", $settings->getObjId()),
138  "abstract" => array("text", $settings->getAbstract()),
139  "extro" => array("text", $settings->getExtro()),
140  "gallery" => array("integer", $settings->getMembersGallery())
141  );
142  $this->database->insert(static::TABLE_NAME, $values);
143  }
$values
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select()

ilLearningSequenceSettingsDB::select ( int  $obj_id)
protected

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

References $query, $result, $ret, and PHP_EOL.

Referenced by getSettingsFor().

98  : array
99  {
100  $ret = [];
101  $query =
102  "SELECT abstract, extro, abstract_image, extro_image, gallery" . PHP_EOL
103  . "FROM " . static::TABLE_NAME . PHP_EOL
104  . "WHERE obj_id = " . $this->database->quote($obj_id, "integer") . PHP_EOL
105  ;
106 
107  $result = $this->database->query($query);
108 
109  if ($result->numRows() !== 0) {
110  $ret = $this->database->fetchAssoc($result);
111  }
112 
113  return $ret;
114  }
$result
PHP_EOL
Definition: complexTest.php:5
$query
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

◆ store()

ilLearningSequenceSettingsDB::store ( ilLearningSequenceSettings  $settings)

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

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

31  {
32  $uploads = $settings->getUploads();
33  if (count($uploads) > 0) {
34  foreach ($uploads as $pre => $info) {
35  $settings = $this->ls_filesystem->moveUploaded($pre, $info, $settings);
36  }
37  }
38 
39  $deletions = $settings->getDeletions();
40  if (count($deletions) > 0) {
41  foreach ($deletions as $pre) {
42  $settings = $this->ls_filesystem->delete_image($pre, $settings);
43  }
44  }
45 
46  $where = array(
47  "obj_id" => array("integer", $settings->getObjId())
48  );
49 
50  $values = array(
51  "abstract" => array("text", $settings->getAbstract()),
52  "extro" => array("text", $settings->getExtro()),
53  "abstract_image" => array("text", $settings->getAbstractImage()),
54  "extro_image" => array("text", $settings->getExtroImage()),
55  "gallery" => array("integer", $settings->getMembersGallery())
56  );
57 
58  $this->database->update(static::TABLE_NAME, $values, $where);
59  }
$values
$info
Definition: index.php:5
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilLearningSequenceSettingsDB::$database
protected

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

Referenced by __construct().

◆ $ls_filesystem

ilLearningSequenceSettingsDB::$ls_filesystem
protected

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

Referenced by __construct().

◆ TABLE_NAME

const ilLearningSequenceSettingsDB::TABLE_NAME = 'lso_settings'

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


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