19 declare(strict_types=1);
37 return $this->data->posting(
39 (
int) $rec[
'blog_id'],
40 (
string) $rec[
'title'],
43 (
bool) $rec[
'approved'],
44 $rec[
'last_withdrawn'] !==
null 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()],
58 'author' => [
'integer', $posting->
getAuthor()],
59 'approved' => [
'integer', $posting->
isApproved()],
67 $this->db->update(
'il_blog_posting', [
68 'title' => [
'text', $posting->
getTitle()],
70 'approved' => [
'integer', $posting->
isApproved()],
73 'id' => [
'integer', $posting->
getId()],
79 $set = $this->db->queryF(
80 'SELECT * FROM il_blog_posting WHERE id = %s',
84 if ($rec = $this->db->fetchAssoc($set)) {
90 public function delete(
int $id):
void 92 $this->db->manipulateF(
93 'DELETE FROM il_blog_posting WHERE id = %s',
101 $this->db->manipulateF(
102 'DELETE FROM il_blog_posting WHERE blog_id = %s',
110 $set = $this->db->queryF(
111 'SELECT blog_id FROM il_blog_posting WHERE id = %s',
115 if ($rec = $this->db->fetchAssoc($set)) {
116 return (
int) $rec[
'blog_id'];
121 public function getAllByBlog(
int $blog_id,
int $limit = 1000,
int $offset = 0): array
124 $this->db->setLimit($limit, $offset);
126 $set = $this->db->queryF(
127 'SELECT * FROM il_blog_posting WHERE blog_id = %s ORDER BY created DESC',
132 while ($rec = $this->db->fetchAssoc($set)) {
138 public function exists(
int $blog_id,
int $posting_id): bool
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]
145 return $this->db->numRows($set) > 0;
151 return $all ? $all[0]->getId() : 0;
157 $set = $this->db->queryF(
158 'SELECT DISTINCT(blog_id) FROM il_blog_posting WHERE author = %s',
162 while ($row = $this->db->fetchAssoc($set)) {
163 $ids[] = (
int) $row[
'blog_id'];
exists(int $blog_id, int $posting_id)
searchBlogsByAuthor(int $user_id)
getLastPost(int $blog_id)
__construct(protected ilDBInterface $db, protected InternalDataService $data)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lookupBlogId(int $posting_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getAllByBlog(int $blog_id, int $limit=1000, int $offset=0)
getPostingFromRecord(array $rec)
deleteAllBlogPostings(int $blog_id)