ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBlogPosting Class Reference

Class ilBlogPosting. More...

+ Inheritance diagram for ilBlogPosting:
+ Collaboration diagram for ilBlogPosting:

Public Member Functions

 getParentType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setBlogId (int $a_id)
 
 getBlogId ()
 
 setCreated (ilDateTime $a_date)
 
 getCreated ()
 
 setAuthor (int $a_id)
 
 getAuthor ()
 
 setApproved (bool $a_status)
 
 isApproved ()
 
 setWithdrawn (ilDateTime $a_date)
 Set last withdrawal date. More...
 
 getWithdrawn ()
 Get last withdrawal date. More...
 
 create (bool $a_import=false)
 Create new blog posting. More...
 
 update (bool $a_validate=true, bool $a_no_history=false, bool $a_notify=true, string $a_notify_action="update")
 
 read ()
 Read blog posting. More...
 
 checkApproval ()
 
 delete ()
 Delete blog posting and all related data. More...
 
 unpublish ()
 Unpublish. More...
 
 setBlogNodeId (int $a_id, bool $a_is_in_workspace=false)
 Set blog node id (needed for notification) More...
 
 getNotificationAbstract ()
 
 updateKeywords (array $keywords)
 
 handleNews (bool $a_update=false)
 Handle news item. More...
 
- Public Member Functions inherited from ilPageObject
 __construct (int $a_id=0, int $a_old_nr=0, string $a_lang="-")
 
 setContentIdManager (\ILIAS\COPage\ID\ContentIdManager $content_id_manager)
 
 afterConstructor ()
 
 getParentType ()
 
 initPageConfig ()
 
 setLanguage (string $a_val)
 Set language. More...
 
 getLanguage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 setConcreteLang (string $a_val)
 
 getConcreteLang ()
 
 getPageConfig ()
 
 setRenderMd5 (string $a_rendermd5)
 
 getRenderMd5 ()
 
 setRenderedContent (string $a_renderedcontent)
 
 getRenderedContent ()
 
 setRenderedTime (string $a_renderedtime)
 
 getRenderedTime ()
 
 setLastChange (string $a_lastchange)
 
 getLastChange ()
 
 setLastChangeUser (int $a_val)
 
 getLastChangeUser ()
 
 setShowActivationInfo (bool $a_val)
 
 getShowActivationInfo ()
 
 getCreationUserId ()
 
 read ()
 Read page data. More...
 
 buildDom (bool $a_force=false)
 
 freeDom ()
 
 getDomDoc ()
 Get dom doc (DOMDocument) More...
 
 setId (int $a_id)
 
 getId ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 addUpdateListener (object $a_object, string $a_method, $a_parameters="")
 
 callUpdateListeners ()
 
 setActive (bool $a_active)
 
 getActive (bool $a_check_scheduled_activation=false)
 
 setActivationStart (?string $a_activationstart)
 
 getActivationStart ()
 
 setActivationEnd (?string $a_activationend)
 Set Activation End. More...
 
 getActivationEnd ()
 
 getContentObject (string $a_hier_id, string $a_pc_id="")
 Get a content object of the page. More...
 
 getContentObjectForPcId (string $pcid)
 Get content object for pc id. More...
 
 getParentContentObjectForPcId (string $pcid)
 Get parent content object for pc id. More...
 
 getContentDomNode (string $a_hier_id, string $a_pc_id="")
 
 getDomNodeForPCId (string $pc_id)
 
 setXMLContent (string $a_xml, string $a_encoding="UTF-8")
 set xml content of page, start with <PageObject...>, end with </PageObject>, comply with ILIAS DTD, omit MetaData, use utf-8! More...
 
 appendXMLContent (string $a_xml)
 
   append xml content to page
   setXMLContent must be called before and the same encoding must be used

