GroupModel
extends Model
in package
implements
MediaConstants
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.
Tags
Interfaces, Classes, Traits and Enums
- MediaConstants
- Shared constants and enums used by components that are involved in the media related operations
Table of Contents
- DEFAULT_DESCRIPTION_LENGTH = 150
- Default maximum character length of a search summary
- MAX_SNIPPET_TITLE_LENGTH = 20
- MIN_SNIPPET_LENGTH = 100
- NEEDS_DESCRIPTION_FILE = \seekquarry\yioop\configs\APP_DIR . "/resources/needs_descriptions.txt"
- File to tell DescriptionUpdateJob that a wiki resource folder might have files that need descriptions
- NEEDS_THUMBS_DIR = \seekquarry\yioop\configs\APP_DIR . "/resources/needs_thumbs"
- Directory to tell WikiThumbDetailJob that a wiki resource needs a thumb
- SNIPPET_LENGTH_LEFT = 20
- SNIPPET_LENGTH_RIGHT = 40
- SNIPPET_TITLE_LENGTH = 20
- $any_fields : array<string|int, mixed>
- 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
- $cache : object
- Cache object to be used if we are doing caching
- $db : object
- Reference to a DatasourceManager
- $db_name : string
- Name of the search engine database
- $edited_page_summaries : array<string|int, mixed>
- Associative array of page summaries which might be used to override default page summaries if set.
- $private_db : object
- Reference to a private DatasourceManager
- $private_db_name : string
- Name of the private search engine database
- $search_table_column_map : array<string|int, mixed>
- Associations of the form name of field for web forms => database column names/abbreviations In this case, things will in general map to the SOCIAL_GROUPS, o USER_GROUP or GROUP_ITEM tables in the Yioop database
- $web_site : object
- Reference to a WebSite object in use to serve pages (if any)
- __construct() : mixed
- Sets up the database manager that will be used and name of the search engine database
- addGroup() : int
- Add a groupname to the database using provided string
- addGroupItem() : int
- Creates a new group item
- addGroupItemModeration() : int
- Adds a flagged group item to the moderation group
- addUserGroup() : mixed
- Add an allowed user to an existing group
- alreadyFlagged() : mixed
- Checks if post is already flagged
- alreadyVoted() : bool
- Returns true or false depending on whether a given user has voted on a given post or not
- approveFlaggedPost() : mixed
- Moderator approves a flagged post
- boldKeywords() : string
- Given a string, wraps in bold html tags a set of key words it contains.
- cellNameAsRowColumn() : array<string|int, mixed>
- Converts a string of the form letter sequence followed by number sequence to an array of int's of the form [row, column]
- changeOwnerGroup() : mixed
- To update the OWNER_ID of a group
- checkUserGroup() : int
- 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)
- convertSpreadsheetRectangle() : array<string|int, mixed>
- Used to convert a pair of spreadsheet coordinates into a pair of integer rectangular coordinates. For example [A3, B4] into [[0,2], [1, 3]]
- copyFileToGroupPageResource() : mixed
- 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 configured) 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.
- copyResourceToClipFolder() : mixed
- Used to copy a resource in the provided folder to the user's clip folder
- copyThreadResources() : mixed
- Copies resources associated with a thread post in one group to the resource folders associated with a different group and thread id
- countGroupUsers() : int
- Get the number of users which belong to a group and whose user_name matches a filter
- countPageRelationships() : mixed
- Gets if there is any page related to this particular wiki page.
- countUserGroups() : int
- Get a count of the number of groups to which user_id belongs.
- createIfNecessaryDirectory() : int
- Creates a directory and sets it to world permission if it doesn't already exist
- cullExpiredGroupItems() : mixed
- Deletes Group Items which are older than the expiry date for posts for that group
- decrypt() : string
- Decrypts data based on provided key.
- decryptFlag() : string
- Decrypts flag value based on provided key.
- deletableUser() : bool
- 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
- deleteFlaggedPost() : mixed
- Deletes a flagged post from group items
- deleteGroup() : mixed
- Delete a group from the database and any associated data in GROUP_ITEM and USER_GROUP tables.
- deleteGroupItem() : mixed
- Removes a group feed item from the GROUP_ITEM table.
- deleteResource() : bool
- Deletes a resource (image, video, etc) associated with a wiki page or group feed post belong to a group
- deleteResources() : bool
- Deletes all resources (image, video, etc) associated with a wiki page belonging to a group.
- deleteUserGroup() : mixed
- Delete a user from a group by userid an groupid
- emptyClipFolder() : mixed
- Deletes the resources in the clipboard of user with id $user_id
- encrypt() : string
- Encrypts data based on provided key.
- encryptFlag() : string
- Encrypts flag value based on provided key.
- evalCellNameExpression() : array<string|int, mixed>
- 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
- evalFunctionInvocation() : array<string|int, mixed>
- Used to evaluate a function call appearing in a CSV spreadsheet cell formula
- evalNegatedExpression() : array<string|int, mixed>
- Used to parse expression of the form: -expr appearing in a CSV spreadsheet cell formula
- evalNumericExpression() : array<string|int, mixed>
- Used to parse a integer or float expression appearing in a CSV spreadsheet cell formula
- evalParenthesizedExpression() : array<string|int, mixed>
- Used to evaluate a spreadsheet expression surrounded by parentheses appearing in a CSV spreadsheet cell formula
- evalRangeExpression() : array<string|int, mixed>
- 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
- evalStringExpression() : array<string|int, mixed>
- Used to parse a string expression, "some string" or 'some string', appearing in a CSV spreadsheet cell formula
- evaluateArgListExpression() : array<string|int, mixed>
- Used to evaluate the expressions in a list of arguments to a function call appearing in a CSV spreadsheet cell formula
- evaluateCell() : array<string|int, mixed>
- 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.
- evaluateFactor() : array<string|int, mixed>
- Used to evaluate the left hand factor of a binary operator appearing in a CSV spreadsheet cell
- extractResource() : bool
- Uncompresses a compressed resource associated with a wiki page or group feed post belong to a group
- fileGetContents() : 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.
- filePutContents() : mixed
- 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.
- flagGroupItem() : mixed
- Flags a group feed item in the GROUP_ITEM table.
- formatSinglePageResult() : array<string|int, mixed>
- 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.
- fromCallback() : 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 overridden in subclasses of Model
- getClipboardResourceNames() : array<string|int, mixed>
- Get the names of the resources in the clipboard of $user_id
- getDbmsList() : array<string|int, mixed>
- Gets a list of all DBMS that work with the search engine
- getFeedClipboardId() : int
- Get the id of the clipboard thread used for moving around group items for a given user.
- getFlagCount() : mixed
- Retrieves flag column value from the database
- getGroupBots() : array<string|int, mixed>
- Get an array of bots that belong to a group
- getGroupById() : array<string|int, mixed>
- Returns information about the group with id $group_id provided that the requesting user $user_id has access to it
- getGroupId() : int
- Get group id associated with groupname (so groupnames better be unique)
- getGroupIdPageIdSubPathFromName() : array<string|int, mixed>
- 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
- getGroupItem() : array<string|int, mixed>
- Returns the GROUP_FEED item with the given id
- getGroupItemCount() : int
- 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
- getGroupItems() : array<string|int, mixed>
- 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.
- getGroupKey() : string
- Get the key of a private/encrypted group.
- getGroupName() : string
- Get group id associated with groupname (so groupnames better be unique)
- getGroupPageCount() : int
- Returns the number of non-empty wiki pages a group has (across all locales)
- getGroupPageResourcesFolders() : array<string|int, mixed>
- 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.
- getGroupPageResourceUrl() : string
- Return the url needed to get a resource of a given resource name that belongs to the provided group and page.
- getGroupPageResourceUrls() : array<string|int, mixed>
- Gets all the urls of resources belonging to a particular groups wiki page.
- getGroupPostCount() : int
- Returns the number of posts to a group
- getGroupThreadCount() : int
- Returns the number of distinct threads in a group's feed
- getGroupThreadId() : int
- Get the PARENT_ID of a thread based on the group-id opf group thread is in, the user_id of the user posting the thread and the exact thread title
- getGroupUserIds() : array<string|int, mixed>
- Get user id's of all members of a group determined by a group_id
- getGroupUsers() : array<string|int, mixed>
- Get an array of users that belong to a group
- getHistoryPage() : array<string|int, mixed>
- Returns an historical revision of a wiki page
- getMessagesThreadTitle() : string
- Messages use the same storage mechanism as group posts, so need a title, The title used is always computed as the `-` concatenation of the sorted id's of the participants in the message session. This method computes such a title string from an array of message participants.
- getMostRecentGroupPost() : array<string|int, mixed>
- Returns the most recent post posted to a group
- getPageHistoryList() : array<string|int, mixed>
- Returns a list of revision history info for a wiki page.
- getPageId() : 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).
- getPageInfoByName() : array<string|int, mixed>
- Return the page id, page string, and discussion thread id of the most recent revision of a wiki page
- getPageInfoByPageId() : array<string|int, mixed>
- Returns the group_id, language, and page name of a wiki page corresponding to $page_id
- getPageInfoByThread() : array<string|int, mixed>
- Returns the group_id, language, page name, last modified date of a wiki pagecorresponding to a page discussion thread with id $page_thread_id
- getPageList() : array<string|int, mixed>
- Returns a list of applicable wiki pages of a group
- getPageResource() : string
- Reads in and returns as a string the contents of a resource that has been associated to a page.
- getPageType() : mixed
- Returns the page type of an unparsed wiki page
- getParentGroupId() : mixed
- Get the group id of the parent thread
- getParentIdOfParentPost() : mixed
- Get parent_id of the parent thread of a given post
- getParentPostById() : mixed
- Get the id of the parent thread of a post
- getPersonalGroupId() : int
- Get group id of personal group of a User.
- getRegisterType() : int
- 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)
- getRelationshipId() : array<string|int, mixed>
- Returns the id of the relationship between wiki pages with the given name
- getRelationshipsToFromPage() : array<string|int, mixed>
- Gets all the relationship types between this particular wiki page and all other pages that it is linked to.
- getResourceDescription() : string
- Gets the text description file of a resource
- getRows() : array<string|int, mixed>
- Gets a range of rows which match the provided search criteria from $th provided table
- getSnippets() : 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.
- getTemplateMap() : array<string|int, mixed>
- Returns an array page_id => page_name of all templates for a given Group for a given language
- getThreadFollowers() : array<string|int, mixed>
- Returns an array of user information about users who have contributed to a thread or own the group a thread belongs to
- getThreadPostCount() : int
- Returns the number of posts to a thread
- getThresholdValue() : mixed
- Get the minimum number of times a post has to be flagged to be reviewed by the moderator
- getUserGroups() : array<string|int, mixed>
- 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
- getUserId() : 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)
- getUserPostCount() : int
- Returns the number of posts to groups that a user belongs to since a timestamp
- insertResourcesParsePage() : 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
- insertVideoImageResourceParsePage() : string
- Auxiliary method for @see insertResourcesParsePage used to insert video and image resources into an otherwise parsed to HTML wiki page.
- isGroupEncrypted() : bool
- Check whether group's encryption is enabled or not
- isSingleLocalhost() : bool
- Used to determine if an action involves just one yioop instance on the current local machine or not
- isUserIdInContacts() : bool
- Checks is a given $user_id is in the list of users of the personcal group of a $contact_user_id
- letterRepresentation() : string
- Converts a decimal number to a base 26 number string using A-Z for 0-25.
- linkResourceFolders() : mixed
- Creates a symlink between two resource folders (and their associate thumb folders)
- loginDbms() : bool
- Returns whether the provided dbms needs a login and password or not (sqlite or sqlite3)
- makeThumbStripExif() : bool
- 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).
- moveResourceToClipFolder() : mixed
- Used to move a resource in the provided folder to the user's clip folder
- newResource() : bool
- Create a new resource in the given group and page's resource folder/sub_path of the type requests.
- pagesLinkedWithRelationship() : two
- Gets all the pages that are linked to a particular wiki page by providing a particular relationship type.
- pasteAllClipFolder() : mixed
- Used to paste all resources from the user's clip folder to the provided folder
- pasteFromClipFolder() : mixed
- Used to paste a resource from the user's clip folder to the provided folder
- postQueryCallback() : array<string|int, mixed>
- 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
- renameResource() : bool
- Renames a resource (image, video, etc) associated with a wiki page belonging to a group.
- revertResources() : mixed
- Called to revert a wiki pages resources to those that existed for the wiki page at a give time
- rowCallback() : array<string|int, mixed>
- Called after as row is retrieved by getRows from the database to perform some manipulation that would be useful for this model.
- searchArrayToWhereOrderClauses() : array<string|int, mixed>
- 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
- selectCallback() : string
- Used to determine the select clause for SOCIAL_GROUPS table when do query to marshal group objects for the controller mainly in mangeGroups
- setPageName() : int
- 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
- setPageResource() : mixed
- Saves the string for an page resource that has been updated to the appropriate folder for that wiki page.
- setResourceDescription() : bool
- Sets the text description file of a resource
- skipWhiteSpace() : int
- Finds the next non-whitespace location in the provided spreadsheet $cell_expression after position $location
- spreadsheetRectangleData() : array<string|int, mixed>
- 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.
- translateDb() : mixed
- Used to get the translation of a string_id stored in the database to the given locale.
- updateGroup() : mixed
- Takes the passed associated array $group representing changes fields of a SOCIAL_GROUPS row, and executes an UPDATE statement to persist those changes fields to the database.
- updateGroupItem() : mixed
- Updates a group feed item's title and description. This assumes the given item already exists.
- updateStatusUserGroup() : mixed
- Change the status of a user in a group
- versionGroupPage() : mixed
- 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.
- voteDown() : mixed
- Casts one up vote by a user to a post
- voteUp() : mixed
- Casts one up vote by a user to a post
- whereCallback() : 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
- getClipTransferPaths() : mixed
- Helper method to get file_paths for copying/moving resources to a user's personal clipboard
Constants
DEFAULT_DESCRIPTION_LENGTH
Default maximum character length of a search summary
public
mixed
DEFAULT_DESCRIPTION_LENGTH
= 150
MAX_SNIPPET_TITLE_LENGTH
public
mixed
MAX_SNIPPET_TITLE_LENGTH
= 20
MIN_SNIPPET_LENGTH
public
mixed
MIN_SNIPPET_LENGTH
= 100
NEEDS_DESCRIPTION_FILE
File to tell DescriptionUpdateJob that a wiki resource folder might have files that need descriptions
public
mixed
NEEDS_DESCRIPTION_FILE
= \seekquarry\yioop\configs\APP_DIR . "/resources/needs_descriptions.txt"
NEEDS_THUMBS_DIR
Directory to tell WikiThumbDetailJob that a wiki resource needs a thumb
public
mixed
NEEDS_THUMBS_DIR
= \seekquarry\yioop\configs\APP_DIR . "/resources/needs_thumbs"
SNIPPET_LENGTH_LEFT
public
mixed
SNIPPET_LENGTH_LEFT
= 20
SNIPPET_LENGTH_RIGHT
public
mixed
SNIPPET_LENGTH_RIGHT
= 40
SNIPPET_TITLE_LENGTH
public
mixed
SNIPPET_TITLE_LENGTH
= 20
Properties
$any_fields
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
public
array<string|int, mixed>
$any_fields
= ["access", "register", "voting", "lifetime"]
$cache
Cache object to be used if we are doing caching
public
static object
$cache
$db
Reference to a DatasourceManager
public
object
$db
$db_name
Name of the search engine database
public
string
$db_name
$edited_page_summaries
Associative array of page summaries which might be used to override default page summaries if set.
public
array<string|int, mixed>
$edited_page_summaries
= null
$private_db
Reference to a private DatasourceManager
public
object
$private_db
$private_db_name
Name of the private search engine database
public
string
$private_db_name
$search_table_column_map
Associations of the form name of field for web forms => database column names/abbreviations In this case, things will in general map to the SOCIAL_GROUPS, o USER_GROUP or GROUP_ITEM tables in the Yioop database
public
array<string|int, mixed>
$search_table_column_map
= ["access" => "G.MEMBER_ACCESS", "created_time" => "G.CREATED_TIME", "group_id" => "G.GROUP_ID", "post_id" => "GI.ID", "join_date" => "UG.JOIN_DATE", "name" => "G.GROUP_NAME", "owner" => "O.USER_NAME", "pub_date" => "GI.PUBDATE", "parent_id" => "GI.PARENT_ID", "register" => "G.REGISTER_TYPE", "status" => "UG.STATUS", "user_id" => "O.USER_ID", "voting" => "G.VOTE_ACCESS", "lifetime" => "G.POST_LIFETIME", "key" => "G.GROUP_ID"]
$web_site
Reference to a WebSite object in use to serve pages (if any)
public
object
$web_site
Methods
__construct()
Sets up the database manager that will be used and name of the search engine database
public
__construct([string $db_name = CDB_NAME ][, bool $connect = true ][, mixed $web_site = null ]) : mixed
Parameters
- $db_name : string = CDB_NAME
-
the name of the database for the search engine
- $connect : bool = true
-
whether to connect to the database by default after making the datasource class
- $web_site : mixed = null
Return values
mixed —addGroup()
Add a groupname to the database using provided string
public
addGroup(string $group_name, int $user_id[, int $register = CREQUEST_JOIN ][, int $member = CGROUP_READ ][, int $voting = CNON_VOTING_GROUP ][, int $post_lifetime = CFOREVER ], int $encryption) : int
Parameters
- $group_name : string
-
the groupname to be added
- $user_id : int
-
user identifier of who owns the group
- $register : int = CREQUEST_JOIN
-
flag that says what kinds of registration are allowed for this group INVITE_ONLY_JOIN, REQUEST_JOIN, PUBLIC_JOIN, or some group fee amount in credits 100, 200, 500, 1000, 2000
- $member : int = CGROUP_READ
-
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)
- $voting : int = CNON_VOTING_GROUP
-
flag that says how members can vote on each others posts: NON_VOTING_GROUP, UP_VOTING_GROUP, UP_DOWN_VOTING_GROUP
- $post_lifetime : int = CFOREVER
-
specifies the time in seconds that posts should live before they expire and are deleted
- $encryption : int
-
0 means don't encrypt group, 1 means encrypt group
Return values
int —id of group added
addGroupItem()
Creates a new group item
public
addGroupItem(int $parent_id, int $group_id, int $user_id, string $title, string $description[, int $type = CSTANDARD_GROUP_ITEM ], int $post_time[, string $url = "" ], int $edit_time, int $ups, int $downs, int $flag) : int
Parameters
- $parent_id : int
-
thread id to use for the item
- $group_id : int
-
what group the item should be added to
- $user_id : int
-
of user making the post
- $title : string
-
title of the group feed item
- $description : string
-
actual content of the post
- $type : int = CSTANDARD_GROUP_ITEM
-
flag saying what kind of group item this is. One of STANDARD_GROUP_ITEM, WIKI_GROUP_ITEM (used for threads discussing a wiki page)
- $post_time : int
-
timstamp for when this group item was created default to the current time
- $url : string = ""
-
a url associated with this group item (mainly for search group, otherwise use empty string)
- $edit_time : int
-
timestamp for when this group item was last edited
- $ups : int
-
number of times the item has been upvoted
- $downs : int
-
number of times the item has been down voted
- $flag : int
-
number of times the item has been flagged
Return values
int —$id of item added
addGroupItemModeration()
Adds a flagged group item to the moderation group
public
addGroupItemModeration(int $parent_id, int $group_id, int $user_id, string $title, string $description, mixed $flag, mixed $parent_item_id, mixed $parent_group_id[, int $type = CSTANDARD_GROUP_ITEM ], int $post_time[, string $url = "" ]) : int
Parameters
- $parent_id : int
-
thread id to use for the item
- $group_id : int
-
what group the item should be added to
- $user_id : int
-
of user making the post
- $title : string
-
title of the group feed item
- $description : string
-
actual content of the post
- $flag : mixed
- $parent_item_id : mixed
- $parent_group_id : mixed
- $type : int = CSTANDARD_GROUP_ITEM
-
flag saying what kind of group item this is. One of STANDARD_GROUP_ITEM, WIKI_GROUP_ITEM (used for threads discussing a wiki page)
- $post_time : int
-
timstamp for when this group item was created default to the current time
- $url : string = ""
-
a url associated with this group item (mainly for search group)
Return values
int —$id of item added
addUserGroup()
Add an allowed user to an existing group
public
addUserGroup(string $user_id, string $group_id[, int $status = CACTIVE_STATUS ]) : mixed
Parameters
- $user_id : string
-
the id of the user to add
- $group_id : string
-
the group id of the group to add the user to
- $status : int = CACTIVE_STATUS
-
what should be the membership status of the added user. Should be one of ACTIVE_STATUS, INACTIVE_STATUS, SUSPENDED_STATUS, INVITED_STATUS
Return values
mixed —alreadyFlagged()
Checks if post is already flagged
public
alreadyFlagged(mixed $user_id, int $post_id) : mixed
Parameters
- $user_id : mixed
- $post_id : int
-
to check if the thread is already flagged
Return values
mixed —alreadyVoted()
Returns true or false depending on whether a given user has voted on a given post or not
public
alreadyVoted(int $user_id, int $post_id) : bool
Parameters
- $user_id : int
-
id of user to check if voted
- $post_id : int
-
id of GROUP_ITEM to see if voted on
Return values
bool —whether or not the user has voted on that item
approveFlaggedPost()
Moderator approves a flagged post
public
approveFlaggedPost(int $post_id) : mixed
Parameters
- $post_id : int
-
to fetch the flagged post
Return values
mixed —boldKeywords()
Given a string, wraps in bold html tags a set of key words it contains.
public
boldKeywords(string $text, array<string|int, mixed> $words) : string
Parameters
- $text : string
-
haystack string to look for the key words
- $words : array<string|int, mixed>
-
an array of words to bold face
Return values
string —the resulting string after boldfacing has been applied
cellNameAsRowColumn()
Converts a string of the form letter sequence followed by number sequence to an array of int's of the form [row, column]
public
cellNameAsRowColumn(string $cell_name) : array<string|int, mixed>
Parameters
- $cell_name : string
-
name of spreadsheet cell to convert
Return values
array<string|int, mixed> —[row, column] name corresponds to
changeOwnerGroup()
To update the OWNER_ID of a group
public
changeOwnerGroup(string $user_id, string $group_id) : mixed
Parameters
- $user_id : string
-
the id of the user who becomes the admin of group
- $group_id : string
-
the group id to transfer admin privileges
Return values
mixed —checkUserGroup()
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)
public
checkUserGroup(int $user_id, int $group_id[, int $status = -1 ]) : int
Parameters
- $user_id : int
-
user to look up
- $group_id : int
-
group to check if member of
- $status : int = -1
-
membership type
Return values
int —whether or not is a member
convertSpreadsheetRectangle()
Used to convert a pair of spreadsheet coordinates into a pair of integer rectangular coordinates. For example [A3, B4] into [[0,2], [1, 3]]
public
convertSpreadsheetRectangle(array<string|int, mixed> $spreadsheet_coords) : array<string|int, mixed>
Parameters
- $spreadsheet_coords : array<string|int, mixed>
-
a pair of spreadsheet cell coordinates
Return values
array<string|int, mixed> —rectangular integer pair corresponding to these coordinates
copyFileToGroupPageResource()
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 configured) 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.
public
copyFileToGroupPageResource(string $tmp_name, string $file_name, string $mime_type, int $group_id, int $page_id[, string $sub_path = "" ][, string $data = "" ]) : mixed
Parameters
- $tmp_name : string
-
tmp location that uploaded file initially stored at
- $file_name : string
-
file name of file that has been uploaded
- $mime_type : string
-
mime type of uploaded file
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want copy a page resource for
- $sub_path : string = ""
-
used to specify sub-folder of default resource folder to copy to
- $data : string = ""
-
string data for file to use instead of filename (only used in case run non-empty)
Return values
mixed —copyResourceToClipFolder()
Used to copy a resource in the provided folder to the user's clip folder
public
copyResourceToClipFolder(int $user_id, string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $user_id : int
-
of user whose clip_folder copying to
- $resource_name : string
-
what to copy
- $group_id : int
-
id of group the file resource belongs to
- $page_id : int
-
id of page the file resource belongs to
- $sub_path : string = ""
-
path within the page resource folder to the folder that contains the resource to copy
Return values
mixed —copyThreadResources()
Copies resources associated with a thread post in one group to the resource folders associated with a different group and thread id
public
copyThreadResources(int $from_group_id, int $from_thread_id, int $to_group_id, int $to_thread_id) : mixed
Parameters
- $from_group_id : int
-
group resources are coming from
- $from_thread_id : int
-
thread post to get resources from
- $to_group_id : int
-
group that we are copying to
- $to_thread_id : int
-
resource folder of this thread post will be copied to
Return values
mixed —countGroupUsers()
Get the number of users which belong to a group and whose user_name matches a filter
public
countGroupUsers(int $group_id[, string $filter = "" ]) : int
Parameters
- $group_id : int
-
id of the group to get a count of
- $filter : string = ""
-
to filter usernames by
Return values
int —count of matching users
countPageRelationships()
Gets if there is any page related to this particular wiki page.
public
countPageRelationships(int $page_id) : mixed
Parameters
- $page_id : int
-
identifier for the current page
Return values
mixed —countUserGroups()
Get a count of the number of groups to which user_id belongs.
public
countUserGroups(int $user_id[, string $filter = "" ][, bool $include_personal = false ][, array<string|int, mixed> $allowed_statuses = [CACTIVE_STATUS] ]) : int
Parameters
- $user_id : int
-
to get groups for
- $filter : string = ""
-
to LIKE filter groups
- $include_personal : bool = false
-
whether to include $user_id's personal group
- $allowed_statuses : array<string|int, mixed> = [CACTIVE_STATUS]
-
a list of group membership statuses that to restrict the returned list to
Return values
int —number of groups of the filtered type for the user
createIfNecessaryDirectory()
Creates a directory and sets it to world permission if it doesn't already exist
public
createIfNecessaryDirectory(string $directory) : int
Parameters
- $directory : string
-
name of directory to create
Return values
int —-1 on failure, 0 if already existed, 1 if created
cullExpiredGroupItems()
Deletes Group Items which are older than the expiry date for posts for that group
public
cullExpiredGroupItems() : mixed
Return values
mixed —decrypt()
Decrypts data based on provided key.
public
decrypt(string $data, string $key[, string $cipher_method = 'aes-256-cbc' ]) : string
Parameters
- $data : string
-
what data to decrypt
- $key : string
-
what key to use to decrypt
- $cipher_method : string = 'aes-256-cbc'
-
a cipher encrypt/decrypt method supported by OpenSSL
Return values
string —$out_data the decrypted string
decryptFlag()
Decrypts flag value based on provided key.
public
decryptFlag(mixed $encrypted_data, string $key[, string $cipher_method = 'AES-256-ECB' ]) : string
Parameters
- $encrypted_data : mixed
- $key : string
-
what key to use to decrypt
- $cipher_method : string = 'AES-256-ECB'
-
a cipher encrypt/decrypt method supported by OpenSSL
Return values
string —$out_data the decrypted string
deletableUser()
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
public
deletableUser(int $user_id, int $group_id) : bool
Parameters
- $user_id : int
-
which user to look up
- $group_id : int
-
which group to look up for
Return values
bool —where user is deletable
deleteFlaggedPost()
Deletes a flagged post from group items
public
deleteFlaggedPost(int $post_id, string $message) : mixed
Parameters
- $post_id : int
-
to fetch the flagged post
- $message : string
-
string to show for the removed post
Return values
mixed —deleteGroup()
Delete a group from the database and any associated data in GROUP_ITEM and USER_GROUP tables.
public
deleteGroup(string $group_id) : mixed
Parameters
- $group_id : string
-
id of the group to delete
Return values
mixed —deleteGroupItem()
Removes a group feed item from the GROUP_ITEM table.
public
deleteGroupItem(int $post_id, int $user_id) : mixed
Parameters
- $post_id : int
-
of item to remove
- $user_id : int
-
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
Return values
mixed —deleteResource()
Deletes a resource (image, video, etc) associated with a wiki page or group feed post belong to a group
public
deleteResource(string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $resource_name : string
-
name of resource to delete
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
deleteResources()
Deletes all resources (image, video, etc) associated with a wiki page belonging to a group.
public
deleteResources(int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
deleteUserGroup()
Delete a user from a group by userid an groupid
public
deleteUserGroup(string $user_id, string $group_id) : mixed
Parameters
- $user_id : string
-
the userid of the user to delete
- $group_id : string
-
the group id of the group to delete
Return values
mixed —emptyClipFolder()
Deletes the resources in the clipboard of user with id $user_id
public
emptyClipFolder(int $user_id) : mixed
Parameters
- $user_id : int
-
that we want to delete the contents of the clipboard for
Return values
mixed —encrypt()
Encrypts data based on provided key.
public
encrypt(string $data, string $key[, string $cipher_method = 'aes-256-cbc' ]) : string
Parameters
- $data : string
-
what data to encrypt
- $key : string
-
what key to use to encrypt
- $cipher_method : string = 'aes-256-cbc'
-
a cipher encrypt/decrypt method supported by OpenSSL
Return values
string —$out_data the encrypted string
encryptFlag()
Encrypts flag value based on provided key.
public
encryptFlag(string $data, string $key[, string $cipher_method = 'AES-256-ECB' ]) : string
Parameters
- $data : string
-
what data to encrypt
- $key : string
-
what key to use to encrypt
- $cipher_method : string = 'AES-256-ECB'
-
a cipher encrypt/decrypt method supported by OpenSSL
Return values
string —$out_data the encrypted string
evalCellNameExpression()
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
public
evalCellNameExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of cell name expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evalFunctionInvocation()
Used to evaluate a function call appearing in a CSV spreadsheet cell formula
public
evalFunctionInvocation(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of function call that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evalNegatedExpression()
Used to parse expression of the form: -expr appearing in a CSV spreadsheet cell formula
public
evalNegatedExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of negated expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evalNumericExpression()
Used to parse a integer or float expression appearing in a CSV spreadsheet cell formula
public
evalNumericExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of integer or float expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evalParenthesizedExpression()
Used to evaluate a spreadsheet expression surrounded by parentheses appearing in a CSV spreadsheet cell formula
public
evalParenthesizedExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of parentheses expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evalRangeExpression()
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
public
evalRangeExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of range expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, array of range cells]
evalStringExpression()
Used to parse a string expression, "some string" or 'some string', appearing in a CSV spreadsheet cell formula
public
evalStringExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of string expression that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
evaluateArgListExpression()
Used to evaluate the expressions in a list of arguments to a function call appearing in a CSV spreadsheet cell formula
public
evaluateArgListExpression(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of argument list that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, array of arg-list]
evaluateCell()
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.
public
evaluateCell(mixed $cell_expression, mixed $location, mixed $data, mixed $operator_pos) : array<string|int, mixed>
Parameters
- $cell_expression : mixed
- $location : mixed
- $data : mixed
- $operator_pos : mixed
Return values
array<string|int, mixed> —[new_loc, the value of the cell or the String 'NaN' if the expression was not evaluatable]
evaluateFactor()
Used to evaluate the left hand factor of a binary operator appearing in a CSV spreadsheet cell
public
evaluateFactor(string $cell_expression, int $location, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $cell_expression : string
-
cell formula to evaluate
- $location : int
-
start offset in cell expression of factor protion that this method needs to evaluate
- $data : array<string|int, mixed>
-
array of spreadsheet data to be used for evaluation
Return values
array<string|int, mixed> —[new_loc, the value of sub-expression]
extractResource()
Uncompresses a compressed resource associated with a wiki page or group feed post belong to a group
public
extractResource(string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $resource_name : string
-
name of resource to delete
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
fileGetContents()
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.
public
fileGetContents(string $filename[, bool $force_read = false ]) : string
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
- $filename : string
-
name of file to get contents of
- $force_read : bool = false
-
whether to force the file to be read from persistent storage rather than the cache
Return values
string —contents of the file given by $filename
filePutContents()
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.
public
filePutContents(string $filename, string $data) : mixed
Parameters
- $filename : string
-
name of file to write to persistent storages
- $data : string
-
string of data to store in file
Return values
mixed —flagGroupItem()
Flags a group feed item in the GROUP_ITEM table.
public
flagGroupItem(int $post_id, int $user_id) : mixed
Parameters
- $post_id : int
-
of item to be flagged
- $user_id : int
-
the id of the person trying to flag the item If user does not belong to the group, the item won't be flagged
Return values
mixed —formatSinglePageResult()
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.
public
formatSinglePageResult(array<string|int, mixed> $page[, array<string|int, mixed> $words = null ][, int $description_length = self::DEFAULT_DESCRIPTION_LENGTH ]) : array<string|int, mixed>
Parameters
- $page : array<string|int, mixed>
-
a single search result summary
- $words : array<string|int, mixed> = null
-
keywords (typically what was searched on)
- $description_length : int = self::DEFAULT_DESCRIPTION_LENGTH
-
length of the description
Return values
array<string|int, mixed> —$page which has been snippified and bold faced
fromCallback()
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 overridden in subclasses of Model
public
fromCallback([mixed $args = null ]) : string
Parameters
- $args : mixed = null
-
any additional arguments which should be used to determine these tables (in this case none)
Return values
string —a comma separated list of tables suitable for a SQL query
getClipboardResourceNames()
Get the names of the resources in the clipboard of $user_id
public
getClipboardResourceNames(int $user_id) : array<string|int, mixed>
Parameters
- $user_id : int
-
of user we want to get clipboard resource names for
Return values
array<string|int, mixed> —names of resources in clipboard
getDbmsList()
Gets a list of all DBMS that work with the search engine
public
getDbmsList() : array<string|int, mixed>
Return values
array<string|int, mixed> —Names of available data sources
getFeedClipboardId()
Get the id of the clipboard thread used for moving around group items for a given user.
public
getFeedClipboardId(int $user_id) : int
Parameters
- $user_id : int
-
id of user to get the clipboard thread for
Return values
int —id of thread
getFlagCount()
Retrieves flag column value from the database
public
getFlagCount(int $post_id) : mixed
Parameters
- $post_id : int
-
of thread whose flag value needs to be fetched
Return values
mixed —getGroupBots()
Get an array of bots that belong to a group
public
getGroupBots(string $group_id) : array<string|int, mixed>
Parameters
- $group_id : string
-
the group_id to get bots for
Return values
array<string|int, mixed> —of bot rows
getGroupById()
Returns information about the group with id $group_id provided that the requesting user $user_id has access to it
public
getGroupById(int $group_id, int $user_id[, bool $require_root_or_member = false ]) : array<string|int, mixed>
Parameters
- $group_id : int
-
id of group to look up
- $user_id : int
-
user asking for group info
- $require_root_or_member : bool = false
-
require the $user_id to be in the group or root
Return values
array<string|int, mixed> —row from group table or false (if no access or doesn't exists)
getGroupId()
Get group id associated with groupname (so groupnames better be unique)
public
getGroupId(string $group_name) : int
Parameters
- $group_name : string
-
to use to look up a group_id
Return values
int —group_id corresponding to the groupname.
getGroupIdPageIdSubPathFromName()
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
public
getGroupIdPageIdSubPathFromName(string $complete_group_page_name[, string $locale_tag = CDEFAULT_LOCALE ]) : array<string|int, mixed>
Parameters
- $complete_group_page_name : string
-
formatted as described in summary
- $locale_tag : string = CDEFAULT_LOCALE
-
language of wiki page
Return values
array<string|int, mixed> —[group_id, page_id, sub_path, some_file]
getGroupItem()
Returns the GROUP_FEED item with the given id
public
getGroupItem(int $item_id[, mixed $is_group_id = false ]) : array<string|int, mixed>
Parameters
- $item_id : int
-
the item to get info about
- $is_group_id : mixed = false
Return values
array<string|int, mixed> —row from GROUP_FEED table
getGroupItemCount()
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
public
getGroupItemCount([array<string|int, mixed> $search_array = [] ][, int $user_id = CROOT_ID ][, int $for_group = -1 ]) : int
Parameters
- $search_array : array<string|int, mixed> = []
-
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
- $user_id : int = CROOT_ID
-
who is making this request to determine which
- $for_group : int = -1
-
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
Return values
int —number of items matching the search criteria for the given user_id
getGroupItems()
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.
public
getGroupItems(int $limit[, int $num = 100 ][, array<string|int, mixed> $search_array = [] ][, int $user_id = CROOT_ID ][, int $for_group = -1 ]) : array<string|int, mixed>
Parameters
- $limit : int
-
starting offset group item to display
- $num : int = 100
-
number of items from offset to display
- $search_array : array<string|int, mixed> = []
-
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
- $user_id : int = CROOT_ID
-
who is making this request to determine which
- $for_group : int = -1
-
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
Return values
array<string|int, mixed> —elements of which represent one group feed item
getGroupKey()
Get the key of a private/encrypted group.
public
getGroupKey(int $group_id) : string
Parameters
- $group_id : int
-
to get key for
Return values
string —key of the group
getGroupName()
Get group id associated with groupname (so groupnames better be unique)
public
getGroupName(int $group_id) : string
Parameters
- $group_id : int
-
to use to look up a group name
Return values
string —group_name corresponding to the id.
getGroupPageCount()
Returns the number of non-empty wiki pages a group has (across all locales)
public
getGroupPageCount(int $group_id) : int
Parameters
- $group_id : int
-
id of group to return the number of wiki pages for
Return values
int —number of wiki pages for that group
getGroupPageResourcesFolders()
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.
public
getGroupPageResourcesFolders(int $group_id, int $page_id[, string $sub_path = "" ][, bool $create = false ][, bool $check_redirect = true ][, bool $check_exists = true ]) : array<string|int, mixed>
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want folder paths for
- $sub_path : string = ""
-
file system path within the resource folder to get the folder name for
- $create : bool = false
-
if folder doesn't exist whether to create it or not
- $check_redirect : bool = true
-
whether to check the default group page folder for a redirect to a different folder
- $check_exists : bool = true
-
if true and $create false, then check if the file path exists and return false if it doesn't. If false, and prefix path doesn't exist, this flag will cause it to be created
Return values
array<string|int, mixed> —(page_folder, thumb_folder, base_page_folder, base_thumb_folder)
getGroupPageResourceUrl()
Return the url needed to get a resource of a given resource name that belongs to the provided group and page.
public
getGroupPageResourceUrl(string $csrf_token, int $group_id, int $page_id, string $resource_name[, string $sub_path = "" ]) : string
Parameters
- $csrf_token : string
-
a token used to prevent CSRF attacks
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to get page resources for
- $resource_name : string
-
file name of resource
- $sub_path : string = ""
-
additional path beneath the default folder used for the resource folder
Return values
string —relative url to get resource
getGroupPageResourceUrls()
Gets all the urls of resources belonging to a particular groups wiki page.
public
getGroupPageResourceUrls(int $group_id, int $page_id[, string $sub_path = "" ][, bool $create = false ][, mixed $needs_descriptions_format = null ]) : array<string|int, mixed>
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to get page resources for
- $sub_path : string = ""
-
additional path beneath the default folder used for the resource folder
- $create : bool = false
-
if folder doesn't exist whether to create it or not
- $needs_descriptions_format : mixed = null
Return values
array<string|int, mixed> —(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)
getGroupPostCount()
Returns the number of posts to a group
public
getGroupPostCount(int $group_id, int $timestamp) : int
Parameters
- $group_id : int
-
id of the group to get post count for
- $timestamp : int
-
only post with value pubdate greater or EDIT_DATE than this will be counted
Return values
int —number of posts
getGroupThreadCount()
Returns the number of distinct threads in a group's feed
public
getGroupThreadCount(int $group_id) : int
Parameters
- $group_id : int
-
id of the group to get thread count for
Return values
int —number of threads
getGroupThreadId()
Get the PARENT_ID of a thread based on the group-id opf group thread is in, the user_id of the user posting the thread and the exact thread title
public
getGroupThreadId(int $group_id, int $user_id, string $title) : int
Parameters
- $group_id : int
-
id of group thread is in
- $user_id : int
-
id of user posting to thread
- $title : string
-
exact title of thread
Return values
int —the id of the first thread matching the above criteria
getGroupUserIds()
Get user id's of all members of a group determined by a group_id
public
getGroupUserIds(int $group_id) : array<string|int, mixed>
Parameters
- $group_id : int
-
id of group to get members for
Return values
array<string|int, mixed> —of the group's user ids
getGroupUsers()
Get an array of users that belong to a group
public
getGroupUsers(string $group_id[, string $filter = "" ][, array<string|int, mixed> $sorts = [] ][, int $limit = "" ][, int $num = CNUM_RESULTS_PER_PAGE ]) : array<string|int, mixed>
Parameters
- $group_id : string
-
the group_id to get users for
- $filter : string = ""
-
to LIKE filter users
- $sorts : array<string|int, mixed> = []
-
directions on how to sort the columns of the results format is column_name => direction
- $limit : int = ""
-
first user to get
- $num : int = CNUM_RESULTS_PER_PAGE
-
number of users to return
Return values
array<string|int, mixed> —of USERS rows
getHistoryPage()
Returns an historical revision of a wiki page
public
getHistoryPage(int $page_id, int $pubdate) : array<string|int, mixed>
Parameters
- $page_id : int
-
identifier of wiki page want revision for
- $pubdate : int
-
timestamp of revision desired
Return values
array<string|int, mixed> —(id, non-parsed wiki page, page_name, group id, locale_tag, discussion thread id) of page revision
getMessagesThreadTitle()
Messages use the same storage mechanism as group posts, so need a title, The title used is always computed as the `-` concatenation of the sorted id's of the participants in the message session. This method computes such a title string from an array of message participants.
public
getMessagesThreadTitle(array<string|int, mixed> $thread_follower_ids) : string
Parameters
- $thread_follower_ids : array<string|int, mixed>
-
message chat participants
Return values
string —appropriate title of chat thread.
getMostRecentGroupPost()
Returns the most recent post posted to a group
public
getMostRecentGroupPost(int $group_id) : array<string|int, mixed>
Parameters
- $group_id : int
-
id of the group to get the most recent post for
Return values
array<string|int, mixed> —associate array of post details
getPageHistoryList()
Returns a list of revision history info for a wiki page.
public
getPageHistoryList(int $page_id, int $limit, int $num) : array<string|int, mixed>
Parameters
- $page_id : int
-
identifier for page want revision history of
- $limit : int
-
first row we want from the result set
- $num : int
-
number of rows we want starting from the first row in the result set
Return values
array<string|int, mixed> —elements of which are array with the revision date (PUBDATE), user name, page length, edit reason for the wiki pages revision
getPageId()
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).
public
getPageId(int $group_id, string $page_name, string $locale_tag) : mixed
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_name : string
-
title of wiki page to look up
- $locale_tag : string
-
IANA language tag of page to lookup
Return values
mixed —$page_id of page if exists, false otherwise
getPageInfoByName()
Return the page id, page string, and discussion thread id of the most recent revision of a wiki page
public
getPageInfoByName(int $group_id, string $name, string $locale_tag, string $mode) : array<string|int, mixed>
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $name : string
-
title of wiki page to look up
- $locale_tag : string
-
IANA language tag of page to lookup
- $mode : string
-
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
Return values
array<string|int, mixed> —(page_id, page, discussion_id) of desired wiki page
getPageInfoByPageId()
Returns the group_id, language, and page name of a wiki page corresponding to $page_id
public
getPageInfoByPageId(int $page_id) : array<string|int, mixed>
Parameters
- $page_id : int
-
to look up page info for
Return values
array<string|int, mixed> —(group_id, language, and page name) of that wiki page
getPageInfoByThread()
Returns the group_id, language, page name, last modified date of a wiki pagecorresponding to a page discussion thread with id $page_thread_id
public
getPageInfoByThread(int $page_thread_id) : array<string|int, mixed>
Parameters
- $page_thread_id : int
-
the id of a wiki page discussion thread to look up page info for
Return values
array<string|int, mixed> —(group_id, language, and page name) of that wiki page
getPageList()
Returns a list of applicable wiki pages of a group
public
getPageList(int $group_id, string $locale_tag, string $filter, string $sort, string $limit, string $num) : array<string|int, mixed>
Parameters
- $group_id : int
-
of group want list of wiki pages for
- $locale_tag : string
-
language want wiki page list for
- $filter : string
-
string we want to filter wiki page title by
- $sort : string
-
one of name_asc, name_desc, date_asc, date_desc specifying how the page list should be sorted
- $limit : string
-
first row we want from the result set
- $num : string
-
number of rows we want starting from the first row in the result set
Return values
array<string|int, mixed> —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.
getPageResource()
Reads in and returns as a string the contents of a resource that has been associated to a page.
public
getPageResource(string $file_name, int $group_id, int $page_id[, string $sub_path = "" ][, bool $raw = false ]) : string
Parameters
- $file_name : string
-
file name of page resource desired
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want copy a page resource for
- $sub_path : string = ""
-
subpath with the resource folder that should be used to look up filename in
- $raw : bool = false
-
if csv file don't content to array of rows
Return values
string —desired page resource
getPageType()
Returns the page type of an unparsed wiki page
public
getPageType(string $unparsed_page) : mixed
Parameters
- $unparsed_page : string
-
an unparsed wiki page (i.e., so has the configuration parameters in its head)
Return values
mixed —getParentGroupId()
Get the group id of the parent thread
public
getParentGroupId(int $post_id) : mixed
Parameters
- $post_id : int
-
denotes the thread
Return values
mixed —getParentIdOfParentPost()
Get parent_id of the parent thread of a given post
public
getParentIdOfParentPost(int $post_id) : mixed
Parameters
- $post_id : int
-
denotes the post
Return values
mixed —getParentPostById()
Get the id of the parent thread of a post
public
getParentPostById(int $post_id) : mixed
Parameters
- $post_id : int
-
denotes the thread
Return values
mixed —getPersonalGroupId()
Get group id of personal group of a User.
public
getPersonalGroupId(string $user_id) : int
Parameters
- $user_id : string
-
to use to look up a group_id
Return values
int —group_id of personal group of that user
getRegisterType()
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)
public
getRegisterType(int $group_id) : int
Parameters
- $group_id : int
-
which group to find the type of
Return values
int —the numeric code for the registration type
getRelationshipId()
Returns the id of the relationship between wiki pages with the given name
public
getRelationshipId(string $relationship_type) : array<string|int, mixed>
Parameters
- $relationship_type : string
-
the relationship type to get id about
Return values
array<string|int, mixed> —row from PAGE_RELATIONSHIP table or false (if no access or doesn't exist)
getRelationshipsToFromPage()
Gets all the relationship types between this particular wiki page and all other pages that it is linked to.
public
getRelationshipsToFromPage(int $page_id, string $limit, string $num) : array<string|int, mixed>
Parameters
- $page_id : int
-
identifier for the current page
- $limit : string
-
first row we want from the result set
- $num : string
-
number of rows we want starting from the first row in the result set
Return values
array<string|int, mixed> —of relationship types which represent all relationships between the given wiki page and all other linked wiki pages
getResourceDescription()
Gets the text description file of a resource
public
getResourceDescription(string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : string
Parameters
- $resource_name : string
-
name of resource to set description for
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
string —the text description of a resource
getRows()
Gets a range of rows which match the provided search criteria from $th provided table
public
getRows(int $limit, int $num, int &$total[, array<string|int, mixed> $search_array = [] ][, array<string|int, mixed> $args = null ]) : array<string|int, mixed>
Parameters
- $limit : int
-
starting row from the potential results to return
- $num : int
-
number of rows after start row to return
- $total : int
-
gets set with the total number of rows that can be returned by the given database query
- $search_array : array<string|int, mixed> = []
-
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
- $args : array<string|int, mixed> = null
-
additional values which may be used to get rows (what these are will typically depend on the subclass implementation)
Return values
array<string|int, mixed> —getSnippets()
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.
public
getSnippets(string $text, array<string|int, mixed> $words, string $description_length) : string
There is also a rule that a snippet should avoid ending in the middle of a word
Parameters
- $text : string
-
haystack to extract snippet from
- $words : array<string|int, mixed>
-
keywords used to make look in haystack
- $description_length : string
-
length of the description desired
Return values
string —a concatenation of the extracted snippets of each word
getTemplateMap()
Returns an array page_id => page_name of all templates for a given Group for a given language
public
getTemplateMap(int $group_id, string $locale_tag) : array<string|int, mixed>
Parameters
- $group_id : int
-
id of group to produce template map for
- $locale_tag : string
-
of language to produce template map for
Return values
array<string|int, mixed> —page_id => page_name for each template for the given group in the provided language
getThreadFollowers()
Returns an array of user information about users who have contributed to a thread or own the group a thread belongs to
public
getThreadFollowers(int $thread_id[, int $owner_id = -1 ][, int $exclude_id = -1 ]) : array<string|int, mixed>
Parameters
- $thread_id : int
-
the id of the thread that want users for
- $owner_id : int = -1
-
usually owner of group thread belongs to however could be id of any additional user want info for. If left a default value (-1) than only user's who have contributed to thread will be returned
- $exclude_id : int = -1
-
an id of a user to exclude from the array returned
Return values
array<string|int, mixed> —user information of users following the thread
getThreadPostCount()
Returns the number of posts to a thread
public
getThreadPostCount(int $thread_id, int $timestamp) : int
Parameters
- $thread_id : int
-
id of the thread to get post count for
- $timestamp : int
-
only post with value pubdate greater or EDIT_DATE than this will be counted
Return values
int —number of posts
getThresholdValue()
Get the minimum number of times a post has to be flagged to be reviewed by the moderator
public
getThresholdValue(int $group_id) : mixed
Parameters
- $group_id : int
-
to get threshold value for the given group
Return values
mixed —getUserGroups()
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
public
getUserGroups(int $user_id, string $filter, array<string|int, mixed> $sorts, int $limit[, int $num = CNUM_RESULTS_PER_PAGE ][, bool $include_personal = false ][, array<string|int, mixed> $allowed_statuses = [CACTIVE_STATUS] ]) : array<string|int, mixed>
Parameters
- $user_id : int
-
to get groups for
- $filter : string
-
to LIKE filter groups
- $sorts : array<string|int, mixed>
-
directions on how to sort the columns of the results format is column_name => direction
- $limit : int
-
first user to get
- $num : int = CNUM_RESULTS_PER_PAGE
-
number of users to return
- $include_personal : bool = false
-
whether to include $user_id's personal group
- $allowed_statuses : array<string|int, mixed> = [CACTIVE_STATUS]
-
a list of group membership statuses that to restrict the returned list to
Return values
array<string|int, mixed> —an array of group_id, group_name pairs
getUserId()
Get the user_id associated with a given username (In base class as used as an internal method in both signin and user models)
public
getUserId(string $username) : string
Parameters
- $username : string
-
the username to look up
Return values
string —the corresponding userid
getUserPostCount()
Returns the number of posts to groups that a user belongs to since a timestamp
public
getUserPostCount(int $user_id, int $timestamp) : int
Parameters
- $user_id : int
-
id of the user to get posts for
- $timestamp : int
-
only post with value pubdate greater than this will be counted
Return values
int —number of posts
insertResourcesParsePage()
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
public
insertResourcesParsePage(int $group_id, int $page_id, string $locale_tag, string $parsed_page[, string $csrf_token = "" ][, string $controller = 'admin' ][, string $include_charts_and_spreadsheets = false ]) : string
Parameters
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to parse resources for
- $locale_tag : string
-
the locale of the parsed page.
- $parsed_page : string
-
the parsed wiki page before resources added
- $csrf_token : string = ""
-
to prevent cross-site request forgery
- $controller : string = 'admin'
-
name of controller (admin or group) that inserted urls should be for
- $include_charts_and_spreadsheets : string = false
Return values
string —resulting html page
insertVideoImageResourceParsePage()
Auxiliary method for @see insertResourcesParsePage used to insert video and image resources into an otherwise parsed to HTML wiki page.
public
insertVideoImageResourceParsePage(string $mime_type, string $parsed_page, bool $thumb_resource, bool $nolink_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, int $group_id, int $current_page_id, string $sub_path) : string
Parameters
- $mime_type : string
-
of resource to insert
- $parsed_page : string
-
partiall parsed wiki page to insert resources into
- $thumb_resource : bool
-
whether this is a thumbnail image resource.
- $nolink_resource : bool
-
whether this is a nolink image resource (one not enclosed is a link to the resource).
- $resource_name : string
-
name of resource that is being inserted
- $resource_url : string
-
url of resource that's being inserted
- $resource_description : string
-
human description of resource to be inserted
- $autoplay : string
-
html code for attribute saying whether or not this is an autoplay resource
- $current_folder : string
-
folder in which resource lives, so can check if there is an associated vtt transscript of audio
- $data_resource : string
-
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
- $match_string : 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
- $locale_tag : string
-
tag name language of wiki page
- $csrf_token : string
-
cross site request forgery token to be used in links
- $group_id : int
-
group of page into which resources are being inserted
- $current_page_id : int
-
of page within group
- $sub_path : string
-
of folder structure of wiki page from which resource comes
Return values
string —the page with resources inserted
isGroupEncrypted()
Check whether group's encryption is enabled or not
public
isGroupEncrypted(int $group_id) : bool
Parameters
- $group_id : int
-
to check for encryption value
Return values
bool —whether the group is encrypted or not
isSingleLocalhost()
Used to determine if an action involves just one yioop instance on the current local machine or not
public
isSingleLocalhost(array<string|int, mixed> $machine_urls[, string $index_timestamp = -1 ]) : bool
Parameters
- $machine_urls : array<string|int, mixed>
-
urls of yioop instances to which the action applies
- $index_timestamp : string = -1
-
if timestamp exists checks if the index has declared itself to be a no network index.
Return values
bool —whether it involves a single local yioop instance (true) or not (false)
isUserIdInContacts()
Checks is a given $user_id is in the list of users of the personcal group of a $contact_user_id
public
isUserIdInContacts(int $user_id, int $contact_user_id) : bool
Parameters
- $user_id : int
-
user id to check if in other personal group
- $contact_user_id : int
-
user id to check personal group of
Return values
bool —whether $user_id was in list of contacts or not
letterRepresentation()
Converts a decimal number to a base 26 number string using A-Z for 0-25.
public
letterRepresentation(int $number) : string
Used where drawing column headers for spreadsheet
Parameters
- $number : int
-
the value to convert to base 26
Return values
string —result of conversion
linkResourceFolders()
Creates a symlink between two resource folders (and their associate thumb folders)
public
linkResourceFolders(string $link_group_id, string $link_store_id, string $target_group_id, string $target_store_id) : mixed
Parameters
- $link_group_id : string
-
group with page that is going to get the symlink
- $link_store_id : string
-
page_id of page that is going to get the symlink
- $target_group_id : string
-
group whose page resources will be linked to
- $target_store_id : string
-
page whose page resources will be linked to
Return values
mixed —loginDbms()
Returns whether the provided dbms needs a login and password or not (sqlite or sqlite3)
public
loginDbms(string $dbms) : bool
Parameters
- $dbms : string
-
the name of a database management system
Return values
bool —true if needs a login and password; false otherwise
makeThumbStripExif()
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).
public
makeThumbStripExif(string $file_name, string $folder, string $thumb_folder[, string $mime_type = "" ]) : bool
Parameters
- $file_name : string
-
name of file to create thumb for
- $folder : string
-
the folder in which the file lives
- $thumb_folder : string
-
the folder in which to save thumbs
- $mime_type : string = ""
-
the mime type of the file
Return values
bool —whether a thumb was made or not
moveResourceToClipFolder()
Used to move a resource in the provided folder to the user's clip folder
public
moveResourceToClipFolder(int $user_id, string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $user_id : int
-
of user whose clip_folder moving to
- $resource_name : string
-
what to move
- $group_id : int
-
id of group the file resource belongs to
- $page_id : int
-
id of page the file resource belongs to
- $sub_path : string = ""
-
path within the page resource folder to the folder that contains the resource to move
Return values
mixed —newResource()
Create a new resource in the given group and page's resource folder/sub_path of the type requests.
public
newResource(string $resource_type, int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $resource_type : string
-
either new-file or new-folder
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
pagesLinkedWithRelationship()
Gets all the pages that are linked to a particular wiki page by providing a particular relationship type.
public
pagesLinkedWithRelationship(int $page_id, int $group_id, string $page_name, string $relationship, string $limit, string $num) : two
Parameters
- $page_id : int
-
identifier for the current page
- $group_id : int
-
group that wiki page belongs
- $page_name : string
-
name of the current page (in case page didn't exist before)
- $relationship : string
-
the type of relationship linking the wiki pages
- $limit : string
-
first row we want from the result set
- $num : string
-
number of rows we want starting from the first row in the result set
Return values
two —arrays of elements which represent all pages linked to and from the given wiki page with a particular relationship
pasteAllClipFolder()
Used to paste all resources from the user's clip folder to the provided folder
public
pasteAllClipFolder(int $user_id, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $user_id : int
-
of user whose clip_folder copying to
- $group_id : int
-
id of group the file resource belongs to
- $page_id : int
-
id of page the file resource belongs to
- $sub_path : string = ""
-
path within the page resource folder to the folder that contains the resource to copy
Return values
mixed —pasteFromClipFolder()
Used to paste a resource from the user's clip folder to the provided folder
public
pasteFromClipFolder(int $user_id, string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $user_id : int
-
of user whose clip_folder copying to
- $resource_name : string
-
what to copy
- $group_id : int
-
id of group the file resource belongs to
- $page_id : int
-
id of page the file resource belongs to
- $sub_path : string = ""
-
path within the page resource folder to the folder that contains the resource to copy
Return values
mixed —postQueryCallback()
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
public
postQueryCallback(array<string|int, mixed> $rows) : array<string|int, mixed>
Parameters
- $rows : array<string|int, mixed>
-
that have been calculated so far by getRows
Return values
array<string|int, mixed> —$rows after this final manipulation
renameResource()
Renames a resource (image, video, etc) associated with a wiki page belonging to a group.
public
renameResource(string $old_resource_name, string $new_resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $old_resource_name : string
-
name of resource before renaming
- $new_resource_name : string
-
name of resource after renaming
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
revertResources()
Called to revert a wiki pages resources to those that existed for the wiki page at a give time
public
revertResources(int $page_id, int $group_id, int $timestamp) : mixed
Parameters
- $page_id : int
-
of page that new version is being made for
- $group_id : int
-
of group wiki page belongs to
- $timestamp : int
-
of when to revert resources back to
Return values
mixed —rowCallback()
Called after as row is retrieved by getRows from the database to perform some manipulation that would be useful for this model.
public
rowCallback(array<string|int, mixed> $row, mixed $args) : array<string|int, mixed>
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
- $row : array<string|int, mixed>
-
row as retrieved from database query
- $args : mixed
-
additional arguments that might be used by this callback
Return values
array<string|int, mixed> —$row after callback manipulation
searchArrayToWhereOrderClauses()
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
public
searchArrayToWhereOrderClauses(array<string|int, mixed> $search_array[, array<string|int, mixed> $any_fields = ['status'] ]) : array<string|int, mixed>
Parameters
- $search_array : array<string|int, mixed>
-
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
- $any_fields : array<string|int, mixed> = ['status']
-
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
Return values
array<string|int, mixed> —string for where clause, string for order by clause
selectCallback()
Used to determine the select clause for SOCIAL_GROUPS table when do query to marshal group objects for the controller mainly in mangeGroups
public
selectCallback([mixed $args = null ]) : string
Parameters
- $args : mixed = null
-
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
Return values
string —a comma separated list of columns suitable for a SQL query
setPageName()
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
public
setPageName(int $user_id, int $group_id, string $page_name, string $page, string $locale_tag, string $edit_comment, string $thread_title, string $thread_description[, string $base_address = "" ][, array<string|int, mixed> $additional_substitutions = [] ][, bool $add_relationship_data = true ]) : int
Parameters
- $user_id : int
-
identifier of who is adding this revision
- $group_id : int
-
which group the wiki page revision if being done in
- $page_name : string
-
title of page being revised
- $page : string
-
wiki page with potential wiki mark up containing the revision
- $locale_tag : string
-
locale we are adding the revision to
- $edit_comment : string
-
user's reason for making the revision
- $thread_title : string
-
if this is the first revision, then this should contain the title for the discussion thread about the revision
- $thread_description : string
-
if this is the first revision, then this should be the body of the first post in discussion thread
- $base_address : string = ""
-
default url to be used in links on wiki page that use short syntax
- $additional_substitutions : array<string|int, mixed> = []
-
list of pairs additional wiki page rewrites to do when parsing wiki pages
- $add_relationship_data : bool = true
-
whether to add link relationship data for this wiki page or not (default add, typically won't add for knowledge wiki pages for search results generated by configs/TokenTool.php)
Return values
int —$page_id id of added or updated page
setPageResource()
Saves the string for an page resource that has been updated to the appropriate folder for that wiki page.
public
setPageResource(string $file_name, string $resource_data, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $file_name : string
-
file name of page resource desired
- $resource_data : string
-
the data to be saved
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want copy a page resource for
- $sub_path : string = ""
-
subpath with the resource folder that should be add to resource path and filename
Return values
mixed —setResourceDescription()
Sets the text description file of a resource
public
setResourceDescription(string $resource_name, string $resource_description, int $group_id, int $page_id[, string $sub_path = "" ]) : bool
Parameters
- $resource_name : string
-
name of resource to set description for
- $resource_description : string
-
description of the resource
- $group_id : int
-
group identifier of group wiki page belongs to
- $page_id : int
-
identifier for page want to delete resource from
- $sub_path : string = ""
-
path to a subfolder of default resource folder if desired
Return values
bool —whether the deletion was successful
skipWhiteSpace()
Finds the next non-whitespace location in the provided spreadsheet $cell_expression after position $location
public
skipWhiteSpace(string $cell_expression, int $location) : int
Parameters
- $cell_expression : string
-
cell formula to search in
- $location : int
-
start offset to bbegin search at
Return values
int —location of non-whitespace character or the length of the cell expression
spreadsheetRectangleData()
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.
public
spreadsheetRectangleData(array<string|int, mixed> $rectangle, mixed $data) : array<string|int, mixed>
Parameters
- $rectangle : array<string|int, mixed>
-
coordinates to use when getting data out of spreadsheet
- $data : mixed
Return values
array<string|int, mixed> —2D array corresponding to the portion of the spreadsheet defined by the rectangle given.
translateDb()
Used to get the translation of a string_id stored in the database to the given locale.
public
translateDb(string $string_id, string $locale_tag) : mixed
Parameters
- $string_id : string
-
id to translate
- $locale_tag : string
-
to translate to
Return values
mixed —translation if found, $string_id, otherwise
updateGroup()
Takes the passed associated array $group representing changes fields of a SOCIAL_GROUPS row, and executes an UPDATE statement to persist those changes fields to the database.
public
updateGroup(array<string|int, mixed> $group) : mixed
Parameters
- $group : array<string|int, mixed>
-
associative array with a GROUP_ID as well as the fields to update
Return values
mixed —updateGroupItem()
Updates a group feed item's title and description. This assumes the given item already exists.
public
updateGroupItem(int $id, string $title, string $description) : mixed
Parameters
- $id : int
-
which item to change
- $title : string
-
the new title
- $description : string
-
the new description
Return values
mixed —updateStatusUserGroup()
Change the status of a user in a group
public
updateStatusUserGroup(int $user_id, int $group_id, int $status) : mixed
Parameters
- $user_id : int
-
of user to change
- $group_id : int
-
of group to change status for
- $status : int
-
what the new status should be
Return values
mixed —versionGroupPage()
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.
public
versionGroupPage(int $user_id, int $page_id, mixed $version_reason) : mixed
Parameters
- $user_id : int
-
of user responsible for version being created
- $page_id : int
-
of page that new version is being made for
- $version_reason : mixed
Return values
mixed —voteDown()
Casts one up vote by a user to a post
public
voteDown(int $user_id, int $post_id) : mixed
Parameters
- $user_id : int
-
id of user to cast vote for
- $post_id : int
-
id of post on which to cast vote
Return values
mixed —voteUp()
Casts one up vote by a user to a post
public
voteUp(int $user_id, int $post_id) : mixed
Parameters
- $user_id : int
-
id of user to cast vote for
- $post_id : int
-
id of post on which to cast vote
Return values
mixed —whereCallback()
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
public
whereCallback([array<string|int, mixed> $args = null ]) : string
Parameters
- $args : array<string|int, mixed> = null
-
first two elements are the $user_id of the user and the $browse flag which says whether or not user is browsing through all groups to which he could subscribe and read or just those groups to which he is already subscribed.
Return values
string —a SQL WHERE clause suitable to perform the above restrictions
getClipTransferPaths()
Helper method to get file_paths for copying/moving resources to a user's personal clipboard
private
getClipTransferPaths(int $user_id, string $resource_name, int $group_id, int $page_id[, string $sub_path = "" ]) : mixed
Parameters
- $user_id : int
-
of user whose clip_folder need paths for
- $resource_name : string
-
what to copy/move
- $group_id : int
-
id of group the file resource belongs to
- $page_id : int
-
id of page the file resource belongs to
- $sub_path : string = ""
-
path within the page resource folder to the folder that contains the resource to copy/move