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 include_once(
"./Services/News/classes/class.ilNewsItem.php");
252 $query =
"DELETE FROM il_blog_posting".
253 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
254 $ilDB->manipulate(
$query);
268 $this->
update(
true,
false,
false);
270 include_once(
"./Services/News/classes/class.ilNewsItem.php");
285 include_once
'Services/MetaData/classes/class.ilMD.php';
287 $query =
"SELECT * FROM il_blog_posting".
288 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer");
289 $set = $ilDB->query(
$query);
290 while($rec = $ilDB->fetchAssoc($set))
293 $md_obj =
new ilMD($a_blog_id, $rec[
"id"],
"blp");
294 if(is_object($md_section = $md_obj->getGeneral()))
296 foreach($md_section->getKeywordIds() as
$id)
298 $md_key = $md_section->getKeyword(
$id);
318 $query =
"SELECT blog_id FROM il_blog_posting".
319 " WHERE id = ".$ilDB->quote($a_posting_id,
"integer");
320 $set = $ilDB->query(
$query);
321 if ($rec = $ilDB->fetchAssoc($set))
323 return $rec[
"blog_id"];
340 $pages = parent::getAllPages(
"blp", $a_blog_id);
344 $ilDB->setLimit($a_limit, $a_offset);
347 $query =
"SELECT * FROM il_blog_posting".
348 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer").
349 " ORDER BY created DESC";
350 $set = $ilDB->query(
$query);
352 while($rec = $ilDB->fetchAssoc($set))
354 if (isset($pages[$rec[
"id"]]))
356 $post[$rec[
"id"]] = $pages[$rec[
"id"]];
357 $post[$rec[
"id"]][
"title"] = $rec[
"title"];
359 $post[$rec[
"id"]][
"author"] = $rec[
"author"];
360 $post[$rec[
"id"]][
"approved"] = (bool)$rec[
"approved"];
362 foreach(self::getPageContributors(
"blp", $rec[
"id"]) as $editor)
364 if($editor[
"user_id"] != $rec[
"author"])
366 $post[$rec[
"id"]][
"editors"][] = $editor[
"user_id"];
382 static function exists($a_blog_id, $a_posting_id)
386 $query =
"SELECT id FROM il_blog_posting".
387 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer").
388 " AND id = ".$ilDB->quote($a_posting_id,
"integer");
389 $set = $ilDB->query(
$query);
390 if($rec = $ilDB->fetchAssoc($set))
405 $data = self::getAllPostings($a_blog_id, 1);
408 return array_pop(array_keys(
$data));
420 $this->blog_node_id = (int)$a_id;
421 $this->blog_node_is_wsp = (bool)$a_is_in_workspace;
436 $sql =
"SELECT DISTINCT(blog_id)".
437 " FROM il_blog_posting".
438 " WHERE author = ".$ilDB->quote($a_user_id);
439 $set = $ilDB->query($sql);
440 while(
$row = $ilDB->fetchAssoc($set))
442 $ids[] =
$row[
"blog_id"];
449 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
453 $snippet = str_replace(
'<br/>',
"\n", $snippet);
454 $snippet = str_replace(
'<br />',
"\n", $snippet);
455 $snippet = str_replace(
'</p>',
"\n", $snippet);
456 $snippet = str_replace(
'</div>',
"\n", $snippet);
458 return trim(strip_tags($snippet));
467 include_once
'Services/MetaData/classes/class.ilMD.php';
469 if(!is_object($md_section = $md_obj->getGeneral()))
471 $md_section = $md_obj->addGeneral();
483 $ulang = $ilUser->getLanguage();
484 $keywords =
array($ulang=>$keywords);
486 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
492 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
507 include_once(
"./Services/News/classes/class.ilNewsItem.php");
531 $default_visibility = $news_set->get(
"default_visibility",
"users");
534 $news_item->setContext(
541 $news_item->setVisibility($default_visibility);
545 $news_item->setUserId($ilUser->getId());
550 $news_item->setTitle($this->
getTitle());
553 ?
"blog_news_posting_updated" 554 :
"blog_news_posting_published";
557 include_once
"Services/User/classes/class.ilUserUtil.php";
561 $contributors =
array();
564 $contributors[] = $user[
"user_id"];
566 if(
sizeof($contributors) > 1 || !in_array($this->
getAuthor(), $contributors))
570 foreach($contributors as $user_id)
577 $content .=
"\n".sprintf($lng->txt(
"blog_news_posting_authors"), implode(
", ", $authors));
580 $news_item->setContentTextIsLangVar(
false);
581 $news_item->setContent($content);
583 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
585 $news_item->setContentLong($snippet);
587 if(!$news_item->getId())
589 $news_item->create();
593 $news_item->update(
true);
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.
setActive($a_active)
set activation
create($a_import=false)
Create new blog posting.
setAuthor($a_id)
Set author user id.
static getKeywords($a_obj_id, $a_posting_id)
handleNews($a_update=false)
Handle news item.
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 getLastNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="", $a_only_today=false)
Get last news id of news set related to a certain context.
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)
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
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.
Create styles array
The data for the language used.
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 deleteNewsOfContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
Delete all news of a context.
static deleteAllBlogPostings($a_blog_id)
Delete all postings for blog.
setBlogId($a_id)
Set blog object id.