System

This class encapsulates core LnBlog system functions.

The system class exists in order to provide functions that are global to the installation rather then particular to a blog or user.  This includes things such as listing blogs and users, maintaining user permissions, and so forth.

This may not be the best way to accomplish this particular purpose.  However, it is very convenient and doesn’t cause any design problems for the time being.

Summary
This class encapsulates core LnBlog system functions.
Registers a blog with the system.
Get a list of blogs handled by LnBlog.
Gets the list of blogs to which a given user can add posts.
Get a list of all users.
Gets a list of groups.
Gets the groups to which a particular user belongs.
Determines whether or not a particular user belongs to a given group.
Determines if a specified group exists or not.
Adds a user to a group.
Determines if there is at least one user who is a system administrator.
Determines if a given user owns an object.
Determines if a given user has permissions to add child objects to some particular object.

Functions

registerBlog

function registerBlog($blogid)

Registers a blog with the system.  This lets the system know that the blog’s directory is handled by LnBlog.

Parameters

blogidThe path to the blog.  This should be relative to the server’s document root directory, e.g. a blog at http://somehost.com/blogs/techblog/ would use the blogid blogs/techblog.  Returns: True if the blog is registered correctly or is already registered, false if it fails to register.

getBlogList

function getBlogList()

Get a list of blogs handled by LnBlog.

Returns

An array of blog objects.

getUserBlogs

function getUserBlogs($usr)

Gets the list of blogs to which a given user can add posts.

Parameters

usrA User object for the user to check.

Returns

An array of Blog objects.

getUserList

function getUserList()

Get a list of all users.

Returns

An array of user objects.

getGroupList

function getGroupList()

Gets a list of groups.

Parameters

usrThe user whose groups we want to get.

Returns

An array of group names.

getGroups

function getGroups($usrid)

Gets the groups to which a particular user belongs.

Parameters

usridThe username of the user in question.

Returns

An array of group names.

inGroup

function inGroup($usrid,
$grp)

Determines whether or not a particular user belongs to a given group.

Parameters

usridThe username of the user to check.
grpThe group name to which the user should belong.

Returns

True if usrid is in grp or if everyone is in grp, false otherwise.

groupExists

function groupExists($grp)

Determines if a specified group exists or not.

Parameters

grpThe group name to check.

Returns

True if the group exists, false otherwise.

addToGroup

function addToGroup(&$usr,
$group)

Adds a user to a group.

Parameters

usrA user object representing the user to add.
groupThe group name to add the user to.

Returns

True on success, false on failure.  If the user is already in the group, then the return value is true.  If the group does not exist, the value is false.

hasAdministrator

function hasAdministrator()

Determines if there is at least one user who is a system administrator.

Returns

True if the user defined by the ADMIN_USER constant exists or if there is at least one existing user in the administrators group, false otherwise.

isOwner

function isOwner($usrid,
$obj)

Determines if a given user owns an object.

Parameters

usridThe username of the user to check.
objThe object to check.  Must have a uid or owner property.

Returns

True if the user is the object’s owner, false otherwise.

canAddTo

function canAddTo($parm,  
$usr = false)

Determines if a given user has permissions to add child objects to some particular object.

Parameters

parmAn object of some kind, usually a Blog, BlogEntry, or Article.
usrA User object for the user whose permissions we want to check.  Returns: True if the
function registerBlog($blogid)
Registers a blog with the system.
function getBlogList()
Get a list of blogs handled by LnBlog.
function getUserBlogs($usr)
Gets the list of blogs to which a given user can add posts.
function getUserList()
Get a list of all users.
function getGroupList()
Gets a list of groups.
function getGroups($usrid)
Gets the groups to which a particular user belongs.
function inGroup($usrid,
$grp)
Determines whether or not a particular user belongs to a given group.
function groupExists($grp)
Determines if a specified group exists or not.
function addToGroup(&$usr,
$group)
Adds a user to a group.
function hasAdministrator()
Determines if there is at least one user who is a system administrator.
function isOwner($usrid,
$obj)
Determines if a given user owns an object.
function canAddTo($parm,  
$usr = false)
Determines if a given user has permissions to add child objects to some particular object.