ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Blog\Posting\PostingDBRepository Class Reference
+ Collaboration diagram for ILIAS\Blog\Posting\PostingDBRepository:

Public Member Functions

 __construct (protected ilDBInterface $db, protected InternalDataService $data)
 
 create (Posting $posting)
 
 update (Posting $posting)
 
 getById (int $id)
 
 delete (int $id)
 
 deleteAllBlogPostings (int $blog_id)
 
 lookupBlogId (int $posting_id)
 
 getAllByBlog (int $blog_id, int $limit=1000, int $offset=0)
 
 exists (int $blog_id, int $posting_id)
 
 getLastPost (int $blog_id)
 
 searchBlogsByAuthor (int $user_id)
 

Protected Member Functions

 getPostingFromRecord (array $rec)
 

Detailed Description

Definition at line 27 of file class.PostingDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Blog\Posting\PostingDBRepository::__construct ( protected ilDBInterface  $db,
protected InternalDataService  $data 
)

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

32 {
33 }

Member Function Documentation

◆ create()

ILIAS\Blog\Posting\PostingDBRepository::create ( Posting  $posting)

Definition at line 50 of file class.PostingDBRepository.php.

50 : int
51 {
52 $id = $this->db->nextId('il_blog_posting');
53 $this->db->insert('il_blog_posting', [
54 'id' => ['integer', $id],
55 'blog_id' => ['integer', $posting->getBlogId()],
56 'title' => ['text', $posting->getTitle()],
57 'created' => ['timestamp', $posting->getCreated()->get(IL_CAL_DATETIME)],
58 'author' => ['integer', $posting->getAuthor()],
59 'approved' => ['integer', $posting->isApproved()],
60 'last_withdrawn' => ['timestamp', $posting->getLastWithdrawn()?->get(IL_CAL_DATETIME)],
61 ]);
62 return $id;
63 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const IL_CAL_DATETIME

References $id, ILIAS\Blog\Posting\Posting\getAuthor(), ILIAS\Blog\Posting\Posting\getBlogId(), ILIAS\Blog\Posting\Posting\getCreated(), ILIAS\Blog\Posting\Posting\getLastWithdrawn(), ILIAS\Blog\Posting\Posting\getTitle(), IL_CAL_DATETIME, and ILIAS\Blog\Posting\Posting\isApproved().

+ Here is the call graph for this function:

◆ delete()

ILIAS\Blog\Posting\PostingDBRepository::delete ( int  $id)

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

90 : void
91 {
92 $this->db->manipulateF(
93 'DELETE FROM il_blog_posting WHERE id = %s',
94 ['integer'],
95 [$id]
96 );
97 }

References $id.

◆ deleteAllBlogPostings()

ILIAS\Blog\Posting\PostingDBRepository::deleteAllBlogPostings ( int  $blog_id)

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

99 : void
100 {
101 $this->db->manipulateF(
102 'DELETE FROM il_blog_posting WHERE blog_id = %s',
103 ['integer'],
104 [$blog_id]
105 );
106 }

◆ exists()

ILIAS\Blog\Posting\PostingDBRepository::exists ( int  $blog_id,
int  $posting_id 
)

Definition at line 138 of file class.PostingDBRepository.php.

138 : bool
139 {
140 $set = $this->db->queryF(
141 'SELECT id FROM il_blog_posting WHERE blog_id = %s AND id = %s',
142 ['integer', 'integer'],
143 [$blog_id, $posting_id]
144 );
145 return $this->db->numRows($set) > 0;
146 }

◆ getAllByBlog()

ILIAS\Blog\Posting\PostingDBRepository::getAllByBlog ( int  $blog_id,
int  $limit = 1000,
int  $offset = 0 
)

Definition at line 121 of file class.PostingDBRepository.php.

121 : array
122 {
123 if ($limit) {
124 $this->db->setLimit($limit, $offset);
125 }
126 $set = $this->db->queryF(
127 'SELECT * FROM il_blog_posting WHERE blog_id = %s ORDER BY created DESC',
128 ['integer'],
129 [$blog_id]
130 );
131 $posts = [];
132 while ($rec = $this->db->fetchAssoc($set)) {
133 $posts[] = $this->getPostingFromRecord($rec);
134 }
135 return $posts;
136 }

References ILIAS\Blog\Posting\PostingDBRepository\getPostingFromRecord().

Referenced by ILIAS\Blog\Posting\PostingDBRepository\getLastPost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getById()

ILIAS\Blog\Posting\PostingDBRepository::getById ( int  $id)

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

77 : ?Posting
78 {
79 $set = $this->db->queryF(
80 'SELECT * FROM il_blog_posting WHERE id = %s',
81 ['integer'],
82 [$id]
83 );
84 if ($rec = $this->db->fetchAssoc($set)) {
85 return $this->getPostingFromRecord($rec);
86 }
87 return null;
88 }

References $id, and ILIAS\Blog\Posting\PostingDBRepository\getPostingFromRecord().

+ Here is the call graph for this function:

◆ getLastPost()

ILIAS\Blog\Posting\PostingDBRepository::getLastPost ( int  $blog_id)

Definition at line 148 of file class.PostingDBRepository.php.

148 : int
149 {
150 $all = $this->getAllByBlog($blog_id, 1, 0);
151 return $all ? $all[0]->getId() : 0;
152 }
getAllByBlog(int $blog_id, int $limit=1000, int $offset=0)

References ILIAS\Blog\Posting\PostingDBRepository\getAllByBlog().

+ Here is the call graph for this function:

◆ getPostingFromRecord()

ILIAS\Blog\Posting\PostingDBRepository::getPostingFromRecord ( array  $rec)
protected

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

35 : Posting
36 {
37 return $this->data->posting(
38 (int) $rec['id'],
39 (int) $rec['blog_id'],
40 (string) $rec['title'],
41 new ilDateTime($rec['created'], IL_CAL_DATETIME),
42 (int) $rec['author'],
43 (bool) $rec['approved'],
44 $rec['last_withdrawn'] !== null
45 ? new ilDateTime($rec['last_withdrawn'], IL_CAL_DATETIME)
46 : null
47 );
48 }
@classDescription Date and time handling

References IL_CAL_DATETIME.

Referenced by ILIAS\Blog\Posting\PostingDBRepository\getAllByBlog(), and ILIAS\Blog\Posting\PostingDBRepository\getById().

+ Here is the caller graph for this function:

◆ lookupBlogId()

ILIAS\Blog\Posting\PostingDBRepository::lookupBlogId ( int  $posting_id)

Definition at line 108 of file class.PostingDBRepository.php.

108 : ?int
109 {
110 $set = $this->db->queryF(
111 'SELECT blog_id FROM il_blog_posting WHERE id = %s',
112 ['integer'],
113 [$posting_id]
114 );
115 if ($rec = $this->db->fetchAssoc($set)) {
116 return (int) $rec['blog_id'];
117 }
118 return null;
119 }

◆ searchBlogsByAuthor()

ILIAS\Blog\Posting\PostingDBRepository::searchBlogsByAuthor ( int  $user_id)

Definition at line 154 of file class.PostingDBRepository.php.

154 : array
155 {
156 $ids = [];
157 $set = $this->db->queryF(
158 'SELECT DISTINCT(blog_id) FROM il_blog_posting WHERE author = %s',
159 ['integer'],
160 [$user_id]
161 );
162 while ($row = $this->db->fetchAssoc($set)) {
163 $ids[] = (int) $row['blog_id'];
164 }
165 return $ids;
166 }

References $user_id, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ update()

ILIAS\Blog\Posting\PostingDBRepository::update ( Posting  $posting)

Definition at line 65 of file class.PostingDBRepository.php.

65 : void
66 {
67 $this->db->update('il_blog_posting', [
68 'title' => ['text', $posting->getTitle()],
69 'created' => ['timestamp', $posting->getCreated()->get(IL_CAL_DATETIME)],
70 'approved' => ['integer', $posting->isApproved()],
71 'last_withdrawn' => ['timestamp', $posting->getLastWithdrawn()?->get(IL_CAL_DATETIME)],
72 ], [
73 'id' => ['integer', $posting->getId()],
74 ]);
75 }

References ILIAS\Blog\Posting\Posting\getCreated(), ILIAS\Blog\Posting\Posting\getId(), ILIAS\Blog\Posting\Posting\getLastWithdrawn(), ILIAS\Blog\Posting\Posting\getTitle(), IL_CAL_DATETIME, and ILIAS\Blog\Posting\Posting\isApproved().

+ Here is the call graph for this function:

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