Moodle  2.2.1
http://www.collinsharper.com
repository Class Reference
Inheritance diagram for repository:

Public Member Functions

 __construct ($repositoryid, $context=SYSCONTEXTID, $options=array(), $readonly=0)
 has_moodle_files ()
 copy_to_area ($encoded, $draftitemid, $new_filepath, $new_filename)
 append_suffix ($filename)
 prepare_file ($filename)
 get_link ($url)
 get_file ($url, $filename= '')
 get_file_size ($source)
 is_visible ()
 get_name ()
 supported_filetypes ()
 supported_returntypes ()
 get_meta ()
 delete ()
 hide ($hide= 'toggle')
 set_option ($options=array())
 get_option ($config= '')
 filter (&$value)
 get_listing ($path= '', $page= '')
 search ($search_text)
 logout ()
 check_login ()
 print_login ()
 print_search ()
 callback ()
 global_search ()
 cron ()
 type_config_form ($mform, $classname= 'repository')
 instance_config_form ($mform)
 get_short_filename ($str, $maxlength)
 overwrite_existing_draftfile ($itemid, $filepath, $filename, $newfilepath, $newfilename)
 delete_tempfile_from_draft ($draftitemid, $filepath, $filename)

Static Public Member Functions

static get_type_by_typename ($typename)
static get_type_by_id ($id)
static get_types ($visible=null)
static check_capability ($contextid, $instance)
static draftfile_exists ($itemid, $filepath, $filename)
static get_unused_filename ($itemid, $filepath, $filename)
static get_editable_types ($context=null)
static get_instances ($args=array())
static get_instance ($id)
static static_function ($plugin, $function)
static antivir_scan_file ($thefile, $filename, $deleteinfected)
static move_to_filepool ($thefile, $record)
static build_tree ($fileinfo, $search, $dynamicmode, &$list)
static display_instances_list ($context, $typename=null)
static create ($type, $userid, $context, $params, $readonly=0)
static plugin_init ()
static type_form_validation ($mform, $data, $errors)
static get_type_option_names ()
static get_instance_option_names ()
static instance_form_validation ($mform, $data, $errors)

Data Fields

 $disabled = false
 $id
 $context
 $options
 $readonly
 $returntypes
 $instance

Detailed Description

Definition at line 472 of file lib.php.


Constructor & Destructor Documentation

__construct ( repositoryid,
context = SYSCONTEXTID,
options = array(),
readonly = 0 
)

1. Initialize context and options 2. Accept necessary parameters

Parameters:
integer$repositoryidrepository instance id
integer|objecta context id or context object
array$optionsrepository options

Reimplemented in repository_flickr_public.

Definition at line 492 of file lib.php.

Here is the call graph for this function:


Member Function Documentation

static antivir_scan_file ( thefile,
filename,
deleteinfected 
) [static]

Scan file, throws exception in case of infected file.

Please note that the scanning engine must be able to access the file, permissions of the file are not modified here!

Parameters:
string$thefile
string$filenamename of the file
bool$deleteinfected
Returns:
void

Definition at line 969 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

append_suffix ( filename)

Append a suffix to filename

Parameters:
string$filename
Returns:
string

Definition at line 700 of file lib.php.

Here is the caller graph for this function:

static build_tree ( fileinfo,
search,
dynamicmode,
&$  list 
) [static]

Builds a tree of files This function is then called recursively.

Parameters:
$fileinfoan object returned by file_browser::get_file_info()
$searchsearched string
$dynamicmodebool no recursive call is done when in dynamic mode
$list- the array containing the files under the passed $fileinfo
Returns:
int the number of files found

todo: take $search into account, and respect a threshold for dynamic loading

Definition at line 1113 of file lib.php.

Here is the call graph for this function:

callback ( )

For oauth like external authentication, when external repository direct user back to moodle, this funciton will be called to set up token and token_secret

Reimplemented in repository_boxnet, and repository_dropbox.

Definition at line 1725 of file lib.php.

static check_capability ( contextid,
instance 
) [static]

To check if the context id is valid object $USER

Parameters:
int$contextid
Returns:
boolean

Definition at line 582 of file lib.php.

