function viewfolder($folderid, $userid, $level) { $prefix = ""; for ($i = 0; $i < $level; $i++) { $prefix .= ">"; } $fileprefix = $prefix . ">"; if ($folderid == -1) { $body = <<<END <option value="">ROOT</option> END; } else { $current_folder = get_record('file_folders', 'owner', $userid, 'ident', $folderid); $name = strtoupper(stripslashes($current_folder->name)); $body = <<<END <option value="">{$prefix} {$name}</option> END; } if ($files = get_records_select('files', "owner = ? AND folder = ?", array($userid, $folderid))) { foreach ($files as $file) { $filetitle = stripslashes($file->title); $body .= <<<END <option value="{$file->ident}">{$fileprefix} {$filetitle}</option> END; } } if ($folders = get_records_select('file_folders', "owner = ? AND parent = ? ", array($userid, $folderid))) { foreach ($folders as $folder) { $body .= viewfolder($folder->ident, $userid, $level + 1); } } return $body; }
/** * Cron that runs any automatically scheduled reports weekly or monthly. */ function report_customsql_cron() { global $CFG; $timenow = time(); if (!empty($CFG->reportcustomsqlmaxruntime)) { $timestop = $timenow + $CFG->reportcustomsqlmaxruntime; } else { $timestop = $timenow + 180; // Three minutes. } list($startofthisweek, $startoflastweek) = report_customsql_get_week_starts($timenow); list($startofthismonth) = report_customsql_get_month_starts($timenow); mtrace("... Looking for old temp CSV files to delete."); $numdeleted = report_customsql_delete_old_temp_files($startoflastweek); if ($numdeleted) { mtrace("... {$numdeleted} files deleted."); } $reportstorun = get_records_select('report_customsql_queries', "(runable = 'weekly' AND lastrun < {$startofthisweek}) OR\n (runable = 'monthly' AND lastrun < {$startofthismonth})", 'lastrun'); if (empty($reportstorun)) { return; } while (!empty($reportstorun) && time() < $timestop) { $report = array_shift($reportstorun); mtrace("... Running report " . strip_tags($report->displayname)); try { report_customsql_generate_csv($report, $timenow); } catch (Exception $e) { mtrace("... REPORT FAILED " . $e->getMessage()); } } }
function ownedusers_pagesetup() { // register links -- global $profile_id; global $PAGE; global $CFG; global $USER; $page_owner = $profile_id; if ($CFG->owned_users) { if (defined("context") && context == "network") { if (run("users:type:get", $page_owner) == "person") { $PAGE->menu_sub[] = array('name' => 'ownedusers:requests', 'html' => '<a href="' . $CFG->wwwroot . '_ownedusers/owned.php?owner=' . $page_owner . '">' . gettext("Owned " . $CFG->owned_users_caption) . '</a>'); } } if (defined("context") && context == "weblog") { if (run("users:type:get", $page_owner) == "person") { if ($result = get_records_select('users', "owner = ? AND user_type = ?", array($page_owner, 'person'))) { $PAGE->menu_sub[] = array('name' => 'ownedusers:requests', 'html' => '<a href="' . $CFG->wwwroot . $USER->username . '/weblog/ownedusers/' . '">' . gettext($CFG->owned_users_caption . "' blogs") . '</a>'); } } } if (defined("context") && context == "profile" && logged_on && !run("users:flags:get", array("admin", $USER->ident))) { if ($result = get_records_select('users', "ident = ? and owner = ? AND user_type = ?", array($page_owner, $USER->ident, 'person'))) { $PAGE->menu_sub[] = array('name' => 'profile:edit', 'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $page_owner . '">' . gettext("Edit this profile") . '</a>'); if (run("permissions:check", "profile")) { $PAGE->menu_sub[] = array('name' => 'owneduser:pic', 'html' => a_hrefg("{$CFG->wwwroot}_icons/?context=profile&profile_id={$page_owner}", gettext("Change site picture"))); $PAGE->menu_sub[] = array('name' => 'profile:help', 'html' => '<a href="' . $CFG->wwwroot . 'help/profile_help.php">' . gettext("Page help") . '</a>'); } } } } }
function viewfolder($folderid, $userid, $level, $selected = -1) { $prefix = ""; for ($i = 0; $i < $level; $i++) { $prefix .= ">"; } $fileprefix = $prefix . ">"; $folders = get_records_select('file_folders', "files_owner = ? AND parent = ?", array($userid, $folderid)); if ($folderid == -1) { $body = "<option value=\"-1\" "; if ($selected == -1) { $body .= "selected = \"selected\""; } $root = __gettext("Root"); $body .= ">{$root}</option>"; } else { $current_folder = get_record('file_folders', 'files_owner', $userid, 'ident', $folderid); $name = stripslashes($current_folder->name); $ident = $current_folder->ident; if ($ident == $selected) { $selectstring = "selected=\"selected\""; } else { $selectstring = ""; } $body = <<<END <option value="{$ident}" {$selectstring} >{$prefix} {$name} </option> END; } if (!empty($folders)) { foreach ($folders as $folder) { $body .= viewfolder($folder->ident, $userid, $level + 1, $selected); } } return $body; }
function mail_delete_instance($id) { /// Given an ID of an instance of this module, /// this function will permanently delete the instance /// and any data that depends on it. global $CFG; if (!($mail = get_record("mail", "id", "{$id}"))) { return false; } $result = true; if (!delete_records("mail", "id", "{$mail->id}")) { $result = false; } if (!delete_records("mail_folder", "mailid", "{$mail->id}")) { $result = false; } if ($messages = get_records_select("mail_messages", "mailid = {$mail->id}")) { foreach ($messages as $message) { delete_records("mail_to_messages", "messageid", "{$message->id}"); delete_records("mail_messages", "id", "{$message->id}"); } } if ($groups = get_records_select("mail_groups", "mailid = {$mail->id}")) { foreach ($groups as $group) { delete_records("mail_members_groups", "groupid", "{$group->id}"); delete_records("mail_groups", "id", "{$group->id}"); } } if (!delete_records("mail_statistics", "course", "{$mail->course}")) { $result = false; } //$dir = $CFG->dataroot.'/'.$portafolio->course.'/moddata/portafolio/'.$portafolio->id; //$result = fulldelete($dir); return $result; }
function print_filter(&$mform) { global $CFG; $filter_categories = optional_param('filter_categories', 0, PARAM_INT); $reportclassname = 'report_' . $this->report->type; $reportclass = new $reportclassname($this->report); if ($this->report->type != 'sql') { $components = cr_unserialize($this->report->components); $conditions = $components['conditions']; $categorieslist = $reportclass->elements_by_conditions($conditions); } else { $categorieslist = array_keys(get_records('course')); } $courseoptions = array(); $courseoptions[0] = get_string('choose'); if (!empty($categorieslist)) { $categories = get_records_select('course_categories', 'id in (' . implode(',', $categorieslist) . ')'); foreach ($categories as $c) { $courseoptions[$c->id] = format_string($c->name); } } $select =& $mform->addElement('select', 'filter_categories', get_string('category'), $courseoptions); $select->setMultiple(true); $mform->setType('filter_categories', PARAM_INT); }
function game_backup_one_mod($bf, $preferences, $game) { global $CFG; $status = true; if (is_numeric($game)) { $game = get_record('game', 'id', $game); } //Start mod fwrite($bf, start_tag("MOD", 3, true)); //Print game data $game->modtype = 'game'; game_backup_record($bf, $game, 4); $recs = get_records_select('game_snakes_database'); game_backup_table($bf, $recs, 'GAME_SNAKES_DATABASE', 5, 'GAME_SNAKES_DATABASE_RECORD', 6); $recs = get_records_select('game_bookquiz_questions', "gameid={$game->id}"); game_backup_table($bf, $recs, 'GAME_BOOKQUIZ_QUESTIONS', 5, 'GAME_BOOKQUIZ_QUESTION', 6); $recs = get_records_select('game_grades', "gameid={$game->id}"); game_backup_table($bf, $recs, 'GAME_GRADES', 5, 'GAME_GRADE', 6); $sql = "SELECT DISTINCT g.questioncategoryid as id,qc.stamp FROM " . " {$CFG->prefix}game g,{$CFG->prefix}question_categories qc " . " WHERE g.questioncategoryid = qc.id"; $recs = get_records_sql($sql); game_backup_table($bf, $recs, 'QUESTION_CATEGORIES', 5, 'QUESTION_CATEGORY', 6); game_backup_attempts($bf, $preferences, $game->id); //End mod $status = fwrite($bf, end_tag("MOD", 3, true)); return $status; }
/** * Returns the groupingid of a grouping with the name specified for the course. * Grouping names should be unique in course * @param int $courseid The id of the course * @param string $name name of group (without magic quotes) * @return int $groupid */ function groups_get_grouping_by_name($courseid, $name) { if ($groupings = get_records_select('groupings', "courseid={$courseid} AND name='" . addslashes($name) . "'")) { return key($groupings); } return false; }
/** * Invite known user * @param int $id Id of known Moodle user * @param bool $inviteeUnknown True if user was invited, false otherwise * @return Mediabird user ID */ function inviteKnownUser($moodleid, &$inviteeUnknown) { global $helper; $mbuser = false; if ($records = get_records_select('user', "id={$moodleid}", '', 'id,username,firstname,lastname,email')) { $record = $records[$moodleid]; $email = $record->email; $fullname = $record->firstname . ' ' . $record->lastname; if (strlen(trim($fullname)) == 0) { $fullname = $record->username; } if ($account_link = get_record("studynotes_account_links", "system", "moodle", "external_id", $moodleid)) { $mbuser = $account_link->internal_id; $inviteeUnknown = false; } else { if ($mbuser = $helper->registerUser($fullname, 1, $email)) { $account_link = (object) null; $account_link->external_id = $moodleid; $account_link->internal_id = $mbuser; $account_link->system = "moodle"; insert_record("studynotes_account_links", $account_link, false); $inviteeUnknown = true; } } } return $mbuser; }
function execute($finalelements, $data) { $filter_fuserfield = optional_param('filter_fuserfield_' . $data->field, 0, PARAM_RAW); if ($filter_fuserfield) { // addslashes is done in clean param $filter = clean_param(base64_decode($filter_fuserfield), PARAM_CLEAN); if (strpos($data->field, 'profile_') === 0) { if ($fieldid = get_field('user_info_field', 'id', 'shortname', str_replace('profile_', '', $data->field))) { $sql = "fieldid = {$fieldid} AND data = '{$filter}' AND userid IN(" . implode(',', $finalelements) . ")"; if ($infodata = get_records_select('user_info_data', $sql)) { $finalusersid = array(); foreach ($infodata as $d) { $finalusersid[] = $d->userid; } return $finalusersid; } } } else { $sql = "{$data->field} = '{$filter}' AND id IN(" . implode(',', $finalelements) . ")"; if ($elements = get_records_select('user', $sql)) { $finalelements = array_keys($elements); } } } return $finalelements; }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible choices on the course // Get the ID of the choice type $rec = get_record('modules', 'name', 'choice'); if (!$rec) { sloodle_debug("Failed to get choice module type."); exit; } $choicemoduleid = $rec->id; // Get all visible choices in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$choicemoduleid} AND visible = 1"); if (!$recs) { error(get_string('nochoices', 'sloodle')); exit; } $choices = array(); foreach ($recs as $cm) { // Fetch the choice instance $inst = get_record('choice', 'id', $cm->instance); if (!$inst) { continue; } // Store the choice details $choices[$cm->id] = $inst->name; } // Sort the list by name natcasesort($choices); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 600); $sloodlerelative = (int) sloodle_get_value($settings, 'sloodlerelative', 0); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a choice echo get_string('selectchoice', 'sloodle') . ': '; choose_from_menu($choices, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Ask the user for a refresh period (# seconds between automatic updates) echo get_string('refreshtimeseconds', 'sloodle') . ': '; echo '<input type="text" name="sloodlerefreshtime" value="' . $sloodlerefreshtime . '" size="8" maxlength="8" />'; echo "<br><br>\n"; // Show relative results echo get_string('relativeresults', 'sloodle') . ': '; choose_from_menu_yesno('sloodlerelative', $sloodlerelative); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings, true, false, true); }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible chatrooms on the course // Get the ID of the chat type $rec = get_record('modules', 'name', 'chat'); if (!$rec) { sloodle_debug("Failed to get chatroom module type."); exit; } $chatmoduleid = $rec->id; // Get all visible chatrooms in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$chatmoduleid} AND visible = 1"); if (!$recs) { error(get_string('nochatrooms', 'sloodle')); exit; } $chatrooms = array(); foreach ($recs as $cm) { // Fetch the chatroom instance $inst = get_record('chat', 'id', $cm->instance); if (!$inst) { continue; } // Store the chatroom details $chatrooms[$cm->id] = $inst->name; } // Sort the list by name natcasesort($chatrooms); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlelistentoobjects = (int) sloodle_get_value($settings, 'sloodlelistentoobjects', 0); $sloodleautodeactivate = (int) sloodle_get_value($settings, 'sloodleautodeactivate', 1); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a chatroom echo get_string('selectchatroom', 'sloodle') . ': '; choose_from_menu($chatrooms, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Listening to object chat echo get_string('listentoobjects', 'sloodle') . ': '; choose_from_menu_yesno('sloodlelistentoobjects', $sloodlelistentoobjects); echo "<br><br>\n"; // Allowing auto-deactivation echo get_string('allowautodeactivation', 'sloodle') . ': '; choose_from_menu_yesno('sloodleautodeactivate', $sloodleautodeactivate); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings); }
/** * * @uses CFG, USER * @param int $brainstormid * @param int $slotid * @param int $userid * @param int $groupid * @param boolean $excludemyself */ function merge_get_customentries($brainstormid, $slotid, $userid = null, $groupid = 0, $excludemyself = false) { global $CFG; $accessClause = brainstorm_get_accessclauses($userid, $groupid, $excludemyself); $select = "\r\n brainstormid = {$brainstormid} AND\r\n operatorid = 'merge' AND\r\n intvalue = {$slotid} AND\r\n itemsource = 0\r\n {$accessClause}\r\n "; $records = get_records_select('brainstorm_operatordata AS od', $select); return $records; }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible Sloodle Object assignments on the course // Get the ID of the assignment type $rec = get_record('modules', 'name', 'assignment'); if (!$rec) { sloodle_debug("Failed to get assignment module type."); exit; } $assignmentmoduleid = $rec->id; // Get all visible assignments in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$assignmentmoduleid} AND visible = 1"); if (!$recs) { error(get_string('noassignments', 'sloodle')); exit; } $assignments = array(); foreach ($recs as $cm) { // Fetch the assignment instance $inst = get_record('assignment', 'id', $cm->instance); if (!$inst) { continue; } // Ignore anything except Sloodle Object assignments if ($inst->assignmenttype != 'sloodleobject') { continue; } // Store the assignment details $assignments[$cm->id] = $inst->name; } // Make sure that we got some Sloodle Object assignments if (count($assignments) == 0) { error(get_string('nosloodleassignments', 'sloodle')); exit; } // Sort the list by name natcasesort($assignments); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select an assignment echo get_string('selectassignment', 'sloodle') . ': '; choose_from_menu($assignments, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings); }
function get_rows($elements, $sqlorder = '') { global $CFG; $finalelements = array(); if (!empty($elements)) { return get_records_select('course_categories', 'id IN (' . implode(',', $elements) . ')', $sqlorder); } return $finalelements; }
function remove_friend($username, $friendusername) { if (!($userids = get_records_select('user', "username = '******' OR username = '******'", '', 'username,id'))) { return; } $userid = $userids[$username]->id; $friendid = $userids[$friendusername]->id; delete_records_select('user_friend', "(userid = {$userid} AND friendid = {$friendid}) OR (userid = {$friendid} AND friendid = {$userid})"); }
function get_rows($elements, $sqlorder = '') { global $CFG; if (!empty($elements)) { return get_records_select('user', 'id IN (' . implode(',', $elements) . ')', $sqlorder); } else { return array(); } }
function resource_upgrade($oldversion) { // This function does anything necessary to upgrade // older versions to match current functionality global $CFG; if ($oldversion < 2004013101) { modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'update', 'resource', 'name');"); modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'add', 'resource', 'name');"); } if ($oldversion < 2004071000) { table_column("resource", "", "popup", "text", "", "", "", "", "alltext"); if ($resources = get_records_select("resource", "type='3' OR type='5'", "", "id, alltext")) { foreach ($resources as $resource) { $resource->popup = addslashes($resource->alltext); $resource->alltext = ""; if (!update_record("resource", $resource)) { notify("Error updating popup field for resource id = {$resource->id}"); } } } require_once "{$CFG->dirroot}/course/lib.php"; rebuild_course_cache(); } if ($oldversion < 2004071300) { table_column("resource", "", "options", "varchar", "255", "", "", "", "popup"); } if ($oldversion < 2004071303) { table_column("resource", "type", "type", "varchar", "30", "", "", "", ""); modify_database("", "UPDATE prefix_resource SET type='reference' WHERE type='1';"); modify_database("", "UPDATE prefix_resource SET type='file', options='frame' WHERE type='2';"); modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='3';"); modify_database("", "UPDATE prefix_resource SET type='text', options='0' WHERE type='4';"); modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='5';"); modify_database("", "UPDATE prefix_resource SET type='html' WHERE type='6';"); modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';"); modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';"); modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';"); } if ($oldversion < 2004080801) { modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';"); rebuild_course_cache(); } if ($oldversion < 2004111200) { //drop first to avoid conflicts when upgrading execute_sql("DROP INDEX {$CFG->prefix}resource_course_idx;", false); modify_database('', 'CREATE INDEX prefix_resource_course_idx ON prefix_resource (course);'); } if ($oldversion < 2005041100) { // replace wiki-like with markdown include_once "{$CFG->dirroot}/lib/wiki_to_markdown.php"; $wtm = new WikiToMarkdown(); $wtm->update('resource', 'alltext', 'options'); } ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions. return true; }
function survey_user_outline($course, $user, $mod, $survey) { if ($answers = get_records_select("survey_answers", "survey='{$survey->id}' AND userid='{$user->id}'")) { $lastanswer = array_pop($answers); $result->info = get_string("done", "survey"); $result->time = $lastanswer->time; return $result; } return NULL; }
/** * @todo Documenting this function. Capabilities checking */ function stampcoll_user_outline($course, $user, $mod, $stampcoll) { if ($stamps = get_records_select("stampcoll_stamps", "userid={$user->id} AND stampcollid={$stampcoll->id}")) { $result = new stdClass(); $result->info = get_string('numberofcollectedstamps', 'stampcoll', count($stamps)); $result->time = 0; // empty return $result; } return NULL; }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible distributors on the course // Get the ID of the Sloodle type $rec = get_record('modules', 'name', 'sloodle'); if (!$rec) { sloodle_debug("Failed to get Sloodle module type."); exit; } // Get all visible Sloodle modules in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$rec->id} AND visible = 1"); if (!is_array($recs)) { $recs = array(); } $distributors = array(); foreach ($recs as $cm) { // Fetch the distributor instance $inst = get_record('sloodle', 'id', $cm->instance, 'type', SLOODLE_TYPE_DISTRIB); if (!$inst) { continue; } // Store the distributor details $distributors[$cm->id] = $inst->name; } // Sort the list by name natcasesort($distributors); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 3600); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a distributor echo get_string('selectdistributor', 'sloodle') . ': '; choose_from_menu($distributors, 'sloodlemoduleid', $sloodlemoduleid, '<i>(' . get_string('nodistributorinterface', 'sloodle') . ')</i>', '', 0); echo "<br><br>\n"; // Ask the user for a refresh period (# seconds between automatic updates) echo get_string('refreshtimeseconds', 'sloodle') . ': '; echo '<input type="text" name="sloodlerefreshtime" value="' . $sloodlerefreshtime . '" size="8" maxlength="8" />'; echo "<br><br>\n"; print_box_end(); ///// ACCESS LEVELS ///// // There is no need for server access controls, as users cannot access the server through the object // (server access is entirely done through Moodle for this one) sloodle_print_access_level_options($settings, true, true, false); }
/** * Gets the tasks that have been cached in the database for this * component. * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results' * @return array of tasks * * INTERNAL - to be used from cronlib only */ function elis_tasks_get_cached($component) { $cachedtasks = array(); $component = addslashes($component); if ($storedtasks = get_records_select('elis_scheduled_tasks', "plugin = '{$component}' AND taskname IS NULL")) { foreach ($storedtasks as $task) { $cachedtasks[$task->callfunction] = (array) $task; } } return $cachedtasks; }
/** * Returns an array of custom profile fields * @return array of profile fields */ function get_profile_fields() { if (!($fields = get_records_select('user_info_field', '', 'shortname', 'id,shortname'))) { return null; } $res = array(0 => get_string('anyfield', 'filters')); foreach ($fields as $k => $v) { $res[$k] = $v->shortname; } return $res; }
/** * @desc Deletes all events relating to the wwassignment passed in. * @param $wwassignmentid integer The wwassignment ID. * @return integer 0 on success */ function _wwassignment_delete_events($wwassignment) { $wwassignmentid = $wwassignment->id; if ($events = get_records_select('event', "modulename = 'wwassignment' and instance = '{$wwassignmentid}'")) { foreach ($events as $event) { // error_log("deleting event ".$event->id); delete_event($event->id); } } return 0; }
/** * Returns an array of custom profile fields * @return array of profile fields */ function getProfileFields() { $fields =& get_records_select('user_info_field', '', 'shortname', 'id,shortname'); if (empty($fields)) { return null; } $res[0] = get_string('anyfield', 'filters'); foreach ($fields as $k => $v) { $res[$k] = $v->shortname; } return $res; }
function lightboxgallery_user_complete($course, $user, $mod, $resource) { if ($logs = get_records_select('log', "userid='{$user->id}' AND module='lightboxgallery' AND action='view' AND info='{$resource->id}'", 'time ASC')) { $numviews = count($logs); $lastlog = array_pop($logs); $strmostrecently = get_string('mostrecently'); $strnumviews = get_string('numviews', '', $numviews); echo $strnumviews . ' - ' . $strmostrecently . ' ' . userdate($lastlog->time); } else { print_string('neverseen', 'resource'); } }
/** * Weblog class constructor * * <p>Will set all weblog properties, if the provided weblog id exist * (which effectively will be a user id, regardless if one is dealing * with a person or a community - for Elgg both are users).</p> * * @param int $user_id The user id. * @param int $blog_id The weblog id. */ function Weblog($user_id, $blog_id) { $this->community = false; // dealing with community or not // username/id conversions if (is_numeric($user_id)) { $this->user_id = $user_id; } elseif (is_string($user_id)) { $this->user_id = get_field('users', 'ident', 'username', $user_id); } if (is_numeric($blog_id)) { $this->ident = $blog_id; } elseif (is_string($blog_id)) { $this->ident = get_field('users', 'ident', 'username', $blog_id); } // Are we dealing with a person or a community? if (run("users:type:get", $this->ident) == "person") { if ($result = get_record('users', 'ident', $this->user_id)) { $this->user_name = $result->name; $this->user_username = $result->username; } $posts = get_records_select('weblog_posts', "owner = ? AND weblog = ?", array($this->user_id, $this->user_id), 'posted DESC'); $this->blog_name = $this->user_name; $this->blog_username = $this->user_username; $this->owner = $this->user_id; } else { // It's a community $this->community = true; // Get the owner $this->owner = get_field('users', 'owner', 'ident', $this->ident); // Inject an SQL restriction if the user is not owner $sql_insert = ""; if ($this->owner != $this->user_id) { $sql_insert = " and owner = {$this->user_id} "; } if ($result = get_record('users', 'ident', $this->ident)) { $this->blog_name = $result->name; $this->blog_username = $result->username; } $posts = get_records_select('weblog_posts', "weblog = {$this->ident} {$sql_insert}", null, 'posted DESC'); $user = run('users:instance', array('user_id' => $this->user_id)); $this->user_name = $user->getName(); $this->user_username = $user->getUserName(); } $this->posts = array(); if (is_array($posts) && sizeof($posts) > 0) { foreach ($posts as $post) { $this->posts[] = $post->ident; } } else { } }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible presenters on the course // Get the ID of the chat type $rec = get_record('modules', 'name', 'sloodle'); if (!$rec) { sloodle_debug("Failed to get Sloodle module type."); exit; } $sloodlemoduleid = $rec->id; // Get all visible presenters in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$sloodlemoduleid} AND visible = 1"); $presenters = array(); foreach ($recs as $cm) { // Fetch the Sloodle instance $inst = get_record('sloodle', 'id', $cm->instance, 'type', SLOODLE_TYPE_PRESENTER); if (!$inst) { continue; } // Store the Sloodle details $presenters[$cm->id] = $inst->name; } // Make sure there are some presenters to be had if (count($presenters) < 1) { error(get_string('nopresenters', 'sloodle')); exit; } // Sort the list by name natcasesort($presenters); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlelistentoobjects = (int) sloodle_get_value($settings, 'sloodlelistentoobjects', 0); $sloodleautodeactivate = (int) sloodle_get_value($settings, 'sloodleautodeactivate', 1); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a Slideshow echo get_string('selectpresenter', 'sloodle') . ': '; choose_from_menu($presenters, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings, false, true, false); }
function execute($finalelements, $data) { $filter_fcoursefield = optional_param('filter_fcoursefield_' . $data->field, 0, PARAM_RAW); if ($filter_fcoursefield) { // addslashes is done in clean param $filter = clean_param(base64_decode($filter_fcoursefield), PARAM_CLEAN); $sql = "{$data->field} = '{$filter}' AND id IN(" . implode(',', $finalelements) . ")"; if ($elements = get_records_select('course', $sql)) { $finalelements = array_keys($elements); } } return $finalelements; }
function get_question_options(&$question) { // Get additional information from database // and attach it to the question object if (!($question->options = get_record('question_multichoice', 'question', $question->id))) { notify('Error: Missing question options for multichoice question' . $question->id . '!'); return false; } if (!($question->options->answers = get_records_select('question_answers', 'id IN (' . $question->options->answers . ')', 'id'))) { notify('Error: Missing question answers for multichoice question' . $question->id . '!'); return false; } return true; }