wiki Class Reference

the controller More...

Inheritance diagram for wiki:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 wiki (&$con, $prefix)
 constructs a new instance from a connection object and a prefix
 getLangs ()
 retrieve all langs available in the wiki
 getLangById ($id)
 retrieve a lang by id
 addUnconfirmedUser ($login, $fname, $lname, $password, $email, $lang_fk, $lang_ui)
 add a new unconfirmed user
 confirmUser ($key)
 confirm a user
 userExists ($login)
 does the user exists ?
 anonymousUser ()
 creates an anonymous user object
 getUser ($id, $md5password)
 returns a user from its id and md5 encoded password
 findUser ($login, $password)
 find a user by login and plain text password
 updateUser ($id, $login, $fname, $lname, $password, $email, $lang_fk, $lang_ui)
 update a user
 getUsers ()
 get users
 getAdminEmails ()
 returns emails of admins
 getGroups ()
 returns all available groups
 getNodeParents ($related_id, $lang_id)
 returns an ordered list of parent nodes from a related node and a lang id
 sortByAlternateTitle ($link1, $link2)
 getNodeSubLinks ($related_id, $lang_id, $user_id=-1)
 returns the list of sub nodes from a node
 getNodesAtUpperLevel ($related_content_id, $lang_id, $level)
 returns the list of nodes at a level
 getNodeComments ($node_id)
 get comments associated to a node
 getNodeGroups ($node_id)
 returns list of group having write access to node
 getNodeLangs ($related_id)
 return list of lang that translates a given node
 setRelatedNodeInfo_ ($node)
 set related info of a node
 filterNodeResult_ ($result, $lang)
 private method called from getNodeByIdAndLang or getNodeByTitleAndLang
 getRootNodeInLang ($lang)
 retrieve root node in required lang code
 getNodeByIdAndLang ($node_id, $lang)
 retrieve a node from its id and its lang code
 getNodeByTitleAndLang ($title, $lang)
 retrieve a node from its title and its lang code
 getSubNodesId_ ($id)
 returns the list of ALL direct and indirect sub nodes of node
 contentExists ($title, $lang_id)
 look if a given node exists
 contentExistsById ($node_id)
 look if a given node exists
 isMasterNode ($node_id)
 look if a given node exists and if this node is a master node
 editContent ($node_id, $old_parent_node_id, $parent_node_id, $title, $alternate_title, $content, $commit_msg, $minor_major, $related_content_id, $user, $left, $right)
 edit an existing content
 addContent ($parent_node_id, $title, $alternate_title, $content, $commit_msg, $minor_major, $lang_id, $related_content_id, $user)
 add a new node to the wiki
 makeNewRootPage ($id)
 make a new root node out of an existing page
 deleteContentById ($id)
 delete a node and all its related nodes (translations)
 saveHistory ($node)
 save a new version in history
 getHistory ($content_id)
 returns history of a node
 getHistoryVersion ($history_id)
 return a particular version of the history from database id
 getHistoryByDate ($node_id, $timestamp)
 get nearest history by date strictly below given date
 getHistoryByTitle ($title, $lang, $offset, $limit, $withAuthor=false, $withContent=false, $withId=false)
 return a list of version identified by title and lang
 deleteHistory ($id)
 delete an entry of history
 deleteAllHistory ($id)
 delete all history of a page
 anonymousComment ($node_id, $author, $email, $title, $comment)
 add an anonymous comment
 comment ($node_id, $user, $title, $comment)
 add a comment from a logged user
 deleteComment ($id)
 delete a comment
 getAllNodesIdByLang ($lang_id)
 returns list of nodes by lang
 searchPages ($search, $offset, $limit)
 search pages by keywords (implicit AND)
 recentChanges ($offset, $limit, $withAuthor=false, $withContent=false, $withUserForReadAcl=-1)
 returns the list of recently modified nodes
 recentComments ($offset, $limit, $withAuthor=false, $withContent=false)
 returns the list of recent comments
 recentCommentsByTitle ($title, $lang, $offset, $limit, $withAuthor=false, $withContent=false)
 returns the list of recent comments from a page
 whatLinksHere ($title, $offset, $limit)
 return a list of page that may link to page
 existAclOnIdAndType ($id, $acl_type)
 check if an acl exist for a node
 existAclOnTitleLangAndType ($title, $lang, $acl_type)
 check if an acl exist for a node
 addACLOnGroups ($id, $groups, $acl_type, $recApply)
 add a list of groups having acl_type access to page
 addACLOnUsers ($id, $users, $acl_type, $recApply)
 add a list of users having acl_type access to page
 removeACLOnGroups ($id, $groups, $acl_type, $recApply)
 remove a list of groups from the groups that have acl_type access to page
 removeACLOnUsers ($id, $users, $acl_type, $recApply)
 remove a list of users from the users that have acl_type access to page
 getEmails ($content_id, $userIdExclusionList=array())
 get the list of emails that have subscribed to page
 getWatches ($user_id)
 get list of node we have subscribed to
 addWatch ($node_id, $user_id)
 subscribe a user to a node
 removeWatch ($node_id, $user_id)
 remove a user subscription to a node
 addWatchRecursively ($node_id, $user_id)
 subscribe a user to a node and all subnodes
 removeAllWatch ($user_id)
 remove all subscription of a user
 getMetaDatas ()
 get the list of defined metadatas
 getMetaDataByName ($name)
 get metadata by name
 getClosedMetadataValues ($id)
 get the list of authorized values for a closed metadata
 addContentMetaDataValue ($node_id, $metadata_id, $value)
 add an opened metadata value to a node
 addContentMetadataClosedValue ($node_id, $metadata_id, $metadata_value_id)
 add a closed metadata value to a node
 getMetaDataInfoByContentId ($id)
 returns the list of metadatas attached to a node
 delContentMetaDataValue ($id)
 delete a metadata value
 getClosedMetadataValuesByIds ($closed_metadatas_ids)
 get the list of closed metadata values
 addBan ($ip)
 add a new ip to the list of banned ip
 getAlreadyBannedIps ($ips)
 return a list of already banned ips from an array of ip
 addBans ($ips)
 ban several ips at once
 isBanned ($ip)
 look if ip is banned
 containsBannedIp ($ips)
 look if one ip of a list of ip is banned
 attachFileToPage ($file_name, $node_id, $user_id)
 add a new attachment to a page
 deleteAttachments ($file_name, $node_id)
 delete an attachment
 getAttachments ($node_id)
 get all attachments linked to a page

