ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilStudyProgrammeAutoCategoryDBRepository Class Reference

Class ilStudyProgrammeAutoCategoryDBRepository. More...

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

Public Member Functions

 __construct (ilDBInterface $db, int $current_usr_id)
 
 readFor (int $prg_obj_id)
 Read category-surveillance settings of programme.
Parameters
int$prg_obj_id
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.
Returns
ilStudyProgrammeAutoCategory
More...
 
 update (ilStudyProgrammeAutoCategory $ac)
 Store a category-surveillance setting.
Parameters
ilStudyProgrammeAutoCategory$ac
More...
 
 delete (int $prg_obj_id, array $cat_ref_ids)
 Delete a single category-surveillance.
Parameters
int$prg_obj_id
int[]$cat_ref_ids
More...
 
 deleteFor (int $prg_obj_id)
 Delete all category-surveillance settings for a StudyProgramme.
Parameters
int$prg_obj_id
More...
 
 readFor (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...
 

Data Fields

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'
 

Protected Attributes

 $db
 
 $current_usr_id
 

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.

Returns
ilStudyProgrammeAutoCategory

Implements ilStudyProgrammeAutoCategoryRepository.

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

72 if (is_null($last_edited_usr_id)) {
73 $last_edited_usr_id = $this->current_usr_id;
74 }
75 if (is_null($last_edited)) {
76 $last_edited = new \DateTimeImmutable();
77 }
78
80 $prg_obj_id,
81 $category_ref_id,
82 $last_edited_usr_id,
83 $last_edited
84 );
85 }
Class ilStudyProgrammeAutoCategory.

References $current_usr_id.

Referenced by readFor().

+ 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$prg_obj_id
int[]$cat_ref_ids

Implements ilStudyProgrammeAutoCategoryRepository.

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

123 {
124 $ids = array_map(
125 function ($id) {
126 return $this->db->quote($id, 'integer');
127 },
128 $cat_ref_ids
129 );
130 $ids = implode(',', $ids);
131
132 $query = 'DELETE FROM ' . self::TABLE
133 . PHP_EOL . 'WHERE prg_obj_id = ' . $this->db->quote($prg_obj_id, 'integer')
134 . PHP_EOL . 'AND cat_ref_id IN (' . $ids . ')';
135 $this->db->manipulate($query);
136 }
$query

References $query.

◆ deleteFor()

ilStudyProgrammeAutoCategoryDBRepository::deleteFor ( int  $prg_obj_id)

Delete all category-surveillance settings for a StudyProgramme.

Parameters
int$prg_obj_id

Implements ilStudyProgrammeAutoCategoryRepository.

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

142 {
143 $query = 'DELETE FROM ' . self::TABLE
144 . PHP_EOL . 'WHERE prg_obj_id = ' . $this->db->quote($prg_obj_id, 'integer');
145 $this->db->manipulate($query);
146 }

References $query.

◆ 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 152 of file class.ilStudyProgrammeAutoCategoryDBRepository.php.

152 : array
153 {
154 global $ilDB;
155 $query = 'SELECT ' . self::FIELD_PRG_OBJ_ID
156 . PHP_EOL . 'FROM ' . self::TABLE . ' prgs'
157 . PHP_EOL . 'INNER JOIN object_reference oref ON '
158 . 'prgs.' . self::FIELD_PRG_OBJ_ID . ' = oref.obj_id'
159 . PHP_EOL . 'WHERE ' . self::FIELD_CAT_REF_ID . ' = ' . $ilDB->quote($cat_ref_id, 'integer')
160 . PHP_EOL . 'AND oref.deleted IS NULL';
161
162 $res = $ilDB->query($query);
163 $ret = $ilDB->fetchAll($res);
164 return $ret;
165 }
$ret
Definition: parser.php:6
foreach($_POST as $key=> $value) $res
global $ilDB

References $ilDB, $query, $res, and $ret.

◆ readFor()

ilStudyProgrammeAutoCategoryDBRepository::readFor ( int  $prg_obj_id)

