38        $this->title = $a_title;
 
   78        $this->created = $a_date;
 
   98        $this->author = (int) $a_id;
 
  116        $this->approved = (bool) $a_status;
 
  136        $this->withdrawn = $a_date;
 
  152    public function create($a_import = 
false)
 
  156        $id = 
$ilDB->nextId(
"il_blog_posting");
 
  167        $query = 
"INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved, last_withdrawn)" .
 
  169            $ilDB->quote($this->
getId(), 
"integer") . 
"," .
 
  193    public function update($a_validate = 
true, $a_no_history = 
false, $a_notify = 
true, $a_notify_action = 
"update")
 
  199        $query = 
"UPDATE il_blog_posting SET" .
 
  204            " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
  207        parent::update($a_validate, $a_no_history);
 
  223        $query = 
"SELECT * FROM il_blog_posting" .
 
  224            " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
  226        $rec = 
$ilDB->fetchAssoc($set);
 
  232        if ((
bool) $rec[
"approved"]) {
 
  246            $this->approved = 
false;
 
  256    public function delete()
 
  267        $query = 
"DELETE FROM il_blog_posting" .
 
  268            " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
  284        $this->
update(
true, 
false, 
false);
 
  306        $query = 
"SELECT * FROM il_blog_posting" .
 
  307            " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer");
 
  309        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  311            $md_obj = 
new ilMD($a_blog_id, $rec[
"id"], 
"blp");
 
  312            if (is_object($md_section = $md_obj->getGeneral())) {
 
  313                foreach ($md_section->getKeywordIds() as 
$id) {
 
  314                    $md_key = $md_section->getKeyword(
$id);
 
  336        $query = 
"SELECT blog_id FROM il_blog_posting" .
 
  337            " WHERE id = " . 
$ilDB->quote($a_posting_id, 
"integer");
 
  339        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  340            return $rec[
"blog_id"];
 
  353    public static function getAllPostings($a_blog_id, $a_limit = 1000, $a_offset = 0)
 
  359        $pages = parent::getAllPages(
"blp", $a_blog_id);
 
  362            $ilDB->setLimit($a_limit, $a_offset);
 
  365        $query = 
"SELECT * FROM il_blog_posting" .
 
  366            " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer") .
 
  367            " ORDER BY created DESC";
 
  370        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  371            if (isset($pages[$rec[
"id"]])) {
 
  372                $post[$rec[
"id"]] = $pages[$rec[
"id"]];
 
  373                $post[$rec[
"id"]][
"title"] = $rec[
"title"];
 
  375                $post[$rec[
"id"]][
"author"] = $rec[
"author"];
 
  376                $post[$rec[
"id"]][
"approved"] = (bool) $rec[
"approved"];
 
  379                foreach (self::getPageContributors(
"blp", $rec[
"id"]) as $editor) {
 
  380                    if ($editor[
"user_id"] != $rec[
"author"]) {
 
  381                        $post[$rec[
"id"]][
"editors"][] = $editor[
"user_id"];
 
  397    public static function exists($a_blog_id, $a_posting_id)
 
  403        $query = 
"SELECT id FROM il_blog_posting" .
 
  404            " WHERE blog_id = " . 
$ilDB->quote($a_blog_id, 
"integer") .
 
  405            " AND id = " . 
$ilDB->quote($a_posting_id, 
"integer");
 
  407        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  423            return array_pop(array_keys(
$data));
 
  435        $this->blog_node_id = (int) $a_id;
 
  436        $this->blog_node_is_wsp = (bool) $a_is_in_workspace;
 
  453        $sql = 
"SELECT DISTINCT(blog_id)" .
 
  454            " FROM il_blog_posting" .
 
  455            " WHERE author = " . 
$ilDB->quote($a_user_id);
 
  456        $set = 
$ilDB->query($sql);
 
  457        while ($row = 
$ilDB->fetchAssoc($set)) {
 
  458            $ids[] = $row[
"blog_id"];
 
  468        $snippet = str_replace(
'<br/>', 
"\n", $snippet);
 
  469        $snippet = str_replace(
'<br />', 
"\n", $snippet);
 
  470        $snippet = str_replace(
'</p>', 
"\n", $snippet);
 
  471        $snippet = str_replace(
'</div>', 
"\n", $snippet);
 
  473        return trim(strip_tags($snippet));
 
  483        if (!is_object($md_section = $md_obj->getGeneral())) {
 
  484            $md_section = $md_obj->addGeneral();
 
  496        $ulang = 
$ilUser->getLanguage();
 
  497        $keywords = array($ulang => $keywords);
 
  526        if ((
bool) $a_update) {
 
  543            $default_visibility = $news_set->get(
"default_visibility", 
"users");
 
  546            $news_item->setContext(
 
  553            $news_item->setVisibility($default_visibility);
 
  557        $news_item->setUserId(
$ilUser->getId());
 
  562        $news_item->setTitle($this->
getTitle());
 
  565            ? 
"blog_news_posting_updated" 
  566            : 
"blog_news_posting_published";
 
  572        $contributors = array();
 
  574            $contributors[] = 
$user[
"user_id"];
 
  576        if (
sizeof($contributors) > 1 || !in_array($this->
getAuthor(), $contributors)) {
 
  579            foreach ($contributors as $user_id) {
 
  584            $content .= 
"\n" . sprintf(
$lng->txt(
"blog_news_posting_authors"), implode(
", ", $authors));
 
  587        $news_item->setContentTextIsLangVar(
false);
 
  588        $news_item->setContent($content);
 
  591        $news_item->setContentLong($snippet);
 
  593        if (!$news_item->getId()) {
 
  594            $news_item->create();
 
  596            $news_item->update(
true);
 
  607    protected static function lookup($a_field, $a_posting_id)
 
  613        $set = 
$db->query(
"SELECT $a_field FROM il_blog_posting " .
 
  614            " WHERE id = " . 
$db->quote($a_posting_id, 
"integer"));
 
  615        $rec = 
$db->fetchAssoc($set);
 
  617        return $rec[$a_field];
 
An exception for terminatinating execution or to throw for unit testing.
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.
static lookupTitle($a_posting_id)
Lookup title.
isApproved()
Get approved status.
getNotificationAbstract()
update($a_validate=true, $a_no_history=false, $a_notify=true, $a_notify_action="update")
Update blog posting.
static lookup($a_field, $a_posting_id)
Lookup posting property.
getCreated()
Get creation date.
handleNews($a_update=false)
Handle news item.
getParentType()
Get parent type.
updateKeywords(array $keywords)
static getLastPost($a_blog_id)
Get newest posting for blog.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
create($a_import=false)
Create new blog posting.
setCreated(ilDateTime $a_date)
Set creation date.
setBlogNodeId($a_id, $a_is_in_workspace=false)
Set blog node id (needed for notification)
static searchBlogsByAuthor($a_user_id)
Get all blogs where user has postings.
setAuthor($a_id)
Set author user id.
static lookupBlogId($a_posting_id)
Lookup blog id.
static exists($a_blog_id, $a_posting_id)
Checks whether a posting exists.
setWithdrawn(ilDateTime $a_date)
Set last withdrawal date.
getBlogId()
Get blog object id.
setTitle($a_title)
Set title.
static getKeywords($a_obj_id, $a_posting_id)
getAuthor()
Get author user id.
setApproved($a_status)
Toggle approval status.
getWithdrawn()
Get last withdrawal date.
setBlogId($a_id)
Set blog object id.
static deleteAllBlogPostings($a_blog_id)
Delete all postings for blog.
@classDescription Date and time handling
static lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids=false)
Lookup Keywords.
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 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 sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment=null)
addUpdateListener(&$a_object, $a_method, $a_parameters="")
setActive($a_active)
set activation
getActive($a_check_scheduled_activation=false)
get activation
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:
static now()
Return current timestamp in Y-m-d H:i:s format.