Here is the call graph for this function:

copy_to_area ( encoded,
draftitemid,
new_filepath,
new_filename 
)

This function is used to copy a moodle file to draft area

object $USER object $DB

Parameters:
string$encodedThe metainfo of file, it is base64 encoded php serialized data
string$draftitemiditemid
string$new_filenameThe intended name of file
string$new_filepaththe new path in draft area
Returns:
array The information of file

Reimplemented in repository_recent.

Definition at line 628 of file lib.php.

Here is the call graph for this function:

static create ( type,
userid,
context,
params,
readonly = 0 
) [static]

Create an instance for this plug-in object $CFG object $DB

Parameters:
string$typethe type of the repository
integer$useridthe user id
object$contextthe context
array$paramsthe options for this instance
integer$readonlywhether to create it readonly or not (defaults to not)
Returns:
mixed

Reimplemented in repository_filesystem.

Definition at line 1473 of file lib.php.

Here is the call graph for this function:

cron ( )

Defines operations that happen occasionally on cron

Returns:
boolean

Definition at line 1740 of file lib.php.

delete ( ) [final]

delete a repository instance object $DB

Returns:
mixed

Definition at line 1518 of file lib.php.

delete_tempfile_from_draft ( draftitemid,
filepath,
filename 
)

Delete a temp file from draft area

Parameters:
int$draftitemid
string$filepath
string$filename
Returns:
boolean

Definition at line 1853 of file lib.php.

Here is the call graph for this function:

static display_instances_list ( context,
typename = null 
) [static]

Display a repository instance list (with edit/delete/create links) object $CFG object $USER object $OUTPUT

Parameters:
object$contextthe context for which we display the instance
string$typenameif set, we display only one type of instance

Definition at line 1196 of file lib.php.

Here is the call graph for this function:

static draftfile_exists ( itemid,
filepath,
filename 
) [static]

Check if file already exists in draft area

Parameters:
int$itemid
string$filepath
string$filename
Returns:
boolean

Definition at line 598 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter ( &$  value)

Definition at line 1610 of file lib.php.

Here is the call graph for this function:

static get_editable_types ( context = null) [static]

Return all types that you a user can create/edit and which are also visible Note: Mostly used in order to know if at least one editable type can be set

Parameters:
object$contextthe context for which we want the editable types
Returns:
array types

Definition at line 715 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_file ( url,
filename = '' 
)

Download a file, this function can be overridden by subclass.

object $CFG

Parameters:
string$urlthe url of file
string$filenamesave location
Returns:
string the location of the file
See also:
curl package

Reimplemented in repository_flickr_public, repository_flickr, repository_dropbox, repository_alfresco, repository_filesystem, repository_googledocs, repository_s3, repository_webdav, and repository_url.

Definition at line 1358 of file lib.php.

Here is the call graph for this function:

get_file_size ( source)

Return size of a file in bytes.

Parameters:
string$sourceencoded and serialized data of file
Returns:
integer file size in bytes

Definition at line 1373 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_instance ( id) [static]

Get single repository instance object $DB object $CFG

Parameters:
integer$idrepository id
Returns:
object repository instance

Definition at line 898 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_instance_option_names ( ) [static]

Return names of the instance options By default: no instance option name

Returns:
array

Reimplemented in repository_flickr_public, repository_alfresco, repository_webdav, and repository_filesystem.

Definition at line 1801 of file lib.php.

static get_instances ( args = array()) [static]

Return repository instances object $DB object $CFG object $USER

Parameters:
array$argsArray containing the following keys: currentcontext context onlyvisible type accepted_types return_types userid
Returns:
array repository instances

Definition at line 751 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_link ( url)

Return file URL, for most plugins, the parameter is the original url, but some plugins use a file id, so we need this function to convert file id to original url.

Parameters:
string$urlthe url of file
Returns:
string

Reimplemented in repository_flickr_public, repository_flickr, repository_alfresco, and repository_coursefiles.

Definition at line 1344 of file lib.php.

get_listing ( path = '',
page = '' 
)

Given a path, and perhaps a search, get a list of files.

See details on http://docs.moodle.org/dev/Repository_plugins