Read category-surveillance settings of programme.

Parameters
int$prg_obj_id
Returns
ilStudyProgrammeAutoCategory[]

Implements ilStudyProgrammeAutoCategoryRepository.

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

39 : array
40 {
41 $query = 'SELECT '
42 . self::FIELD_PRG_OBJ_ID . ','
43 . self::FIELD_CAT_REF_ID . ','
44 . self::FIELD_EDITOR_ID . ','
45 . self::FIELD_LAST_EDITED
46 . PHP_EOL . 'FROM ' . self::TABLE
47 . PHP_EOL . 'WHERE ' . self::FIELD_PRG_OBJ_ID . ' = '
48 . $this->db->quote($prg_obj_id, 'integer');
49
50 $res = $this->db->query($query);
51 $ret = [];
52 while ($rec = $this->db->fetchAssoc($res)) {
53 $ret[] = $this->create(
54 (int) $rec[self::FIELD_PRG_OBJ_ID],
55 (int) $rec[self::FIELD_CAT_REF_ID],
56 (int) $rec[self::FIELD_EDITOR_ID],
57 new \DateTimeImmutable($rec[self::FIELD_LAST_EDITED])
58 );
59 }
60 return $ret;
61 }
create(int $prg_obj_id, int $category_ref_id, int $last_edited_usr_id=null, \DateTimeImmutable $last_edited=null)
Build an auto-category object.ilStudyProgrammeAutoCategory

References $query, $res, $ret, and create().

+ Here is the call graph for this function:

◆ update()

ilStudyProgrammeAutoCategoryDBRepository::update ( ilStudyProgrammeAutoCategory  $ac)

Store a category-surveillance setting.

Parameters
ilStudyProgrammeAutoCategory$ac

Implements ilStudyProgrammeAutoCategoryRepository.

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

91 {
92 $ilAtomQuery = $this->db->buildAtomQuery();
93 $ilAtomQuery->addTableLock(self::TABLE);
94
96 $ilAtomQuery->addQueryCallable(
97 function (ilDBInterface $db) use ($ac, $current_usr_id) {
98 $query = 'DELETE FROM ' . self::TABLE
99 . PHP_EOL . 'WHERE prg_obj_id = ' . $ac->getPrgObjId()
100 . PHP_EOL . 'AND cat_ref_id = ' . $ac->getCategoryRefId();
101 $db->manipulate($query);
102
103 $now = new \DateTimeImmutable();
104 $now = $now->format('Y-m-d H:i:s');
105 $db->insert(
106 self::TABLE,
107 [
108 self::FIELD_PRG_OBJ_ID => ['integer', $ac->getPrgObjId()],
109 self::FIELD_CAT_REF_ID => ['integer', $ac->getCategoryRefId()],
110 self::FIELD_EDITOR_ID => ['integer', $current_usr_id],
111 self::FIELD_LAST_EDITED => ['timestamp', $now]
112 ]
113 );
114 }
115 );
116 $ilAtomQuery->run();
117 }
Interface ilDBInterface.

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

+ Here is the call graph for this function:

Field Documentation

◆ $current_usr_id

ilStudyProgrammeAutoCategoryDBRepository::$current_usr_id
protected

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

Referenced by __construct(), and create().

◆ $db

ilStudyProgrammeAutoCategoryDBRepository::$db
protected

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

Referenced by __construct().

◆ FIELD_CAT_REF_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_CAT_REF_ID = 'cat_ref_id'

◆ FIELD_EDITOR_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_EDITOR_ID = 'last_usr_id'

◆ FIELD_LAST_EDITED

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_LAST_EDITED = 'last_edited'

◆ FIELD_PRG_OBJ_ID

const ilStudyProgrammeAutoCategoryDBRepository::FIELD_PRG_OBJ_ID = 'prg_obj_id'

◆ TABLE

const ilStudyProgrammeAutoCategoryDBRepository::TABLE = 'prg_auto_content'

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