Public Attributes

 $con
 connection to the database
 $prefix
 prefix table to use when building query

Detailed Description

the controller

this class act has a controller for all datas stored in the wiki. this class is used from all views and all views must use this class. it contains user handling, data handling (nodes, comments), lang handling, group handling ...


Member Function Documentation

wiki::addACLOnGroups ( id,
groups,
acl_type,
recApply 
)

add a list of groups having acl_type access to page

Parameters:
id database id of node we want to write protect
groups array[group_id]
acl_type type of acl to apply
recApply wether to recursively apply acls to sub groups too

wiki::addACLOnUsers ( id,
users,
acl_type,
recApply 
)

add a list of users having acl_type access to page

Parameters:
id database id of node we want to write protect
$users array[user_id]
acl_type type of acl to apply
recApply wether to recursively apply acls to sub groups too

wiki::addBan ( ip  ) 

add a new ip to the list of banned ip

Parameters:
ip the ip to ban
Returns:
true if the ip was added, false if it was already present

wiki::addBans ( ips  ) 

ban several ips at once

Parameters:
ips the ips to ban
Returns:
true if one ip was added, false if none was added

wiki::addContent ( parent_node_id,
title,
alternate_title,
content,
commit_msg,
minor_major,
lang_id,
related_content_id,
user 
)

add a new node to the wiki

create a new node in the wiki. If this node is a master node (a node in site default lang) then create an entry in table hierarchy and in table content_lang

Parameters:
parent_node_id database id of parent node
title title of node
alternate_title alternate title of node
content content of node
commit_msg commit message
minor_major is it a major or a minor changement ?
lang_id database id of lang
related_content_id database id of related content (can be zero if this node is a master node)
user user object that is creating this node

wiki::addContentMetadataClosedValue ( node_id,
metadata_id,
metadata_value_id 
)

add a closed metadata value to a node

add a metadata to a node with a closed value

Parameters:
node_id database id of node
metadata_id database id of metadata
metadata_value_id value of closed metadata

wiki::addContentMetaDataValue ( node_id,
metadata_id,
value 
)

add an opened metadata value to a node

add a metadata to a node with an open value

Parameters:
node_id database id of node
metadata_id database id of metadata
value value of open metadata

wiki::addUnconfirmedUser ( login,
fname,
lname,
password,
email,
lang_fk,
lang_ui 
)

add a new unconfirmed user

When a user subscribe, as we want to be sure of its email address, we send back to him an email with an hidden link. The user remain 'unconfirmed' while he has not visited the link provided in the email and cannot log in the system.

Parameters:
login choosen login
fname first name
lname last name
password password
email email
lang_fk choosen lang for content (one available in table lang)
lang_ui choosen lang for ui (one available in i18n/)
Returns:
randomly generated key associated to user or empty if there was an error

wiki::addWatch ( node_id,
user_id 
)

subscribe a user to a node

Parameters:
node_id node to subscribe
user_id user to subscribe

wiki::addWatchRecursively ( node_id,
user_id 
)

subscribe a user to a node and all subnodes

Parameters:
node_id node to subscribe
user_id user to subscribe

wiki::anonymousComment ( node_id,
author,
email,
title,
comment 
)

add an anonymous comment

Parameters:
node_id database if of node to comment
author user given author information
email user given email
title title of comment
comment 

wiki::anonymousUser (  ) 

creates an anonymous user object

wiki::attachFileToPage ( file_name,
node_id,
user_id 
)

add a new attachment to a page

Parameters:
file_name file to attach to page
node_id id of page
user_id id of user attaching to page

wiki::comment ( node_id,
user,
title,
comment 
)

add a comment from a logged user

Parameters:
node_id database if of node to comment
user user
title title of comment
comment 

wiki::confirmUser ( key  ) 

confirm a user

when the user click on the link provided to him in the email that was sent to him when he registered this function is called. The key is a randomly generated key that is passed in the url and must match a value in column temp_key.

Parameters:
key the temporary key that was assigned to him when he registered
Returns:
array[id, password]

wiki::containsBannedIp ( ips  ) 

look if one ip of a list of ip is banned

Parameters:
ips the ip to look
Returns:
true if the ip was banned, false otherwise

wiki::contentExists ( title,
lang_id 
)

look if a given node exists

the lookup does not default to site default lang if not found. => the match is exact

Parameters:
title title of node to look for
lang_id foreign key to table lang
Returns:
true if content exist, false otherwise

wiki::contentExistsById ( node_id  ) 

look if a given node exists

Parameters:
node_id id of node to look for
Returns:
true if content exist, false otherwise

wiki::delContentMetaDataValue ( id  ) 

delete a metadata value

Parameters:
id database id of metadata value

wiki::deleteAllHistory ( id  ) 

delete all history of a page

Parameters:
id database id of page's history to delete

wiki::deleteAttachments ( file_name,
node_id 
)

delete an attachment

Parameters:
file_name name of attachment to delete
node_id id of node from which we want to delete the attachement

wiki::deleteComment ( id  ) 

delete a comment

Parameters:
id database id of comment to delete

wiki::deleteContentById ( id  ) 

delete a node and all its related nodes (translations)

history, comments, acl, notifications associated to the node. If the node is a master node, all translated nodes associated to it will be deleted too.

Parameters:
id database id of node to delete

wiki::deleteHistory ( id  ) 

delete an entry of history

Parameters:
id database id of history to delete

wiki::editContent ( node_id,
old_parent_node_id,
parent_node_id,
title,
alternate_title,
content,
commit_msg,
minor_major,
related_content_id,
user,
left,
right 
)

edit an existing content

this is the heart of the wiki : it manages content updating AND hierarchy updating by updating the nested set model

Parameters:
node_id database if of node
old_parent_node_id the old parent id before the content was edited
parent_node_id new parent id (may be equals to old_parent_node_id)
title new title
alternate_title new alternate_title
content new content
commit_msg commit message
minor_major is it a major or a minor changement ?
related_content_id related_content_id !!should not be changed!!
user user object that modified this node
left left value in nested set model !!should not be changed!!
right right value in nested set model !!should not be changed!!

wiki::existAclOnIdAndType ( id,
acl_type 
)

check if an acl exist for a node

Parameters:
id database id of node we want to look at
acl_type type of acl to look for

wiki::existAclOnTitleLangAndType ( title,
lang,
acl_type 
)

check if an acl exist for a node

Parameters:
title title of page to look at
lang lang of page to look at
acl_type type of acl to look for

wiki::filterNodeResult_ ( result,
lang 
)

private method called from getNodeByIdAndLang or getNodeByTitleAndLang

composition of result is not documented, look inside caller methods The purpose is to filter out the most relevant node in all nodes contained in $result according to the the desired lang. The fallback is the main lang.

Returns:
only one result

wiki::findUser ( login,
password 
)

find a user by login and plain text password

When the user register in, login and password are sent as plain text. we then try to find the user in the database and returns it back

Parameters:
login login of user
password password of user

wiki::getAdminEmails (  ) 

returns emails of admins

Returns:
list of emails

wiki::getAllNodesIdByLang ( lang_id  ) 

returns list of nodes by lang

the match is exact

Parameters:
lang_id database id of a lang
Returns:
array[array[id, lang]]

wiki::getAlreadyBannedIps ( ips  ) 

return a list of already banned ips from an array of ip

Parameters:
ips the ips to look for
Returns:
array of ips that are in ips and are already banned

wiki::getAttachments ( node_id  ) 

get all attachments linked to a page

Parameters:
node_id id of node from which to get attachments
Returns:
array<file_name>

wiki::getClosedMetadataValues ( id  ) 

get the list of authorized values for a closed metadata

Parameters:
id database id of metadata
Returns:
map<id, value>

wiki::getClosedMetadataValuesByIds ( closed_metadatas_ids  ) 

get the list of closed metadata values

Parameters:
closed_metadatas_ids list of closed metadata ids
Returns:
map[metadata_id, map<value_id, value>>

wiki::getEmails ( content_id,
userIdExclusionList = array() 
)

get the list of emails that have subscribed to page

Parameters:
content_id database id of node
userIdExclusionList list of user to exclude from result
Returns:
array[array[email]]

wiki::getGroups (  ) 

returns all available groups

Returns:
list of group objects

wiki::getHistory ( content_id  ) 

returns history of a node

return ordered list of versions of a node

Parameters:
content_id database id of node to retrieve
Returns:
array[node]

wiki::getHistoryByDate ( node_id,
timestamp 
)

get nearest history by date strictly below given date

Parameters:
node_id database id of node
timestamp date to look at
Returns:
node object representing wanted version

wiki::getHistoryByTitle ( title,
lang,
offset,
limit,
withAuthor = false,
withContent = false,
withId = false 
)

return a list of version identified by title and lang

the list includes also the current content

Parameters:
title title of node
lang lang of node
offset what portion of the list to return
limit max number of versions to return
withAuthor add author information in result (firstname, lastname)
withContent add complete content in result
withId add id of history in result
Returns:
array[title, alt_title, date, lang, author, content]

wiki::getHistoryVersion ( history_id  ) 

return a particular version of the history from database id

Parameters:
history_id database id of version to retrieve
Returns:
node object representing wanted version

wiki::getLangById ( id  ) 

retrieve a lang by id

Parameters:
id the database id of the lang
Returns:
a lang object

wiki::getLangs (  ) 

retrieve all langs available in the wiki

Returns:
a list of lang objects

wiki::getMetaDataByName ( name  ) 

get metadata by name

Returns:
metadata object

wiki::getMetaDataInfoByContentId ( id  ) 

returns the list of metadatas attached to a node

As an optimisation we return open and closed metadata in one request you will have to compare open_value and closed_value_id to see what kind of metadata you're looking at

Parameters:
id database id of node
Returns:
array[array[id, name, value_id, open_value, closed_value_id]]

wiki::getMetaDatas (  ) 

get the list of defined metadatas

Returns:
list of metadata object

wiki::getNodeByIdAndLang ( node_id,
lang 
)

retrieve a node from its id and its lang code

if node does not exist in required lang, default to site default lang

Parameters:
node_id database id of lang
lang lang code
Returns:
complete node

wiki::getNodeByTitleAndLang ( title,
lang 
)

retrieve a node from its title and its lang code

if node does not exist in required lang, default to site default lang

Parameters:
title title of node
lang lang code
Returns:
complete node

wiki::getNodeComments ( node_id  ) 

get comments associated to a node

Parameters:
node_id database if of node
Returns:
list of comment objects

wiki::getNodeGroups ( node_id  ) 

returns list of group having write access to node

Parameters:
node_id id of node
Returns:
list of group objects

wiki::getNodeLangs ( related_id  ) 

return list of lang that translates a given node

Parameters:
related_id master node
Returns:
map<lang_id, lang_code>

wiki::getNodeParents ( related_id,
lang_id 
)

returns an ordered list of parent nodes from a related node and a lang id

Look into hierarchy table for each node that are parent from the nested set model. Once all possible parent nodes have been retrieved, keep only the one that are in the desired lang if it exist, or default to node in site default lang

Parameters:
related_id master node in site default lang
lang_id the desired lang of parent nodes
Returns:
array<id, title, alternate_title>

wiki::getNodesAtUpperLevel ( related_content_id,
lang_id,
level 
)

returns the list of nodes at a level

A little explanation needs to be done here... Let's say you retrieve the parent or the grand parent of the Nth parent of a node and you want to have all other nodes at same N level in the hierarchy. That's exactly what this function is doing. An example :
Level0Root
Level1C1.1C1.2
Level2GC1.1.1GC1.1.2GC1.2.1GC1.2.2GC1.2.3
Level3GGC1.1.2.1GGC1.1.2.2GGC1.2.3.1GGC1.2.3.2GC1.2.3.2

Now you're displaying node GC1.2.3.2 and you want to display in a tree view for example all nodes at level 2 (GC1.2.1 GC1.2.2 GC1.2.3) Then you call getNodesAtUpperLevel(GC1.2.3.2, lang_id, 2)

Parameters:
related_content_id master node in site default lang
lang_id the desired lang of parent nodes
level desired level for nodes
Returns:
array<id, title, alternate_title>

wiki::getNodeSubLinks ( related_id,
lang_id,
user_id = -1 
)

returns the list of sub nodes from a node

Look into the hierarchy table for all nodes that have a parent node equals to related_id. Once they have been retrieved, keep only the one in desired lang if they exist, or default to node in site default lang

Parameters:
related_id master node in site default lang
lang_id the desired lang of parent nodes
user_id filter nodes by returning only nodes that are readable by user identified by user_id
Returns:
array<id, title, alternate_title>

wiki::getRootNodeInLang ( lang  ) 

retrieve root node in required lang code

if node does not exist in required lang, default to site default lang

Parameters:
lang lang code
Returns:
complete node

wiki::getSubNodesId_ ( id  ) 

returns the list of ALL direct and indirect sub nodes of node

private method used in this class.

Parameters:
id database id of node
Returns:
list of id

wiki::getUser ( id,
md5password 
)

returns a user from its id and md5 encoded password

the cookie sent to the browser contains two fields : id and encoded password this enables to quickly find a user from the cookie

Parameters:
id database id of user
md5password md5 encoded password
Returns:
user object representing found user, or anonymous user if not found

wiki::getUsers (  ) 

get users

get all users (including anonymous)

Returns:
array<id, login>

wiki::getWatches ( user_id  ) 

get list of node we have subscribed to

Parameters:
user_id id of user we're looking
Returns:
array[array[id, title, lang]]

wiki::isBanned ( ip  ) 

look if ip is banned

Parameters:
ip the ip to look
Returns:
true if the ip was banned, false otherwise

wiki::isMasterNode ( node_id  ) 

look if a given node exists and if this node is a master node

Parameters:
node_id id of node to look for
Returns:
true if content exist and is a master node, false otherwise

wiki::makeNewRootPage ( id  ) 

make a new root node out of an existing page

Parameters:
id database id of new root node

wiki::recentChanges ( offset,
limit,
withAuthor = false,
withContent = false,
withUserForReadAcl = -1 
)

returns the list of recently modified nodes

Parameters:
offset what portion of the list to return
limit max number of elements to return
withAuthor includes also in result author information
withContent includes also full content in result
withUserForReadAcl filter nodes by returning only nodes that are readable by user identified by user_id
Returns:
array[title, alt_title, date, lang, author, content]

wiki::recentComments ( offset,
limit,
withAuthor = false,
withContent = false 
)

returns the list of recent comments

Parameters:
offset what portion of the list to return
limit max number of elements to return
withAuthor includes also in result author information
withContent includes also full content in result
Returns:
array[content_title, id, title, date, lang, author, content]

wiki::recentCommentsByTitle ( title,
lang,
offset,
limit,
withAuthor = false,
withContent = false 
)

returns the list of recent comments from a page

Parameters:
title title of page to look at
lang lang of page to look at
offset what portion of the list to return
limit max number of elements to return
withAuthor includes also in result author information
withContent includes also full content in result
Returns:
array[content_title, id, title, date, lang, author, content]

wiki::removeACLOnGroups ( id,
groups,
acl_type,
recApply 
)

remove a list of groups from the groups that have acl_type access to page

Parameters:
id database id of node to protect
groups array[group_id]
acl_type type of acl to apply
recApply wether to recursively apply modification to sub nodes too

wiki::removeACLOnUsers ( id,
users,
acl_type,
recApply 
)

remove a list of users from the users that have acl_type access to page

Parameters:
id database id of node to protect
users array[user_id]
acl_type type of acl to apply
recApply wether to recursively apply modification to sub nodes too

wiki::removeAllWatch ( user_id  ) 

remove all subscription of a user

Parameters:
user_id database id of user we want to clear subscription

wiki::removeWatch ( node_id,
user_id 
)

remove a user subscription to a node

Parameters:
node_id node to unsubscribe
user_id user to unsubscribe

wiki::saveHistory ( node  ) 

save a new version in history

History are a stripped down version of content : hierarchy, parent relationship, translation relationship, comments, acls, notifications are not saved

Parameters:
node the node to save

wiki::searchPages ( search,
offset,
limit 
)

search pages by keywords (implicit AND)

the pages are searched from content and title

Parameters:
search space separated list of keywords
offset what portion of the list to return
limit max number of elements to return
Returns:
array[array[title, alt_title, code]]

wiki::setRelatedNodeInfo_ ( node  ) 

set related info of a node

private method used in this class. it will set fields parents, sublinks, comments, groups, langs

Parameters:
node 

wiki::updateUser ( id,
login,
fname,
lname,
password,
email,
lang_fk,
lang_ui 
)

update a user

update a user from the user preference dialog

Parameters:
id database id of user
login login of user
fname first name of user
lname last name of user
password password of user (can be empty if user do not want to update it)
email email of user
lang_fk foreign key to lang table (for content)
lang_ui lang code corresponding to an i18n file (for ui)

wiki::userExists ( login  ) 

does the user exists ?

Parameters:
login the login to check
Returns:
true if user exists, false otherwise

wiki::whatLinksHere ( title,
offset,
limit 
)

return a list of page that may link to page

in fact, the search is naive as we return the list of content that contains title

Parameters:
title the title to search for
offset what portion of the list to return
limit max number of elements to return
Returns:
array[array[title, lang]]

wiki::wiki ( &$  con,
prefix 
)

constructs a new instance from a connection object and a prefix

Parameters:
con the connection object to a database
prefix prefix used for all tables


Member Data Documentation

wiki::$con

connection to the database

wiki::$prefix

prefix table to use when building query


The documentation for this class was generated from the following file:
Generated on Mon Feb 19 19:11:59 2007 for Wiclear by  doxygen 1.4.7