ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilStudyProgrammeAutoCategoryDBRepository Class Reference

Class ilStudyProgrammeAutoCategoryDBRepository. More...

+ Inheritance diagram for ilStudyProgrammeAutoCategoryDBRepository:
+ Collaboration diagram for ilStudyProgrammeAutoCategoryDBRepository:

Public Member Functions

 __construct (ilDBInterface $db, int $current_usr_id)
 
 getFor (int $prg_obj_id)
 Read category-surveillance settings of programme.
Returns
ilStudyProgrammeAutoCategory[]
More...
 
 create (int $prg_obj_id, int $category_ref_id, ?int $last_edited_usr_id=null, ?DateTimeImmutable $last_edited=null)
 Build an auto-category object. More...
 
 update (ilStudyProgrammeAutoCategory $ac)
 Store a category-surveillance setting. More...
 
 delete (int $prg_obj_id, array $cat_ref_ids)
 Delete a single category-surveillance.
Parameters
int[]$cat_ref_ids
More...
 
 deleteFor (int $prg_obj_id)
 Delete all category-surveillance settings for a StudyProgramme. More...
 
 getFor (int $prg_obj_id)
 Read category-surveillance settings of programme. More...
 
 create (int $prg_obj_id, int $category_ref_id, ?int $last_edited_usr_id=null, ?DateTimeImmutable $last_edited=null)
 Build an auto-category object. More...
 
 update (ilStudyProgrammeAutoCategory $ac)
 Store a category-surveillance setting. More...
 
 delete (int $prg_obj_id, array $cat_ref_ids)
 Delete a single category-surveillance. More...
 
 deleteFor (int $prg_obj_id)
 Delete all category-surveillance settings for a StudyProgramme. More...
 

Static Public Member Functions

static getProgrammesFor (int $cat_ref_id)
 Get all programmes' ref_ids monitoring the given category.
Returns
int[]
More...
 
static getProgrammesFor (int $cat_ref_id)
 Get all programmes' ref_ids monitoring the given category. More...
 

Protected Attributes

ilDBInterface $db
 
int $current_usr_id
 

Private Attributes

const TABLE = 'prg_auto_content'
 
const FIELD_PRG_OBJ_ID = 'prg_obj_id'
 
const FIELD_CAT_REF_ID = 'cat_ref_id'
 
const FIELD_EDITOR_ID = 'last_usr_id'
 
const FIELD_LAST_EDITED = 'last_edited'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeAutoCategoryDBRepository::__construct ( ilDBInterface  $db,
int  $current_usr_id 
)

Member Function Documentation

◆ create()

ilStudyProgrammeAutoCategoryDBRepository::create ( int  $prg_obj_id,
int  $category_ref_id,
?int  $last_edited_usr_id = null,
?DateTimeImmutable  $last_edited = null 
)

Build an auto-category object.

Implements ilStudyProgrammeAutoCategoryRepository.

Definition at line 75 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

81 if (is_null($last_edited_usr_id)) {
82 $last_edited_usr_id = $this->current_usr_id;
83 }
84 if (is_null($last_edited)) {
85 $last_edited = new DateTimeImmutable();
86 }
87
89 $prg_obj_id,
90 $category_ref_id,
91 $last_edited_usr_id,
92 $last_edited
93 );
94 }
Class ilStudyProgrammeAutoCategory.

References $current_usr_id.

Referenced by getFor().

+ Here is the caller graph for this function:

◆ delete()

ilStudyProgrammeAutoCategoryDBRepository::delete ( int  $prg_obj_id,
array  $cat_ref_ids 
)

Delete a single category-surveillance.

Parameters
int[]$cat_ref_ids

Implements ilStudyProgrammeAutoCategoryRepository.

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

