Search moodle.org's
Developer Documentation


Long Term Support Release

  • Bug fixes for general core bugs in 3.1.x ended 8 May 2017 (12 months).
  • Bug fixes for security issues in 3.1.x ended 13 May 2019 (36 months).
  • minimum PHP 5.4.4 (always use latest PHP 5.4.x , 5.5.x or 5.6.x on Windows - http://windows.php.net/download/). PHP 7.0.x is supported but has some engine limitations. PHP 7.1.x is not supported.
  • /blog/ -> locallib.php (source)

    Differences Between: [Versions 29 and 31] [Versions 30 and 31] [Versions 31 and 32] [Versions 31 and 33] [Versions 31 and 34] [Versions 31 and 35] [Versions 31 and 36] [Versions 31 and 37] [Versions 31 and 38]

    Classes for Blogs.

    Copyright: 2009 Nicolas Connault
    License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
    File Size: 1100 lines (38 kb)
    Included or required:0 times
    Referenced: 7 times
    Includes or requires: 0 files

    Defines 9 classes

    blog_entry:: (14 methods):
      __construct()
      prepare_render()
      get_attachments()
      process_attachment()
      add()
      edit()
      delete()
      add_associations()
      add_association()
      remove_associations()
      delete_attachments()
      can_user_edit()
      can_user_view()
      get_applicable_publish_states()

    blog_listing:: (8 methods):
      __construct()
      get_entries()
      count_entries()
      get_entry_fetch_sql()
      print_entries()
      get_baseurl()
      __construct()
      get_instance()

    blog_filter_context:: (1 method):
      __construct()

    blog_filter_user:: (1 method):
      __construct()

    blog_filter_tag:: (1 method):
      __construct()

    blog_filter_entry:: (1 method):
      __construct()

    blog_filter_since:: (1 method):
      __construct()

    blog_filter_search:: (1 method):
      __construct()

    blog_entry_attachment:: (1 method):
      __construct()


    Class: blog_entry  - X-Ref

    Blog_entry class. Represents an entry in a user's blog. Contains all methods for managing this entry.
    This class does not contain any HTML-generating code. See blog_listing sub-classes for such code.
    This class follows the Object Relational Mapping technique, its member variables being mapped to
    the fields of the post table.

    __construct($id=null, $params=null, $form=null)   X-Ref
    Constructor. If given an id, will fetch the corresponding record from the DB.

    param: mixed $idorparams A blog entry id if INT, or data for a new entry if array

    prepare_render()   X-Ref
    Gets the required data to print the entry


    get_attachments()   X-Ref
    Gets the entry attachments list

    return: array List of blog_entry_attachment instances

    process_attachment($form)   X-Ref
    Inserts this entry in the database. Access control checks must be done by calling code.

    param: mform $form Used for attachments
    return: void

    add()   X-Ref
    Inserts this entry in the database. Access control checks must be done by calling code.
    TODO Set the publishstate correctly

    return: void

    edit($params=array()   X-Ref
    Updates this entry in the database. Access control checks must be done by calling code.

    param: array       $params            Entry parameters.
    param: moodleform  $form              Used for attachments.
    param: array       $summaryoptions    Summary options.
    param: array       $attachmentoptions Attachment options.
    return: void

    delete()   X-Ref
    Deletes this entry from the database. Access control checks must be done by calling code.

    return: void

    add_associations($unused = null)   X-Ref
    Function to add all context associations to an entry.

    param: string $unused This does nothing, do not use it.

    add_association($contextid, $unused = null)   X-Ref
    Add a single association for a blog entry

    param: int $contextid - id of context to associate with the blog entry.
    param: string $unused This does nothing, do not use it.

    remove_associations()   X-Ref
    remove all associations for a blog entry

    return: voic

    delete_attachments()   X-Ref
    Deletes all the user files in the attachments area for an entry

    return: void

    can_user_edit($userid=null)   X-Ref
    User can edit a blog entry if this is their own blog entry and they have
    the capability moodle/blog:create, or if they have the capability
    moodle/blog:manageentries.
    This also applies to deleting of entries.

    param: int $userid Optional. If not given, $USER is used
    return: boolean

    can_user_view($targetuserid)   X-Ref
    Checks to see if a user can view the blogs of another user.
    Only blog level is checked here, the capabilities are enforced
    in blog/index.php

    param: int $targetuserid ID of the user we are checking
    return: bool

    get_applicable_publish_states()   X-Ref
    Use this function to retrieve a list of publish states available for
    the currently logged in user.

    return: array This function returns an array ideal for sending to moodles'

    Class: blog_listing  - X-Ref

    Abstract Blog_Listing class: used to gather blog entries and output them as listings. One of the subclasses must be used.

    __construct($filters=array()   X-Ref
    Constructor

    param: array $filters An associative array of filtername => filterid

    get_entries($start=0, $limit=10)   X-Ref
    Fetches the array of blog entries.

    return: array

    count_entries()   X-Ref
    Finds total number of blog entries

    return: int

    get_entry_fetch_sql($count=false, $sort='lastmodified DESC', $userid = false)   X-Ref
    No description

    print_entries()   X-Ref
    Outputs all the blog entries aggregated by this blog listing.

    return: void

    get_baseurl()   X-Ref
    No description

    __construct($id, $type=null)   X-Ref
    An array of filter types which this particular filter type overrides: their conditions will not be evaluated


    get_instance($id, $type)   X-Ref
    TODO This is poor design. A parent class should not know anything about its children.
    The default case helps to resolve this design issue


    Class: blog_filter_context  - X-Ref

    This filter defines the context level of the blog entries being searched: site, course, module

    __construct($id=null, $type='site')   X-Ref
    Constructor

    param: string $type
    param: int    $id

    Class: blog_filter_user  - X-Ref

    This filter defines the user level of the blog entries being searched: a userid or a groupid.
    It can be combined with a context filter in order to refine the search.

    __construct($id=null, $type='user')   X-Ref
    Constructor

    param: string $type
    param: int    $id

    Class: blog_filter_tag  - X-Ref

    This filter defines a tag by which blog entries should be searched.

    __construct($id)   X-Ref
    Constructor

    return: void

    Class: blog_filter_entry  - X-Ref

    This filter defines a specific blog entry id.

    __construct($id)   X-Ref
    No description

    Class: blog_filter_since  - X-Ref

    This filter restricts the results to a time interval in seconds up to time()

    __construct($interval)   X-Ref
    No description

    Class: blog_filter_search  - X-Ref

    Filter used to perform full-text search on an entry's subject, summary and content

    __construct($searchterm)   X-Ref
    No description

    Class: blog_entry_attachment  - X-Ref

    Renderable class to represent an entry attachment

    __construct($file, $entryid)   X-Ref
    Gets the file data

    param: stored_file $file
    param: int $entryid Attachment entry id

    Search This Site: