19declare(strict_types=1);
28 private const TABLE =
'prg_auto_content';
48 public function getFor(
int $prg_obj_id): array
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');
59 $res = $this->db->query($query);
61 while ($rec = $this->db->fetchAssoc(
$res)) {
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])
78 ?
int $last_edited_usr_id =
null,
79 ?DateTimeImmutable $last_edited =
null
81 if (is_null($last_edited_usr_id)) {
84 if (is_null($last_edited)) {
85 $last_edited =
new DateTimeImmutable();
101 $ilAtomQuery = $this->db->buildAtomQuery();
102 $ilAtomQuery->addTableLock(self::TABLE);
104 $current_usr_id = $this->current_usr_id;
105 $ilAtomQuery->addQueryCallable(
108 'DELETE FROM ' . self::TABLE . PHP_EOL
109 .
'WHERE prg_obj_id = ' . $ac->
getPrgObjId() . PHP_EOL
115 $now =
new DateTimeImmutable();
116 $now = $now->format(
'Y-m-d H:i:s');
120 self::FIELD_PRG_OBJ_ID => [
'integer', $ac->
getPrgObjId()],
122 self::FIELD_EDITOR_ID => [
'integer', $current_usr_id],
123 self::FIELD_LAST_EDITED => [
'timestamp', $now]
134 public function delete(
int $prg_obj_id, array $cat_ref_ids):
void
138 return $this->db->quote(
$id,
'integer');
142 $ids = implode(
',', $ids);
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 .
')'
149 $this->db->manipulate($query);
158 'DELETE FROM ' . self::TABLE . PHP_EOL
159 .
'WHERE prg_obj_id = ' . $this->db->quote($prg_obj_id,
'integer')
161 $this->db->manipulate($query);
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';
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class ilStudyProgrammeAutoCategoryDBRepository.
deleteFor(int $prg_obj_id)
Delete all category-surveillance settings for a StudyProgramme.
getFor(int $prg_obj_id)
Read category-surveillance settings of programme.ilStudyProgrammeAutoCategory[]
update(ilStudyProgrammeAutoCategory $ac)
Store a category-surveillance setting.
create(int $prg_obj_id, int $category_ref_id, ?int $last_edited_usr_id=null, ?DateTimeImmutable $last_edited=null)
Build an auto-category object.
static getProgrammesFor(int $cat_ref_id)
Get all programmes' ref_ids monitoring the given category.int[]
__construct(ilDBInterface $db, int $current_usr_id)
Class ilStudyProgrammeAutoCategory.
insert(string $table_name, array $values)
manipulate(string $query)
Run a (write) Query on the database.
Persistence of "monitored" categories for a StudyProgramme.
if(!file_exists('../ilias.ini.php'))