134 : void
135 {
136 $ids = array_map(
137 function ($id) {
138 return $this->db->quote($id, 'integer');
139 },
140 $cat_ref_ids
141 );
142 $ids = implode(',', $ids);
143
144 $query =
145 'DELETE FROM ' . self::TABLE . PHP_EOL
146 . 'WHERE prg_obj_id = ' . $this->db->quote($prg_obj_id, 'integer') . PHP_EOL
147 . 'AND cat_ref_id IN (' . $ids . ')'
148 ;
149 $this->db->manipulate($query);
150 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

◆ deleteFor()

ilStudyProgrammeAutoCategoryDBRepository::deleteFor ( int  $prg_obj_id)

Delete all category-surveillance settings for a StudyProgramme.

Implements ilStudyProgrammeAutoCategoryRepository.

Definition at line 155 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

155 : void
156 {
157 $query =
158 'DELETE FROM ' . self::TABLE . PHP_EOL
159 . 'WHERE prg_obj_id = ' . $this->db->quote($prg_obj_id, 'integer')
160 ;
161 $this->db->manipulate($query);
162 }

◆ getFor()

ilStudyProgrammeAutoCategoryDBRepository::getFor ( int  $prg_obj_id)

Read category-surveillance settings of programme.

Returns
ilStudyProgrammeAutoCategory[]

Implements ilStudyProgrammeAutoCategoryRepository.

Definition at line 48 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

48 : array
49 {
50 $query = 'SELECT '
51 . self::FIELD_PRG_OBJ_ID . ','
52 . self::FIELD_CAT_REF_ID . ','
53 . self::FIELD_EDITOR_ID . ','
54 . self::FIELD_LAST_EDITED
55 . PHP_EOL . 'FROM ' . self::TABLE
56 . PHP_EOL . 'WHERE ' . self::FIELD_PRG_OBJ_ID . ' = '
57 . $this->db->quote($prg_obj_id, 'integer');
58
59 $res = $this->db->query($query);
60 $ret = [];
61 while ($rec = $this->db->fetchAssoc($res)) {
62 $ret[] = $this->create(
63 (int) $rec[self::FIELD_PRG_OBJ_ID],
64 (int) $rec[self::FIELD_CAT_REF_ID],
65 (int) $rec[self::FIELD_EDITOR_ID],
66 new DateTimeImmutable($rec[self::FIELD_LAST_EDITED])
67 );
68 }
69 return $ret;
70 }
create(int $prg_obj_id, int $category_ref_id, ?int $last_edited_usr_id=null, ?DateTimeImmutable $last_edited=null)
Build an auto-category object.
$res
Definition: ltiservices.php:69

References $res, and create().

+ Here is the call graph for this function:

◆ getProgrammesFor()

static ilStudyProgrammeAutoCategoryDBRepository::getProgrammesFor ( int  $cat_ref_id)
static

Get all programmes' ref_ids monitoring the given category.

Returns
int[]

Implements ilStudyProgrammeAutoCategoryRepository.

Definition at line 168 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

168 : array
169 {
170 global $ilDB;
171 $query = 'SELECT ' . self::FIELD_PRG_OBJ_ID
172 . PHP_EOL . 'FROM ' . self::TABLE . ' prgs'
173 . PHP_EOL . 'INNER JOIN object_reference oref ON '
174 . 'prgs.' . self::FIELD_PRG_OBJ_ID . ' = oref.obj_id'
175 . PHP_EOL . 'WHERE ' . self::FIELD_CAT_REF_ID . ' = ' . $ilDB->quote($cat_ref_id, 'integer')
176 . PHP_EOL . 'AND oref.deleted IS NULL';
177
178 $res = $ilDB->query($query);
179 return $ilDB->fetchAll($res);
180 }

References $ilDB, and $res.

◆ update()

ilStudyProgrammeAutoCategoryDBRepository::update ( ilStudyProgrammeAutoCategory  $ac)

Store a category-surveillance setting.

Implements ilStudyProgrammeAutoCategoryRepository.

Definition at line 99 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

99 : void
100 {
101 $ilAtomQuery = $this->db->buildAtomQuery();
102 $ilAtomQuery->addTableLock(self::TABLE);
103
105 $ilAtomQuery->addQueryCallable(
106 function (ilDBInterface $db) use ($ac, $current_usr_id) {
107 $query =
108 'DELETE FROM ' . self::TABLE . PHP_EOL
109 . 'WHERE prg_obj_id = ' . $ac->getPrgObjId() . PHP_EOL
110 . 'AND cat_ref_id = ' . $ac->getCategoryRefId()
111 ;
112
113 $db->manipulate($query);
114
115 $now = new DateTimeImmutable();
116 $now = $now->format('Y-m-d H:i:s');
117 $db->insert(
118 self::TABLE,
119 [
120 self::FIELD_PRG_OBJ_ID => ['integer', $ac->getPrgObjId()],
121 self::FIELD_CAT_REF_ID => ['integer', $ac->getCategoryRefId()],
122 self::FIELD_EDITOR_ID => ['integer', $current_usr_id],
123 self::FIELD_LAST_EDITED => ['timestamp', $now]
124 ]
125 );
126 }
127 );
128 $ilAtomQuery->run();
129 }
Interface ilDBInterface.
insert(string $table_name, array $values)
manipulate(string $query)
Run a (write) Query on the database.

References ilStudyProgrammeAutoCategory\getCategoryRefId(), ilStudyProgrammeAutoCategory\getPrgObjId(), ilDBInterface\insert(), and ilDBInterface\manipulate().

+ Here is the call graph for this function:

Field Documentation

◆ $current_usr_id

int ilStudyProgrammeAutoCategoryDBRepository::$current_usr_id
protected

Definition at line 35 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

Referenced by __construct(), and create().

◆ $db

ilDBInterface ilStudyProgrammeAutoCategoryDBRepository::$db
protected

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

Referenced by __construct().

◆ FIELD_CAT_REF_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_CAT_REF_ID = 'cat_ref_id'
private

◆ FIELD_EDITOR_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_EDITOR_ID = 'last_usr_id'
private

◆ FIELD_LAST_EDITED

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_LAST_EDITED = 'last_edited'
private

◆ FIELD_PRG_OBJ_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_PRG_OBJ_ID = 'prg_obj_id'
private

◆ TABLE

const ilStudyProgrammeAutoCategoryDBRepository::TABLE = 'prg_auto_content'
private

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