s More...

 
 getXMLContent (bool $a_incl_head=false)
 get xml content of page More...
 
 copyXmlContent (bool $a_clone_mobs=false, int $a_new_parent_id=0, int $obj_copy_id=0, bool $self_ass=true)
 Copy content of page; replace page components with copies where necessary (e.g. More...
 
 handleDeleteContent (?DOMNode $a_node=null, $move_operation=false)
 Handle content before deletion This currently treats only plugged content If no node is given, then the whole dom will be scanned. More...
 
 getXMLFromDom (bool $a_incl_head=false, bool $a_append_mobs=false, bool $a_append_bib=false, string $a_append_str="", bool $a_omit_pageobject_tag=false, int $style_id=0, bool $offline=false)
 get xml content of page from dom (use this, if any changes are made to the document) More...
 
 getLanguageVariablesXML (int $style_id=0)
 Get language variables as XML. More...
 
 getFirstParagraphText ()
 
 getParagraphForPCID (string $pcid)
 
 setContainsIntLink (bool $a_contains_link)
 lm parser set this flag to true, if the page contains intern links (this method should only be called by the import parser) todo: move to ilLMPageObject !? More...
 
 containsIntLink ()
 returns true, if page was marked as containing an intern link (via setContainsIntLink) (this method should only be called by the import parser) More...
 
 setImportMode (bool $a_val)
 
 getImportMode ()
 
 needsImportParsing (?bool $a_parse=null)
 
 setContainsQuestion (bool $a_val)
 
 getContainsQuestion ()
 
 collectMediaObjects (bool $a_inline_only=true)
 get all media objects, that are referenced and used within the page More...
 
 getInternalLinks ()
 get all internal links that are used within the page More...
 
 getMultimediaXML (bool $offline=false)
 get a xml string that contains all media object elements, that are referenced by any media alias in the page More...
 
 getMediaAliasElement (int $a_mob_id, int $a_nr=1)
 get complete media object (alias) element More...
 
 validateDom (bool $throw=false)
 Validate the page content agains page DTD. More...
 
 addHierIDs ()
 Add hierarchical ID (e.g. More...
 
 getHierIds ()
 
 stripHierIDs ()
 
 stripPCIDs ()
 
 getHierIdsForPCIds (array $a_pc_ids)
 Get hier ids for a set of pc ids. More...
 
 getHierIdForPcId (string $pcid)
 
 getPCIdsForHierIds (array $hier_ids)
 Get hier ids for a set of pc ids. More...
 
 getPCIdForHierId (string $hier_id)
 
 addFileSizes ()
 add file sizes More...
 
 resolveIntLinks (?array $a_link_map=null)
 Resolves all internal link targets of the page, if targets are available (after import) More...
 
 resolveMediaAliases (array $a_mapping, bool $a_reuse_existing_by_import=false)
 Resolve media aliases (after import) More...
 
 resolveIIMMediaAliases (array $a_mapping)
 Resolve iim media aliases (in ilContObjParse) More...
 
 resolveFileItems (array $a_mapping)
 Resolve file items (after import) More...
 
 resolveQuestionReferences (array $a_mapping)
 Resolve all quesiont references (after import) More...
 
 moveIntLinks (array $a_from_to)
 Move internal links from one destination to another. More...
 
 handleRepositoryLinksOnCopy (array $a_mapping, int $a_source_ref_id)
 Handle repository links on copy process. More...
 
 setEmptyPageXml ()
 
 createFromXML ()
 Create new page object with current xml content. More...
 
 updateFromXML ()
 Updates page object with current xml content This function is currently (8 beta) called by: More...
 
 afterUpdate (DOMDocument $domdoc, string $xml)
 After update. More...
 
 update (bool $a_validate=true, bool $a_no_history=false)
 update complete page content in db (dom xml content is used) More...
 
 delete ()
 
 saveStyleUsage (DOMDocument $a_domdoc, int $a_old_nr=0)
 Save all style class/template usages. More...
 
 deleteStyleUsages (int $a_old_nr=0)
 Delete style usages. More...
 
 getLastUpdateOfIncludedElements ()
 Get last update of included elements (media objects and files). More...
 
 deleteInternalLinks ()
 Delete internal links. More...
 
 saveInternalLinks (DOMDocument $a_domdoc)
 save internal links of page More...
 
 create (bool $a_import=false)
 create new page (with current xml data) More...
 
 deleteContent (string $a_hid, bool $a_update=true, string $a_pcid="", bool $move_operation=false)
 delete content object with hierarchical id $a_hid More...
 
 deleteContents (array $a_hids, bool $a_update=true, bool $a_self_ass=false, bool $move_operation=false)
 Delete multiple content objects. More...
 
 cutContents (array $a_hids)
 Copy contents to clipboard and cut them from the page. More...
 
 copyContents (array $a_hids)
 Copy contents to clipboard. More...
 
 pasteContents (string $a_hier_id, bool $a_self_ass=false)
 Paste contents from pc clipboard. More...
 
 switchEnableMultiple (array $a_hids, bool $a_update=true, bool $a_self_ass=false)
 (De-)activate elements More...
 
 insertContent (ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
 insert a content node before/after a sibling or as first child of a parent More...
 
 insertContentNode (DOMNode $a_cont_node, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="")
 insert a content node before/after a sibling or as first child of a parent More...
 
 moveContentAfter (string $a_source, string $a_target, string $a_spcid="", string $a_tpcid="")
 move content object from position $a_source before position $a_target (both hierarchical content ids) More...
 
 insertInstIntoIDs (string $a_inst, bool $a_res_ref_to_obj_id=true)
 inserts installation id into ids (e.g. More...
 
 checkPCIds ()
 Check, whether (all) page content hashes are set. More...
 
 getAllPCIds ()
 Get all pc ids. More...
 
 hasDuplicatePCIds ()
 
 getDuplicatePCIds ()
 Get all duplicate PC Ids. More...
 
 generatePCId ()
 
 insertPCIds ()
 Insert Page Content IDs. More...
 
 sendParagraph (string $par_id, string $filename)
 
 registerOfflineHandler (object $handler)
 
 getOfflineHandler ()
 
 containsDeactivatedElements (string $a_content)
 Check whether content contains deactivated elements. More...
 
 getHistoryEntries ()
 Get History Entries. More...
 
 getHistoryEntry (int $a_old_nr)
 Get History Entry. More...
 
 getHistoryInfo (int $a_nr)
 Get information about a history entry, its predecessor and its successor. More...
 
 preparePageForCompare (ilPageObject $page)
 
 increaseViewCnt ()
 Increase view cnt. More...
 
 writeRenderedContent (string $a_content, string $a_md5)
 Write rendered content. More...
 
 containsIntLinks (string $a_content)
 Check whether content contains internal links. More...
 
 performAutomaticModifications ()
 Perform automatic modifications (may be overwritten by sub classes) More...
 
 saveInitialOpenedContent (string $a_type, int $a_id, string $a_target)
 Save initial opened content. More...
 
 getInitialOpenedContent ()
 Get initial opened content. More...
 
 beforePageContentUpdate (ilPageContent $a_page_content)
 Before page content update Note: This one is "work in progress", currently only text paragraphs call this hook It is called before the page content object invokes the update procedure of ilPageObject. More...
 
 copy (int $a_id, string $a_parent_type="", int $a_new_parent_id=0, bool $a_clone_mobs=false, int $obj_copy_id=0, bool $overwrite_existing=true)
 Copy page. More...
 
 copyPageToTranslation (string $a_target_lang)
 Copy page to translation. More...
 
 getEditLock ()
 Get page lock. More...
 
 releasePageLock ()
 Release page lock. More...
 
 getEditLockInfo ()
 Get edit lock info. More...
 
 getContentTemplates ()
 Get content templates. More...
 
 getEffectiveEditLockTime ()
 
 resolveResources (array $ref_mapping)
 Resolve resources. More...
 
 getRepoObjId ()
 Get object id of repository object that contains this page, return 0 if page does not belong to a repo object. More...
 
 getPCModel ()
 Get page component model. More...
 
 assignCharacteristic (array $targets, string $char_par, string $char_sec, string $char_med)
 Assign characteristic. More...
 

Static Public Member Functions

static deleteAllBlogPostings (int $a_blog_id)
 Delete all postings for blog. More...
 
static lookupBlogId (int $a_posting_id)
 
static getAllPostings (int $a_blog_id, int $a_limit=1000, int $a_offset=0)
 Get all postings of blog. More...
 
static exists (int $a_blog_id, int $a_posting_id)
 Checks whether a posting exists. More...
 
static getLastPost (int $a_blog_id)
 Get newest posting for blog. More...
 
static searchBlogsByAuthor (int $a_user_id)
 Get all blogs where user has postings. More...
 
static getKeywords (int $a_obj_id, int $a_posting_id)
 
static lookupTitle (int $a_posting_id)
 
- Static Public Member Functions inherited from ilPageObject
static _exists (string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
 Checks whether page exists. More...
 
static _existsAndNotEmpty (string $a_parent_type, int $a_id, string $a_lang="-")
 Checks whether page exists and is not empty (may return true on some empty pages) More...
 
static preloadActivationDataByParentId (int $a_parent_id)
 Preload activation data by Parent Id. More...
 
static _lookupActive (int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
 lookup activation status More...
 
static _isScheduledActivation (int $a_id, string $a_parent_type, string $a_lang="-")
 Check whether page is activated by time schedule. More...
 
static _writeActive (int $a_id, string $a_parent_type, bool $a_active)
 write activation status More...
 
static _lookupActivationData (int $a_id, string $a_parent_type, string $a_lang="-")
 Lookup activation data. More...
 
static lookupParentId (int $a_id, string $a_type)
 
static _writeParentId (string $a_parent_type, int $a_pg_id, int $a_par_id)
 
static _lookupContainsDeactivatedElements (int $a_id, string $a_parent_type, string $a_lang="-")
 lookup whether page contains deactivated elements More...
 
static getRecentChanges (string $a_parent_type, int $a_parent_id, int $a_period=30, string $a_lang="")
 Get recent pages changes for parent object. More...
 
static getAllPages (string $a_parent_type, int $a_parent_id, string $a_lang="-")
 Get all pages for parent object. More...
 
static getNewPages (string $a_parent_type, int $a_parent_id, string $a_lang="-")
 Get new pages. More...
 
static getParentObjectContributors (string $a_parent_type, int $a_parent_id, string $a_lang="-")
 Get all contributors for parent object. More...
 
static getPageContributors (string $a_parent_type, int $a_page_id, string $a_lang="-")
 Get all contributors for parent object. More...
 
static getPagesWithLinks (string $a_parent_type, int $a_parent_id, string $a_lang="-")
 Get all pages for parent object that contain internal links. More...
 
static lookupTranslations (string $a_parent_type, int $a_id)
 Lookup translations. More...
 
static truncateHTML (string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
 Truncate (html) string. More...
 
static getLastChangeByParent (string $a_parent_type, int $a_parent_id, string $a_lang="")
 Get all pages for parent object. More...
 

Static Protected Member Functions

static lookup (string $a_field, int $a_posting_id)
 Lookup posting property. More...
 

Protected Attributes

string $title = ""
 
ilDateTime $created = null
 
int $blog_node_id = 0
 
bool $blog_node_is_wsp = false
 
int $author = 0
 
bool $approved = false
 
ilDateTime $withdrawn = null
 
- Protected Attributes inherited from ilPageObject
ILIAS COPage Dom DomUtil $dom_util
 
ILIAS COPage Link LinkManager $link
 
ILIAS COPage PC PCDefinition $pc_definition
 
int $create_user = 0
 
array $id_elements
 
bool $page_not_found = false
 
bool $show_page_act_info = false
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilObjUser $user
 
ilLanguage $lng
 
ilTree $tree
 
LOMServices $lom_services
 
int $id
 
string $language = "-"
 
bool $import_mode = false
 
ilLogger $log
 
array $page_record = array()
 
bool $active = false
 
ilPageConfig $page_config
 
string $rendermd5 = ""
 
string $renderedcontent = ""
 
string $renderedtime = ""
 
string $lastchange = ""
 
bool $contains_question = false
 
array $hier_ids = []
 
string $activationstart = null
 
string $activationend = null
 
ILIAS COPage ReadingTime ReadingTimeManager $reading_time_manager
 
 $concrete_lang = ""
 
ILIAS COPage ID ContentIdManager $content_id_manager
 
ILIAS COPage Page PageManager $page_manager
 
ILIAS COPage Style StyleManager $style_manager
 
ILIAS COPage PC DomainService $pc_service
 

Additional Inherited Members

- Data Fields inherited from ilPageObject
int $old_nr
 
DOMDocument $dom = null
 
string $xml = ""
 
string $encoding = ""
 
DomNode $node
 
string $cur_dtd = "ilias_pg_9.dtd"
 
bool $contains_int_link = false
 
bool $needs_parsing = false
 
string $parent_type = ""
 
int $parent_id = 0
 
array $update_listeners = []
 
int $update_listener_cnt = 0
 
object $offline_handler = null
 
bool $dom_builded = false
 
bool $history_saved = false
 
int $last_change_user = 0
 
- Static Public Attributes inherited from ilPageObject
static array $exists = array()
 
- Protected Member Functions inherited from ilPageObject
 getIliasAbsolutePath ()
 
 getLangVarXML (string $var)
 
 __afterUpdate (DOMDocument $a_domdoc, string $a_xml, bool $a_creation=false, bool $a_empty=false)
 After update event handler (internal). More...
 
 isTranslationPage ()
 
 __beforeDelete ()
 Before deletion handler (internal). More...
 
 __afterDelete ()
 
 afterDelete ()
 
 __afterHistoryEntry (DOMDocument $a_old_domdoc, string $a_old_content, int $a_old_nr)
 
 getContentManager ()
 
 setCopyProperties (ilPageObject $new_page)
 
 setTranslationProperties (self $transl_page)
 
- Static Protected Attributes inherited from ilPageObject
static array $activation_data = array()
 

Detailed Description

Member Function Documentation

◆ checkApproval()

ilBlogPosting::checkApproval ( )

Definition at line 198 of file class.ilBlogPosting.php.

References ilPageObject\getActive(), isApproved(), and update().

198  : void
199  {
200  if (!$this->getActive() && $this->isApproved()) {
201  $this->approved = false;
202  $this->update();
203  }
204  }
getActive(bool $a_check_scheduled_activation=false)
update(bool $a_validate=true, bool $a_no_history=false, bool $a_notify=true, string $a_notify_action="update")
+ Here is the call graph for this function:

◆ create()

ilBlogPosting::create ( bool  $a_import = false)

Create new blog posting.

Definition at line 111 of file class.ilBlogPosting.php.

References ilPageObject\$db, ilPageObject\$id, $ilDB, getAuthor(), getBlogId(), getCreated(), ilPageObject\getId(), getTitle(), getWithdrawn(), IL_CAL_DATETIME, isApproved(), ilUtil\now(), and ilPageObject\setId().

113  : void {
114  $ilDB = $this->db;
115 
116  $id = $ilDB->nextId("il_blog_posting");
117  $this->setId($id);
118 
119  if (!$a_import) {
120  $created = ilUtil::now();
121  } else {
122  $created = $this->getCreated()->get(IL_CAL_DATETIME);
123  }
124 
125  // we are using a separate creation date to enable sorting without JOINs
126  $withdrawn = $this->getWithdrawn()?->get(IL_CAL_DATETIME);
127  $query = "INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved, last_withdrawn)" .
128  " VALUES (" .
129  $ilDB->quote($this->getId(), "integer") . "," .
130  $ilDB->quote($this->getTitle(), "text") . "," .
131  $ilDB->quote($this->getBlogId(), "integer") . "," .
132  $ilDB->quote($created, "timestamp") . "," .
133  $ilDB->quote($this->getAuthor(), "integer") . "," .
134  $ilDB->quote($this->isApproved(), "integer") . "," . // #16526 - import
135  $ilDB->quote($withdrawn, "timestamp") . ")";
136  $ilDB->manipulate($query);
137 
138  if (!$a_import) {
139  parent::create($a_import);
140  // $this->saveInternalLinks($this->getXMLContent());
141  }
142  }
const IL_CAL_DATETIME
getWithdrawn()
Get last withdrawal date.
static now()
Return current timestamp in Y-m-d H:i:s format.
ilDBInterface $db
+ Here is the call graph for this function:

◆ delete()

ilBlogPosting::delete ( )

Delete blog posting and all related data.

Definition at line 209 of file class.ilBlogPosting.php.

References ilPageObject\$db, $ilDB, ilNewsItem\deleteNewsOfContext(), getBlogId(), ilPageObject\getId(), and getParentType().

209  : void
210  {
211  $ilDB = $this->db;
212 
214  $this->getBlogId(),
215  "blog",
216  $this->getId(),
217  $this->getParentType()
218  );
219 
220  $query = "DELETE FROM il_blog_posting" .
221  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
222  $ilDB->manipulate($query);
223 
224  parent::delete();
225  }
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.
ilDBInterface $db
+ Here is the call graph for this function:

◆ deleteAllBlogPostings()

static ilBlogPosting::deleteAllBlogPostings ( int  $a_blog_id)
static

Delete all postings for blog.

Definition at line 249 of file class.ilBlogPosting.php.

References $DIC, $ilDB, ilPageObject\$lom_services, and $post.

Referenced by ilObjBlog\doDelete().

251  : void {
252  global $DIC;
253 
254  $ilDB = $DIC->database();
255  $lom_services = $DIC->learningObjectMetadata();
256 
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)) {
261  // delete lom
262  $lom_services->deleteAll($a_blog_id, $rec["id"], "blp");
263 
264  $post = new ilBlogPosting($rec["id"]);
265  $post->delete();
266  }
267  }
Class ilBlogPosting.
global $DIC
Definition: shib_login.php:22
LOMServices $lom_services
$post
Definition: ltitoken.php:46
+ Here is the caller graph for this function:

◆ exists()

static ilBlogPosting::exists ( int  $a_blog_id,
int  $a_posting_id 
)
static

Checks whether a posting exists.

Definition at line 331 of file class.ilBlogPosting.php.

References $DIC, and $ilDB.

334  : bool {
335  global $DIC;
336 
337  $ilDB = $DIC->database();
338 
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)) {
344  return true;
345  }
346  return false;
347  }
global $DIC
Definition: shib_login.php:22

◆ getAllPostings()

static ilBlogPosting::getAllPostings ( int  $a_blog_id,
int  $a_limit = 1000,
int  $a_offset = 0 
)
static

Get all postings of blog.

Definition at line 288 of file class.ilBlogPosting.php.

References $DIC, $ilDB, $post, and IL_CAL_DATETIME.

Referenced by ilObjBlogGUI\buildPostingList(), ILIAS\Wiki\Export\BlogHtmlExport\collectAllPagesPageElements(), ilObjBlog\deliverRSS(), ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPages(), ILIAS\Blog\BlogPrintViewProviderGUI\getPages(), ILIAS\Blog\BlogPrintViewProviderGUI\getSelectionForm(), ilBlogDraftsDerivedTaskProvider\getTasks(), ilBlogExporter\getXmlExportTailDependencies(), ilBlogPostingGUI\initKeywordsForm(), and ilPCBlogGUI\initPostingForm().

292  : array {
293  global $DIC;
294 
295  $ilDB = $DIC->database();
296 
297  $pages = parent::getAllPages("blp", $a_blog_id);
298 
299  if ($a_limit) {
300  $ilDB->setLimit($a_limit, $a_offset);
301  }
302 
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);
307  $post = array();
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"];
312  $post[$rec["id"]]["created"] = new ilDateTime($rec["created"], IL_CAL_DATETIME);
313  $post[$rec["id"]]["author"] = $rec["author"];
314  $post[$rec["id"]]["approved"] = (bool) $rec["approved"];
315  $post[$rec["id"]]["last_withdrawn"] = new ilDateTime($rec["last_withdrawn"], IL_CAL_DATETIME);
316 
317  foreach (self::getPageContributors("blp", $rec["id"]) as $editor) {
318  if ($editor["user_id"] != $rec["author"]) {
319  $post[$rec["id"]]["editors"][] = $editor["user_id"];
320  }
321  }
322  }
323  }
324 
325  return $post;
326  }
const IL_CAL_DATETIME
global $DIC
Definition: shib_login.php:22
$post
Definition: ltitoken.php:46
+ Here is the caller graph for this function:

◆ getAuthor()

ilBlogPosting::getAuthor ( )

Definition at line 76 of file class.ilBlogPosting.php.

References $author.

Referenced by create(), and handleNews().

76  : int
77  {
78  return $this->author;
79  }
+ Here is the caller graph for this function:

◆ getBlogId()

ilBlogPosting::getBlogId ( )

Definition at line 56 of file class.ilBlogPosting.php.

References ilPageObject\getParentId().

Referenced by create(), delete(), handleNews(), unpublish(), and updateKeywords().

56  : int
57  {
58  return $this->getParentId();
59  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCreated()

ilBlogPosting::getCreated ( )

Definition at line 66 of file class.ilBlogPosting.php.

References $created.

Referenced by create(), and update().

66  : ilDateTime
67  {
68  return $this->created;
69  }
+ Here is the caller graph for this function:

◆ getKeywords()

static ilBlogPosting::getKeywords ( int  $a_obj_id,
int  $a_posting_id 
)
static

Definition at line 417 of file class.ilBlogPosting.php.

References $DIC, and ilPageObject\$lom_services.

Referenced by ilObjBlogGUI\filterItemsByKeyword(), ilObjBlogGUI\getKeywords(), ilBlogPostingGUI\initKeywordsForm(), ilBlogDataSet\readData(), and ilObjBlogGUI\renderList().

420  : array {
421  global $DIC;
422 
423  $lom_services = $DIC->learningObjectMetadata();
424 
425  $result = [];
426  $keywords = $lom_services->read($a_obj_id, $a_posting_id, "blp")
427  ->allData($lom_services->paths()->keywords());
428  foreach ($keywords as $keyword) {
429  if ($keyword->value() !== "") {
430  $result[] = $keyword->value();
431  }
432  }
433 
434  return $result;
435  }
global $DIC
Definition: shib_login.php:22
LOMServices $lom_services
+ Here is the caller graph for this function:

◆ getLastPost()

static ilBlogPosting::getLastPost ( int  $a_blog_id)
static

Get newest posting for blog.

Definition at line 352 of file class.ilBlogPosting.php.

References $data.

354  : int {
355  $data = self::getAllPostings($a_blog_id, 1);
356  if ($data) {
357  $keys = array_keys($data);
358  return end($keys);
359  }
360  return 0;
361  }

◆ getNotificationAbstract()

ilBlogPosting::getNotificationAbstract ( )

Definition at line 396 of file class.ilBlogPosting.php.

References ilPageObject\getId(), and ilBlogPostingGUI\getSnippet().

396  : string
397  {
398  $snippet = ilBlogPostingGUI::getSnippet($this->getId(), true);
399 
400  // making things more readable
401  $snippet = str_replace(array('<br/>', '<br />', '</p>', '</div>'), "\n", $snippet);
402 
403  return trim(strip_tags($snippet));
404  }
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.
+ Here is the call graph for this function:

◆ getParentType()

ilBlogPosting::getParentType ( )

Definition at line 36 of file class.ilBlogPosting.php.

Referenced by delete(), handleNews(), and unpublish().

36  : string
37  {
38  return "blp";
39  }
+ Here is the caller graph for this function:

◆ getTitle()

ilBlogPosting::getTitle ( )

Definition at line 46 of file class.ilBlogPosting.php.

References $title.

Referenced by create(), handleNews(), and update().

46  : string
47  {
48  return $this->title;
49  }
+ Here is the caller graph for this function:

◆ getWithdrawn()

ilBlogPosting::getWithdrawn ( )

Get last withdrawal date.

Definition at line 103 of file class.ilBlogPosting.php.

References $withdrawn.

Referenced by create(), and update().

103  : ?ilDateTime
104  {
105  return $this->withdrawn;
106  }
+ Here is the caller graph for this function:

◆ handleNews()

ilBlogPosting::handleNews ( bool  $a_update = false)

Handle news item.

Definition at line 440 of file class.ilBlogPosting.php.

References ilPageObject\$lng, ilPageObject\$user, $user_id, ilPageObject\getActive(), getAuthor(), getBlogId(), ilPageObject\getId(), ilNewsItem\getLastNewsIdForContext(), ilUserUtil\getNamePresentation(), getParentType(), ilBlogPostingGUI\getSnippet(), getTitle(), NEWS_NOTICE, null, and ilLanguage\txt().

442  : void {
443  $lng = $this->lng;
444  $ilUser = $this->user;
445 
446  // see ilWikiPage::updateNews()
447 
448  if (!$this->getActive()) {
449  return;
450  }
451 
452  $news_item = null;
453 
454  // try to re-use existing news item
455  if ($a_update) {
456  // get last news item of the day (if existing)
458  $this->getBlogId(),
459  "blog",
460  $this->getId(),
461  $this->getParentType(),
462  true
463  );
464  if ($news_id > 0) {
465  $news_item = new ilNewsItem($news_id);
466  }
467  }
468 
469  // create new news item
470  if (!$news_item) {
471  $news_set = new ilSetting("news");
472  $default_visibility = $news_set->get("default_visibility", "users");
473 
474  $news_item = new ilNewsItem();
475  $news_item->setContext(
476  $this->getBlogId(),
477  "blog",
478  $this->getId(),
479  $this->getParentType()
480  );
481  $news_item->setPriority(NEWS_NOTICE);
482  $news_item->setVisibility($default_visibility);
483  }
484 
485  // news author
486  $news_item->setUserId($ilUser->getId());
487 
488 
489  // news title/content
490 
491  $news_item->setTitle($this->getTitle());
492 
493  $content = $a_update
494  ? "blog_news_posting_updated"
495  : "blog_news_posting_published";
496 
497  // news "author"
498  $content = sprintf($lng->txt($content), ilUserUtil::getNamePresentation($ilUser->getId()));
499 
500  // posting author[s]
501  $contributors = array();
502  foreach (self::getPageContributors($this->getParentType(), $this->getId()) as $user) {
503  $contributors[] = $user["user_id"];
504  }
505  if (count($contributors) > 1 || !in_array($this->getAuthor(), $contributors)) {
506  // original author should come first?
507  $authors = array(ilUserUtil::getNamePresentation($this->getAuthor()));
508  foreach ($contributors as $user_id) {
509  if ($user_id != $this->getAuthor()) {
510  $authors[] = ilUserUtil::getNamePresentation($user_id);
511  }
512  }
513  $content .= "\n" . sprintf($lng->txt("blog_news_posting_authors"), implode(", ", $authors));
514  }
515 
516  $news_item->setContentTextIsLangVar(false);
517  $news_item->setContent($content);
518 
519  $snippet = ilBlogPostingGUI::getSnippet($this->getId());
520  $news_item->setContentLong($snippet);
521 
522  if (!$news_item->getId()) {
523  $news_item->create();
524  } else {
525  $news_item->update(true);
526  }
527  }
getActive(bool $a_check_scheduled_activation=false)
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 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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return 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:
const NEWS_NOTICE
A news item can be created by different sources.
+ Here is the call graph for this function:

