4 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
41 $this->title = $a_title;
81 $this->created = $a_date;
101 $this->author = (int)$a_id;
119 $this->approved = (bool)$a_status;
139 $id = $ilDB->nextId(
"il_blog_posting");
153 $query =
"INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved)".
155 $ilDB->quote($this->
getId(),
"integer").
",".
156 $ilDB->quote($this->
getTitle(),
"text").
",".
157 $ilDB->quote($this->
getBlogId(),
"integer").
",".
158 $ilDB->quote(
$created,
"timestamp").
",".
159 $ilDB->quote($this->
getAuthor(),
"integer").
",".
160 $ilDB->quote($this->
isApproved(),
"integer").
")";
161 $ilDB->manipulate(
$query);
179 function update($a_validate =
true, $a_no_history =
false, $a_notify =
true, $a_notify_action =
"update")
185 $query =
"UPDATE il_blog_posting SET".
186 " title = ".$ilDB->quote($this->
getTitle(),
"text").
188 ",approved =".$ilDB->quote($this->
isApproved(),
"integer").
189 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
190 $ilDB->manipulate(
$query);
192 parent::update($a_validate, $a_no_history);
196 include_once
"Modules/Blog/classes/class.ilObjBlog.php";
210 $query =
"SELECT * FROM il_blog_posting".
211 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
212 $set = $ilDB->query(
$query);
213 $rec = $ilDB->fetchAssoc($set);
219 if((
bool)$rec[
"approved"])
234 $this->approved =
false;
248 $query =
"DELETE FROM il_blog_posting".
249 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
250 $ilDB->manipulate(
$query);
266 include_once
'Services/MetaData/classes/class.ilMD.php';
268 $query =
"SELECT * FROM il_blog_posting".
269 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer");
270 $set = $ilDB->query(
$query);
271 while($rec = $ilDB->fetchAssoc($set))
274 $md_obj =
new ilMD($a_blog_id, $rec[
"id"],
"blp");
275 if(is_object($md_section = $md_obj->getGeneral()))
277 foreach($md_section->getKeywordIds() as
$id)
279 $md_key = $md_section->getKeyword(
$id);
299 $query =
"SELECT blog_id FROM il_blog_posting".
300 " WHERE id = ".$ilDB->quote($a_posting_id,
"integer");
301 $set = $ilDB->query(
$query);
302 if ($rec = $ilDB->fetchAssoc($set))
304 return $rec[
"blog_id"];
321 $pages = parent::getAllPages(
"blp", $a_blog_id);
325 $ilDB->setLimit($a_limit, $a_offset);
328 $query =
"SELECT * FROM il_blog_posting".
329 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer").
330 " ORDER BY created DESC";
331 $set = $ilDB->query(
$query);
333 while($rec = $ilDB->fetchAssoc($set))
335 if (isset($pages[$rec[
"id"]]))
337 $post[$rec[
"id"]] = $pages[$rec[
"id"]];
338 $post[$rec[
"id"]][
"title"] = $rec[
"title"];
340 $post[$rec[
"id"]][
"author"] = $rec[
"author"];
341 $post[$rec[
"id"]][
"approved"] = (bool)$rec[
"approved"];
343 foreach(self::getPageContributors(
"blp", $rec[
"id"]) as $editor)
345 if($editor[
"user_id"] != $rec[
"author"])
347 $post[$rec[
"id"]][
"editors"][] = $editor[
"user_id"];
363 static function exists($a_blog_id, $a_posting_id)
367 $query =
"SELECT id FROM il_blog_posting".
368 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer").
369 " AND id = ".$ilDB->quote($a_posting_id,
"integer");
370 $set = $ilDB->query(
$query);
371 if($rec = $ilDB->fetchAssoc($set))
386 $data = self::getAllPostings($a_blog_id, 1);
389 return array_pop(array_keys(
$data));
401 $this->blog_node_id = (int)$a_id;
402 $this->blog_node_is_wsp = (bool)$a_is_in_workspace;
417 $sql =
"SELECT DISTINCT(blog_id)".
418 " FROM il_blog_posting".
419 " WHERE author = ".$ilDB->quote($a_user_id);
420 $set = $ilDB->query($sql);
421 while(
$row = $ilDB->fetchAssoc($set))
423 $ids[] =
$row[
"blog_id"];
430 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
434 $snippet = str_replace(
'<br/>',
"\n", $snippet);
435 $snippet = str_replace(
'<br />',
"\n", $snippet);
436 $snippet = str_replace(
'</p>',
"\n", $snippet);
437 $snippet = str_replace(
'</div>',
"\n", $snippet);
439 return trim(strip_tags($snippet));
448 include_once
'Services/MetaData/classes/class.ilMD.php';
450 if(!is_object($md_section = $md_obj->getGeneral()))
452 $md_section = $md_obj->addGeneral();
464 $ulang = $ilUser->getLanguage();
465 $keywords = array($ulang=>$keywords);
467 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
473 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
getNotificationAbstract()
getBlogId()
Get blog object id.
static lookupBlogId($a_posting_id)
Lookup blog id.
setCreated(ilDateTime $a_date)
Set creation date.
static getLastPost($a_blog_id)
Get newest posting for blog.
create($a_import=false)
Create new blog posting.
setAuthor($a_id)
Set author user id.
static getKeywords($a_obj_id, $a_posting_id)
isApproved()
Get approved status.
static now()
Return current timestamp in Y-m-d H:i:s format.
static updateKeywords(ilMDGeneral $a_md_section, array $a_keywords)
Update keywords from input array.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
static searchBlogsByAuthor($a_user_id)
Get all blogs where user has postings.
updateKeywords(array $keywords)
setApproved($a_status)
Toggle approval status.
addUpdateListener(&$a_object, $a_method, $a_parameters="")
static exists($a_blog_id, $a_posting_id)
Checks whether a posting exists.
getActive($a_check_scheduled_activation=false)
get activation
static getSnippet($a_id, $a_truncate=false, $a_truncate_length=500, $a_truncate_sign="...", $a_include_picture=false, $a_picture_width=144, $a_picture_height=144, $a_export_directory=null)
Get first text paragraph of page.
getCreated()
Get creation date.
setBlogNodeId($a_id, $a_is_in_workspace=false)
Set blog node id (needed for notification)
getAuthor()
Get author user id.
getParentType()
Get parent type.
update($a_validate=true, $a_no_history=false, $a_notify=true, $a_notify_action="update")
Update blog posting.
setTitle($a_title)
Set title.
static sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment=null)
static lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids=false)
Lookup Keywords.
static deleteAllBlogPostings($a_blog_id)
Delete all postings for blog.
setBlogId($a_id)
Set blog object id.