idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
28,000
protected function process_assign_userflag ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> assignment = $ this -> get_new_parentid ( 'assign' ) ; $ data -> userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ; if ( ! empty ( $ data -> allocatedmarker ) ) { $ data ->...
Process a user_flags restore
28,001
protected function process_assign_grade ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> assignment = $ this -> get_new_parentid ( 'assign' ) ; $ data -> userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ; $ data -> grader = $ this -> get_mappingid ( 'user' , $ dat...
Process a grade restore
28,002
protected function process_assign_plugin_config ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> assignment = $ this -> get_new_parentid ( 'assign' ) ; $ newitemid = $ DB -> insert_record ( 'assign_plugin_config' , $ data ) ; }
Process a plugin - config restore
28,003
protected function add_plugin_config_files ( $ subtype ) { $ dummyassign = new assign ( null , null , null ) ; $ plugins = $ dummyassign -> load_plugins ( $ subtype ) ; foreach ( $ plugins as $ plugin ) { $ component = $ plugin -> get_subtype ( ) . '_' . $ plugin -> get_type ( ) ; $ areas = $ plugin -> get_config_file_...
Restore files from plugin configuration
28,004
protected function process_assign_override ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ userinfo = $ this -> get_setting_value ( 'userinfo' ) ; if ( ! $ userinfo && ! is_null ( $ data -> userid ) ) { return ; } $ groupinfo = $ this -> get_setting_value ( 'groups' ) ; if ( ! $ group...
Process a assign override restore
28,005
protected function after_execute ( ) { $ this -> add_related_files ( 'mod_assign' , 'intro' , null ) ; $ this -> add_related_files ( 'mod_assign' , 'introattachment' , null ) ; $ this -> add_plugin_config_files ( 'assignsubmission' ) ; $ this -> add_plugin_config_files ( 'assignfeedback' ) ; $ this -> set_latest_submis...
Once the database tables have been fully restored restore the files
28,006
public static function setup_for_course ( moodle_url $ url , $ course , $ subtitle = '' ) { global $ PAGE ; $ context = context_course :: instance ( $ course -> id ) ; $ PAGE -> set_course ( $ course ) ; if ( ! empty ( $ subtitle ) ) { $ title = $ subtitle ; } else { $ title = get_string ( 'coursecompetencies' , 'tool_...
Set - up a course page .
28,007
public static function setup_for_template ( $ pagecontextid , moodle_url $ url , $ template = null , $ subtitle = '' , $ returntype = null ) { global $ PAGE , $ SITE ; $ pagecontext = context :: instance_by_id ( $ pagecontextid ) ; $ context = $ pagecontext ; if ( ! empty ( $ template ) ) { $ context = $ template -> ge...
Set - up a template page .
28,008
public static function setup_for_plan ( $ userid , moodle_url $ url , $ plan = null , $ subtitle = '' , $ returntype = null ) { global $ PAGE , $ USER ; $ user = core_user :: get_user ( $ userid ) ; if ( ! $ user || ! core_user :: is_real_user ( $ userid ) ) { throw new \ moodle_exception ( 'invaliduser' , 'error' ) ; ...
Set - up a plan page .
28,009
public static function setup_for_framework ( $ id , $ pagecontextid , $ framework = null , $ returntype = null ) { global $ PAGE ; $ url = new moodle_url ( "/admin/tool/lp/editcompetencyframework.php" , array ( 'id' => $ id , 'pagecontextid' => $ pagecontextid ) ) ; if ( $ returntype ) { $ url -> param ( 'return' , $ r...
Set - up a framework page .
28,010
public static function setup_for_competency ( $ pagecontextid , moodle_url $ url , $ framework , $ competency = null , $ parent = null ) { global $ PAGE , $ SITE ; $ pagecontext = context :: instance_by_id ( $ pagecontextid ) ; $ PAGE -> set_context ( $ pagecontext ) ; if ( $ pagecontext -> contextlevel == CONTEXT_SYST...
Set - up a competency page .
28,011
public static function store_log_for_task ( task_base $ task , string $ logpath , bool $ failed , int $ dbreads , int $ dbwrites , float $ timestart , float $ timeend ) { global $ DB ; $ logdata = ( object ) [ 'type' => is_a ( $ task , scheduled_task :: class ) ? self :: TYPE_SCHEDULED : self :: TYPE_ADHOC , 'component...
Store the log for the specified task .
28,012
public static function cleanup ( ) { global $ CFG , $ DB ; $ params = [ 'retentionperiod' => time ( ) - $ CFG -> task_logretention , ] ; $ logids = $ DB -> get_fieldset_select ( 'task_log' , 'id' , 'timestart < :retentionperiod' , $ params ) ; self :: delete_task_logs ( $ logids ) ; $ sql = "SELECT classname FROM {task...
Cleanup old task logs .
28,013
public static function getTextWidthPixelsExact ( $ text , PHPExcel_Style_Font $ font , $ rotation = 0 ) { if ( ! function_exists ( 'imagettfbbox' ) ) { throw new PHPExcel_Exception ( 'GD library needs to be enabled' ) ; } $ fontFile = self :: getTrueTypeFontFileFromFont ( $ font ) ; $ textBox = imagettfbbox ( $ font ->...
Get GD text width in pixels for a string of text in a certain font at a certain rotation angle
28,014
public static function getTextWidthPixelsApprox ( $ columnText , PHPExcel_Style_Font $ font = null , $ rotation = 0 ) { $ fontName = $ font -> getName ( ) ; $ fontSize = $ font -> getSize ( ) ; switch ( $ fontName ) { case 'Calibri' : $ columnWidth = ( int ) ( 8.26 * PHPExcel_Shared_String :: CountCharacters ( $ column...
Get approximate width in pixels for a string of text in a certain font at a certain rotation angle
28,015
public static function getCharsetFromFontName ( $ name ) { switch ( $ name ) { case 'EucrosiaUPC' : return self :: CHARSET_ANSI_THAI ; case 'Wingdings' : return self :: CHARSET_SYMBOL ; case 'Wingdings 2' : return self :: CHARSET_SYMBOL ; case 'Wingdings 3' : return self :: CHARSET_SYMBOL ; default : return self :: CHA...
Returns the associated charset for the font name .
28,016
public static function getDefaultRowHeightByFont ( PHPExcel_Style_Font $ font ) { switch ( $ font -> getName ( ) ) { case 'Arial' : switch ( $ font -> getSize ( ) ) { case 10 : $ rowHeight = 12.75 ; break ; case 9 : $ rowHeight = 12 ; break ; case 8 : $ rowHeight = 11.25 ; break ; case 7 : $ rowHeight = 9 ; break ; cas...
Get the effective row height for rows without a row dimension or rows with height - 1 For example for Calibri 11 this is 15 points
28,017
public function recode_legacy_state_answer ( $ state ) { $ answer = $ state -> answer ; $ result = '' ; if ( preg_match ( '~^dataset([0-9]+)-(.*)$~' , $ answer , $ matches ) ) { $ itemid = $ matches [ 1 ] ; $ subanswer = $ matches [ 2 ] ; $ substate = new stdClass ( ) ; $ substate -> answer = $ subanswer ; $ newanswer ...
Given one question_states record return the answer recoded pointing to all the restored stuff for calculatedmulti questions
28,018
public static function load_adhoc ( $ mode , $ component , $ area , array $ options = array ( ) ) { $ id = 'adhoc/' . $ component . '_' . $ area ; $ definition = array ( 'mode' => $ mode , 'component' => $ component , 'area' => $ area , ) ; if ( ! empty ( $ options [ 'simplekeys' ] ) ) { $ definition [ 'simplekeys' ] =...
Creates an ah - hoc cache definition given the required params .
28,019
public function get_cache_class ( ) { if ( ! is_null ( $ this -> overrideclass ) ) { return $ this -> overrideclass ; } return cache_helper :: get_class_for_mode ( $ this -> mode ) ; }
Returns the cache loader class that should be used for this definition .
28,020
public function get_name ( ) { $ identifier = 'cachedef_' . clean_param ( $ this -> area , PARAM_STRINGID ) ; $ component = $ this -> component ; if ( $ component === 'core' ) { $ component = 'cache' ; } return new lang_string ( $ identifier , $ component ) ; }
Returns the name for this definition
28,021
public function set_identifiers ( array $ identifiers = array ( ) ) { if ( $ this -> identifiers !== null ) { throw new coding_exception ( "You can only set identifiers on initial definition creation." . " Define a new cache to set different identifiers." ) ; } if ( ! empty ( $ identifiers ) && ! empty ( $ this -> inva...
Sets the identifiers for this definition or updates them if they have already been set .
28,022
public function get_requirements_bin ( ) { $ requires = 0 ; if ( $ this -> require_data_guarantee ( ) ) { $ requires += cache_store :: SUPPORTS_DATA_GUARANTEE ; } if ( $ this -> require_multiple_identifiers ( ) ) { $ requires += cache_store :: SUPPORTS_MULTIPLE_IDENTIFIERS ; } if ( $ this -> require_searchable ( ) ) { ...
Returns the requirements of this definition as a binary flag .
28,023
public function generate_single_key_prefix ( ) { if ( $ this -> keyprefixsingle === null ) { $ this -> keyprefixsingle = $ this -> mode . '/' . $ this -> component . '/' . $ this -> area ; $ this -> keyprefixsingle .= '/' . $ this -> get_cache_identifier ( ) ; $ identifiers = $ this -> get_identifiers ( ) ; if ( $ iden...
Generates a single key prefix for this definition
28,024
public function generate_multi_key_parts ( ) { if ( $ this -> keyprefixmulti === null ) { $ this -> keyprefixmulti = array ( 'mode' => $ this -> mode , 'component' => $ this -> component , 'area' => $ this -> area , 'siteidentifier' => $ this -> get_cache_identifier ( ) ) ; if ( isset ( $ this -> identifiers ) && ! emp...
Generates a multi key prefix for this definition
28,025
protected function get_cache_identifier ( ) { $ identifiers = array ( ) ; if ( $ this -> selectedsharingoption & self :: SHARING_ALL ) { } else { if ( $ this -> selectedsharingoption & self :: SHARING_SITEID ) { $ identifiers [ ] = cache_helper :: get_site_identifier ( ) ; } if ( $ this -> selectedsharingoption & self ...
Returns a cache identification string .
28,026
function get_required_javascript ( ) { parent :: get_required_javascript ( ) ; $ arguments = array ( 'instanceid' => $ this -> instance -> id ) ; $ this -> page -> requires -> string_for_js ( 'viewallcourses' , 'moodle' ) ; $ this -> page -> requires -> js_call_amd ( 'block_navigation/navblock' , 'init' , $ arguments )...
Gets Javascript that may be required for navigation
28,027
public function html_attributes ( ) { $ attributes = parent :: html_attributes ( ) ; if ( ! empty ( $ this -> config -> enablehoverexpansion ) && $ this -> config -> enablehoverexpansion == 'yes' ) { $ attributes [ 'class' ] .= ' block_js_expansion' ; } return $ attributes ; }
Returns the attributes to set for this block
28,028
public function trim ( navigation_node $ node , $ mode = 1 , $ long = 50 , $ short = 25 , $ recurse = true ) { switch ( $ mode ) { case self :: TRIM_RIGHT : if ( core_text :: strlen ( $ node -> text ) > ( $ long + 3 ) ) { $ node -> text = $ this -> trim_right ( $ node -> text , $ long ) ; } if ( is_string ( $ node -> s...
Trims the text and shorttext properties of this node and optionally all of its children .
28,029
protected function trim_left ( $ string , $ length ) { return '...' . core_text :: substr ( $ string , core_text :: strlen ( $ string ) - $ length , $ length ) ; }
Truncate a string from the left
28,030
protected function trim_center ( $ string , $ length ) { $ trimlength = ceil ( $ length / 2 ) ; $ start = core_text :: substr ( $ string , 0 , $ trimlength ) ; $ end = core_text :: substr ( $ string , core_text :: strlen ( $ string ) - $ trimlength ) ; $ string = $ start . '...' . $ end ; return $ string ; }
Truncate a string in the center
28,031
public function get ( $ key ) { if ( ! isset ( $ this -> _data [ $ key ] ) ) { $ this -> _data [ $ key ] = new $ this -> _obClass ( ) ; } return $ this -> _data [ $ key ] ; }
Return a fetch object creating and storing an empty object in the results set if it doesn t currently exist .
28,032
public function findObjectInArray ( $ objectname , $ arr ) { foreach ( $ arr as $ i => $ object ) { if ( $ objectname == $ object -> getName ( ) ) { return $ i ; } } return null ; }
Returns the position of one object in the array .
28,033
public function comma2array ( $ string ) { $ foundquotes = array ( ) ; $ foundconcats = array ( ) ; preg_match_all ( "/(CONCAT\(.*?\))/is" , $ string , $ matches ) ; foreach ( array_unique ( $ matches [ 0 ] ) as $ key => $ value ) { $ foundconcats [ '<#' . $ key . '#>' ] = $ value ; } if ( ! empty ( $ foundconcats ) ) ...
Returns one array of elements from one comma separated string supporting quoted strings containing commas and concat function calls
28,034
public function build ( stdClass $ user , forum_entity $ forum , discussion_entity $ discussion ) : array { $ favouriteids = [ ] ; if ( $ this -> is_favourited ( $ discussion , $ forum -> get_context ( ) , $ user ) ) { $ favouriteids [ ] = $ discussion -> get_id ( ) ; } $ groupsbyid = $ this -> get_groups_available_in_...
Build any additional variables for the exported discussion for a given set of discussions .
28,035
public function is_favourited ( discussion_entity $ discussion , \ context_module $ forumcontext , \ stdClass $ user ) { if ( ! isloggedin ( ) ) { return false ; } $ usercontext = \ context_user :: instance ( $ user -> id ) ; $ ufservice = \ core_favourites \ service_factory :: get_service_for_user_context ( $ usercont...
Check whether the provided discussion has been favourited by the user .
28,036
function connect ( & $ err ) { if ( ! function_exists ( 'memcache_pconnect' ) ) { $ err = 'Memcache module PECL extension not found!' ; return false ; } $ memcache = new MemCache ; if ( ! is_array ( $ this -> hosts ) ) $ this -> hosts = array ( $ this -> hosts ) ; $ failcnt = 0 ; foreach ( $ this -> hosts as $ host ) {...
implement as lazy connection . The connection only occurs on CacheExecute call
28,037
function writecache ( $ filename , $ contents , $ debug , $ secs2cache ) { if ( ! $ this -> _connected ) { $ err = '' ; if ( ! $ this -> connect ( $ err ) && $ debug ) ADOConnection :: outp ( $ err ) ; } if ( ! $ this -> _memcache ) return false ; if ( ! $ this -> _memcache -> set ( $ filename , $ contents , $ this -> ...
returns true or false . true if successful save
28,038
function readcache ( $ filename , & $ err , $ secs2cache , $ rsClass ) { $ false = false ; if ( ! $ this -> _connected ) $ this -> connect ( $ err ) ; if ( ! $ this -> _memcache ) return $ false ; $ rs = $ this -> _memcache -> get ( $ filename ) ; if ( ! $ rs ) { $ err = 'Item with such key doesn\'t exists on the memca...
returns a recordset
28,039
public function add_node ( node $ node ) { $ name = $ node -> name ; if ( isset ( $ this -> nodes [ $ name ] ) ) { throw new \ coding_exception ( "Node name $name already used" ) ; } $ this -> nodes [ $ node -> name ] = $ node ; }
Add a node to the tree .
28,040
public function add_category ( category $ cat ) { $ name = $ cat -> name ; if ( isset ( $ this -> categories [ $ name ] ) ) { throw new \ coding_exception ( "Category name $name already used" ) ; } $ this -> categories [ $ cat -> name ] = $ cat ; }
Add a category to the tree .
28,041
public function sort_categories ( ) { $ this -> attach_nodes_to_categories ( ) ; $ tempcategories = array ( ) ; foreach ( $ this -> categories as $ category ) { $ after = $ category -> after ; if ( $ after == null ) { $ category -> sort_nodes ( ) ; $ tempcategories = array_merge ( $ tempcategories , array ( $ category ...
Sort categories and nodes . Builds the tree structure that would be displayed to the user .
28,042
protected function attach_nodes_to_categories ( ) { foreach ( $ this -> nodes as $ node ) { $ parentcat = $ node -> parentcat ; if ( ! isset ( $ this -> categories [ $ parentcat ] ) ) { throw new \ coding_exception ( "Category $parentcat doesn't exist" ) ; } else { $ this -> categories [ $ parentcat ] -> add_node ( $ n...
Attach various nodes to their respective categories .
28,043
protected function find_categories_after ( $ category ) { $ return = array ( ) ; $ categoryarray = $ this -> categories ; foreach ( $ categoryarray as $ categoryelement ) { if ( $ categoryelement -> after == $ category -> name ) { $ categoryelement -> sort_nodes ( ) ; $ return = array_merge ( $ return , array ( $ categ...
Find all category nodes that should be displayed after a given a category node .
28,044
protected function get_courses ( $ hiddencats ) { global $ DB , $ CFG ; require_once ( $ CFG -> libdir . '/modinfolib.php' ) ; $ params = array ( 'category' => $ this -> category -> id , 'contextlevel' => CONTEXT_COURSE ) ; $ sql = 'c.category = :category' ; foreach ( $ hiddencats as $ category ) { $ catcontext = conte...
List of courses in this category and in hidden subcategories
28,045
protected function get_categories ( ) { global $ DB ; $ fields = 'c.*, ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ coursecats = $ DB -> get_records_sql ( 'SELECT ' . $ fields . ' FROM {course_categories} c LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :co...
Finds accessible and non - accessible direct subcategories
28,046
protected function get_child_course ( $ course ) { context_helper :: preload_from_record ( $ course ) ; $ context = context_course :: instance ( $ course -> id ) ; $ child = new file_info_context_course ( $ this -> browser , $ context , $ course ) ; return $ child -> get_file_info ( null , null , null , null , null ) ;...
Returns the file info element for a given course or null if course is not accessible
28,047
public function verifySignedJwt ( $ id_token , $ cert_location , $ audience , $ issuer , $ max_expiry = null ) { $ auth = new Google_Auth_OAuth2 ( $ this ) ; $ certs = $ auth -> retrieveCertsFromLocation ( $ cert_location ) ; return $ auth -> verifySignedJwtWithCerts ( $ id_token , $ certs , $ audience , $ issuer , $ m...
Verify a JWT that was signed with your own certificates .
28,048
public function render_evaluate_results ( $ results , $ logs = array ( ) ) { global $ OUTPUT ; $ output = '' ; foreach ( $ results as $ timesplittingid => $ result ) { if ( ! CLI_SCRIPT ) { $ output .= $ OUTPUT -> box_start ( 'generalbox mb-3' ) ; } if ( ! is_numeric ( $ timesplittingid ) ) { $ timesplitting = \ core_a...
Web interface evaluate results .
28,049
protected static function _getMimeExtensionMap ( ) { if ( is_null ( self :: $ _map ) ) { require __DIR__ . '/mime.mapping.php' ; self :: $ _map = $ mime_extension_map ; } return self :: $ _map ; }
Returns a copy of the MIME extension map .
28,050
public static function extToMime ( $ ext ) { if ( empty ( $ ext ) ) { return 'application/octet-stream' ; } $ ext = Horde_String :: lower ( $ ext ) ; $ map = self :: _getMimeExtensionMap ( ) ; $ pos = 0 ; while ( ! isset ( $ map [ $ ext ] ) ) { if ( ( $ pos = strpos ( $ ext , '.' ) ) === false ) { break ; } $ ext = sub...
Attempt to convert a file extension to a MIME type based on the global Horde and application specific config files .
28,051
public static function filenameToMime ( $ filename , $ unknown = true ) { $ pos = strlen ( $ filename ) + 1 ; $ type = '' ; $ map = self :: _getMimeExtensionMap ( ) ; for ( $ i = 0 ; $ i <= $ map [ '__MAXPERIOD__' ] ; ++ $ i ) { $ npos = strrpos ( substr ( $ filename , 0 , $ pos - 1 ) , '.' ) ; if ( $ npos === false ) ...
Attempt to convert a filename to a MIME type based on the global Horde and application specific config files .
28,052
public static function mimeToExt ( $ type ) { if ( empty ( $ type ) ) { return false ; } if ( ( $ key = array_search ( $ type , self :: _getMimeExtensionMap ( ) ) ) === false ) { list ( $ major , $ minor ) = explode ( '/' , $ type ) ; if ( $ major == 'x-extension' ) { return $ minor ; } if ( strpos ( $ minor , 'x-' ) =...
Attempt to convert a MIME type to a file extension based on the global Horde and application specific config files .
28,053
public static function analyzeFile ( $ path , $ magic_db = null , $ opts = array ( ) ) { if ( Horde_Util :: extensionExists ( 'fileinfo' ) ) { $ res = empty ( $ magic_db ) ? finfo_open ( FILEINFO_MIME ) : finfo_open ( FILEINFO_MIME , $ magic_db ) ; if ( $ res ) { $ type = trim ( finfo_file ( $ res , $ path ) ) ; finfo_...
Attempt to determine the MIME type of an unknown file .
28,054
public static function analyzeData ( $ data , $ magic_db = null , $ opts = array ( ) ) { if ( Horde_Util :: extensionExists ( 'fileinfo' ) ) { $ res = empty ( $ magic_db ) ? @ finfo_open ( FILEINFO_MIME ) : @ finfo_open ( FILEINFO_MIME , $ magic_db ) ; if ( ! $ res ) { return false ; } $ type = trim ( finfo_buffer ( $ ...
Attempt to determine the MIME type of an unknown byte stream .
28,055
function updateColsCount ( ) { $ this -> _colsCount = sizeof ( $ this -> flds ) ; foreach ( $ this -> _belongsTo as $ foreignTable ) $ this -> _colsCount += sizeof ( $ foreignTable -> TableInfo ( ) -> flds ) ; foreach ( $ this -> _hasMany as $ foreignTable ) $ this -> _colsCount += sizeof ( $ foreignTable -> TableInfo ...
total columns count including relations
28,056
function Error ( $ err , $ fn ) { global $ _ADODB_ACTIVE_DBS ; $ fn = get_class ( $ this ) . '::' . $ fn ; $ this -> _lasterr = $ fn . ': ' . $ err ; if ( $ this -> _dbat < 0 ) { $ db = false ; } else { $ activedb = $ _ADODB_ACTIVE_DBS [ $ this -> _dbat ] ; $ db = $ activedb -> db ; } if ( function_exists ( 'adodb_thro...
error handler for both PHP4 + 5 .
28,057
function ErrorMsg ( ) { if ( ! function_exists ( 'adodb_throw' ) ) { if ( $ this -> _dbat < 0 ) { $ db = false ; } else { $ db = $ this -> DB ( ) ; } if ( $ db && $ db -> ErrorMsg ( ) ) { return $ db -> ErrorMsg ( ) ; } } return $ this -> _lasterr ; }
return last error message
28,058
function DB ( ) { global $ _ADODB_ACTIVE_DBS ; if ( $ this -> _dbat < 0 ) { $ false = false ; $ this -> Error ( "No database connection set: use ADOdb_Active_Record::SetDatabaseAdaptor(\$db)" , "DB" ) ; return $ false ; } $ activedb = $ _ADODB_ACTIVE_DBS [ $ this -> _dbat ] ; $ db = $ activedb -> db ; return $ db ; }
retrieve ADOConnection from _ADODB_Active_DBs
28,059
function LastInsertID ( & $ db , $ fieldname ) { if ( $ db -> hasInsertID ) { $ val = $ db -> Insert_ID ( $ this -> _table , $ fieldname ) ; } else { $ val = false ; } if ( is_null ( $ val ) || $ val === false ) { return $ db -> GetOne ( "select max(" . $ fieldname . ") from " . $ this -> _table ) ; } return $ val ; }
get last inserted id for INSERT
28,060
protected function get_time_range_weeks_number ( $ starttime , $ endtime ) { if ( $ endtime <= $ starttime ) { throw new \ coding_exception ( 'End time timestamp should be greater than start time.' ) ; } $ starttimedt = new \ DateTime ( ) ; $ starttimedt -> setTimestamp ( $ starttime ) ; $ starttimedt -> setTimezone ( ...
Returns the number of weeks a time range contains .
28,061
protected function classify_value ( $ value , $ ranges ) { $ rangeweight = ( static :: get_max_value ( ) - static :: get_min_value ( ) ) / ( count ( $ ranges ) - 1 ) ; foreach ( $ ranges as $ key => $ range ) { $ match = false ; if ( count ( $ range ) != 2 ) { throw new \ coding_exception ( 'classify_value() $ranges ar...
Classifies the provided value into the provided range according to the ranges predicates .
28,062
private function array_merge_recursive_keep_keys ( ) { $ arrays = func_get_args ( ) ; $ base = array_shift ( $ arrays ) ; foreach ( $ arrays as $ array ) { reset ( $ base ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && ! empty ( $ base [ $ key ] ) && is_array ( $ base [ $ key ] ) ) { $ base [...
Merges arrays recursively keeping the same keys the original arrays have .
28,063
function notemptyfield ( $ value , $ name ) { global $ USER ; $ names = explode ( '_' , $ name ) ; if ( $ names [ 2 ] == 'file' ) { $ usercontext = context_user :: instance ( $ USER -> id ) ; $ fs = get_file_storage ( ) ; $ files = $ fs -> get_area_files ( $ usercontext -> id , 'user' , 'draft' , $ value ) ; return cou...
Custom notempty function
28,064
public static function delete_data_for_userlist ( \ core_privacy \ local \ request \ approved_userlist $ userlist ) { global $ DB ; list ( $ sql , $ params ) = static :: get_sql_where_from_contexts ( [ $ userlist -> get_context ( ) ] ) ; if ( empty ( $ sql ) ) { return ; } list ( $ usersql , $ userparams ) = $ DB -> ge...
Delete all data for a list of users in the specified context .
28,065
protected static function get_sql_where_from_contexts ( array $ contexts ) { global $ DB ; $ sorted = array_reduce ( $ contexts , function ( $ carry , $ context ) { $ level = $ context -> contextlevel ; if ( $ level == CONTEXT_MODULE || $ level == CONTEXT_COURSE ) { $ carry [ $ level ] [ ] = $ context -> instanceid ; }...
Get an SQL where statement from a list of contexts .
28,066
function init ( ) { parent :: init ( ) ; $ this -> can_subaction = ACTION_NONE ; $ this -> sesskey_protected = false ; $ this -> loadStrings ( array ( ) ) ; }
Init method every subclass will have its own
28,067
protected function render_report_loglive ( report_loglive_renderable $ reportloglive ) { if ( empty ( $ reportloglive -> selectedlogreader ) ) { return $ this -> output -> notification ( get_string ( 'nologreaderenabled' , 'report_loglive' ) , 'notifyproblem' ) ; } $ table = $ reportloglive -> get_table ( ) ; return $ ...
Return html to render the loglive page ..
28,068
protected function moveImportsToTop ( $ content ) { if ( preg_match_all ( '/@import[^;]+;/' , $ content , $ matches ) ) { foreach ( $ matches [ 0 ] as $ import ) { $ content = str_replace ( $ import , '' , $ content ) ; } $ content = implode ( '' , $ matches [ 0 ] ) . $ content ; } return $ content ; }
Move any import statements to the top .
28,069
protected function combineImports ( $ source , $ content , $ parents ) { $ importRegexes = array ( '/ # import statement @import # whitespace \s+ # open url() url\( # (optional) open path enclosure (?P<quotes...
Combine CSS from import statements .
28,070
protected function importFiles ( $ source , $ content ) { $ regex = '/url\((["\']?)(.+?)\\1\)/i' ; if ( $ this -> importExtensions && preg_match_all ( $ regex , $ content , $ matches , PREG_SET_ORDER ) ) { $ search = array ( ) ; $ replace = array ( ) ; foreach ( $ matches as $ match ) { $ extension = substr ( strrchr (...
Import files into the CSS base64 - ized .
28,071
public function execute ( $ path = null , $ parents = array ( ) ) { $ content = '' ; foreach ( $ this -> data as $ source => $ css ) { $ this -> extractStrings ( ) ; $ this -> stripComments ( ) ; $ css = $ this -> replace ( $ css ) ; $ css = $ this -> stripWhitespace ( $ css ) ; $ css = $ this -> shortenHex ( $ css ) ;...
Minify the data . Perform CSS optimizations .
28,072
protected function shortenFontWeights ( $ content ) { $ weights = array ( 'normal' => 400 , 'bold' => 700 , ) ; $ callback = function ( $ match ) use ( $ weights ) { return $ match [ 1 ] . $ weights [ $ match [ 2 ] ] ; } ; return preg_replace_callback ( '/(font-weight\s*:\s*)(' . implode ( '|' , array_keys ( $ weights ...
Shorten CSS font weights .
28,073
private function escape_token_string ( & $ text , $ token ) { $ text = str_replace ( "~" . $ token , $ this -> protect ( $ token ) , $ text ) ; }
Escape token when it is negated
28,074
protected function define_grade_subplugin_structure ( ) { $ subplugin = $ this -> get_subplugin_element ( ) ; $ subpluginwrapper = new backup_nested_element ( $ this -> get_recommended_name ( ) ) ; $ subpluginelementfiles = new backup_nested_element ( 'feedback_editpdf_files' , null , array ( 'gradeid' ) ) ; $ subplugi...
Returns the subplugin information to attach to feedback element
28,075
public function check_locale_availability ( string $ langpackcode ) : bool { global $ CFG ; if ( empty ( $ langpackcode ) ) { throw new coding_exception ( 'Invalid language pack code in \\' . __METHOD__ . '() call, only non-empty string is allowed' ) ; } if ( $ CFG -> ostype === 'WINDOWS' ) { $ stringtofetch = 'localew...
Checks availability of locale on current operating system .
28,076
private function allowed_tags_message ( $ badtag ) { $ a = new stdClass ( ) ; $ a -> tag = htmlspecialchars ( $ badtag ) ; $ a -> allowed = $ this -> get_list_of_printable_allowed_tags ( $ this -> allowedhtmltags ) ; if ( $ a -> allowed ) { return get_string ( 'tagsnotallowed' , 'qtype_gapselect' , $ a ) ; } else { ret...
Returns a message indicating what tags are allowed .
28,077
private function get_list_of_printable_allowed_tags ( $ allowedhtmltags ) { $ allowedtaglist = array ( ) ; foreach ( $ allowedhtmltags as $ htmltag ) { $ allowedtaglist [ ] = htmlspecialchars ( '<' . $ htmltag . '>' ) ; } return implode ( ', ' , $ allowedtaglist ) ; }
Returns a prinatble list of allowed HTML tags .
28,078
protected function definition_answer_choice ( & $ mform ) { $ mform -> addElement ( 'header' , 'choicehdr' , get_string ( 'choices' , 'qtype_gapselect' ) ) ; $ mform -> setExpanded ( 'choicehdr' , 1 ) ; $ mform -> addElement ( 'checkbox' , 'shuffleanswers' , get_string ( 'shuffle' , 'qtype_gapselect' ) ) ; $ mform -> s...
Defines form elements for answer choices .
28,079
protected function choice_group ( $ mform ) { $ options = array ( ) ; for ( $ i = 1 ; $ i <= $ this -> get_maximum_choice_group_number ( ) ; $ i += 1 ) { $ options [ $ i ] = question_utils :: int_to_letter ( $ i ) ; } $ grouparray = array ( ) ; $ grouparray [ ] = $ mform -> createElement ( 'text' , 'answer' , get_strin...
Creates an array with elements for a choice group .
28,080
private function validate_slots ( $ questiontext , $ choices ) { $ error = 'Please check the Question text: ' ; if ( ! $ questiontext ) { return get_string ( 'errorquestiontextblank' , 'qtype_gapselect' ) ; } $ matches = array ( ) ; preg_match_all ( $ this -> squarebracketsregex , $ questiontext , $ matches ) ; $ slots...
Finds errors in question slots .
28,081
protected function _connect ( ) { if ( ! is_null ( $ this -> _connection ) ) { return ; } try { $ this -> _connection = new Horde_Imap_Client_Socket_Connection_Socket ( $ this -> getParam ( 'hostspec' ) , $ this -> getParam ( 'port' ) , $ this -> getParam ( 'timeout' ) , $ this -> getParam ( 'secure' ) , $ this -> getP...
Connects to the IMAP server .
28,082
protected function _authInitialResponse ( $ method , $ ir , $ username = null ) { $ cmd = $ this -> _command ( 'AUTHENTICATE' ) -> add ( $ method ) ; if ( $ this -> _capability ( 'SASL-IR' ) ) { $ cmd -> add ( $ ir ) ; if ( $ username ) { $ cmd -> debug = array ( sprintf ( 'AUTHENTICATE %s [INITIAL CLIENT RESPONSE (use...
Create the AUTHENTICATE command for the initial client response .
28,083
protected function _loginTasks ( $ firstlogin = true , array $ resp = array ( ) ) { if ( ! $ firstlogin && ! empty ( $ resp [ 'proxyreuse' ] ) ) { if ( isset ( $ this -> _init [ 'enabled' ] ) ) { foreach ( $ this -> _init [ 'enabled' ] as $ val ) { $ this -> _capability ( ) -> enable ( $ val ) ; } } if ( ! isset ( $ th...
Perform login tasks .
28,084
protected function _prepareStatusResponse ( $ request , $ mailbox ) { $ mbox_ob = $ this -> _mailboxOb ( $ mailbox ) ; $ out = array ( ) ; foreach ( $ request as $ val ) { $ out [ $ val ] = $ mbox_ob -> getStatus ( $ this -> _statusFields [ $ val ] ) ; } return $ out ; }
Prepares a status response for a mailbox .
28,085
protected function _appendData ( $ data , & $ asize ) { if ( is_resource ( $ data ) ) { rewind ( $ data ) ; } $ ob = new Horde_Imap_Client_Data_Format_String_Nonascii ( $ data , array ( 'eol' => true , 'skipscan' => true ) ) ; $ ob -> forceLiteral ( ) ; $ asize += $ ob -> length ( ) ; return $ ob ; }
Prepares append message data for insertion into the IMAP command string .
28,086
protected function _convertCatenateUrl ( $ url ) { $ e = $ part = null ; $ url = new Horde_Imap_Client_Url_Imap ( $ url ) ; if ( ! is_null ( $ url -> mailbox ) && ! is_null ( $ url -> uid ) ) { try { $ status_res = is_null ( $ url -> uidvalidity ) ? null : $ this -> status ( $ url -> mailbox , Horde_Imap_Client :: STAT...
Converts a CATENATE URL to stream data .
28,087
protected function _partialAtom ( $ opts ) { if ( ! empty ( $ opts [ 'length' ] ) ) { return '<' . ( empty ( $ opts [ 'start' ] ) ? 0 : intval ( $ opts [ 'start' ] ) ) . '.' . intval ( $ opts [ 'length' ] ) . '>' ; } return empty ( $ opts [ 'start' ] ) ? '' : ( '<' . intval ( $ opts [ 'start' ] ) . '>' ) ; }
Add a partial atom to an IMAP command based on the criteria options .
28,088
protected function _parseStructureParams ( $ data ) { $ params = array ( ) ; if ( is_null ( $ data ) ) { return $ params ; } while ( ( $ name = $ data -> next ( ) ) !== false ) { $ params [ Horde_String :: lower ( $ name ) ] = $ data -> next ( ) ; } $ cp = new Horde_Mime_Headers_ContentParam ( 'Unused' , $ params ) ; r...
Helper function to parse a parameters - like tokenized array .
28,089
protected function _storeCmd ( $ options ) { $ cmds = array ( ) ; $ silent = empty ( $ options [ 'unchangedsince' ] ) ? ! ( $ this -> _debug -> debug || $ this -> _initCache ( true ) ) : false ; if ( ! empty ( $ options [ 'replace' ] ) ) { $ cmds [ ] = array ( 'FLAGS' . ( $ silent ? '.SILENT' : '' ) , $ options [ 'repl...
Create a store command .
28,090
protected function _getAnnotateMoreEntry ( $ name ) { if ( substr ( $ name , 0 , 7 ) === '/shared' ) { return array ( substr ( $ name , 7 ) , 'value.shared' ) ; } else if ( substr ( $ name , 0 , 8 ) === '/private' ) { return array ( substr ( $ name , 8 ) , 'value.priv' ) ; } $ e = new Horde_Imap_Client_Exception ( Hord...
Split a name for the METADATA extension into the correct syntax for the older ANNOTATEMORE version .
28,091
protected function _getMboxFormatOb ( $ mailbox , $ list = false ) { if ( $ this -> _capability ( ) -> isEnabled ( 'UTF8=ACCEPT' ) ) { try { return $ list ? new Horde_Imap_Client_Data_Format_ListMailbox_Utf8 ( $ mailbox ) : new Horde_Imap_Client_Data_Format_Mailbox_Utf8 ( $ mailbox ) ; } catch ( Horde_Imap_Client_Data_...
Return the proper mailbox format object based on the server s capabilities .
28,092
protected function _processCmdContinuation ( $ pipeline , $ noexception = false ) { do { $ ob = $ this -> _getLine ( $ pipeline ) ; } while ( $ ob instanceof Horde_Imap_Client_Interaction_Server_Untagged ) ; if ( $ ob instanceof Horde_Imap_Client_Interaction_Server_Continuation ) { return $ ob ; } elseif ( $ noexceptio...
Process a command continuation response .
28,093
protected function _pipeline ( $ cmd = null ) { if ( ! isset ( $ this -> _temp [ 'fetchob' ] ) ) { $ this -> _temp [ 'fetchob' ] = new Horde_Imap_Client_Fetch_Results ( $ this -> _fetchDataClass , Horde_Imap_Client_Fetch_Results :: SEQUENCE ) ; } $ ob = new Horde_Imap_Client_Interaction_Pipeline ( clone $ this -> _temp...
Shortcut to creating a new pipeline object .
28,094
protected function _getLine ( Horde_Imap_Client_Interaction_Pipeline $ pipeline ) { $ server = Horde_Imap_Client_Interaction_Server :: create ( $ this -> _connection -> read ( ) ) ; switch ( get_class ( $ server ) ) { case 'Horde_Imap_Client_Interaction_Server_Continuation' : $ this -> _responseCode ( $ pipeline , $ se...
Gets data from the IMAP server stream and parses it .
28,095
public function init ( ) { global $ PAGE , $ DB ; $ result = new workshop_allocation_result ( $ this ) ; $ customdata = array ( ) ; $ customdata [ 'workshop' ] = $ this -> workshop ; $ current = $ DB -> get_record ( 'workshopallocation_scheduled' , array ( 'workshopid' => $ this -> workshop -> id ) , '*' , IGNORE_MISSI...
Save the settings for the random allocator to execute it later
28,096
public function execute ( ) { global $ DB ; $ result = new workshop_allocation_result ( $ this ) ; if ( $ this -> workshop -> phase != workshop :: PHASE_SUBMISSION ) { $ result -> set_status ( workshop_allocation_result :: STATUS_FAILED , get_string ( 'resultfailedphase' , 'workshopallocation_scheduled' ) ) ; return $ ...
Executes the allocation
28,097
protected function store_settings ( $ enabled , $ reset , workshop_random_allocator_setting $ settings , workshop_allocation_result $ result ) { global $ DB ; $ data = new stdClass ( ) ; $ data -> workshopid = $ this -> workshop -> id ; $ data -> enabled = $ enabled ; $ data -> submissionend = $ this -> workshop -> sub...
Stores the pre - defined random allocation settings for later usage
28,098
public function send_file ( $ storedfile , $ lifetime = null , $ filter = 0 , $ forcedownload = false , array $ options = null ) { $ reference = $ this -> unpack_reference ( $ storedfile -> get_reference ( ) ) ; $ maxcachesize = $ this -> max_cache_bytes ( ) ; if ( empty ( $ maxcachesize ) ) { $ cachefile = true ; } el...
Repository method to serve the referenced file .
28,099
public function get_file_reference ( $ source ) { global $ USER ; $ reference = new stdClass ; $ reference -> userid = $ USER -> id ; $ reference -> username = fullname ( $ USER ) ; $ reference -> path = $ source ; $ usefilereference = optional_param ( 'usefilereference' , false , PARAM_BOOL ) ; if ( $ usefilereference...
Prepare file reference information .