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;
135 public function create($a_import =
false)
139 $id =
$ilDB->nextId(
"il_blog_posting");
150 $query =
"INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved)" .
152 $ilDB->quote($this->
getId(),
"integer") .
"," .
175 public function update($a_validate =
true, $a_no_history =
false, $a_notify =
true, $a_notify_action =
"update")
181 $query =
"UPDATE il_blog_posting SET" .
185 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
191 include_once
"Modules/Blog/classes/class.ilObjBlog.php";
205 $query =
"SELECT * FROM il_blog_posting" .
206 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
208 $rec =
$ilDB->fetchAssoc($set);
214 if ((
bool) $rec[
"approved"]) {
227 $this->approved =
false;
237 public function delete()
241 include_once(
"./Services/News/classes/class.ilNewsItem.php");
249 $query =
"DELETE FROM il_blog_posting" .
250 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
265 $this->
update(
true,
false,
false);
267 include_once(
"./Services/News/classes/class.ilNewsItem.php");
286 $ilDB = $DIC->database();
288 include_once
'Services/MetaData/classes/class.ilMD.php';
290 $query =
"SELECT * FROM il_blog_posting" .
291 " WHERE blog_id = " .
$ilDB->quote($a_blog_id,
"integer");
293 while ($rec =
$ilDB->fetchAssoc($set)) {
295 $md_obj =
new ilMD($a_blog_id, $rec[
"id"],
"blp");
296 if (is_object($md_section = $md_obj->getGeneral())) {
297 foreach ($md_section->getKeywordIds() as
$id) {
298 $md_key = $md_section->getKeyword(
$id);
318 $ilDB = $DIC->database();
320 $query =
"SELECT blog_id FROM il_blog_posting" .
321 " WHERE id = " .
$ilDB->quote($a_posting_id,
"integer");
323 if ($rec =
$ilDB->fetchAssoc($set)) {
324 return $rec[
"blog_id"];
337 public static function getAllPostings($a_blog_id, $a_limit = 1000, $a_offset = 0)
341 $ilDB = $DIC->database();
343 $pages = parent::getAllPages(
"blp", $a_blog_id);
346 $ilDB->setLimit($a_limit, $a_offset);
349 $query =
"SELECT * FROM il_blog_posting" .
350 " WHERE blog_id = " .
$ilDB->quote($a_blog_id,
"integer") .
351 " ORDER BY created DESC";
354 while ($rec =
$ilDB->fetchAssoc($set)) {
355 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) {
363 if (
$editor[
"user_id"] != $rec[
"author"]) {
380 public static function exists($a_blog_id, $a_posting_id)
384 $ilDB = $DIC->database();
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");
390 if ($rec =
$ilDB->fetchAssoc($set)) {
404 $data = self::getAllPostings($a_blog_id, 1);
406 return array_pop(array_keys(
$data));
418 $this->blog_node_id = (int) $a_id;
419 $this->blog_node_is_wsp = (bool) $a_is_in_workspace;
432 $ilDB = $DIC->database();
436 $sql =
"SELECT DISTINCT(blog_id)" .
437 " FROM il_blog_posting" .
438 " WHERE author = " .
$ilDB->quote($a_user_id);
439 $set =
$ilDB->query($sql);
441 $ids[] =
$row[
"blog_id"];
448 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
452 $snippet = str_replace(
'<br/>',
"\n", $snippet);
453 $snippet = str_replace(
'<br />',
"\n", $snippet);
454 $snippet = str_replace(
'</p>',
"\n", $snippet);
455 $snippet = str_replace(
'</div>',
"\n", $snippet);
457 return trim(strip_tags($snippet));
466 include_once
'Services/MetaData/classes/class.ilMD.php';
468 if (!is_object($md_section = $md_obj->getGeneral())) {
469 $md_section = $md_obj->addGeneral();
481 $ulang =
$ilUser->getLanguage();
482 $keywords = array($ulang => $keywords);
484 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
490 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
510 include_once(
"./Services/News/classes/class.ilNewsItem.php");
514 if ((
bool) $a_update) {
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();
563 $contributors[] = $user[
"user_id"];
565 if (
sizeof($contributors) > 1 || !in_array($this->
getAuthor(), $contributors)) {
568 foreach ($contributors as $user_id) {
573 $content .=
"\n" . sprintf(
$lng->txt(
"blog_news_posting_authors"), implode(
", ", $authors));
576 $news_item->setContentTextIsLangVar(
false);
577 $news_item->setContent($content);
579 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
581 $news_item->setContentLong($snippet);
583 if (!$news_item->getId()) {
584 $news_item->create();
586 $news_item->update(
true);
597 protected static function lookup($a_field, $a_posting_id)
601 $db = $DIC->database();
603 $set =
$db->query(
"SELECT $a_field FROM il_blog_posting " .
604 " WHERE id = " .
$db->quote($a_posting_id,
"integer"));
605 $rec =
$db->fetchAssoc($set);
607 return $rec[$a_field];
618 $t = self::lookup(
"title", $a_posting_id);
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 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.
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.
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)
static lookup($a_field, $a_posting_id)
Lookup posting property.
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, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
getAuthor()
Get author user id.
update($pash, $contents, Config $config)
getParentType()
Get parent type.
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 lookupTitle($a_posting_id)
Lookup title.
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.