19 declare(strict_types=1);
    41     public function setTitle(
string $a_title): void
    43         $this->title = $a_title;
    63         $this->created = $a_date;
    73         $this->author = $a_id;
    83         $this->approved = $a_status;
    97         $this->withdrawn = $a_date;
   112         bool $a_import = 
false   116         $id = 
$ilDB->nextId(
"il_blog_posting");
   127         $query = 
"INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved, last_withdrawn)" .
   129             $ilDB->quote($this->
getId(), 
"integer") . 
"," .
   132             $ilDB->quote($created, 
"timestamp") . 
"," .
   135             $ilDB->quote($withdrawn, 
"timestamp") . 
")";
   136         $ilDB->manipulate($query);
   139             parent::create($a_import);
   145         bool $a_validate = 
true,
   146         bool $a_no_history = 
false,
   147         bool $a_notify = 
true,
   148         string $a_notify_action = 
"update"   154         $query = 
"UPDATE il_blog_posting SET" .
   158             ",last_withdrawn =" . 
$ilDB->quote($withdrawn, 
"timestamp") .
   159             " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
   160         $ilDB->manipulate($query);
   162         $ret = parent::update($a_validate, $a_no_history);
   178         $query = 
"SELECT * FROM il_blog_posting" .
   179             " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
   180         $set = 
$ilDB->query($query);
   181         $rec = 
$ilDB->fetchAssoc($set);
   187         if ($rec[
"approved"]) {
   201             $this->approved = 
false;
   209     public function delete(): 
void   220         $query = 
"DELETE FROM il_blog_posting" .
   221             " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
   222         $ilDB->manipulate($query);
   235         $this->
update(
true, 
false, 
false);
   254         $ilDB = $DIC->database();
   257         $query = 
"SELECT * FROM il_blog_posting" .
   258             " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer");
   259         $set = 
$ilDB->query($query);
   260         while ($rec = 
$ilDB->fetchAssoc($set)) {
   274         $ilDB = $DIC->database();
   276         $query = 
"SELECT blog_id FROM il_blog_posting" .
   277             " WHERE id = " . 
$ilDB->quote($a_posting_id, 
"integer");
   278         $set = 
$ilDB->query($query);
   279         if ($rec = 
$ilDB->fetchAssoc($set)) {
   280             return (
int) $rec[
"blog_id"];
   295         $ilDB = $DIC->database();
   297         $pages = parent::getAllPages(
"blp", $a_blog_id);
   300             $ilDB->setLimit($a_limit, $a_offset);
   303         $query = 
"SELECT * FROM il_blog_posting" .
   304             " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer") .
   305             " ORDER BY created DESC";
   306         $set = 
$ilDB->query($query);
   308         while ($rec = 
$ilDB->fetchAssoc($set)) {
   309             if (isset($pages[$rec[
"id"]])) {
   310                 $post[$rec[
"id"]] = $pages[$rec[
"id"]];
   311                 $post[$rec[
"id"]][
"title"] = $rec[
"title"];
   313                 $post[$rec[
"id"]][
"author"] = $rec[
"author"];
   314                 $post[$rec[
"id"]][
"approved"] = (bool) $rec[
"approved"];
   317                 foreach (self::getPageContributors(
"blp", $rec[
"id"]) as $editor) {
   318                     if ($editor[
"user_id"] != $rec[
"author"]) {
   319                         $post[$rec[
"id"]][
"editors"][] = $editor[
"user_id"];
   337         $ilDB = $DIC->database();
   339         $query = 
"SELECT id FROM il_blog_posting" .
   340             " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer") .
   341             " AND id = " . 
$ilDB->quote($a_posting_id, 
"integer");
   342         $set = 
$ilDB->query($query);
   343         if ($rec = 
$ilDB->fetchAssoc($set)) {
   355         $data = self::getAllPostings($a_blog_id, 1);
   357             $keys = array_keys(
$data);
   368         bool $a_is_in_workspace = 
false   370         $this->blog_node_id = $a_id;
   371         $this->blog_node_is_wsp = $a_is_in_workspace;
   382         $ilDB = $DIC->database();
   386         $sql = 
"SELECT DISTINCT(blog_id)" .
   387             " FROM il_blog_posting" .
   388             " WHERE author = " . 
$ilDB->quote($a_user_id);
   389         $set = 
$ilDB->query($sql);
   390         while ($row = 
$ilDB->fetchAssoc($set)) {
   391             $ids[] = (
int) $row[
"blog_id"];
   401         $snippet = str_replace(array(
'<br/>', 
'<br />', 
'</p>', 
'</div>'), 
"\n", $snippet);
   403         return trim(strip_tags($snippet));
   411         $this->lom_services->manipulate($this->
getBlogId(), $this->
getId(), 
"blp")
   412                            ->prepareDelete($this->lom_services->paths()->keywords())
   413                            ->prepareCreateOrUpdate($this->lom_services->paths()->keywords(), ...$keywords)
   426         $keywords = 
$lom_services->read($a_obj_id, $a_posting_id, 
"blp")
   428         foreach ($keywords as $keyword) {
   429             if ($keyword->value() !== 
"") {
   430                 $result[] = $keyword->value();
   441         bool $a_update = 
false   472             $default_visibility = $news_set->get(
"default_visibility", 
"users");
   475             $news_item->setContext(
   482             $news_item->setVisibility($default_visibility);
   486         $news_item->setUserId($ilUser->getId());
   491         $news_item->setTitle($this->
getTitle());
   494             ? 
"blog_news_posting_updated"   495             : 
"blog_news_posting_published";
   501         $contributors = array();
   503             $contributors[] = $user[
"user_id"];
   505         if (count($contributors) > 1 || !in_array($this->
getAuthor(), $contributors)) {
   508             foreach ($contributors as 
$user_id) {
   513             $content .= 
"\n" . sprintf(
$lng->
txt(
"blog_news_posting_authors"), implode(
", ", $authors));
   516         $news_item->setContentTextIsLangVar(
false);
   517         $news_item->setContent($content);
   520         $news_item->setContentLong($snippet);
   522         if (!$news_item->getId()) {
   523             $news_item->create();
   525             $news_item->update(
true);
   538         $db = $DIC->database();
   540         $set = 
$db->
query(
"SELECT $a_field FROM il_blog_posting " .
   541             " WHERE id = " . 
$db->
quote($a_posting_id, 
"integer"));
   544         return $rec[$a_field] ?? null;
   549         return (
string) self::lookup(
"title", $a_posting_id);
 getActive(bool $a_check_scheduled_activation=false)
 
getNotificationAbstract()
 
static lookupTitle(int $a_posting_id)
 
static getLastPost(int $a_blog_id)
Get newest posting for blog. 
 
static deleteNewsOfContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Delete all news of a context. 
 
static searchBlogsByAuthor(int $a_user_id)
Get all blogs where user has postings. 
 
setCreated(ilDateTime $a_date)
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
static getLastNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="", bool $a_only_today=false)
Get last news id of news set related to a certain context. 
 
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog. 
 
fetchAssoc(ilDBStatement $statement)
 
static exists(int $a_blog_id, int $a_posting_id)
Checks whether a posting exists. 
 
update(bool $a_validate=true, bool $a_no_history=false, bool $a_notify=true, string $a_notify_action="update")
 
setTitle(string $a_title)
 
quote($value, string $type)
 
getWithdrawn()
Get last withdrawal date. 
 
static now()
Return current timestamp in Y-m-d H:i:s format. 
 
handleNews(bool $a_update=false)
Handle news item. 
 
static deleteAllBlogPostings(int $a_blog_id)
Delete all postings for blog. 
 
static lookup(string $a_field, int $a_posting_id)
Lookup posting property. 
 
setApproved(bool $a_status)
 
updateKeywords(array $keywords)
 
static sendNotification(string $a_action, bool $a_in_wsp, int $a_blog_node_id, int $a_posting_id, ?string $a_comment=null)
 
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is: 
 
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD) 
 
query(string $query)
Run a (read-only) Query on the database. 
 
setBlogNodeId(int $a_id, bool $a_is_in_workspace=false)
Set blog node id (needed for notification) 
 
static lookupBlogId(int $a_posting_id)
 
A news item can be created by different sources. 
 
LOMServices $lom_services
 
addUpdateListener(object $a_object, string $a_method, $a_parameters="")
 
create(bool $a_import=false)
Create new blog posting. 
 
setWithdrawn(ilDateTime $a_date)
Set last withdrawal date. 
 
static getSnippet(int $a_id, bool $a_truncate=false, int $a_truncate_length=500, string $a_truncate_sign="...", bool $a_include_picture=false, int $a_picture_width=144, int $a_picture_height=144, string $a_export_directory=null)
Get first text paragraph of page. 
 
static getKeywords(int $a_obj_id, int $a_posting_id)
 
setActive(bool $a_active)