◆ isApproved()

ilBlogPosting::isApproved ( )

Definition at line 86 of file class.ilBlogPosting.php.

References $approved.

Referenced by checkApproval(), create(), and update().

86  : bool
87  {
88  return $this->approved;
89  }
+ Here is the caller graph for this function:

◆ lookup()

static ilBlogPosting::lookup ( string  $a_field,
int  $a_posting_id 
)
staticprotected

Lookup posting property.

Definition at line 532 of file class.ilBlogPosting.php.

References ilPageObject\$db, $DIC, ilDBInterface\fetchAssoc(), null, ilDBInterface\query(), and ilDBInterface\quote().

535  : ?string {
536  global $DIC;
537 
538  $db = $DIC->database();
539 
540  $set = $db->query("SELECT $a_field FROM il_blog_posting " .
541  " WHERE id = " . $db->quote($a_posting_id, "integer"));
542  $rec = $db->fetchAssoc($set);
543 
544  return $rec[$a_field] ?? null;
545  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
query(string $query)
Run a (read-only) Query on the database.
ilDBInterface $db
+ Here is the call graph for this function:

◆ lookupBlogId()

static ilBlogPosting::lookupBlogId ( int  $a_posting_id)
static

Definition at line 269 of file class.ilBlogPosting.php.

References $DIC, $ilDB, and null.

Referenced by ilObjBlogGUI\__construct(), ilBlogImporter\finalProcessing(), and ilBlogDataSet\readData().

271  : ?int {
272  global $DIC;
273 
274  $ilDB = $DIC->database();
275 
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"];
281  }
282  return null;
283  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ lookupTitle()

static ilBlogPosting::lookupTitle ( int  $a_posting_id)
static

Definition at line 547 of file class.ilBlogPosting.php.

547  : string
548  {
549  return (string) self::lookup("title", $a_posting_id);
550  }

◆ read()

ilBlogPosting::read ( )

Read blog posting.

Definition at line 174 of file class.ilBlogPosting.php.

References ilPageObject\$db, $ilDB, ilPageObject\addUpdateListener(), ilPageObject\getId(), IL_CAL_DATETIME, setApproved(), setAuthor(), setBlogId(), setCreated(), setTitle(), and setWithdrawn().

174  : void
175  {
176  $ilDB = $this->db;
177 
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);
182 
183  $this->setTitle($rec["title"]);
184  $this->setBlogId($rec["blog_id"]);
185  $this->setCreated(new ilDateTime($rec["created"], IL_CAL_DATETIME));
186  $this->setAuthor($rec["author"]);
187  if ($rec["approved"]) {
188  $this->setApproved(true);
189  }
190  $this->setWithdrawn(new ilDateTime($rec["last_withdrawn"], IL_CAL_DATETIME));
191 
192  // when posting is deactivated it should loose the approval
193  $this->addUpdateListener($this, "checkApproval");
194 
195  parent::read();
196  }
const IL_CAL_DATETIME
setCreated(ilDateTime $a_date)
setTitle(string $a_title)
setApproved(bool $a_status)
ilDBInterface $db
addUpdateListener(object $a_object, string $a_method, $a_parameters="")
setWithdrawn(ilDateTime $a_date)
Set last withdrawal date.
+ Here is the call graph for this function:

◆ searchBlogsByAuthor()

static ilBlogPosting::searchBlogsByAuthor ( int  $a_user_id)
static

Get all blogs where user has postings.

Definition at line 377 of file class.ilBlogPosting.php.

References $DIC, $ilDB, and ILIAS\Repository\int().

Referenced by ilBlogDraftsDerivedTaskProvider\getTasks(), and ilPCBlogGUI\initForm().

379  : array {
380  global $DIC;
381 
382  $ilDB = $DIC->database();
383 
384  $ids = array();
385 
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"];
392  }
393  return $ids;
394  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setApproved()

ilBlogPosting::setApproved ( bool  $a_status)

Definition at line 81 of file class.ilBlogPosting.php.

Referenced by read(), and unpublish().

81  : void
82  {
83  $this->approved = $a_status;
84  }
+ Here is the caller graph for this function:

◆ setAuthor()

ilBlogPosting::setAuthor ( int  $a_id)

Definition at line 71 of file class.ilBlogPosting.php.

Referenced by read().

71  : void
72  {
73  $this->author = $a_id;
74  }
+ Here is the caller graph for this function:

◆ setBlogId()

ilBlogPosting::setBlogId ( int  $a_id)

Definition at line 51 of file class.ilBlogPosting.php.

References ilPageObject\setParentId().

