\seekquarry\yioop\modelsGroupModel

This is class is used to handle db results related to Group Administration. Groups are collections of users who might access a common blog/news feed and set of pages. This method also controls adding and deleting entries to a group feed and does limited access control checks of these operations.

Summary

Methods
Properties
Constants
__construct()
fileGetContents()
filePutContents()
createIfNecessaryDirectory()
formatSinglePageResult()
getSnippets()
boldKeywords()
getDbmsList()
loginDbms()
isSingleLocalhost()
translateDb()
getUserId()
searchArrayToWhereOrderClauses()
getRows()
selectCallback()
fromCallback()
whereCallback()
rowCallback()
postQueryCallback()
getGroupUsers()
countGroupUsers()
addGroup()
updateGroup()
checkUserGroup()
updateStatusUserGroup()
getGroupId()
getGroupName()
isGroupEncrypted()
deleteGroup()
getRegisterType()
getGroupById()
getUserGroups()
countUserGroups()
getGroupKey()
changeOwnerGroup()
addUserGroup()
deletableUser()
deleteUserGroup()
getGroupItem()
getRelationshipId()
getThreadFollowers()
addGroupItem()
encrypt()
decrypt()
updateGroupItem()
deleteGroupItem()
getGroupItems()
getGroupItemCount()
getMostRecentGroupPost()
getGroupThreadCount()
getGroupPostCount()
cullExpiredGroupItems()
alreadyVoted()
voteUp()
voteDown()
setPageName()
getTemplateMap()
getPageId()
pagesLinkedWithRelationship()
getRelationshipsToFromPage()
countPageRelationships()
getPageInfoByName()
getPageInfoByThread()
getPageInfoByPageId()
getHistoryPage()
getPageHistoryList()
getGroupIdPageIdSubPathFromName()
getGroupPageResourcesFolders()
insertResourcesParsePage()
insertVideoImageResourceParsePage()
convertSpreadsheetRectangle()
spreadsheetRectangleData()
evaluateCell()
evaluateFactor()
evalFunctionInvocation()
evalParenthesizedExpression()
evaluateArgListExpression()
evalRangeExpression()
evalNegatedExpression()
evalNumericExpression()
evalCellNameExpression()
evalStringExpression()
skipWhiteSpace()
cellNameAsRowColumn()
letterRepresentation()
versionGroupPage()
revertResources()
deleteResource()
extractResource()
deleteResources()
newResource()
renameResource()
copyFileToGroupPageResource()
getPageResource()
setPageResource()
makeThumbStripExif()
copyResourceToClipFolder()
getGroupPageResourceUrls()
getGroupPageResourceUrl()
getGroupPageCount()
getPageList()
getGroupBots()
$db
$db_name
$private_db
$private_db_name
$edited_page_summaries
$any_fields
$search_table_column_map
$web_site
$cache
SNIPPET_TITLE_LENGTH
MAX_SNIPPET_TITLE_LENGTH
SNIPPET_LENGTH_LEFT
SNIPPET_LENGTH_RIGHT
MIN_SNIPPET_LENGTH
DEFAULT_DESCRIPTION_LENGTH
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

SNIPPET_TITLE_LENGTH

SNIPPET_TITLE_LENGTH

MAX_SNIPPET_TITLE_LENGTH

MAX_SNIPPET_TITLE_LENGTH

SNIPPET_LENGTH_LEFT

SNIPPET_LENGTH_LEFT

SNIPPET_LENGTH_RIGHT

SNIPPET_LENGTH_RIGHT

MIN_SNIPPET_LENGTH

MIN_SNIPPET_LENGTH

DEFAULT_DESCRIPTION_LENGTH

DEFAULT_DESCRIPTION_LENGTH

Default maximum character length of a search summary

Properties

$db

$db :object

Reference to a DatasourceManager

Type

object

$db_name

$db_name :string

Name of the search engine database

Type

string

$private_db

$private_db :object

Reference to a private DatasourceManager

Type

object

$private_db_name

$private_db_name :string

Name of the private search engine database

Type

string

$edited_page_summaries

$edited_page_summaries :array

Associative array of page summaries which might be used to override default page summaries if set.

Type

array

$any_fields

$any_fields :array

These fields if present in $search_array (used by @see getRows() ), but with value "-1", will be skipped as part of the where clause but will be used for order by clause

Type

array

$search_table_column_map

$search_table_column_map :array

Associations of the form name of field for web forms => database column names/abbreviations In this case, things will in general map to the GROUPS, or USER_GROUP or GROUP_ITEM tables in the Yioop database

Type

array

$web_site

$web_site :object

Reference to a WebSite object in use to serve pages (if any)

Type

object

$cache

$cache :object

Cache object to be used if we are doing caching

Type

object

Methods

__construct()

__construct(string  $db_name = \seekquarry\yioop\configs\DB_NAME,boolean  $connect = true,  $web_site = null)

Sets up the database manager that will be used and name of the search engine database

Parameters

string $db_name

the name of the database for the search engine

boolean $connect

whether to connect to the database by default after making the datasource class

$web_site

fileGetContents()

fileGetContents(string  $filename,boolean  $force_read = false): string

Either a wrapper for file_get_contents, or if a WebSite object is being used to serve pages, it reads it in using blocking I/O file_get_contents() and caches it before return its string contents.

Note this function assumes that only the web server is performing I/O with this file. filemtime() can be used to see if a file on disk has been changed and then you can use $force_read = true below to force re- reading the file into the cache

Parameters

string $filename

name of file to get contents of

boolean $force_read

whether to force the file to be read from presistent storage rather than the cache

Returns

string —

contents of the file given by $filename

filePutContents()

filePutContents(string  $filename,string  $data)

Either a wrapper for file_put_contents, or if a WebSite object is being used to serve pages, writes $data to the persistent file with name $filename. Saves a copy in the RAM cache if there is a copy already there.

Parameters

string $filename

name of file to write to persistent storages

string $data

string of data to store in file

createIfNecessaryDirectory()

createIfNecessaryDirectory(string  $directory): integer

Creates a directory and sets it to world permission if it doesn't aleady exist

Parameters

string $directory

name of directory to create

Returns

integer —

-1 on failure, 0 if already existed, 1 if created

formatSinglePageResult()

formatSinglePageResult(array  $page,array  $words = null,integer  $description_length = self::DEFAULT_DESCRIPTION_LENGTH): array

Given a page summary, extracts snippets which are related to a set of search words. For each snippet, bold faces the search terms, and then creates a new summary array.

Parameters

array $page

a single search result summary

array $words

keywords (typically what was searched on)

integer $description_length

length of the description

Returns

array —

$page which has been snippified and bold faced

getSnippets()

getSnippets(string  $text,array  $words,string  $description_length): string

Given a string, extracts a snippets of text related to a given set of key words. For a given word a snippet is a window of characters to its left and right that is less than a maximum total number of characters.

There is also a rule that a snippet should avoid ending in the middle of a word

Parameters

string $text

haystack to extract snippet from

array $words

keywords used to make look in haystack

string $description_length

length of the description desired

Returns

string —

a concatenation of the extracted snippets of each word

boldKeywords()

boldKeywords(string  $text,array  $words): string

Given a string, wraps in bold html tags a set of key words it contains.

Parameters

string $text

haystack string to look for the key words

array $words

an array of words to bold face

Returns

string —

the resulting string after boldfacing has been applied

getDbmsList()

getDbmsList(): array

Gets a list of all DBMS that work with the search engine

Returns

array —

Names of available data sources

loginDbms()

loginDbms(string  $dbms): boolean

Returns whether the provided dbms needs a login and password or not (sqlite or sqlite3)

Parameters

string $dbms

the name of a database management system

Returns

boolean —

true if needs a login and password; false otherwise

isSingleLocalhost()

isSingleLocalhost(array  $machine_urls,string  $index_timestamp = -1): boolean

Used to determine if an action involves just one yioop instance on the current local machine or not

Parameters

array $machine_urls

urls of yioop instances to which the action applies

string $index_timestamp

if timestamp exists checks if the index has declared itself to be a no network index.

Returns

boolean —

whether it involves a single local yioop instance (true) or not (false)

translateDb()

translateDb(string  $string_id,string  $locale_tag): mixed

Used to get the translation of a string_id stored in the database to the given locale.

Parameters

string $string_id

id to translate

string $locale_tag

to translate to

Returns

mixed —

translation if found, $string_id, otherwise

getUserId()

getUserId(string  $username): string

Get the user_id associated with a given username (In base class as used as an internal method in both signin and user models)

Parameters

string $username

the username to look up

Returns

string —

the corresponding userid

searchArrayToWhereOrderClauses()

searchArrayToWhereOrderClauses(array  $search_array,array  $any_fields = array('status')): array

Creates the WHERE and ORDER BY clauses for a query of a Yioop table such as USERS, ROLE, GROUP, which have associated search web forms. Searches are case insensitive

Parameters

array $search_array

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

array $any_fields

these fields if present in search array but with value "-1" will be skipped as part of the where clause but will be used for order by clause

Returns

array —

string for where clause, string for order by clause

getRows()

getRows(integer  $limit,integer  $num,\seekquarry\yioop\models\int&  $total,array  $search_array = array(),array  $args = null): array

Gets a range of rows which match the provided search criteria from $th provided table

Parameters

integer $limit

starting row from the potential results to return

integer $num

number of rows after start row to return

\seekquarry\yioop\models\int& $total

gets set with the total number of rows that can be returned by the given database query

array $search_array

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

array $args

additional values which may be used to get rows (what these are will typically depend on the subclass implementation)

Returns

array

selectCallback()

selectCallback(mixed  $args = null): string

Used to determine the select clause for GROUPS table when do query to marshal group objects for the controller mainly in mangeGroups

This defaults to *, but in general will be overriden in subclasses of Model

Parameters

mixed $args

We use $args[1] to say whether in browse mode or not. browse mode is for groups a user could join rather than ones already joined

Returns

string —

a comma separated list of columns suitable for a SQL query

fromCallback()

fromCallback(mixed  $args = null): string

Controls which tables and the names of tables underlie the given model and should be used in a getRows call This defaults to the single table whose name is whatever is before Model in the name of the model. For example, by default on FooModel this method would return "FOO". If a different behavior, this can be overriden in subclasses of Model

Parameters

mixed $args

any additional arguments which should be used to determine these tables (in this case none)

Returns

string —

a comma separated list of tables suitable for a SQL query

whereCallback()

whereCallback(array  $args = null): string

Used to restrict getRows in which rows it returns. Rows in this case corresponding to Yioop groups. The restrictions added are to restrict to those group available to a given user_id and whether or not the user wants groups subscribed to, or groups that could be subscribed to

This defaults to an empty WHERE clause.

Parameters

array $args

first two elements are the $user_id of the user and the $browse flag which says whether or not user is browing through all groups to which he could subscribe and read or just those groups to which he is alrady subscribed.

Returns

string —

a SQL WHERE clause suitable to perform the above restrictions

rowCallback()

rowCallback(array  $row,mixed  $args): array

Called after as row is retrieved by getRows from the database to perform some manipulation that would be useful for this model.

For example, in CrawlModel, after a row representing a crawl mix has been gotten, this is used to perform an additional query to marshal its components. By default this method just returns this row unchanged.

Parameters

array $row

row as retrieved from database query

mixed $args

additional arguments that might be used by this callback

Returns

array —

$row after callback manipulation

postQueryCallback()

postQueryCallback(array  $rows): array

Called after getRows has retrieved all the rows that it would retrieve but before they are returned to give one last place where they could be further manipulated. For example, in MachineModel this callback is used to make parallel network calls to get the status of each machine returned by getRows. The default for this method is to leave the rows that would be returned unchanged

Parameters

array $rows

that have been calculated so far by getRows

Returns

array —

$rows after this final manipulation

getGroupUsers()

getGroupUsers(string  $group_id,string  $filter = "",array  $sorts = array(),integer  $limit = "",integer  $num = \seekquarry\yioop\configs\NUM_RESULTS_PER_PAGE): array

Get an array of users that belong to a group

Parameters

string $group_id

the group_id to get users for

string $filter

to LIKE filter users

array $sorts

directions on how to sort the columns of the results format is column_name => direction

integer $limit

first user to get

integer $num

number of users to return

Returns

array —

of USERS rows

countGroupUsers()

countGroupUsers(integer  $group_id,string  $filter = ""): integer

Get the number of users which belong to a group and whose user_name matches a filter

Parameters

integer $group_id

id of the group to get a count of

string $filter

to filter usernames by

Returns

integer —

count of matching users

addGroup()

addGroup(string  $group_name,integer  $user_id,integer  $register = \seekquarry\yioop\configs\REQUEST_JOIN,integer  $member = \seekquarry\yioop\configs\GROUP_READ,integer  $voting = \seekquarry\yioop\configs\NON_VOTING_GROUP,integer  $post_lifetime = \seekquarry\yioop\configs\FOREVER,integer  $encryption): integer

Add a groupname to the database using provided string

Parameters

string $group_name

the groupname to be added

integer $user_id

user identifier of who owns the group

integer $register

flag that says what kinds of registration are allowed for this group NO_JOIN, REQUEST_JOIN, PUBLIC_JOIN, or some group fee amount in credits 100, 200, 500, 1000, 2000

integer $member

flag that says how members other than the owner can access this group GROUP_READ, GROUP_READ_COMMENT (can comment on threads but not start. i.e., a blog), GROUP_READ_WRITE, (can read, comment, start threads), GROUP_READ_WIKI, (can read, comment, start threads, and edit the wiki)

integer $voting

flag that says how members can vote on each others posts: NON_VOTING_GROUP, UP_VOTING_GROUP, UP_DOWN_VOTING_GROUP

integer $post_lifetime

specifies the time in seconds that posts should live before they expire and are deleted

integer $encryption

0 means don't encrypt group, 1 means encrypt group

Returns

integer —

id of group added

updateGroup()

updateGroup(array  $group)

Takes the passed associated array $group representing changes fields of a GROUPS row, and executes an UPDATE statement to persist those changes fields to the database.

Parameters

array $group

associative array with a GROUP_ID as well as the fields to update

checkUserGroup()

checkUserGroup(integer  $user_id,integer  $group_id,integer  $status = -1): boolean

Check is a user given by $user_id belongs to a group given by $group_id. If the field $status is sent then check if belongs to the group with $status access (active, invited, request, banned)

Parameters

integer $user_id

user to look up

integer $group_id

group to check if member of

integer $status

membership type

Returns

boolean —

whether or not is a member

updateStatusUserGroup()

updateStatusUserGroup(integer  $user_id,integer  $group_id,integer  $status)

Change the status of a user in a group

Parameters

integer $user_id

of user to change

integer $group_id

of group to change status for

integer $status

what the new status should be

getGroupId()

getGroupId(string  $group_name): integer

Get group id associated with groupname (so groupnames better be unique)

Parameters

string $group_name

to use to look up a group_id

Returns

integer —

group_id corresponding to the groupname.

getGroupName()

getGroupName(integer  $group_id): string

Get group id associated with groupname (so groupnames better be unique)

Parameters

integer $group_id

to use to look up a group name

Returns

string —

group_name corresponding to the id.

isGroupEncrypted()

isGroupEncrypted(integer  $group_id): boolean

Check whether group's encryption is enabled or not

Parameters

integer $group_id

to check for encryption value

Returns

boolean —

whether thte group is encrypted or not

deleteGroup()

deleteGroup(string  $group_id)

Delete a group from the database and any associated data in GROUP_ITEM and USER_GROUP tables.

Parameters

string $group_id

id of the group to delete

getRegisterType()

getRegisterType(integer  $group_id): integer

Return the type of the registration for a group given by $group_id This says who is allowed to register for the group (i.e., is it by invitation only, by request, or anyone can join)

Parameters

integer $group_id

which group to find the type of

Returns

integer —

the numeric code for the registration type

getGroupById()

getGroupById(integer  $group_id,integer  $user_id,boolean  $require_root_or_member = false): array

Returns information about the group with id $group_id provided that the requesting user $user_id has access to it

Parameters

integer $group_id

id of group to look up

integer $user_id

user asking for group info

boolean $require_root_or_member

require the $user_id to be in the group or root

Returns

array —

row from group table or false (if no access or doesn't exists)

getUserGroups()

getUserGroups(integer  $user_id,string  $filter,array  $sorts,integer  $limit,integer  $num = \seekquarry\yioop\configs\NUM_RESULTS_PER_PAGE): array

Get a list of all groups which user_id belongs to. Group names are not localized since these are created by end user admins of the search engine

Parameters

integer $user_id

to get groups for

string $filter

to LIKE filter groups

array $sorts

directions on how to sort the columns of the results format is column_name => direction

integer $limit

first user to get

integer $num

number of users to return

Returns

array —

an array of group_id, group_name pairs

countUserGroups()

countUserGroups(integer  $user_id,string  $filter = ""): integer

Get a count of the number of groups to which user_id belongs.

Parameters

integer $user_id

to get groups for

string $filter

to LIKE filter groups

Returns

integer —

number of groups of the filtered type for the user

getGroupKey()

getGroupKey(integer  $group_id): string

Get the key of the group.

Parameters

integer $group_id

to get key for

Returns

string —

key of the group

changeOwnerGroup()

changeOwnerGroup(string  $user_id,string  $group_id)

To update the OWNER_ID of a group

Parameters

string $user_id

the id of the user who becomes the admin of group

string $group_id

the group id to transfer admin privileges

addUserGroup()

addUserGroup(string  $user_id,string  $group_id,integer  $status = \seekquarry\yioop\configs\ACTIVE_STATUS)

Add an allowed user to an existing group

Parameters

string $user_id

the id of the user to add

string $group_id

the group id of the group to add the user to

integer $status

what should be the membership status of the added user. Should be one of ACTIVE_STATUS, INACTIVE_STATUS, SUSPENDED_STATUS, INVITED_STATUS

deletableUser()

deletableUser(integer  $user_id,integer  $group_id): boolean

Checks if a user belongs to a group but is not the owner of that group Such a user could be deleted from the group

Parameters

integer $user_id

which user to look up

integer $group_id

which group to look up for

Returns

boolean —

where user is deletable

deleteUserGroup()

deleteUserGroup(string  $user_id,string  $group_id)

Delete a user from a group by userid an groupid

Parameters

string $user_id

the userid of the user to delete

string $group_id

the group id of the group to delete

getGroupItem()

getGroupItem(integer  $item_id): array

Returns the GROUP_FEED item with the given id

Parameters

integer $item_id

the item to get info about

Returns

array —

row from GROUP_FEED table

getRelationshipId()

getRelationshipId(string  $relationship_type): array

Returns the id of the relationship between wiki pages with the given name

Parameters

string $relationship_type

the relationship type to get id about

Returns

array —

row from PAGE_RELATIONSHIP table or false (if no access or doesn't exist)

getThreadFollowers()

getThreadFollowers(integer  $thread_id,integer  $owner_id,integer  $exclude_id = -1): array

Returns an array of user information about users who have contributed to a thread or own the group a thread belongs to

Parameters

integer $thread_id

the id of the thread that want users for

integer $owner_id

owner of group thread belongs to

integer $exclude_id

an id of a user to exclude from the array returned

Returns

array —

user information of users following the thread

addGroupItem()

addGroupItem(integer  $parent_id,integer  $group_id,integer  $user_id,string  $title,string  $description,integer  $type = \seekquarry\yioop\configs\STANDARD_GROUP_ITEM,integer  $post_time,string  $url = ""): integer

Creates a new group item

Parameters

integer $parent_id

thread id to use for the item

integer $group_id

what group the item should be added to

integer $user_id

of user making the post

string $title

title of the group feed item

string $description

actual content of the post

integer $type

flag saying what kind of group item this is. One of STANDARD_GROUP_ITEM, WIKI_GROUP_ITEM (used for threads discussing a wiki page)

integer $post_time

timstamp for when this group item was created default to the current time

string $url

a url associated with this group item (mainly for search group)

Returns

integer —

$id of item added

encrypt()

encrypt(string  $data,string  $key,string  $cipher_method = 'aes-256-cbc'): string

Encrypts data based on provided key.

Parameters

string $data

what data to encrypt

string $key

what key to use to encrypt

string $cipher_method

a cipher encrypt/decrypt method supported by OpenSSL

Returns

string —

$out_data the encrypted string

decrypt()

decrypt(string  $data,string  $key,string  $cipher_method = 'aes-256-cbc'): string

Decrypts data based on provided key.

Parameters

string $data

what data to decrypt

string $key

what key to use to decrypt

string $cipher_method

a cipher encrypt/decrypt method supported by OpenSSL

Returns

string —

$out_data the decrypted string

updateGroupItem()

updateGroupItem(integer  $id,string  $title,string  $description)

Updates a group feed item's title and description. This assumes the given item already exists.

Parameters

integer $id

which item to change

string $title

the new title

string $description

the new description

deleteGroupItem()

deleteGroupItem(integer  $post_id,integer  $user_id)

Removes a group feed item from the GROUP_ITEM table.

Parameters

integer $post_id

of item to remove

integer $user_id

the id of the person trying to perform the removal. If not root, or the original creator of the item, the item won't be removed

getGroupItems()

getGroupItems(integer  $limit,integer  $num = 100,array  $search_array = array(),integer  $user_id = \seekquarry\yioop\configs\ROOT_ID,integer  $for_group = -1): array

Gets the group feed items visible to a user with $user_id and which match the supplied search criteria found in $search_array, starting from the $limit'th matching item to the $limit+$num item.

Parameters

integer $limit

starting offset group item to display

integer $num

number of items from offset to display

array $search_array

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

integer $user_id

who is making this request to determine which

integer $for_group

if this value is set it is a assumed that group_items are being returned for only one group and that they should be grouped by thread

Returns

array —

elements of which represent one group feed item

getGroupItemCount()

getGroupItemCount(array  $search_array = array(),integer  $user_id = \seekquarry\yioop\configs\ROOT_ID,integer  $for_group = -1): integer

Gets the number of group feed items visible to a user with $user_id and which match the supplied search criteria found in $search_array

Parameters

array $search_array

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

integer $user_id

who is making this request to determine which

integer $for_group

if this value is set it is a assumed that group_items are being returned for only one group and that the count desired is over the number of threads in that group

Returns

integer —

number of items matching the search criteria for the given user_id

getMostRecentGroupPost()

getMostRecentGroupPost(  $group_id)

Parameters

$group_id

getGroupThreadCount()

getGroupThreadCount(  $group_id)

Parameters

$group_id

getGroupPostCount()

getGroupPostCount(  $group_id)

Parameters

$group_id

cullExpiredGroupItems()

cullExpiredGroupItems()

Deletes Group Items which are older than the expiry date for posts for that group

alreadyVoted()

alreadyVoted(integer  $user_id,integer  $post_id): boolean

Returns true or false depending on whether a given user has voted on a given post or not

Parameters

integer $user_id

id of user to check if voted

integer $post_id

id of GROUP_ITEM to see if voted on

Returns

boolean —

whether or not the user has voted on that item

voteUp()

voteUp(integer  $user_id,integer  $post_id)

Casts one up vote by a user to a post

Parameters

integer $user_id

id of user to cast vote for

integer $post_id

id of post on which to cast vote

voteDown()

voteDown(integer  $user_id,integer  $post_id)

Casts one up vote by a user to a post

Parameters

integer $user_id

id of user to cast vote for

integer $post_id

id of post on which to cast vote

setPageName()

setPageName(integer  $user_id,integer  $group_id,string  $page_name,string  $page,string  $locale_tag,string  $edit_comment,string  $thread_title,string  $thread_description,string  $base_address = "",array  $additional_substitutions = array()): integer

Used to add a wiki page revision by a given user to a wiki page of a given name in a given group viewing the group under a given language. If the page does not exist yet it, and its corresponding discussion thread is created. Two pages are used for storage GROUP_PAGE which contains a parsed to html version of the most recent revision of a wiki page and GROUP_PAGE_HISTORY which contains non-parsed versions of all revisions

Parameters

integer $user_id

identifier of who is adding this revision

integer $group_id

which group the wiki page revision if being done in

string $page_name

title of page being revised

string $page

wiki page with potential wiki mark up containing the revision

string $locale_tag

locale we are adding the revision to

string $edit_comment

user's reason for making the revision

string $thread_title

if this is the first revision, then this should contain the title for the discussion thread about the revision

string $thread_description

if this is the first revision, then this should be the body of the first post in discussion thread

string $base_address

default url to be used in links on wiki page that use short syntax

array $additional_substitutions

list of pairs additional wiki page rewrites to do when parsing wiki pages

Returns

integer —

$page_id id of added or updated page

getTemplateMap()

getTemplateMap(integer  $group_id,string  $locale_tag): array

Returns an array page_id => page_name of all templates for a given Group for a given language

Parameters

integer $group_id

id of group to produce template map for

string $locale_tag

of language to produce template map for

Returns

array —

page_id => page_name for each template for the given group in the provided language

getPageId()

getPageId(integer  $group_id,string  $page_name,string  $locale_tag): mixed

Looks up the page_id of a wiki page based on the group it belongs to, its title, and the language it is in (these three things together should uniquely fix a page).

Parameters

integer $group_id

group identifier of group wiki page belongs to

string $page_name

title of wiki page to look up

string $locale_tag

IANA language tag of page to lookup

Returns

mixed —

$page_id of page if exists, false otherwise

pagesLinkedWithRelationship()

pagesLinkedWithRelationship(integer  $page_id,integer  $group_id,string  $page_name,string  $relationship,string  $limit,string  $num): \seekquarry\yioop\models\two

Gets all the pages that are linked to a particular wiki page by providing a particular relationship type.

Parameters

integer $page_id

identifier for the current page

integer $group_id

group that wiki page belongs

string $page_name

name of the current page (in case page didn't exist before)

string $relationship

the type of relationship linking the wiki pages

string $limit

first row we want from the result set

string $num

number of rows we want starting from the first row in the result set

Returns

\seekquarry\yioop\models\two —

arrays of elements which represent all pages linked to and from the given wiki page with a particular relationship

getRelationshipsToFromPage()

getRelationshipsToFromPage(integer  $page_id,string  $limit,string  $num): array

Gets all the relationship types between this particular wiki page and all other pages that it is linked to.

Parameters

integer $page_id

identifier for the current page

string $limit

first row we want from the result set

string $num

number of rows we want starting from the first row in the result set

Returns

array —

of relationship types which represent all relationships between the given wiki page and all other linked wiki pages

countPageRelationships()

countPageRelationships(integer  $page_id)

Gets if there is any page related to this particular wiki page.

Parameters

integer $page_id

identifier for the current page

getPageInfoByName()

getPageInfoByName(integer  $group_id,string  $name,string  $locale_tag,string  $mode): array

Return the page id, page string, and discussion thread id of the most recent revision of a wiki page

Parameters

integer $group_id

group identifier of group wiki page belongs to

string $name

title of wiki page to look up

string $locale_tag

IANA language tag of page to lookup

string $mode

if "edit" we assume we are looking up the page so that it can be edited and so we return the most recent non-parsed revision of the page. Otherwise, we assume the page is meant to be read and so we return the variant of the page where wiki markup has already been replaced with HTML

Returns

array —

(page_id, page, discussion_id) of desired wiki page

getPageInfoByThread()

getPageInfoByThread(integer  $page_thread_id): array

Returns the group_id, language, and page name of a wiki page corresponding to a page discussion thread with id $page_thread_id

Parameters

integer $page_thread_id

the id of a wiki page discussion thread to look up page info for

Returns

array —

(group_id, language, and page name) of that wiki page

getPageInfoByPageId()

getPageInfoByPageId(integer  $page_id): array

Returns the group_id, language, and page name of a wiki page corresponding to $page_id

Parameters

integer $page_id

to look up page info for

Returns

array —

(group_id, language, and page name) of that wiki page

getHistoryPage()

getHistoryPage(integer  $page_id,integer  $pubdate): array

Returns an historical revision of a wiki page

Parameters

integer $page_id

identifier of wiki page want revision for

integer $pubdate

timestamp of revision desired

Returns

array —

(id, non-parsed wiki page, page_name, group id, locale_tag, discussion thread id) of page revision

getPageHistoryList()

getPageHistoryList(integer  $page_id,integer  $limit,integer  $num): array

Returns a list of revision history info for a wiki page.

Parameters

integer $page_id

identifier for page want revision history of

integer $limit

first row we want from the result set

integer $num

number of rows we want starting from the first row in the result set

Returns

array —

elements of which are array with the revision date (PUBDATE), user name, page length, edit reason for the wiki pages revision

getGroupIdPageIdSubPathFromName()

getGroupIdPageIdSubPathFromName(string  $complete_group_page_name,string  $locale_tag = \seekquarry\yioop\configs\DEFAULT_LOCALE): array

Given the Wiki name in the format GroupName@PageName/sub_path/some_file returns array [group_id, page_id, sub_path, some_file] for the given resource. If one of the components is missing in the above, does its best guess for the value

Parameters

string $complete_group_page_name

formated as described in summary

string $locale_tag

language of wiki page

Returns

array —

[group_id, page_id, sub_path, some_file]

getGroupPageResourcesFolders()

getGroupPageResourcesFolders(integer  $group_id,integer  $page_id,string  $sub_path = "",boolean  $create = false,boolean  $check_redirect = true): array

Returns the folder and thumb folder associated with the resources of a wiki page. Also returns base folders of these which may be different if there is a sub_path.

Parameters

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want folder paths for

string $sub_path

file system path within the resource folder to get the folder name for

boolean $create

if folder doesn't exist whether to create it or not

boolean $check_redirect

whether to check the default group page folder for a redirect to a different folder

Returns

array —

(page_folder, thumb_folder, base_page_folder, base_thumb_folder)

insertResourcesParsePage()

insertResourcesParsePage(integer  $group_id,integer  $page_id,string  $locale_tag,string  $parsed_page,string  $csrf_token = "",string  $controller = 'admin',string  $include_charts_and_spreadsheets = false): string

Given a wiki page that has been parsed to html except for wiki syntax related to resources, this method adds the html to include these resources

Parameters

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to parse resources for

string $locale_tag

the locale of the parsed page.

string $parsed_page

the parsed wiki page before resources added

string $csrf_token

to prevent cross-site request forgery

string $controller

name of controller (admin or group) that inserted urls should be for

string $include_charts_and_spreadsheets

Returns

string —

resulting html page

insertVideoImageResourceParsePage()

insertVideoImageResourceParsePage(string  $mime_type,string  $parsed_page,boolean  $thumb_resource,string  $resource_name,string  $resource_url,string  $resource_description,string  $autoplay,string  $current_folder,string  $data_resource,string  $match_string,string  $locale_tag,string  $csrf_token,integer  $group_id,integer  $current_page_id,string  $sub_path): string

Auxiliary method for @see insertResourcesParsePage used to insert video and image resources into an otherwise parsed to HTML wiki page.

Parameters

string $mime_type

of resource to insert

string $parsed_page

partiall parsed wiki page to insert resources into

boolean $thumb_resource

whether this is a thumbnail image resource.

string $resource_name

name of resource that is being inserted

string $resource_url

url of resource that's being inserted

string $resource_description

human description of resource to be inserted

string $autoplay

html code for attribute saying whether or not this is an autoplay resource

string $current_folder

folder in which resource lives, so can check if there is an associated vtt transscript of audio

string $data_resource

if the Video or Image resource is a data url, then the string of that data url. If this case we use this only to know if should pother with auxiliary source or track tags

string $match_string

code string that was used to make the portion of the partially parsed wiki page to be replaced with htm for the resource to be inserted

string $locale_tag

tag name language of wiki page

string $csrf_token

cross site request forgery token to be used in links

integer $group_id

group of page into which resources are being inserted

integer $current_page_id

of page within group

string $sub_path

of folder structure of wiki page from which resource comes

Returns

string —

the page with resources inserted

convertSpreadsheetRectangle()

convertSpreadsheetRectangle(array  $spreadsheet_coords): array

Used to convert a pair of spreadsheet coordinates into a pair of integer rectangular coordinates. For example [A3, B4] into [[0,2], [1, 3]]

Parameters

array $spreadsheet_coords

a pair of spreadsheet cell coordinates

Returns

array —

rectangular integer pair corresponding to these coordinates

spreadsheetRectangleData()

spreadsheetRectangleData(array  $rectangle,  $data): array

Given a pair of coordinates [top-left, bottom-right] in a spreadsheet returns the rectangular portion of the data in the spreadsheet corresponding to these coordinates.

Parameters

array $rectangle

coordinates to use when getting data out of spreadsheet

$data

Returns

array —

2D array corresponding to the portion of the spreadsheet defined by the rectangle given.

evaluateCell()

evaluateCell(  $cell_expression,  $location,  $data,  $operator_pos): array

Used to evaluate a cell of a CSV spreadsheet. This code runs on the server. In scripts folder there is almost identical Javascript code in spreadsheet.js that runs on the client.

Parameters

$cell_expression
$location
$data
$operator_pos

Returns

array —

[new_loc, the value of the cell or the String 'NaN' if the expression was not evaluatable]

evaluateFactor()

evaluateFactor(string  $cell_expression,integer  $location,array  $data): array

Used to evaluate the left hand factor of a binary operator appearing in a CSV spreadsheet cell

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of factor protion that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evalFunctionInvocation()

evalFunctionInvocation(string  $cell_expression,integer  $location,array  $data): array

Used to evaluate a function call appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of function call that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evalParenthesizedExpression()

evalParenthesizedExpression(string  $cell_expression,integer  $location,array  $data): array

Used to evaluate a spreadsheet expression surrounded by parentheses appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of parentheses expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evaluateArgListExpression()

evaluateArgListExpression(string  $cell_expression,integer  $location,array  $data): array

Used to evaluate the expressions in a list of arguments to a function call appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of argument list that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, array of arg-list]

evalRangeExpression()

evalRangeExpression(string  $cell_expression,integer  $location,array  $data): array

Used to convert range expressions, cell_name1:cell_name2 into a sequence of cells, cell_name1, .

.., cell_name2 so that it may be used as part of an argument list to a function call appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of range expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, array of range cells]

evalNegatedExpression()

evalNegatedExpression(string  $cell_expression,integer  $location,array  $data): array

Used to parse expression of the form: -expr appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of negated expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evalNumericExpression()

evalNumericExpression(string  $cell_expression,integer  $location,array  $data): array

Used to parse a integer or float expression appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of integer or float expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evalCellNameExpression()

evalCellNameExpression(string  $cell_expression,integer  $location,array  $data): array

Used to parse an expression of the form letter sequence followed by number sequence corresponding to the name of a spreadsheet cell appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of cell name expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

evalStringExpression()

evalStringExpression(string  $cell_expression,integer  $location,array  $data): array

Used to parse a string expression, "some string" or 'some string', appearing in a CSV spreadsheet cell formula

Parameters

string $cell_expression

cell formula to evaluate

integer $location

start offset in cell expression of string expression that this method needs to evaluate

array $data

array of spreadsheet data to be used for evaluation

Returns

array —

[new_loc, the value of sub-expression]

skipWhiteSpace()

skipWhiteSpace(string  $cell_expression,integer  $location): integer

Finds the next non-whitespace location in the provided spreadsheet $cell_expression after position $location

Parameters

string $cell_expression

cell formula to search in

integer $location

start offset to bbegin search at

Returns

integer —

location of non-whitespace character or the length of the cell expression

cellNameAsRowColumn()

cellNameAsRowColumn(string  $cell_name): array

Converts a string of the form letter sequence followed by number sequence to an array of int's of the form [row, column]

Parameters

string $cell_name

name of spreadsheet cell to convert

Returns

array —

[row, column] name corresponds to

letterRepresentation()

letterRepresentation(integer  $number): string

Converts a decimal number to a base 26 number string using A-Z for 0-25.

Used where drawing column headers for spreadsheet

Parameters

integer $number

the value to convert to base 26

Returns

string —

result of conversion

versionGroupPage()

versionGroupPage(integer  $user_id,integer  $page_id,  $version_reason)

Creates a new version of a wiki page in the GROUP_PAGE_HISTORY without changing the page contents, but with an edit reason. This function might be called when a resource has been added to the page so that one can restore to a variant of the page with earlier resource lists.

Parameters

integer $user_id

of user responsible for version being created

integer $page_id

of page that new version is being made for

$version_reason

revertResources()

revertResources(integer  $page_id,integer  $group_id,integer  $timestamp)

Called to revert a wiki pages resources to those that existed for the wiki page at a give time

Parameters

integer $page_id

of page that new version is being made for

integer $group_id

of group wiki page belongs to

integer $timestamp

of when to revert resources back to

deleteResource()

deleteResource(string  $resource_name,integer  $group_id,integer  $page_id,string  $sub_path = ""): boolean

Deletes a resource (image, video, etc) associated with a wiki page or group feed post belong to a group

Parameters

string $resource_name

name of resource to delete

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to delete resource from

string $sub_path

path to a subfolder of default resource folder if desired

Returns

boolean —

whether the deletion was successful

extractResource()

extractResource(string  $resource_name,integer  $group_id,integer  $page_id,string  $sub_path = ""): boolean

Uncompresses a compressed resource associated with a wiki page or group feed post belong to a group

Parameters

string $resource_name

name of resource to delete

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to delete resource from

string $sub_path

path to a subfolder of default resource folder if desired

Returns

boolean —

whether the deletion was successful

deleteResources()

deleteResources(integer  $group_id,integer  $page_id,string  $sub_path = ""): boolean

Deletes all resources (image, video, etc) associated with a wiki page belonging to a group.

Parameters

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to delete resource from

string $sub_path

path to a subfolder of default resource folder if desired

Returns

boolean —

whether the deletion was successful

newResource()

newResource(string  $resource_type,integer  $group_id,integer  $page_id,string  $sub_path = ""): boolean

Create a new resource in the given group and page's resource folder/sub_path of the type requests.

Parameters

string $resource_type

either new-file or new-folder

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to delete resource from

string $sub_path

path to a subfolder of default resource folder if desired

Returns

boolean —

whether the deletion was successful

renameResource()

renameResource(string  $old_resource_name,string  $new_resource_name,integer  $group_id,integer  $page_id,string  $sub_path = ""): boolean

Renames a resource (image, video, etc) associated with a wiki page belonging to a group.

Parameters

string $old_resource_name

name of resource before renaming

string $new_resource_name

name of resource after renaming

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to delete resource from

string $sub_path

path to a subfolder of default resource folder if desired

Returns

boolean —

whether the deletion was successful

copyFileToGroupPageResource()

copyFileToGroupPageResource(string  $tmp_name,string  $file_name,string  $mime_type,integer  $group_id,integer  $page_id,string  $sub_path = "",string  $data = "")

Moves a file that has been uploaded via a wiki pages resource form to its correct position in the resources folder so it shows up for that page. For images and video (if FFMPEG configued) thumbs are generated. For video if FFMPEG is configured then a schedule is added to the media_convert folder so that the media_updater can produce mp4 and webm files corresponding to the video file.

Parameters

string $tmp_name

tmp location that uploaded file initially stored at

string $file_name

file name of file that has been uploaded

string $mime_type

mime type of uploaded file

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want copy a page resource for

string $sub_path

used to specify sub-folder of default resource folder to copy to

string $data

string data for file to use instead of filename (only used in case run non-empty)

getPageResource()

getPageResource(string  $file_name,integer  $group_id,integer  $page_id,string  $sub_path = ""): string

Reads in and returns as a string the contents of a resource that has been associated to a page.

Parameters

string $file_name

file name of page resource desired

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want copy a page resource for

string $sub_path

subpath with the resource folder that should be used to look up filename in

Returns

string —

desired page resource

setPageResource()

setPageResource(string  $file_name,string  $resource_data,integer  $group_id,integer  $page_id,string  $sub_path = "")

Saves the string for an page resource that has been updated to the appropriate folder for that wiki page.

Parameters

string $file_name

file name of page resource desired

string $resource_data

the data to be saved

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want copy a page resource for

string $sub_path

subpath with the resource folder that should be add to resource path and filename

makeThumbStripExif()

makeThumbStripExif(string  $file_name,string  $folder,string  $thumb_folder,string  $mime_type = ""): boolean

Makes a thumbnail for files of a type that thumbs can be generated for and strips exif data on jpegs images (only if PHP has exif functions enabled).

Parameters

string $file_name

name of file to create thumb for

string $folder

the folder in which the file lives

string $thumb_folder

the folder in which to save thumbs

string $mime_type

the mime type of the file

Returns

boolean —

whether a thumb was made or not

copyResourceToClipFolder()

copyResourceToClipFolder(array  $clip_folder,string  $resource_name,integer  $group_id,integer  $page_id,string  $sub_path = "")

Used to copy from a resource in the provided folder to the current clip folder

Parameters

array $clip_folder

data about the folder to make a hard link of file resource in

string $resource_name

what to link

integer $group_id

id of group the file resource belongs to

integer $page_id

id of page the file resource belongs to

string $sub_path

path within the page resource folder to the folder that contains the resource to link

getGroupPageResourceUrls()

getGroupPageResourceUrls(integer  $group_id,integer  $page_id,string  $sub_path = "",boolean  $create = false): array

Gets all the urls of resources belonging to a particular groups wiki page.

Parameters

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to get page resources for

string $sub_path

additional path beneath the default folder used for the resource folder

boolean $create

if folder doesn't exist whether to create it or not

Returns

array —

(url_prefix - prefix to apply to all urls, thum_prefix prefix to apply to a resource name to get its thumb, list of resources). Each resource is an pair (name - string file name of the resource, has_thumb a boolean as to whether the resource has a thumb)

getGroupPageResourceUrl()

getGroupPageResourceUrl(string  $csrf_token,integer  $group_id,integer  $page_id,string  $resource_name,string  $sub_path = ""): string

Return the url needed to get a resource of a given resource name that belongs to the provided group and page.

Parameters

string $csrf_token

a token used to prevent CSRF attacks

integer $group_id

group identifier of group wiki page belongs to

integer $page_id

identifier for page want to get page resources for

string $resource_name

file name of resource

string $sub_path

additional path beneath the default folder used for the resource folder

Returns

string —

relative url to get resource

getGroupPageCount()

getGroupPageCount(integer  $group_id): integer

Returns the number of non-empty wiki pages a group has (across all locales)

Parameters

integer $group_id

id of group to return the number of wiki pages for

Returns

integer —

number of wiki pages for that group

getPageList()

getPageList(integer  $group_id,string  $locale_tag,string  $filter,string  $limit,string  $num): array

Returns a list of applicable wiki pages of a group

Parameters

integer $group_id

of group want list of wiki pages for

string $locale_tag

language want wiki page list for

string $filter

string we want to filter wiki page title by

string $limit

first row we want from the result set

string $num

number of rows we want starting from the first row in the result set

Returns

array —

a pair ($total, $pages) where $total is the total number of rows that could be returned if $limit and $num not present $pages is an array each of whose elements is an array corresponding to one TITLE and the first 100 chars out of a wiki page.

getGroupBots()

getGroupBots(string  $group_id): array

Get an array of bots that belong to a group

Parameters

string $group_id

the group_id to get bots for

Returns

array —

of bot rows