Parameters:
string$path,thisparameter can a folder name, or a identification of folder
string$page,thepage number of file list
Returns:
array the list of files, including meta infomation, containing the following keys manage, url to manage url client_id login, login form repo_id, active repository id login_btn_action, the login button action login_btn_label, the login button label total, number of results perpage, items per page page pages, total pages issearchresult, is it a search result? list, file list path, current path and parent path

Reimplemented in repository_flickr_public, repository_flickr, repository_boxnet, repository_alfresco, repository_dropbox, repository_youtube, repository_recent, repository_url, repository_picasa, repository_webdav, repository_googledocs, repository_filesystem, and repository_wikimedia.

Definition at line 1665 of file lib.php.

Here is the caller graph for this function:

get_meta ( ) [final]

Provide repository instance information for Ajax object $CFG

Returns:
object

Definition at line 1448 of file lib.php.

Here is the call graph for this function:

get_name ( )

Return the name of this instance, can be overridden. object $DB

Returns:
string

Reimplemented in repository_coursefiles, and repository_picasa.

Definition at line 1416 of file lib.php.

Here is the caller graph for this function:

get_option ( config = '')

Get settings for repository instance object $DB

Parameters:
string$config
Returns:
array Settings

Reimplemented in repository_dropbox, repository_flickr, repository_boxnet, and repository_flickr_public.

Definition at line 1589 of file lib.php.

Here is the caller graph for this function:

get_short_filename ( str,
maxlength 
)

Definition at line 1809 of file lib.php.

Here is the call graph for this function:

static get_type_by_id ( id) [static]

Get the repository type by a given repository type id. object $DB

Parameters:
int$idthe type id
Returns:
object

Definition at line 539 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_type_by_typename ( typename) [static]

Get a repository type object by a given type name. object $DB

Parameters:
string$typenamethe repository type name
Returns:
repository_type|bool

Definition at line 523 of file lib.php.

Here is the call graph for this function:

static get_type_option_names ( ) [static]

Return names of the general options By default: no general option name

Returns:
array

Reimplemented in repository_flickr_public, repository_flickr, repository_dropbox, repository_boxnet, repository_coursefiles, repository_s3, repository_recent, and repository_merlot.

Definition at line 1792 of file lib.php.

static get_types ( visible = null) [static]

Return all repository types ordered by sortorder field first repository type in returnedarray[0], second repository type in returnedarray[1], ... object $DB object $CFG

Parameters:
boolean$visiblecan return types by visiblity, return all types if null
Returns:
array Repository types

Definition at line 557 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_unused_filename ( itemid,
filepath,
filename 
) [static]

Get unused filename by appending suffix

Parameters:
int$itemid
string$filepath
string$filename
Returns:
string

Definition at line 685 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

is it possible to do glboal search?

Returns:
boolean

Reimplemented in repository_flickr, repository_s3, repository_filesystem, repository_flickr_public, repository_youtube, repository_webdav, repository_wikimedia, and repository_merlot.

Definition at line 1732 of file lib.php.

Does this repository used to browse moodle files?

Returns:
boolean

Reimplemented in repository_recent, repository_coursefiles, repository_local, and repository_user.

Definition at line 614 of file lib.php.

Here is the caller graph for this function:

hide ( hide = 'toggle') [final]

Hide/Show a repository object $DB

Parameters:
string$hide
Returns:
boolean

Definition at line 1531 of file lib.php.

instance_config_form ( mform)

Edit/Create Instance Settings Moodle form

Parameters:
object$mformMoodle form (passed by reference)

Reimplemented in repository_flickr_public, repository_alfresco, repository_webdav, and repository_filesystem.

Definition at line 1784 of file lib.php.

static instance_form_validation ( mform,
data,
errors 
) [static]

Reimplemented in repository_filesystem.

Definition at line 1805 of file lib.php.

Return is the instance is visible (is the type visible ? is the context enable ?)

Returns:
boolean

Reimplemented in repository_coursefiles.

Definition at line 1397 of file lib.php.

Here is the call graph for this function:

logout ( )

Logout from repository instance By default, this function will return a login form

Returns:
string

Reimplemented in repository_dropbox, repository_flickr_public, repository_filesystem, repository_alfresco, repository_picasa, repository_googledocs, repository_flickr, repository_wikimedia, and repository_boxnet.

Definition at line 1687 of file lib.php.

Here is the call graph for this function:

static move_to_filepool ( thefile,
record 
) [static]

Move file from download folder to file pool using FILE API object $DB object $CFG object $USER object $OUTPUT

Parameters:
string$thefilefile path in download folder
object$record
Returns:
array containing the following keys: icon file id url

Definition at line 1041 of file lib.php.

Here is the call graph for this function:

overwrite_existing_draftfile ( itemid,
filepath,
filename,
newfilepath,
newfilename 
)

Overwrite an existing file

Parameters:
int$itemid
string$filepath
string$filename
string$newfilepath
string$newfilename
Returns:
boolean

Definition at line 1827 of file lib.php.

Here is the call graph for this function:

static plugin_init ( ) [static]

function which is run when the type is created (moodle administrator add the plugin)

Returns:
boolean success or fail?

Reimplemented in repository_flickr_public, and repository_alfresco.

Definition at line 1748 of file lib.php.

prepare_file ( filename)

Decide where to save the file, can be overwriten by subclass

Parameters:
stringfilename

Definition at line 1319 of file lib.php.

Here is the caller graph for this function:

Show the login screen, if required

Reimplemented in repository_boxnet, repository_flickr, repository_flickr_public, repository_filesystem, repository_merlot, repository_dropbox, repository_alfresco, repository_picasa, repository_url, repository_wikimedia, repository_recent, repository_upload, repository_coursefiles, repository_local, and repository_user.

Definition at line 1704 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Show the search screen, if required

Returns:
null

Reimplemented in repository_flickr_public, and repository_alfresco.

Definition at line 1712 of file lib.php.

search ( search_text)

Search files in repository When doing global search, $search_text will be used as keyword.

Returns:
mixed, see get_listing()

Reimplemented in repository_alfresco, repository_flickr, repository_boxnet, repository_picasa, repository_googledocs, repository_wikimedia, repository_merlot, and repository_youtube.

Definition at line 1675 of file lib.php.

set_option ( options = array())

Save settings for repository instance $repo->set_option(array('api_key'=>'f2188bde132', 'name'=>'dongsheng')); object $DB

Parameters:
array$optionssettings
Returns:
int Id of the record

Reimplemented in repository_dropbox, repository_filesystem, repository_flickr, repository_boxnet, and repository_flickr_public.

Definition at line 1559 of file lib.php.

static static_function ( plugin,
function 
) [static]

Call a static function. Any additional arguments than plugin and function will be passed through. object $CFG

Parameters:
string$plugin
string$function
Returns:
mixed

Definition at line 927 of file lib.php.

Here is the caller graph for this function:

what kind of files will be in this repository?

Returns:
array return '*' means this repository support any files, otherwise return mimetypes of files, it can be an array

Reimplemented in repository_flickr_public, repository_flickr, repository_dropbox, repository_merlot, repository_youtube, repository_googledocs, and repository_picasa.

Definition at line 1430 of file lib.php.

Here is the caller graph for this function:

type_config_form ( mform,
classname = 'repository' 
)

Edit/Create Admin Settings Moodle form

Parameters:
object$mformMoodle form (passed by reference)
string$classnamerepository class name

Definition at line 1757 of file lib.php.

static type_form_validation ( mform,
data,
errors 
) [static]

Validate Admin Settings Moodle form

Parameters:
object$mformMoodle form (passed by reference)
arrayarray of ("fieldname"=>value) of submitted data
arrayarray of ("fieldname"=>errormessage) of errors
Returns:
array array of errors

Definition at line 1775 of file lib.php.


Field Documentation

Definition at line 478 of file lib.php.

$disabled = false

Definition at line 475 of file lib.php.

$id

Definition at line 476 of file lib.php.

Definition at line 483 of file lib.php.

$options

Definition at line 479 of file lib.php.

$readonly

Definition at line 480 of file lib.php.

$returntypes

Definition at line 481 of file lib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations