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
SystemThis class encapsulates core LnBlog system functions.
Functions
registerBlogRegisters a blog with the system.
unregisterBlogUnregisters a blog with the system.
getBlogListGet a list of blogs handled by LnBlog.
getThemeListGets a list of installed system and user themes.
getUserBlogsGets the list of blogs to which a given user can add posts.
getUserListGet a list of all users.
getGroupListGets a list of groups.
getGroupsGets the groups to which a particular user belongs.
inGroupDetermines whether or not a particular user belongs to a given group.
groupExistsDetermines if a specified group exists or not.
addToGroupAdds a user to a group.
hasAdministratorDetermines if there is at least one user who is a system administrator.
isOwnerDetermines if a given user owns an object.
canAddToDetermines if a given user has permissions to add child objects to some particular object.
canModifyLike canAddTo, except determines if the user can perform updates.
canDeleteLike canAddTo, except determines if the user can delete the object.
uri_to_localpathThe reverse of localpath_to_uri, this function takes a URI handled by LnBlog and converts it into a local path to the file or directory in question.
calculate_document_rootAn alternate way to find the document root.

Functions

registerBlog

public 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.

unregisterBlog

public function unregisterBlog($blogid)

Unregisters a blog with the system.  This reverses registerBlog().

Parameters

blogidTHe path to the blog, as with registerBlog.

Returns

True on success, false on failure or if the blog was not registered.

getBlogList

public function getBlogList()

Get a list of blogs handled by LnBlog.

Returns

An array of blog objects.

getThemeList

public function getThemeList()

Gets a list of installed system and user themes.

Returns

An array of theme names.

getUserBlogs

public 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

public function getUserList()

Get a list of all users.

Returns

An array of user objects.

getGroupList

public function getGroupList()

Gets a list of groups.

Parameters

usrThe user whose groups we want to get.

Returns

An array of group names.

getGroups

public 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

public 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

public 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

public 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

public 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

public 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

public 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

canModify

public function canModify($parm,  
$usr = false)

Like canAddTo, except determines if the user can perform updates.

canDelete

public function canDelete($parm,  
$usr = false)

Like canAddTo, except determines if the user can delete the object.

uri_to_localpath

function uri_to_localpath($uri)

The reverse of localpath_to_uri, this function takes a URI handled by LnBlog and converts it into a local path to the file or directory in question.  This function assumes that the URI is fully qualified, e.g.

http://somehost.com/somepath/somefile.ext

Note that this may or may not play well with Apache .htaccess files.

Parameters

uriThe URI to convert.

Returns

A string containing the local path referenced by the URI.  Not that this path may or may not exist.

calculate_document_root

function calculate_document_root()

An alternate way to find the document root.  This one works by comparing the current URL on the server to the current directory.  The idea is that we can find the location of the current URL in the path and remove it to get the document root.  Note that this function IS case-sensitive.

Returns

The calculated document root path.

public function registerBlog($blogid)
Registers a blog with the system.
public function unregisterBlog($blogid)
Unregisters a blog with the system.
public function getBlogList()
Get a list of blogs handled by LnBlog.
public function getThemeList()
Gets a list of installed system and user themes.
public function getUserBlogs($usr)
Gets the list of blogs to which a given user can add posts.
public function getUserList()
Get a list of all users.
public function getGroupList()
Gets a list of groups.
public function getGroups($usrid)
Gets the groups to which a particular user belongs.
public function inGroup($usrid,
$grp)
Determines whether or not a particular user belongs to a given group.
public function groupExists($grp)
Determines if a specified group exists or not.
public function addToGroup(&$usr,
$group)
Adds a user to a group.
public function hasAdministrator()
Determines if there is at least one user who is a system administrator.
public function isOwner($usrid,
$obj)
Determines if a given user owns an object.
public function canAddTo($parm,  
$usr = false)
Determines if a given user has permissions to add child objects to some particular object.
public function canModify($parm,  
$usr = false)
Like canAddTo, except determines if the user can perform updates.
public function canDelete($parm,  
$usr = false)
Like canAddTo, except determines if the user can delete the object.
function uri_to_localpath($uri)
The reverse of localpath_to_uri, this function takes a URI handled by LnBlog and converts it into a local path to the file or directory in question.
function localpath_to_uri($path,  
$full_uri = true,
$https = false)
Convert a local path to a URI.
function calculate_document_root()
An alternate way to find the document root.
Close