Referenced by read().

51  : void
52  {
53  $this->setParentId($a_id);
54  }
setParentId(int $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBlogNodeId()

ilBlogPosting::setBlogNodeId ( int  $a_id,
bool  $a_is_in_workspace = false 
)

Set blog node id (needed for notification)

Definition at line 366 of file class.ilBlogPosting.php.

369  : void {
370  $this->blog_node_id = $a_id;
371  $this->blog_node_is_wsp = $a_is_in_workspace;
372  }

◆ setCreated()

ilBlogPosting::setCreated ( ilDateTime  $a_date)

Definition at line 61 of file class.ilBlogPosting.php.

Referenced by read().

61  : void
62  {
63  $this->created = $a_date;
64  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBlogPosting::setTitle ( string  $a_title)

Definition at line 41 of file class.ilBlogPosting.php.

Referenced by read().

41  : void
42  {
43  $this->title = $a_title;
44  }
+ Here is the caller graph for this function:

◆ setWithdrawn()

ilBlogPosting::setWithdrawn ( ilDateTime  $a_date)

Set last withdrawal date.

Definition at line 94 of file class.ilBlogPosting.php.

Referenced by read(), and unpublish().

96  : void {
97  $this->withdrawn = $a_date;
98  }
+ Here is the caller graph for this function:

◆ unpublish()

ilBlogPosting::unpublish ( )

Unpublish.

Definition at line 230 of file class.ilBlogPosting.php.

References ilNewsItem\deleteNewsOfContext(), getBlogId(), ilPageObject\getId(), getParentType(), IL_CAL_DATETIME, ilUtil\now(), ilPageObject\setActive(), setApproved(), setWithdrawn(), and update().

230  : void
231  {
232  $this->setApproved(false);
233  $this->setActive(false);
235  $this->update(true, false, false);
236 
238  $this->getBlogId(),
239  "blog",
240  $this->getId(),
241  $this->getParentType()
242  );
243  }
const IL_CAL_DATETIME
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.
update(bool $a_validate=true, bool $a_no_history=false, bool $a_notify=true, string $a_notify_action="update")
static now()
Return current timestamp in Y-m-d H:i:s format.
setApproved(bool $a_status)
setWithdrawn(ilDateTime $a_date)
Set last withdrawal date.
setActive(bool $a_active)
+ Here is the call graph for this function:

◆ update()

ilBlogPosting::update ( bool  $a_validate = true,
bool  $a_no_history = false,
bool  $a_notify = true,
string  $a_notify_action = "update" 
)

Definition at line 144 of file class.ilBlogPosting.php.

References ilPageObject\$db, $ilDB, ilPageObject\getActive(), getCreated(), ilPageObject\getId(), getTitle(), getWithdrawn(), IL_CAL_DATETIME, isApproved(), and ilObjBlog\sendNotification().

Referenced by checkApproval(), and unpublish().

149  {
150  $ilDB = $this->db;
151 
152  // blog_id, author and created cannot be changed
153  $withdrawn = $this->getWithdrawn()?->get(IL_CAL_DATETIME);
154  $query = "UPDATE il_blog_posting SET" .
155  " title = " . $ilDB->quote($this->getTitle(), "text") .
156  ",created = " . $ilDB->quote($this->getCreated()->get(IL_CAL_DATETIME), "timestamp") .
157  ",approved =" . $ilDB->quote($this->isApproved(), "integer") .
158  ",last_withdrawn =" . $ilDB->quote($withdrawn, "timestamp") .
159  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
160  $ilDB->manipulate($query);
161 
162  $ret = parent::update($a_validate, $a_no_history);
163 
164  if ($a_notify && $this->getActive()) {
165  ilObjBlog::sendNotification($a_notify_action, $this->blog_node_is_wsp, $this->blog_node_id, $this->getId());
166  }
167 
168  return $ret;
169  }
getActive(bool $a_check_scheduled_activation=false)
const IL_CAL_DATETIME
getWithdrawn()
Get last withdrawal date.
static sendNotification(string $a_action, bool $a_in_wsp, int $a_blog_node_id, int $a_posting_id, ?string $a_comment=null)
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateKeywords()

ilBlogPosting::updateKeywords ( array  $keywords)

Definition at line 408 of file class.ilBlogPosting.php.

References getBlogId(), and ilPageObject\getId().

410  : void {
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)
414  ->execute();
415  }
+ Here is the call graph for this function:

Field Documentation

◆ $approved

bool ilBlogPosting::$approved = false
protected

Definition at line 33 of file class.ilBlogPosting.php.

Referenced by isApproved().

◆ $author

int ilBlogPosting::$author = 0
protected

Definition at line 32 of file class.ilBlogPosting.php.

Referenced by getAuthor().

◆ $blog_node_id

int ilBlogPosting::$blog_node_id = 0
protected

Definition at line 30 of file class.ilBlogPosting.php.

◆ $blog_node_is_wsp

bool ilBlogPosting::$blog_node_is_wsp = false
protected

Definition at line 31 of file class.ilBlogPosting.php.

◆ $created

ilDateTime ilBlogPosting::$created = null
protected

Definition at line 29 of file class.ilBlogPosting.php.

Referenced by getCreated().

◆ $title

string ilBlogPosting::$title = ""
protected

Definition at line 28 of file class.ilBlogPosting.php.

Referenced by getTitle().

◆ $withdrawn

ilDateTime ilBlogPosting::$withdrawn = null
protected

Definition at line 34 of file class.ilBlogPosting.php.

Referenced by getWithdrawn().


The documentation for this class was generated from the following file: