本文整理汇总了PHP中addslashes_object函数的典型用法代码示例。如果您正苦于以下问题:PHP addslashes_object函数的具体用法?PHP addslashes_object怎么用?PHP addslashes_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addslashes_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_db_upgrade_group
/**
* Upgrades a group for a specified course. To preserve the group ID we do a raw insert.
* @param int $courseid The course to create the group for
* @return int The id of the group created or false if the insert failed.
*/
function groups_db_upgrade_group($courseid, $group)
{
global $CFG;
// Check we have a valid course id
if (!$courseid || !$group || !isset($group->id)) {
return false;
}
$r = addslashes_object($group);
$sql = "INSERT INTO {$CFG->prefix}groups\n (id,name,description, enrolmentkey,lang,theme,picture,hidepicture, timecreated,timemodified)\n VALUES ('{$r->id}','{$r->name}','{$r->description}', '{$r->enrolmentkey}','{$r->lang}',\n '{$r->theme}','{$r->picture}','{$r->hidepicture}', '{$r->timecreated}','{$r->timemodified}')";
if ($result = execute_sql($sql)) {
$record2 = new Object();
$record2->courseid = $courseid;
$record2->groupid = $group->id;
$record2->timeadded = $group->timemodified;
$groupadded = insert_record('groups_courses_groups', $record2);
if (!$groupadded) {
$groupid = false;
}
}
return $group->id;
}
示例2: quiz_restore_wiki2markdown
function quiz_restore_wiki2markdown($restore)
{
global $CFG;
$status = true;
//Convert question->questiontext
if ($records = get_records_sql("SELECT q.id, q.questiontext, q.questiontextformat\n FROM {$CFG->prefix}question q,\n {$CFG->prefix}backup_ids b\n WHERE b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'question' AND\n q.id = b.new_id AND\n q.questiontextformat = " . FORMAT_WIKI)) {
$i = 0;
foreach ($records as $record) {
//Rebuild wiki links
$record->questiontext = restore_decode_wiki_content($record->questiontext, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->questiontext = $wtm->convert($record->questiontext, $restore->course_id);
$record->questiontextformat = FORMAT_MARKDOWN;
$status = update_record('question', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
return $status;
}
示例3: sync_users
//.........这里部分代码省略.........
///
if ($do_updates) {
// narrow down what fields we need to update
$all_keys = array_keys(get_object_vars($this->config));
$updatekeys = array();
foreach ($all_keys as $key) {
if (preg_match('/^field_updatelocal_(.+)$/', $key, $match)) {
if ($this->config->{$key} === 'onlogin') {
array_push($updatekeys, $match[1]);
// the actual key name
}
}
}
// print_r($all_keys); print_r($updatekeys);
unset($all_keys);
unset($key);
// only go ahead if we actually
// have fields to update locally
if (!empty($updatekeys)) {
$sql = 'SELECT u.id, u.username
FROM ' . $CFG->prefix . 'user u
WHERE u.auth=\'db\' AND u.deleted=\'0\' AND u.username IN (' . $quoteduserlist . ')';
if ($update_users = get_records_sql($sql)) {
print "User entries to update: " . count($update_users) . "\n";
foreach ($update_users as $user) {
echo "\t";
print_string('auth_dbupdatinguser', 'auth', array($user->username, $user->id));
if (!$this->update_user_record(addslashes($user->username), $updatekeys)) {
echo " - " . get_string('skipped');
}
echo "\n";
}
unset($update_users);
// free memory
}
}
}
///
/// create missing accounts
///
// NOTE: this is very memory intensive
// and generally inefficient
$sql = 'SELECT u.id, u.username
FROM ' . $CFG->prefix . 'user u
WHERE u.auth=\'db\' AND u.deleted=\'0\'';
$users = get_records_sql($sql);
// simplify down to usernames
$usernames = array();
foreach ($users as $user) {
array_push($usernames, $user->username);
}
unset($users);
$add_users = array_diff($userlist, $usernames);
unset($usernames);
if (!empty($add_users)) {
print_string('auth_dbuserstoadd', 'auth', count($add_users));
echo "\n";
begin_sql();
foreach ($add_users as $user) {
$username = $user;
$user = $this->get_userinfo_asobj($user);
// prep a few params
$user->username = $username;
$user->modified = time();
$user->confirmed = 1;
$user->auth = 'db';
$user->mnethostid = $CFG->mnet_localhost_id;
if (empty($user->lang)) {
$user->lang = $CFG->lang;
}
$user = addslashes_object($user);
// maybe the user has been deleted before
if ($old_user = get_record('user', 'username', $user->username, 'deleted', 1, 'mnethostid', $user->mnethostid)) {
$user->id = $old_user->id;
set_field('user', 'deleted', 0, 'username', $user->username);
echo "\t";
print_string('auth_dbreviveuser', 'auth', array(stripslashes($user->username), $user->id));
echo "\n";
} elseif ($id = insert_record('user', $user)) {
// it is truly a new user
echo "\t";
print_string('auth_dbinsertuser', 'auth', array(stripslashes($user->username), $id));
echo "\n";
// if relevant, tag for password generation
if ($this->config->passtype === 'internal') {
set_user_preference('auth_forcepasswordchange', 1, $id);
set_user_preference('create_password', 1, $id);
}
} else {
echo "\t";
print_string('auth_dbinsertusererror', 'auth', $user->username);
echo "\n";
}
}
commit_sql();
unset($add_users);
// free mem
}
return true;
}
示例4: dialogue_cron
//.........这里部分代码省略.........
$rs = get_recordset_select('dialogue_conversations', 'grouping != 0 AND grouping IS NOT NULL', 'dialogueid, grouping');
$dialogueid = 0;
$grouping = 0;
$groupid = null;
$inconversation = array();
$newusers = array();
while ($conversation = rs_fetch_next_record($rs)) {
if ($dialogueid != $conversation->dialogueid || $groupid != $conversation->groupid || $grouping != $conversation->grouping) {
if ($dialogueid == 0 || $groupid === null) {
$dialogueid = $conversation->dialogueid;
$groupid = $conversation->groupid;
}
$cm = get_coursemodule_from_instance('dialogue', $dialogueid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$users = (array) get_users_by_capability($context, 'mod/dialogue:participate', 'u.id, u.firstname, u.lastname', null, null, null, empty($groupid) ? null : $groupid, null, null, null, false);
$managers = (array) get_users_by_capability($context, 'mod/dialogue:manage', 'u.id, u.firstname, u.lastname', null, null, null, null, null, null, null, false);
$dialogueid = $conversation->dialogueid;
$groupid = $conversation->groupid;
}
if ($grouping != $conversation->grouping) {
if ($grouping) {
if ($userdiff = array_diff_key($users, $inconversation, $managers)) {
foreach ($userdiff as $userid => $value) {
$newusers[$userid . ',' . $grouping] = array('userid' => $userid, 'courseid' => $cm->course, 'grouping' => $grouping);
}
}
}
$inconversation = array();
$grouping = $conversation->grouping;
}
$inconversation[$conversation->recipientid] = true;
}
if (!empty($dialogueid)) {
// Finish of any remaing users
$cm = get_coursemodule_from_instance('dialogue', $dialogueid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$users = (array) get_users_by_capability($context, 'mod/dialogue:participate', 'u.id, u.firstname, u.lastname', null, null, null, empty($groupid) ? null : $groupid, null, null, null, false);
$managers = (array) get_users_by_capability($context, 'mod/dialogue:manage', 'u.id, u.firstname, u.lastname', null, null, null, null, null, null, null, false);
if ($userdiff = array_diff_key($users, $inconversation, $managers)) {
foreach ($userdiff as $userid => $value) {
$newusers[$userid . ',' . $grouping] = array('userid' => $userid, 'courseid' => $cm->course, 'grouping' => $grouping);
}
}
}
rs_close($rs);
if (!empty($newusers)) {
foreach ($newusers as $key => $newuser) {
begin_sql();
course_setup($newuser['courseid']);
if ($conversations = get_records('dialogue_conversations', 'grouping', $newuser['grouping'], 'id', '*', 0, 1)) {
$conversation = array_pop($conversations);
// we only need one to get the common field values
if ($entry = get_records('dialogue_entries', 'conversationid', $conversation->id, 'id', '*', 0, 1)) {
unset($conversation->id);
$conversation->recipientid = $newuser['userid'];
$conversation->lastrecipientid = $newuser['userid'];
$conversation->timemodified = time();
$conversation->seenon = false;
$conversation->closed = 0;
$conversation = addslashes_object($conversation);
if (!($conversationid = insert_record('dialogue_conversations', $conversation))) {
rollback_sql();
continue;
}
$entry = array_pop($entry);
$srcentry = clone $entry;
unset($entry->id);
$entry->conversationid = $conversationid;
$entry->timecreated = $conversation->timemodified;
$entry->recipientid = $conversation->recipientid;
$entry->mailed = false;
$entry = addslashes_object($entry);
if (!($entry->id = insert_record('dialogue_entries', $entry))) {
rollback_sql();
continue;
}
$read = new stdClass();
$lastread = time();
$read->conversationid = $conversationid;
$read->entryid = $entry->id;
$read->userid = $conversation->userid;
$read->firstread = $lastread;
$read->lastread = $lastread;
insert_record('dialogue_read', $read);
if ($entry->attachment) {
$srcdir = dialogue_file_area($srcentry);
$dstdir = dialogue_file_area($entry);
copy($srcdir . '/' . $entry->attachment, $dstdir . '/' . $entry->attachment);
}
} else {
mtrace('Failed to find entry for conversation: ' . $conversation->id);
}
} else {
mtrace('Failed to find conversation: ' . $conversation->id);
}
commit_sql();
}
}
return true;
}
示例5: fullname
$a->user = fullname($user);
email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname), get_string('enrolmentnewuser', '', $a));
}
if (!empty($CFG->enrol_mailadmins)) {
$a->course = $course->fullname;
$a->user = fullname($user);
$admins = get_admins();
foreach ($admins as $admin) {
email_to_user($admin, $user, get_string("enrolmentnew", '', $course->shortname), get_string('enrolmentnewuser', '', $a));
}
}
}
} else {
if (strcmp($result, "INVALID") == 0) {
// ERROR
insert_record("enrol_paypal", addslashes_object($data), false);
email_paypal_error_to_admin("Received an invalid payment notification!! (Fake payment?)", $data);
}
}
}
fclose($fp);
exit;
/// FUNCTIONS //////////////////////////////////////////////////////////////////
function email_paypal_error_to_admin($subject, $data)
{
$admin = get_admin();
$site = get_site();
$message = "{$site->fullname}: Transaction failed.\n\n{$subject}\n\n";
foreach ($data as $key => $value) {
$message .= "{$key} => {$value}\n";
}
示例6: kaltura_restore_wiki2markdown
function kaltura_restore_wiki2markdown($restore)
{
global $CFG;
$status = true;
return $status;
//Convert resource->alltext
if ($records = get_records_sql("SELECT r.id, r.alltext, r.options\n FROM {$CFG->prefix}resource r,\n {$CFG->prefix}backup_ids b\n WHERE r.course = {$restore->course_id} AND\n options = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'resource' AND\n b.new_id = r.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->alltext = restore_decode_wiki_content($record->alltext, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->alltext = $wtm->convert($record->alltext, $restore->course_id);
$record->options = FORMAT_MARKDOWN;
$status = update_record('resource', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
return $status;
}
示例7: import
function import()
{
global $CFG;
list($settings, $newfields, $currentfields) = $this->get_settings();
$preservedfields = array();
$overwritesettings = optional_param('overwritesettings', 0, PARAM_BOOL);
/* Maps fields and makes new ones */
if (!empty($newfields)) {
/* We require an injective mapping, and need to know what to protect */
foreach ($newfields as $nid => $newfield) {
$cid = optional_param("field_{$nid}", -1, PARAM_INT);
if ($cid == -1) {
continue;
}
if (array_key_exists($cid, $preservedfields)) {
error("Not an injective map");
} else {
$preservedfields[$cid] = true;
}
}
foreach ($newfields as $nid => $newfield) {
$cid = optional_param("field_{$nid}", -1, PARAM_INT);
/* A mapping. Just need to change field params. Data kept. */
if ($cid != -1 and isset($currentfields[$cid])) {
$fieldobject = data_get_field_from_id($currentfields[$cid]->id, $this->data);
foreach ($newfield as $param => $value) {
if ($param != "id") {
$fieldobject->field->{$param} = $value;
}
}
unset($fieldobject->field->similarfield);
$fieldobject->update_field();
unset($fieldobject);
} else {
include_once "field/{$newfield->type}/field.class.php";
if (!isset($newfield->description)) {
$newfield->description = '';
}
$classname = 'data_field_' . $newfield->type;
$fieldclass = new $classname($newfield, $this->data);
$fieldclass->insert_field();
unset($fieldclass);
}
}
}
/* Get rid of all old unused data */
if (!empty($preservedfields)) {
foreach ($currentfields as $cid => $currentfield) {
if (!array_key_exists($cid, $preservedfields)) {
/* Data not used anymore so wipe! */
print "Deleting field {$currentfield->name}<br />";
$id = $currentfield->id;
//Why delete existing data records and related comments/ratings??
/*
if ($content = get_records('data_content', 'fieldid', $id)) {
foreach ($content as $item) {
delete_records('data_ratings', 'recordid', $item->recordid);
delete_records('data_comments', 'recordid', $item->recordid);
delete_records('data_records', 'id', $item->recordid);
}
}*/
delete_records('data_content', 'fieldid', $id);
delete_records('data_fields', 'id', $id);
}
}
}
// handle special settings here
if (!empty($settings->defaultsort)) {
if (is_numeric($settings->defaultsort)) {
// old broken value
$settings->defaultsort = 0;
} else {
$settings->defaultsort = (int) get_field('data_fields', 'id', 'dataid', $this->data->id, 'name', addslashes($settings->defaultsort));
}
} else {
$settings->defaultsort = 0;
}
// do we want to overwrite all current database settings?
if ($overwritesettings) {
// all supported settings
$overwrite = array_keys((array) $settings);
} else {
// only templates and sorting
$overwrite = array('singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate', 'jstemplate', 'asearchtemplate', 'defaultsortdir', 'defaultsort');
}
// now overwrite current data settings
foreach ($this->data as $prop => $unused) {
if (in_array($prop, $overwrite)) {
$this->data->{$prop} = $settings->{$prop};
}
}
data_update_instance(addslashes_object($this->data));
if (strstr($this->folder, '/temp/')) {
// Removes the temporary files
clean_preset($this->folder);
}
return true;
}
示例8: journal_restore_wiki2markdown
function journal_restore_wiki2markdown($restore)
{
global $CFG;
$status = true;
//Convert journal_entries->text
if ($records = get_records_sql("SELECT e.id, e.text, e.format\n FROM {$CFG->prefix}journal_entries e,\n {$CFG->prefix}journal j,\n {$CFG->prefix}backup_ids b\n WHERE j.id = e.journal AND\n j.course = {$restore->course_id} AND\n e.format = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'journal_entries' AND\n b.new_id = e.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->text = restore_decode_wiki_content($record->text, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->text = $wtm->convert($record->text, $restore->course_id);
$record->format = FORMAT_MARKDOWN;
$status = update_record('journal_entries', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
//Convert journal->intro
if ($records = get_records_sql("SELECT j.id, j.intro, j.introformat\n FROM {$CFG->prefix}journal j,\n {$CFG->prefix}backup_ids b\n WHERE j.course = {$restore->course_id} AND\n j.introformat = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'journal' AND\n b.new_id = j.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->intro = restore_decode_wiki_content($record->intro, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->intro = $wtm->convert($record->intro, $restore->course_id);
$record->introformat = FORMAT_MARKDOWN;
$status = update_record('journal', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
return $status;
}
示例9: AutenticarUsuarioContenido
//.........这里部分代码省略.........
add_to_log(1, '1-211', serialize(array('ISBN' => $usrcontent->ISBN, 'unitcode' => $usrcontent->IdUnidad)), true);
$result->AutenticarUsuarioContenidoResult->Codigo = "-5";
$result->AutenticarUsuarioContenidoResult->Descripcion = "L'identificador de la unitat no és vàlid";
$result->AutenticarUsuarioContenidoResult->URL = "http://www.xtec.cat/error.html";
return $result;
} else {
/// manipulate the manifest to set href's absolutes
if ($bookpath->format == 'scorm') {
if (!manifest_manipulation($unitpath->path)) {
add_to_log(1, '1-212', serialize(array('ISBN' => $usrcontent->ISBN, 'unitcode' => $usrcontent->IdUnidad, 'path' => $unitpath->path)), true);
}
}
/// set the absolute path to the manifest
$result->AutenticarUsuarioContenidoResult->URL = $path . $unitpath->path;
}
}
} else {
if ($usrcontent->IdUnidad != '' && $usrcontent->IdActividad != '') {
if (!($bookpath = get_record('books', 'isbn', $usrcontent->ISBN))) {
//save log error becouse the ISBN it's not found in db
add_to_log(1, '1-220', serialize(array('ISBN' => $usrcontent->ISBN)), true);
} else {
if (!($unitpath = get_record('books_units', 'bookid', $bookpath->id, 'code', $usrcontent->IdUnidad))) {
//save log error becouse the Unit code it's not found in db
add_to_log(1, '1-221', serialize(array('ISBN' => $usrcontent->ISBN, 'unitcode' => $usrcontent->IdUnidad)), true);
$result->AutenticarUsuarioContenidoResult->Codigo = "-5";
$result->AutenticarUsuarioContenidoResult->Descripcion = "L'identificador de la unitat no és vàlid";
$result->AutenticarUsuarioContenidoResult->URL = "http://www.xtec.cat/error.html";
return $result;
} else {
if (!($activitypath = get_record('books_activities', 'bookid', $bookpath->id, 'unitid', $unitpath->id, 'code', $usrcontent->IdActividad))) {
add_to_log(1, '1-222', serialize(array('ISBN' => $usrcontent->ISBN, 'unitcode' => $usrcontent->IdUnidad, 'activitycode' => $usrcontent->IdActividad, 'path' => $activitypath->path)), true);
$result->AutenticarUsuarioContenidoResult->Codigo = "-6";
$result->AutenticarUsuarioContenidoResult->Descripcion = "L'identificador de la activitat no és vàlid ";
$result->AutenticarUsuarioContenidoResult->URL = "http://www.xtec.cat/error.html";
return $result;
} else {
/// manipulate the manifest to set href's absolutes
if ($bookpath->format == 'scorm') {
if (!manifest_manipulation($activitypath->path)) {
add_to_log(1, '1-223', serialize(array('ISBN' => $usrcontent->ISBN, 'unitcode' => $usrcontent->IdUnidad, 'path' => $activitypath->path)), true);
}
}
/// set the absolute path to the manifest
$result->AutenticarUsuarioContenidoResult->URL = $path . $activitypath->path;
}
}
}
} else {
add_to_log(1, '1-204', serialize(array('ISBN' => $book_credencial->ISBN)));
$result->AutenticarUsuarioContenidoResult->URL = $book_credential->url;
}
}
}
//GAP
//********** AFEGIT XTEC - if URL generated correctly, generates the token and saves the data in the session table
if ($result->AutenticarUsuarioContenidoResult->Codigo == 1) {
if (isset($bookpath->format) and $bookpath->format == 'webcontent' and !isset($_GET['wsdl'])) {
$session = new stdClass();
$session->token = str_replace('.', '', uniqid('', true));
$session->isbn = $usrcontent->ISBN;
$session->userid = $usrcontent->IdUsuario;
$session->nameape = $usrcontent->NombreApe;
$session->groupid = $usrcontent->IdGrupo;
$session->courseid = $usrcontent->IdCurso;
$session->centerid = $usrcontent->IdCentro;
$session->wsurltracking = $usrcontent->URLResultado;
$session->lmscontentid = $usrcontent->IdContenidoLMS;
$session->unitid = $usrcontent->IdUnidad;
$session->activityid = $usrcontent->IdActividad;
$session->addtime = time();
$session->expiretime = time() + 86400;
//expire in 24 hours
$session->urlcontent = $result->AutenticarUsuarioContenidoResult->URL . "?token={$session->token}";
$session = addslashes_object($session);
$result->AutenticarUsuarioContenidoResult->URL = $result->AutenticarUsuarioContenidoResult->URL . "?token={$session->token}";
insert_record("sessions", $session);
}
}
}
//**********
} else {
$result->AutenticarUsuarioContenidoResult->Codigo = '-2';
$result->AutenticarUsuarioContenidoResult->Descripcion = 'El codi de llicencia no es vàlid.';
$result->AutenticarUsuarioContenidoResult->URL = 'http://www.xtec.cat/error.html';
}
} else {
$result->AutenticarUsuarioContenidoResult->Codigo = '-3';
$result->AutenticarUsuarioContenidoResult->Descripcion = 'El ISBN del producte no es vàlid.';
$result->AutenticarUsuarioContenidoResult->URL = 'http://www.xtec.cat/error.html';
}
} else {
$result->AutenticarUsuarioContenidoResult->Codigo = $auth->Codigo;
$result->AutenticarUsuarioContenidoResult->Descripcion = $auth->Descripcion;
$result->AutenticarUsuarioContenidoResult->URL = $auth->url;
}
/// save log registering method response
add_to_log(1, 20, serialize($result->AutenticarUsuarioContenidoResult));
return $result;
}
示例10: glossary_restore_wiki2markdown
function glossary_restore_wiki2markdown($restore)
{
global $CFG;
$status = true;
//Convert glossary_comments->entrycomment
if ($records = get_records_sql("SELECT c.id, c.entrycomment, c.format\n FROM {$CFG->prefix}glossary_comments c,\n {$CFG->prefix}glossary_entries e,\n {$CFG->prefix}glossary g,\n {$CFG->prefix}backup_ids b\n WHERE e.id = c.entryid AND\n g.id = e.glossaryid AND\n g.course = {$restore->course_id} AND\n c.format = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'glossary_comments' AND\n b.new_id = c.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->entrycomment = restore_decode_wiki_content($record->entrycomment, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->entrycomment = $wtm->convert($record->entrycomment, $restore->course_id);
$record->format = FORMAT_MARKDOWN;
$status = update_record('glossary_comments', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
//Convert glossary_entries->definition
if ($records = get_records_sql("SELECT e.id, e.definition, e.format\n FROM {$CFG->prefix}glossary_entries e,\n {$CFG->prefix}glossary g,\n {$CFG->prefix}backup_ids b\n WHERE g.id = e.glossaryid AND\n g.course = {$restore->course_id} AND\n e.format = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'glossary_entries' AND\n b.new_id = e.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->definition = restore_decode_wiki_content($record->definition, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->definition = $wtm->convert($record->definition, $restore->course_id);
$record->format = FORMAT_MARKDOWN;
$status = update_record('glossary_entries', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
return $status;
}
示例11: add_to_log
$log->ActividadOrden = $result->ActividadOrden;
$log->ActividadTitulo = $result->ActividadTitulo;
$log->idUnidad = $result->idUnidad;
$log->UnidadOrden = $result->UnidadOrden;
$log->UnidadTitulo = $result->UnidadTitulo;
$log->idCentro = $result->idCentro;
$log->idContenidoLMS = $result->idContenidoLMS;
$log->idUsuario = $result->idUsuario;
$log->SumaPesos = $result->SumaPesos;
$log->Duracion = $result->Resultado->Duracion;
$log->FechaHoraInicio = $result->Resultado->FechaHoraInicio;
$log->MaxDuracion = $result->Resultado->MaxDuracion;
$log->Observaciones = $result->Resultado->Observaciones;
$log->Calificacion = $result->Resultado->Calificacion;
$log->URLVerResultados = $result->Resultado->URLVerResultados;
add_to_log(3, 12, serialize(addslashes_object($log)));
/// save log registering the number of details
add_to_log(3, 13, serialize(count($result->Detalles)));
$params = new ResultadoDetalleExtendido();
$params->ResultadoExtendido = new SoapVar($result, SOAP_ENC_OBJECT, "SeguimientoExtendido", "http://educacio.gencat.cat/agora/seguimiento/");
$client = new soapclient($reg_session->wsurltracking . '?wsdl', array('trace' => 1));
$auth = array('User' => $reg_credential->username, 'Password' => $reg_credential->password);
$namespace = rcommond_wdsl_parser($reg_session->wsurltracking . '?wsdl');
$header = new SoapHeader($namespace, "WSEAuthenticateHeader", $auth);
$client->__setSoapHeaders(array($header));
/// save log registering the call to ws tracking
add_to_log(3, 14);
try {
$response = $client->__soapCall("ResultadoDetalleExtendido", array($params));
} catch (Exception $e) {
print_r($e);
示例12: survey_copy
function survey_copy($owner)
{
// clear the sid, clear the creation date, change the name, and clear the status
// Since we're copying a data record, addslashes.
$survey = addslashes_object($this->survey);
unset($survey->id);
$survey->owner = $owner;
$survey->name .= '_copy';
$survey->status = 0;
// check for 'name' conflict, and resolve
$i = 0;
$name = $survey->name;
while (count_records('questionnaire_survey', 'name', $name) > 0) {
$name = $survey->name . ++$i;
}
if ($i) {
$survey->name .= $i;
}
// create new survey
if (!($new_sid = insert_record('questionnaire_survey', $survey))) {
return false;
}
// make copies of all the questions
$pos = 1;
foreach ($this->questions as $question) {
$tid = $question->type_id;
$qid = $question->id;
// fix some fields first
unset($question->id);
$question->survey_id = $new_sid;
$question->position = $pos++;
$question->name = addslashes($question->name);
$question->content = addslashes($question->content);
// copy question to new survey
if (!($new_qid = insert_record('questionnaire_question', $question))) {
return false;
}
foreach ($question->choices as $choice) {
unset($choice->id);
$choice->question_id = $new_qid;
$choice->content = addslashes($choice->content);
$choice->value = addslashes($choice->value);
if (!insert_record('questionnaire_quest_choice', $choice)) {
return false;
}
}
}
return $new_sid;
}
示例13: restore_create_questions
function restore_create_questions($restore, $xml_file)
{
global $CFG, $db;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//info will contain the old_id of every category
//in backup_ids->info will be the real info (serialized)
$info = restore_read_xml_questions($restore, $xml_file);
}
//Now, if we have anything in info, we have to restore that
//categories/questions
if ($info) {
if ($info !== true) {
//Iterate over each category
foreach ($info as $category) {
//Skip empty categories (some backups can contain them)
if (!empty($category->id)) {
$status = restore_question_categories($category, $restore);
}
}
//Now we have to recode the parent field of each restored category
$categories = get_records_sql("SELECT old_id, new_id \n FROM {$CFG->prefix}backup_ids\n WHERE backup_code = {$restore->backup_unique_code} AND\n table_name = 'question_categories'");
if ($categories) {
foreach ($categories as $category) {
$restoredcategory = get_record('question_categories', 'id', $category->new_id);
$restoredcategory = addslashes_object($restoredcategory);
if ($restoredcategory->parent != 0) {
$idcat = backup_getid($restore->backup_unique_code, 'question_categories', $restoredcategory->parent);
if ($idcat->new_id) {
$restoredcategory->parent = $idcat->new_id;
} else {
$restoredcategory->parent = 0;
}
update_record('question_categories', $restoredcategory);
}
}
}
}
} else {
$status = false;
}
return $status;
}
示例14: elluminate_cal_edit
/**
* Adds or edits an existing calendar event for an assosciated meeting.
*
* There aqre two possible meeting configurations:
* 1. A private meeting where only the people chosen to be particpants
* are allowed access.
* 2. A public meeting where anyone in a given course is allowed to
* access to meeting.
*
* We must handle adding and removing users to a private meeting and also
* deleteing unnecessary events when a meeting changes from private to
* public and vice versa.
*
* @uses $CFG
* @param int $meetingid The meeting ID to edit the calendar event for.
* @param boolean $delete Whether the meeting is being deleted.
* @return boolean True on success, False otherwise.
*/
function elluminate_cal_edit($meetingid, $delete = false)
{
global $CFG;
if (!($meeting = get_record('elluminate', 'id', $meetingid))) {
return false;
}
/// Special action if we're deleting a meeting.
if ($delete) {
if ($events = elluminate_get_events($meeting->id)) {
foreach ($events as $event) {
delete_records('event', 'id', $event->id);
}
}
return true;
}
if ($meeting->private) {
/// If this meeting has been newly marked private, delete the old, public,
/// event record.
$admin = get_admin();
$sql = "DELETE FROM {$CFG->prefix}event\n\t\t\t\t\t\t\t\t WHERE modulename = 'elluminate'\n\t\t\t\t\t\t\t\t AND instance = {$meeting->id}\n\t\t\t\t\t\t\t\t AND courseid = {$meeting->course}\n\t\t\t\t\t\t\t\t AND userid = {$admin->id}";
execute_sql($sql, false);
} else {
if (!$meeting->private && !elluminate_has_course_event($meeting->id)) {
/// Create the new course event.
$admin = get_admin();
$event = new stdClass();
$event->name = get_string('calendarname', 'elluminate', $meeting->name);
$event->description = $meeting->description;
$event->format = 1;
$event->courseid = $meeting->course;
$event->groupid = 0;
$event->userid = $admin->id;
$event->modulename = 'elluminate';
$event->instance = $meeting->id;
$event->eventtype = '';
$event->visible = 1;
$event->timestart = $meeting->timestart;
$duration = $meeting->timeend - $meeting->timestart;
if ($duration < 0) {
$event->timeduration = 0;
} else {
$event->timeduration = $duration;
}
$event->timemodified = time();
$event = addslashes_object($event);
$event->id = insert_record('event', $event);
return true;
}
}
if (!($elluminate = get_record("elluminate", "id", $meetingid))) {
error("Course module is incorrect");
}
if (!($course = get_record("course", "id", $elluminate->course))) {
error("Course is misconfigured");
}
if (!($cm = get_coursemodule_from_instance("elluminate", $elluminate->id, $course->id))) {
error("Course Module ID was incorrect");
}
/// Modifying any existing events.
if ($events = elluminate_get_events($meeting->id)) {
foreach ($events as $event) {
/// Delete any non-moderator events if this meeting is public...
$deleted = false;
if (empty($meeting->private) && empty($event->userid)) {
if ($elm_id = get_field('elluminate_users', 'elm_id', 'userid', $event->userid)) {
if (!has_capability('mod/elluminate:moderatemeeting', $context, $USER->id, false)) {
$deleted = delete_records('event', 'id', $event->id);
}
}
}
if (!$deleted) {
$event->name = addslashes(get_string('calendarname', 'elluminate', $meeting->name));
$event->description = addslashes($meeting->description);
$event->timestart = $meeting->timestart;
$duration = $meeting->timeend - $meeting->timestart;
if ($duration < 0) {
$event->timeduration = 0;
} else {
$event->timeduration = $duration;
}
$eventtimemodified = time();
if (!update_record('event', $event)) {
//.........这里部分代码省略.........
示例15: forum_restore_wiki2markdown
function forum_restore_wiki2markdown($restore)
{
global $CFG;
$status = true;
//Convert forum_posts->message
if ($records = get_records_sql("SELECT p.id, p.message, p.format\n FROM {$CFG->prefix}forum_posts p,\n {$CFG->prefix}forum_discussions d,\n {$CFG->prefix}forum f,\n {$CFG->prefix}backup_ids b\n WHERE d.id = p.discussion AND\n f.id = d.forum AND\n f.course = {$restore->course_id} AND\n p.format = " . FORMAT_WIKI . " AND\n b.backup_code = {$restore->backup_unique_code} AND\n b.table_name = 'forum_posts' AND\n b.new_id = p.id")) {
foreach ($records as $record) {
//Rebuild wiki links
$record->message = restore_decode_wiki_content($record->message, $restore);
//Convert to Markdown
$wtm = new WikiToMarkdown();
$record->message = $wtm->convert($record->message, $restore->course_id);
$record->format = FORMAT_MARKDOWN;
$status = update_record('forum_posts', addslashes_object($record));
//Do some output
$i++;
if (($i + 1) % 1 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 20 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
return $status;
}