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(
false,
"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"];
355 static function exists($a_blog_id, $a_posting_id)
359 $query =
"SELECT id FROM il_blog_posting".
360 " WHERE blog_id = ".$ilDB->quote($a_blog_id,
"integer").
361 " AND id = ".$ilDB->quote($a_posting_id,
"integer");
362 $set = $ilDB->query(
$query);
363 if($rec = $ilDB->fetchAssoc($set))
378 $data = self::getAllPostings($a_blog_id, 1);
381 return array_pop(array_keys(
$data));
393 $this->blog_node_id = (int)$a_id;
394 $this->blog_node_is_wsp = (bool)$a_is_in_workspace;
409 $sql =
"SELECT DISTINCT(blog_id)".
410 " FROM il_blog_posting".
411 " WHERE author = ".$ilDB->quote($a_user_id);
412 $set = $ilDB->query($sql);
413 while(
$row = $ilDB->fetchAssoc($set))
415 $ids[] =
$row[
"blog_id"];
422 include_once
"Modules/Blog/classes/class.ilBlogPostingGUI.php";
426 $snippet = str_replace(
'<br/>',
"\n", $snippet);
427 $snippet = str_replace(
'<br />',
"\n", $snippet);
428 $snippet = str_replace(
'</p>',
"\n", $snippet);
429 $snippet = str_replace(
'</div>',
"\n", $snippet);
431 return trim(strip_tags($snippet));
440 include_once
'Services/MetaData/classes/class.ilMD.php';
442 if(!is_object($md_section = $md_obj->getGeneral()))
444 $md_section = $md_obj->addGeneral();
456 $ulang = $ilUser->getLanguage();
457 $keywords = array($ulang=>$keywords);
459 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
465 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.