本文整理汇总了PHP中addslashes_recursive函数的典型用法代码示例。如果您正苦于以下问题:PHP addslashes_recursive函数的具体用法?PHP addslashes_recursive怎么用?PHP addslashes_recursive使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addslashes_recursive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Saves (inserts or updates) a workflow data record to the database.
*/
public function save()
{
$this->timemodified = time();
if (!empty($this->id)) {
update_record(self::$table_name, addslashes_recursive($this));
} else {
$this->id = insert_record(self::$table_name, addslashes_recursive($this));
}
}
示例2: addslashes_recursive
function addslashes_recursive($value)
{
if (is_array($value)) {
foreach ($value as $index => $val) {
$value[$index] = addslashes_recursive($val);
}
return $value;
} else {
return addslashes($value);
}
}
示例3: insert
/**
* Records this object in the Database, sets its id to the returned value, and returns that value.
* If successful this function also fetches the new object data from database and stores it
* in object properties.
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*/
function insert($source = null)
{
global $USER, $CFG;
if (!empty($this->id)) {
debugging("Grade object already exists!");
return false;
}
$data = $this->get_record_data();
if (!($this->id = insert_record($this->table, addslashes_recursive($data)))) {
debugging("Could not insert object into db");
return false;
}
// set all object properties from real db data
$this->update_from_db();
$data = $this->get_record_data();
if (empty($CFG->disablegradehistory)) {
unset($data->timecreated);
$data->action = GRADE_HISTORY_INSERT;
$data->oldid = $this->id;
$data->source = $source;
$data->timemodified = time();
$data->loggeduser = $USER->id;
insert_record($this->table . '_history', addslashes_recursive($data));
}
return $this->id;
}
示例4: turnitintool_get_records_sql
/**
* Abstracted version of get_records_sql() to work with Moodle 1.8 through 2.0
*
* @param string $sql The SQL Query
* @param array $params array of sql parameters
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array An array of data objects
*/
function turnitintool_get_records_sql($sql, $params = NULL, $limitfrom = 0, $limitnum = 0)
{
global $DB, $CFG;
if (is_callable(array($DB, 'get_records_sql'))) {
$return = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum);
} else {
$sql = preg_replace('/\\{([a-z][a-z0-9_]*)\\}/', $CFG->prefix . '$1', $sql);
$params = addslashes_recursive($params);
$sql = vsprintf(str_replace("?", "'%s'", $sql), $params);
//$sql = sql_magic_quotes_hack( $sql );
$return = get_records_sql($sql, $limitfrom, $limitnum);
}
return $return;
}
示例5: create_course
function create_course($course_ext, $skip_fix_course_sortorder = 0)
{
global $CFG;
// override defaults with template course
if (!empty($CFG->enrol_ldap_template)) {
$course = get_record("course", 'shortname', $CFG->enrol_ldap_template);
unset($course->id);
// so we are clear to reinsert the record
unset($course->sortorder);
} else {
// set defaults
$course = new object();
$course->student = get_string('defaultcoursestudent');
$course->students = get_string('defaultcoursestudents');
$course->teacher = get_string('defaultcourseteacher');
$course->teachers = get_string('defaultcourseteachers');
$course->format = 'topics';
}
// override with required ext data
$course->idnumber = $course_ext[$CFG->enrol_ldap_course_idnumber][0];
$course->fullname = $course_ext[$CFG->enrol_ldap_course_fullname][0];
$course->shortname = $course_ext[$CFG->enrol_ldap_course_shortname][0];
if (empty($course->idnumber) || empty($course->fullname) || empty($course->shortname)) {
// we are in trouble!
error_log("Cannot create course: missing required data from the LDAP record!");
error_log(var_export($course, true));
return false;
}
$course->summary = empty($CFG->enrol_ldap_course_summary) || empty($course_ext[$CFG->enrol_ldap_course_summary][0]) ? '' : $course_ext[$CFG->enrol_ldap_course_summary][0];
if (!empty($CFG->enrol_ldap_category)) {
// optional ... but ensure it is set!
$course->category = $CFG->enrol_ldap_category;
}
if ($course->category == 0) {
// must be avoided as it'll break moodle
$course->category = 1;
// the misc 'catch-all' category
}
// define the sortorder (yuck)
$sort = get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course WHERE category=' . $course->category);
$sort = $sort->max;
$sort++;
$course->sortorder = $sort;
// override with local data
$course->startdate = time();
$course->timecreated = time();
$course->visible = 1;
$course = addslashes_recursive($course);
// store it and log
if ($newcourseid = insert_record("course", $course)) {
// Set up new course
$section = new object();
$section->course = $newcourseid;
// Create a default section.
$section->section = 0;
$section->id = insert_record("course_sections", $section);
$page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
blocks_repopulate_page($page);
// Return value no
if (!$skip_fix_course_sortorder) {
fix_course_sortorder();
}
add_to_log($newcourseid, "course", "new", "view.php?id={$newcourseid}", "enrol/ldap auto-creation");
} else {
error_log("Could not create new course from LDAP from DN:" . $course_ext['dn']);
notify("Serious Error! Could not create the new course!");
return false;
}
return $newcourseid;
}
示例6: restore_create_users
//.........这里部分代码省略.........
$userauth->preventpassindb = $authplugin->prevent_local_passwords();
$userauth->isinternal = $authplugin->is_internal();
$userauth->canresetpwd = $authplugin->can_reset_password();
$authcache[$user->auth] = $userauth;
} else {
$userauth = $authcache[$user->auth];
// Get from cache
}
// Most external plugins do not store passwords locally
if (!empty($userauth->preventpassindb)) {
$user->password = 'not cached';
// If Moodle is responsible for storing/validating pwd and reset functionality is available, mark
} else {
if ($userauth->isinternal and $userauth->canresetpwd) {
$user->password = 'restored';
}
}
}
//We need to process the POLICYAGREED field to recalculate it:
// - if the destination site is different (by wwwroot) reset it.
// - if the destination site is the same (by wwwroot), leave it unmodified
if (!backup_is_same_site($restore)) {
$user->policyagreed = 0;
} else {
//Nothing to do, we are in the same server
}
//Check if the theme exists in destination server
$themes = get_list_of_themes();
if (!in_array($user->theme, $themes)) {
$user->theme = '';
}
//We are going to create the user
//The structure is exactly as we need
$newid = insert_record("user", addslashes_recursive($user));
//Put the new id
$status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, "new");
}
///TODO: This seccion is to support pre 1.7 course backups, using old roles
/// teacher, coursecreator, student.... providing a basic mapping to new ones.
/// Someday we'll drop support for them and this section will be safely deleted (2.0?)
//Here, if create_roles, do it as necessary
if ($create_roles) {
//Get the newid and current info from backup_ids
$data = backup_getid($restore->backup_unique_code, "user", $userid);
$newid = $data->new_id;
$currinfo = $data->info . ",";
//Now, depending of the role, create records in user_studentes and user_teacher
//and/or mark it in backup_ids
if ($is_admin) {
//If the record (user_admins) doesn't exists
//Only put status in backup_ids
$currinfo = $currinfo . "admin,";
$status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, $currinfo);
}
if ($is_coursecreator) {
//If the record (user_coursecreators) doesn't exists
//Only put status in backup_ids
$currinfo = $currinfo . "coursecreator,";
$status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, $currinfo);
}
if ($is_needed) {
//Only put status in backup_ids
$currinfo = $currinfo . "needed,";
$status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, $currinfo);
}
if ($is_teacher) {
示例7: xmldb_main_upgrade
//.........这里部分代码省略.........
if ($result && $oldversion < 2007082700) {
/// Define field timemodified to be added to tag_instance
$table = new XMLDBTable('tag_instance');
$field = new XMLDBField('timemodified');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'ordering');
/// Launch add field timemodified
$result = $result && add_field($table, $field);
upgrade_main_savepoint($result, 2007082700);
}
/// migrate all tags table to tag - this code MUST use SQL only,
/// because if the db structure changes the library functions will fail in future
if ($result && $oldversion < 2007082701) {
$tagrefs = array();
// $tagrefs[$oldtagid] = $newtagid
if ($rs = get_recordset('tags')) {
$db->debug = false;
while ($oldtag = rs_fetch_next_record($rs)) {
$raw_normalized = clean_param($oldtag->text, PARAM_TAG);
$normalized = moodle_strtolower($raw_normalized);
// if this tag does not exist in tag table yet
if (!($newtag = get_record('tag', 'name', addslashes($normalized), '', '', '', '', 'id'))) {
$itag = new object();
$itag->name = $normalized;
$itag->rawname = $raw_normalized;
$itag->userid = $oldtag->userid;
$itag->timemodified = time();
$itag->descriptionformat = 0;
// default format
if ($oldtag->type == 'official') {
$itag->tagtype = 'official';
} else {
$itag->tagtype = 'default';
}
if ($idx = insert_record('tag', addslashes_recursive($itag))) {
$tagrefs[$oldtag->id] = $idx;
}
// if this tag is already used by tag table
} else {
$tagrefs[$oldtag->id] = $newtag->id;
}
}
$db->debug = true;
rs_close($rs);
}
// fetch all the tag instances and migrate them as well
if ($rs = get_recordset('blog_tag_instance')) {
$db->debug = false;
while ($blogtag = rs_fetch_next_record($rs)) {
if (array_key_exists($blogtag->tagid, $tagrefs)) {
$tag_instance = new object();
$tag_instance->tagid = $tagrefs[$blogtag->tagid];
$tag_instance->itemtype = 'blog';
$tag_instance->itemid = $blogtag->entryid;
$tag_instance->ordering = 1;
// does not matter much, because originally there was no ordering in blogs
$tag_instance->timemodified = time();
insert_record('tag_instance', $tag_instance);
}
}
$db->debug = true;
rs_close($rs);
}
unset($tagrefs);
// release memory
$table = new XMLDBTable('tags');
drop_table($table);
示例8: insertRows
protected function insertRows($rows, $keys, $special_table)
{
if (empty($rows)) {
return;
}
$insert_statement = $this->insertStatement($this->current_step->options);
$ignore_slashes = $this->ignoreSlashes($this->current_step->options);
$insert_rows = array();
foreach ($rows as $row) {
if (empty($ignore_slashes)) {
$insert_rows[] = "'" . implode("', '", addslashes_recursive($row)) . "'";
} else {
$insert_rows[] = "'" . implode("', '", $row) . "'";
}
}
$this->db->query("\n\t\t\t{$insert_statement} {$special_table}\n\t\t\t\t(" . implode(', ', $keys) . ")\n\t\t\tVALUES (" . implode('),
(', $insert_rows) . ")");
}
示例9: duplicate
/**
* Clone a curriculum.
* @param array $options options for cloning. Valid options are:
* - 'tracks': whether or not to clone tracks (default: false)
* - 'courses': whether or not to clone courses (default: false)
* - 'classes': whether or not to clone classes (default: false)
* - 'moodlecourses': whether or not to clone Moodle courses (if they were
* autocreated). Values can be (default: "copyalways"):
* - "copyalways": always copy course
* - "copyautocreated": only copy autocreated courses
* - "autocreatenew": autocreate new courses from course template
* - "link": link to existing course
* - 'targetcluster': the cluster id or cluster object (if any) to
* associate the clones with (default: none)
* @return array array of array of object IDs created. Key in outer array
* is type of object (plural). Key in inner array is original object ID,
* value is new object ID. Outer array also has an entry called 'errors',
* which is an array of any errors encountered when duplicating the
* object.
*/
function duplicate($options = array())
{
require_once CURMAN_DIRLOCATION . '/lib/track.class.php';
$objs = array('errors' => array());
if (isset($options['targetcluster'])) {
$cluster = $options['targetcluster'];
if (!is_object($cluster) || !is_a($cluster, 'cluster')) {
$options['targetcluster'] = $cluster = new cluster($cluster);
}
}
// clone main curriculum object
$clone = new curriculum($this);
unset($clone->id);
if (isset($cluster)) {
// if cluster specified, append cluster's name to curriculum
$clone->name = $clone->name . ' - ' . $cluster->name;
$clone->idnumber = $clone->idnumber . ' - ' . $cluster->name;
}
$clone = new curriculum(addslashes_recursive($clone));
if (!$clone->add()) {
$objs['errors'][] = get_string('failclustcpycurr', 'block_curr_admin', $this);
return $objs;
}
$objs['curricula'] = array($this->id => $clone->id);
$options['targetcurriculum'] = $clone->id;
// associate with target cluster (if any)
if (isset($cluster)) {
clustercurriculum::associate($cluster->id, $clone->id);
}
if (!empty($options['courses'])) {
// copy courses
$currcrs = curriculumcourse_get_list_by_curr($this->id);
if (!empty($currcrs)) {
$objs['courses'] = array();
$objs['classes'] = array();
foreach ($currcrs as $currcrsdata) {
$course = new course($currcrsdata->courseid);
$rv = $course->duplicate($options);
if (isset($rv['errors']) && !empty($rv['errors'])) {
$objs['errors'] = array_merge($objs['errors'], $rv['errors']);
}
if (isset($rv['courses'])) {
$objs['courses'] = $objs['courses'] + $rv['courses'];
}
if (isset($rv['classes'])) {
$objs['classes'] = $objs['classes'] + $rv['classes'];
}
// associate with curriculum
if (isset($rv['courses'][$course->id])) {
$curcrs = new curriculumcourse($currcrsdata);
unset($curcrs->id);
$curcrs->courseid = $rv['courses'][$course->id];
$curcrs->curriculumid = $clone->id;
$curcrs->add();
}
}
}
}
if (!empty($objs['errors'])) {
return $objs;
}
if (!empty($options['tracks'])) {
// copy tracks
$tracks = track_get_listing('name', 'ASC', 0, 0, '', '', $this->id);
if (isset($objs['courses'])) {
$options['coursemap'] = $objs['courses'];
}
if (!empty($tracks)) {
$objs['tracks'] = array();
if (isset($objs['courses'])) {
$options['coursemap'] = $objs['courses'];
}
if (!isset($objs['classes'])) {
$objs['classes'] = array();
}
foreach ($tracks as $track) {
$track = new track($track);
$options['classmap'] = $objs['classes'];
$rv = $track->duplicate($options);
if (isset($rv['errors']) && !empty($rv['errors'])) {
//.........这里部分代码省略.........
示例10: mnet_get_functions
/**
* Parse a file to find out what functions/methods exist in it, and add entries
* for the remote-call-enabled functions to the database.
*
* The path to a file, e.g. auth/mnet/auth.php can be thought of as
* type/parentname/docname
*
* @param string $type mod, auth or enrol
* @param string $parentname Implementation of type, e.g. 'mnet' in the
* case of auth/mnet/auth.php
* @return bool True on success, else false
*/
function mnet_get_functions($type, $parentname)
{
global $CFG;
$dataobject = new stdClass();
$docname = $type . '.php';
$publishes = array();
if ('mod' == $type) {
$docname = 'rpclib.php';
$relname = '/mod/' . $parentname . '/' . $docname;
$filename = $CFG->dirroot . $relname;
if (file_exists($filename)) {
include_once $filename;
}
$mnet_publishes = $parentname . '_mnet_publishes';
if (function_exists($mnet_publishes)) {
(array) ($publishes = $mnet_publishes());
}
} else {
// auth or enrol
$relname = '/' . $type . '/' . $parentname . '/' . $docname;
$filename = $CFG->dirroot . $relname;
if (file_exists($filename)) {
include_once $filename;
}
$class = $type . ($type == 'enrol' ? 'ment' : '') . '_plugin_' . $parentname;
if (class_exists($class)) {
$object = new $class();
if (method_exists($object, 'mnet_publishes')) {
(array) ($publishes = $object->mnet_publishes());
}
}
}
$methodServiceArray = array();
foreach ($publishes as $service) {
if (is_array($service['methods'])) {
foreach ($service['methods'] as $methodname) {
$methodServiceArray[$methodname][] = $service;
}
}
}
// Disable functions that don't exist (any more) in the source
// Should these be deleted? What about their permissions records?
$rpcrecords = get_records_select('mnet_rpc', ' parent=\'' . $parentname . '\' AND parent_type=\'' . $type . '\' ', 'function_name ASC ');
if (!empty($rpcrecords)) {
foreach ($rpcrecords as $rpc) {
if (!array_key_exists($rpc->function_name, $methodServiceArray)) {
$rpc->enabled = 0;
update_record('mnet_rpc', addslashes_recursive($rpc));
}
}
}
if (!file_exists($filename)) {
return false;
}
if (extension_loaded('tokenizer')) {
include_once "{$CFG->dirroot}/{$CFG->admin}/mnet/MethodTable.php";
$functions = (array) MethodTable::create($filename, false);
}
foreach ($methodServiceArray as $method => $servicearray) {
if (!empty($functions[$method])) {
$details = $functions[$method];
$profile = $details['arguments'];
if (!isset($details['returns'])) {
array_unshift($profile, array('type' => 'void', 'description' => 'No return value'));
} else {
array_unshift($profile, $details['returns']);
}
$dataobject->profile = addslashes(serialize($profile));
$dataobject->help = addslashes($details['description']);
} else {
$dataobject->profile = serialize(array(array('type' => 'void', 'description' => 'No return value')));
$dataobject->help = '';
}
$dataobject->function_name = $method;
$dataobject->xmlrpc_path = $type . '/' . $parentname . '/' . $docname . '/' . $method;
$dataobject->parent_type = $type;
$dataobject->parent = $parentname;
$dataobject->enabled = '0';
if ($record_exists = get_record('mnet_rpc', 'xmlrpc_path', $dataobject->xmlrpc_path)) {
$dataobject->id = $record_exists->id;
$dataobject->enabled = $record_exists->enabled;
update_record('mnet_rpc', $dataobject);
} else {
$dataobject->id = insert_record('mnet_rpc', $dataobject, true);
}
foreach ($servicearray as $service) {
$serviceobj = get_record('mnet_service', 'name', $service['name']);
if (false == $serviceobj) {
//.........这里部分代码省略.........
示例11: block_php_report_copy_schedule_instance
/**
* Creates a copy of the specified report schedule instance in the database
*
* @param int $id The record id of the PHP report schedule to copy
*
* @return boolean true on success, otherwise false
*/
function block_php_report_copy_schedule_instance($id)
{
if ($php_report_record = get_record('php_report_schedule', 'id', $id)) {
$config = unserialize($php_report_record->config);
//update modified time to right now
$config['timemodified'] = time();
//modify the label to prevent duplicates
$config['label'] = block_php_report_get_copy_label($config['label']);
$php_report_record->config = serialize($config);
$php_report_record->id = insert_record('php_report_schedule', addslashes_recursive($php_report_record));
//handle associated ELIS schedule records
$taskname = block_php_report_get_taskname_from_id($id);
if ($elis_records = get_recordset('elis_scheduled_tasks', 'taskname', $taskname)) {
while ($elis_record = rs_fetch_next_record($elis_records)) {
//make sure this points back to the new PHP report schedule instance
$elis_record->taskname = block_php_report_get_taskname_from_id($php_report_record->id);
//new instance, so it's never run before
$elis_record->lastruntime = 0;
insert_record('elis_scheduled_tasks', addslashes_recursive($elis_record));
}
return true;
}
}
//not found, so signal failure
return false;
}
示例12: synchronize_moodle_user
/**
* Function to synchronize the curriculum data with the Moodle data.
*
* @param boolean $tomoodle Optional direction to synchronize the data.
*
*/
function synchronize_moodle_user($tomoodle = true, $createnew = false)
{
global $CFG, $CURMAN;
static $mu_loop_detect = array();
// Create a new Moodle user record to update with.
if (!($muserid = get_field('user', 'id', 'idnumber', $this->idnumber, 'mnethostid', $CFG->mnet_localhost_id, 'deleted', 0)) && !$createnew) {
return false;
}
if ($tomoodle) {
if ($createnew && !$muserid) {
/// Add a new user
$record = new stdClass();
$record->idnumber = $this->idnumber;
$record->username = $this->username;
/// Check if already hashed... (not active now)
if (!empty($CURMAN->passwordnothashed)) {
$record->password = hash_internal_user_password($this->password);
} else {
$record->password = $this->password;
}
$record->firstname = $this->firstname;
$record->lastname = $this->lastname;
$record->email = $this->email;
$record->confirmed = 1;
$record->mnethostid = $CFG->mnet_localhost_id;
$record->address = $this->address;
$record->city = $this->city;
$record->country = $this->country;
$record->timemodified = time();
$record->lang = $this->language;
$record->id = insert_record('user', $record);
} else {
if ($muserid) {
/// Update an existing user
$record = new stdClass();
$record->id = $muserid;
$record->idnumber = $this->idnumber;
$record->username = $this->username;
/// Check if already hashed... (not active now)
if (!empty($CURMAN->passwordnothashed)) {
$record->password = hash_internal_user_password($this->password);
} else {
$record->password = $this->password;
}
$record->firstname = $this->firstname;
$record->lastname = $this->lastname;
$record->email = $this->email;
$record->address = $this->address;
$record->city = $this->city;
$record->country = $this->country;
$record->timemodified = time();
$record->lang = $this->language;
update_record('user', $record);
} else {
return true;
}
}
// avoid update loops
if (isset($mu_loop_detect[$this->id])) {
return $record->id;
}
$mu_loop_detect[$this->id] = true;
// synchronize profile fields
$origrec = clone $record;
profile_load_data($origrec);
$fields = field::get_for_context_level(context_level_base::get_custom_context_level('user', 'block_curr_admin'));
$mfields = $CURMAN->db->get_records('user_info_field', '', '', '', 'shortname');
$fields = $fields ? $fields : array();
$changed = false;
require_once CURMAN_DIRLOCATION . '/plugins/moodle_profile/custom_fields.php';
foreach ($fields as $field) {
$field = new field($field);
if (isset($field->owners['moodle_profile']) && $field->owners['moodle_profile']->exclude == cm_moodle_profile::sync_to_moodle && isset($mfields[$field->shortname])) {
$shortname = $field->shortname;
$fieldname = "field_{$shortname}";
$mfieldname = "profile_{$fieldname}";
$mfieldvalue = isset($origrec->{$mfieldname}) ? $origrec->{$mfieldname} : null;
if (isset($this->{$fieldname}) && $mfieldvalue != $this->{$fieldname}) {
$record->{$mfieldname} = $this->{$fieldname};
$changed = true;
}
}
}
profile_save_data(addslashes_recursive($record));
if ($muserid) {
if ($changed) {
events_trigger('user_updated', $record);
}
} else {
events_trigger('user_created', $record);
}
unset($mu_loop_detect[$this->id]);
return $record->id;
}
//.........这里部分代码省略.........
示例13: refresh_log
/**
* Receives an array of log entries from an SP and adds them to the mnet_log
* table
*
* @param array $array An array of usernames
* @return string "All ok" or an error message
*/
function refresh_log($array)
{
global $CFG, $MNET_REMOTE_CLIENT;
// We don't want to output anything to the client machine
$start = ob_start();
$returnString = '';
begin_sql();
$useridarray = array();
foreach ($array as $logEntry) {
$logEntryObj = (object) $logEntry;
$logEntryObj->hostid = $MNET_REMOTE_CLIENT->id;
if (isset($useridarray[$logEntryObj->username])) {
$logEntryObj->userid = $useridarray[$logEntryObj->username];
} else {
$logEntryObj->userid = get_field('user', 'id', 'username', $logEntryObj->username, 'mnethostid', (int) $logEntryObj->hostid);
if ($logEntryObj->userid == false) {
$logEntryObj->userid = 0;
}
$useridarray[$logEntryObj->username] = $logEntryObj->userid;
}
unset($logEntryObj->username);
$logEntryObj = $this->trim_logline($logEntryObj);
$insertok = insert_record('mnet_log', addslashes_recursive($logEntryObj), false);
if ($insertok) {
$MNET_REMOTE_CLIENT->last_log_id = $logEntryObj->remoteid;
$MNET_REMOTE_CLIENT->updateparams->last_log_id = $logEntryObj->remoteid;
} else {
$returnString .= 'Record with id ' . $logEntryObj->remoteid . " failed to insert.\n";
}
}
$MNET_REMOTE_CLIENT->commit();
commit_sql();
$end = ob_end_clean();
if (empty($returnString)) {
return array('code' => 0, 'message' => 'All ok');
}
return array('code' => 1, 'message' => $returnString);
}
示例14: get_record
if ($issue->resolutionpriority > 0) {
$nextissue = get_record('tracker_issue', 'trackerid', $tracker->id, 'resolutionpriority', $issue->resolutionpriority - 1);
$issue->resolutionpriority--;
$nextissue->resolutionpriority++;
update_record('tracker_issue', addslashes_recursive($issue));
update_record('tracker_issue', addslashes_recursive($nextissue));
}
tracker_update_priority_stack($tracker);
} elseif ($action == 'lowertobottom') {
$issueid = required_param('issueid', PARAM_INT);
$issue = get_record('tracker_issue', 'id', $issueid);
if ($issue->resolutionpriority > 0) {
// raise everyone beneath
$sql = "\n UPDATE \n {$CFG->dbprefix}tracker_issue\n SET \n resolutionpriority = resolutionpriority + 1\n WHERE\n trackerid = {$tracker->id} AND\n resolutionpriority < {$issue->resolutionpriority}\n ";
execute_sql($sql);
// update to min priority
$issue->resolutionpriority = 0;
update_record('tracker_issue', addslashes_recursive($issue));
}
tracker_update_priority_stack($tracker);
} elseif ($action == 'askraise') {
$issueid = required_param('issueid', PARAM_INT);
include $CFG->dirroot . '/mod/tracker/views/raiserequest.html';
return -1;
} elseif ($action == 'doaskraise') {
$issueid = required_param('issueid', PARAM_INT);
$reason = required_param('reason', PARAM_TEXT);
$urgent = required_param('urgent', PARAM_INT);
$issue = get_record('tracker_issue', 'id', $issueid);
tracker_notify_raiserequest($issue, $cm, $reason, $urgent, $tracker);
}
示例15: ldap_bulk_insert
/**
* Bulk insert in SQL's temp table
* @param array $users is an array of usernames
*/
function ldap_bulk_insert($users, $temptable)
{
// bulk insert -- superfast with $bulk_insert_records
$sql = 'INSERT INTO ' . $temptable . ' (username) VALUES ';
// make those values safe
$users = addslashes_recursive($users);
// join and quote the whole lot
$sql = $sql . "('" . implode("'),('", $users) . "')";
print "\t+ " . count($users) . " users\n";
execute_sql($sql, false);
}