function log($level, $message)
 {
     xlog($level, $message, 'DATASOURCE');
 }
Example #2
1
File: edit.php Project: nopticon/ei
                    $update_data = array('p_nit' => $nit, 'p_name' => $name);
                    $table = '_prov';
                    $sql_where = sql_filer('p_nit = ?', $search);
                    xlog('pe.' . $search, 0, 0);
                    break;
                case 'c':
                    $update_data = array('c_exe' => (int) $exencion, 'c_date' => (int) $new_date, 'c_nit' => $nit, 'c_text' => $desc);
                    $table = '_constancia';
                    $sql_where = sql_filter('c_exe = ?', $search);
                    xlog('e', $search);
                    break;
                case 'f':
                    $update_data = array('f_serie' => $serie, 'f_date' => $new_date, 'f_total' => $total, 'f_exe' => $exencion, 'f_fact' => $factura);
                    $table = '_factura';
                    $sql_where = sql_filter('f_exe = ? AND f_fact = ?', $search2, $search);
                    xlog('e', $search2, $search);
                    break;
            }
            $sql = 'UPDATE ' . $table . ' SET ' . sql_build('UPDATE', $update_data) . '
				WHERE ' . $sql_where;
            sql_query($sql);
            //
            // End update
            page_header();
            submenu();
            ?>
<div class="vsep-pre"><div class="vsep1">&nbsp;</div></div>
<div class="colorbox darkborder pad10" align="center">
<strong>La informaci&oacute;n fue actualizada.</strong><br /><br /><a class="red bold" href="<?php 
            echo s_link('edit', $screen);
            ?>
define('CLI_SCRIPT', 1);
// Visibility status - 1: Show, 0: Hide
define('CURRENT_VISIBILITY_STATUS', 1);
define('NEW_VISIBILITY_STATUS', 0);
// Run from /admin/cli dir
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->dirroot . '/course/lib.php';
// Open report file
$reportfile = fopen('hide-quizzes-containing-qt3-cli_report.txt', 'w');
// Identify the quizzes in question
$sql = "SELECT DISTINCT\n            cm.id,\n            qz.id AS quizid,\n            qz.name AS quizname,\n            c.id AS courseid,\n            c.fullname AS coursename\n          FROM {question} q\n          JOIN {quiz_slots} qs ON qs.questionid = q.id\n          JOIN {quiz} qz ON qz.id = qs.quizid\n          JOIN {course} c ON c.id = qz.course\n          JOIN {course_modules} cm ON cm.instance = qz.id\n          JOIN {modules} m ON m.id = cm.module\n         WHERE q.qtype = ?\n           AND m.name = ?\n           AND cm.visible = ?\n      ORDER BY cm.id";
$params = array('turtipskupon', 'quiz', CURRENT_VISIBILITY_STATUS);
$records = $DB->get_records_sql($sql, $params);
foreach ($records as $record) {
    $cm = get_coursemodule_from_id('', $record->id, 0, true, MUST_EXIST);
    $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
    $modcontext = context_module::instance($cm->id);
    set_coursemodule_visible($cm->id, NEW_VISIBILITY_STATUS);
    \core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
    xlog("Quiz ID {$record->quizid}: '{$record->quizname}' in course ID {$record->courseid}: '{$record->coursename}' set as hidden as it contains question of type QT3 (turtipskupon)");
}
function xlog($message)
{
    global $reportfile;
    // Output to screen
    mtrace($message);
    // Write to report file
    fwrite($reportfile, $message . "\n");
}
// Close the report file
fclose($reportfile);
 function log($level, $message)
 {
     xlog($level, $message, 'MARKED');
 }
Example #5
0
            if (empty($proveedor)) {
                $error[] = 'Debe ingresar el nombre del proveedor.';
            }
            if (!sizeof($error)) {
                $sql = 'SELECT *
					FROM _prov
					WHERE p_nit = ? OR p_name = ?';
                if ($row = sql_fieldrow(sql_filter($sql, $nit, strtoupper($proveedor)))) {
                    $error[] = 'El NIT o proveedor ya existe.';
                }
            }
            if (!sizeof($error)) {
                $psf = request_var('psf', 0);
                $insert_prov = array('p_nit' => $nit, 'p_name' => strtoupper($proveedor), 'p_sf' => $psf);
                sql_query('INSERT INTO _prov' . sql_build('INSERT', $insert_prov));
                xlog('pi.' . $nit, 0, 0);
            }
            break;
    }
    if (!sizeof($error)) {
        if ($screen == 'p') {
            redirect(array('insert', 'p'));
        }
        if ($return_this != $user->data['user_return_insert']) {
            $sql = 'UPDATE _users SET user_return_insert = ?
				WHERE user_id = ?';
            sql_query(sql_filter($sql, $return_this, $user->data['user_id']));
        }
        if ($screen == 'c') {
            $return_this = 1;
        }
 function log($level, $message)
 {
     xlog($level, $message, 'QUERYPARSER');
 }
Example #7
0
File: null.php Project: nopticon/ei
					AND log_action = ?
					AND log_user_id IN (??)';
                if (!($row = sql_fieldrow(sql_filter($sql, $exe, 'i', implode(',', $exc))))) {
                    $error[] = 'No tiene permisos de anular esta exenci&oacute;n.';
                }
            }
        }
    }
    if (!sizeof($error) && $exe_data['c_null']) {
        $error[] = 'La exenci&oacute;n ya fue anulada.';
    }
    if (!sizeof($error) && $confirm) {
        $sql = 'UPDATE _constancia SET c_null = 1
			WHERE c_exe = ';
        sql_query(sql_filter($sql, $exe));
        xlog('n', $exe);
        //
        // End update
        //
        page_header();
        ?>
<div class="vsep-pre"><div class="vsep1">&nbsp;</div></div>
<div class="colorbox darkborder pad10" align="center">
<strong>La exenci&oacute;n fue anulada.</strong><br /><br /><a class="red bold" href="<?php 
        echo s_link('null');
        ?>
">Click para regresar</a>.
</div>
<?php 
        page_footer();
    }
Example #8
0
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $mode != '' && $EMAIL_BODY != '') {
    $recipient = @$_POST['email'];
    if ($recipient == '') {
        $MESSAGE = 'Invalid email address';
        $MESSAGE_CLASS = 'error-message';
    } else {
        if (@$_POST['cancel'] == '') {
            $email_headers = array();
            $email_headers['From'] = $USER->email;
            $email_headers['To'] = $recipient;
            $email_headers['Subject'] = $email_subject;
            $email_headers['Content-Type'] = $MODULE->content_type('text');
            $body = $EMAIL_BODY;
            if (@$_POST['note'] != '') {
                $note = substr($_POST['note'], 0, $CONF['email_note_length']);
                $body = $note . "\r\n" . $body;
            }
            $MAILER->send($recipient, $email_headers, $body);
            $_SESSION['COUNT_EMAILS_SENT'] = $COUNT_EMAILS_SENT + 1;
            xlog(2, 'Sent email: From ' . $USER->email . ' to ' . $recipient, 'EMAIL');
        }
        header("Location: " . $MODULE->url($mode, $url_query), TRUE, 303);
        if (@$_POST['cancel'] == '') {
            set_session_message(sprintf('Email has been sent to %s.', $recipient), 'info-message');
        }
        exit;
    }
}
// Display page
header('Content-Type: ' . $MODULE->content_type());
require_once $CONF['path_templates'] . $TEMPLATE . '.php';
Example #9
0
                            $TEMPLATE = 'record';
                            $TITLE = $CONF['view_record_prefix'] . @$RECORD['title'];
                            // check permissions
                            if ($MODULE->can_edit($USER)) {
                                // user can edit records
                                $URL_EDIT = $MODULE->url_edit($RECORD, @$_REQUEST);
                            }
                            $SIDEBAR = @$RECORD['sidebar'];
                        }
                    }
                }
            }
        }
        if (!is_null($RECORD)) {
            $_SESSION['HISTORY_RECORDS']->add($RECORD);
            xlog(1, $RECORD['url'], 'VIEW-RECORD', $CONF['record_log']);
        }
    }
}
// If the format is email, redirect to the 'send email' page
if ($output_format == 'email') {
    $req = @$_REQUEST;
    $req['url'] = $RECORD['url'];
    unset($req['format']);
    unset($req['PHPSESSID']);
    $req = http_build_query($req);
    header("Location: " . $MODULE->url('email', '/index?' . $req), TRUE, 303);
    exit;
}
// Display page to user
header('Content-Type: ' . $MODULE->content_type($output_format));
function db_log($level, $message)
{
    xlog($level, $message, 'DB');
}
Example #11
0
function debug_stop_timer($msg = "Duration")
{
    global $debug_timer;
    $debug_timer = microtime(TRUE) - $debug_timer;
    $debug_timer = round($debug_timer, 2);
    xlog(1, "{$msg}={$debug_timer}", "DEBUG-TIMER");
}
$users = db_get_all($sql);
foreach ($users as $user) {
    $id = $user[0];
    xlog(3, "Converting user: {$id}");
    // Insert default rights
    $sql = "INSERT INTO UserRight (user_id, right_id)\n        SELECT {$id}, id FROM Rights WHERE name IN('" . join("', '", $CONF['default_user_rights']) . "')";
    db_query($sql);
    // Convert data
    $userdata = $user[1];
    // Avoid clashing with the new classes
    $userdata = str_ireplace('"query', '"Zuery', $userdata);
    // Remove old escape hack
    $userdata = str_replace(_UDB_ESCAPE, '\\', $userdata);
    $legacy_data = @unserialize($userdata);
    if ($legacy_data === FALSE) {
        xlog(3, "No data: {$id}");
        continue;
    }
    $prefs = array();
    $saved_searches_active = array();
    // Listings
    if (isset($legacy_data['listings_multi_ids'])) {
        $prefs['listings_channels'] = $legacy_data['listings_multi_ids'];
    }
    // Auto alerts
    if (isset($legacy_data['saved_searches'])) {
        $list = new QueryList();
        $query_list = $legacy_data['saved_searches'];
        $prefs['saved_search_day'] = $query_list->alert_day;
        foreach ($query_list as $legacy_query) {
            $saved_searches_active[] = $legacy_query->alert_is_active ? "1" : "0";
Example #13
0
$user->allow_access('delete');
//
$error = array();
$fid = request_var('fid', 0);
if ($fid) {
    $sql = 'SELECT *
		FROM _factura
		WHERE f_id = ?';
    if (!($f_data = sql_fieldrow(sql_filter($sql, $fid)))) {
        $error[] = 'La factura no existe, por favor verificar.';
    }
    if (!sizeof($error)) {
        $sql = 'DELETE FROM _factura
			WHERE f_id = ?';
        sql_query(sql_filter($sql, $fid));
        xlog('f', $f_data['f_exe'], $f_data['f_fact']);
        //
        page_header();
        ?>
<div class="vsep-pre"><div class="vsep1">&nbsp;</div></div>
<div class="colorbox darkborder pad10" align="center">
<strong>La factura fue borrada.</strong><br /><br /><a class="red bold" href="<?php 
        echo s_link('search');
        ?>
">Click para regresar</a>.
</div>
<?php 
        page_footer();
    }
}
exit;
 function get_results()
 {
     // Execute the handles
     debug_start_timer();
     $active = null;
     do {
         $mrc = curl_multi_exec($this->ch_multi, $active);
     } while ($mrc == CURLM_CALL_MULTI_PERFORM);
     while ($active && $mrc == CURLM_OK) {
         if (curl_multi_select($this->ch_multi) != -1) {
             do {
                 $mrc = curl_multi_exec($this->ch_multi, $active);
             } while ($mrc == CURLM_CALL_MULTI_PERFORM);
         }
     }
     // Gather results and return
     $result = array();
     foreach ($this->results as $info) {
         $content = curl_multi_getcontent($info['ch']);
         $info['results'] = unserialize($content);
         xlog(1, 'Bad/missing results from web service', 'FED DS');
         $result[] = $info;
     }
     debug_stop_timer("Duration (curl)");
     return $result;
 }
Example #15
0
/**
 * Use always Wordpress default template when mobilizing (known to work)
 * 
 * @param $template
 * @return unknown_type
 */
function mobilizejs_template($template) {

	if(is_mobile() || is_test_page_load()) {
        xlog("Serving mobile template");
		return MOBILE_THEME_BASE;
	}
	
	xlog("Serving default template");
		
	return $template;
}
 function _log_end($results, $duration, $accuracy = 'exact')
 {
     global $CONF;
     $message = "{$this->_qid} {$results} {$accuracy} {$duration}";
     xlog(1, $message, 'QUERY-END', $CONF['query_log']);
 }
 function log($level, $message, $modname = NULL)
 {
     $modname = $modname ? $modname : (isset($this) ? $this->name : NULL);
     xlog($level, $message, 'MOD', array('modname' => $modname));
 }
Example #18
0
if (@substr_compare($tmp[0], '.php', -4, 4) == 0) {
    $path_info = @$_SERVER['PATH_INFO'];
} else {
    $_ENV['MODULE'] = $tmp[0];
    array_shift($tmp);
    $path_info = '/' . join('/', $tmp);
}
// Special case when previous fails
if ($path_info == '') {
    $tmp = explode('/', $_SERVER['REQUEST_URI']);
    while ($tmp[0] != 'module.php') {
        array_shift($tmp);
    }
    array_shift($tmp);
    $path_info = '/' . join('/', $tmp);
}
include './include.php';
// Work out what file we really want
$filename = $MODULE->path . 'web' . $path_info;
$found = is_file($filename);
xlog(4, 'Dispatch file: ' . @$_SERVER['PATH_INFO'] . ' -> ' . $filename . ' (' . ($found ? 'found' : 'not found') . ')', 'MODULE');
// Not found - 404
if (!$found) {
    $TITLE = 'Module dispatch';
    header("HTTP/1.0 404 Not found");
    $MESSAGE = $STRINGS['error_404'];
    require_once $CONF['path_templates'] . 'error.php';
    exit;
}
// Dispatch to the file
require_once $filename;
 function delete_related($meta, $other_meta, $id, $records = NULL)
 {
     $db_table = $this->_new_db_table($other_meta);
     $related_field = $other_meta['key'];
     $related_info = $meta['fields'][$related_field];
     if ($related_info['type'] == 'many_to_many') {
         return TRUE;
     }
     // check permissions
     if (!@$other_meta['mutable']) {
         xlog(1, "Error: 405 Delete related: method not allowed", 'DATASOURCE');
         return TRUE;
         // fail silently
     }
     // if keep_related flag is set only delete the specified records, not all related records
     if (@$related_info['keep_related'] && !is_null($records) && isset($related_info['lookup'])) {
         if (!is_array($records)) {
             $records = array($records);
         }
         foreach ($records as $record) {
             $field = $related_info['lookup'];
             if (is_array($record)) {
                 $value = $record[$field];
             } else {
                 $value = $record;
             }
             $result = $db_table->delete("{$db_table->table}.{$related_info['foreign_key']}={$id} AND {$field}='{$value}'");
             if (PEAR::isError($result)) {
                 return $this->_set_error($result);
             }
         }
     } else {
         $result = $db_table->delete("{$db_table->table}.{$related_info['foreign_key']}={$id}");
         if (PEAR::isError($result)) {
             return $this->_set_error($result);
         }
     }
     return TRUE;
     //### error handling $result;
 }
 function search(&$ds, $table, $tree, $offset, $max_count)
 {
     global $STRINGS;
     if (is_null($this->db)) {
         return $ds->_set_error(500, $STRINGS['error_500_db']);
     }
     $meta = $ds->_get_meta($table);
     // Should we use sphinx at all with this table?
     if (!@$meta['search']['sphinx']) {
         return NULL;
     }
     // Check if sphinx is available on this system
     $sphinx_generator = $this->_new_sphinx_generator($meta);
     if (is_null($sphinx_generator)) {
         return NULL;
     }
     // Get the Sphinx index to search in
     $sphinx_index = $this->_find_sphinx_index($sphinx_generator, $meta, $tree);
     // Get group by config
     $group_by = $this->_find_group_by($sphinx_generator, $meta, $tree);
     if (empty($group_by)) {
         $group_by = NULL;
     }
     // Add main query
     $query_id = $sphinx_generator->add_query($sphinx_index, $tree, $offset, $max_count, $group_by);
     if (is_null($query_id)) {
         if (@$sphinx_generator->error_message != '') {
             $ds->_set_error(400, 'Sphinx generation error: ' . $sphinx_generator->error_message);
         }
         return NULL;
     }
     // Add facets query
     $has_facets = isset($meta['facets']);
     if ($has_facets) {
         $facets_query_id = $sphinx_generator->add_group_by($sphinx_index, 'facets');
     }
     // Call Sphinx
     $all_sphinx_results = $this->_run_sphinx_queries($ds, $sphinx_generator, $query_id);
     if (is_null($all_sphinx_results)) {
         return NULL;
     }
     $search_result = $all_sphinx_results[$query_id];
     // No results?
     if (!isset($search_result["matches"])) {
         return $ds->_make_search_results_array(array(), 0, 0, 0);
     }
     // Process results
     $max_weight = 1.0;
     $sphinx_matches = array();
     foreach ($search_result["matches"] as $sphinx_record) {
         $sphinx_matches[$sphinx_record['id']] = $sphinx_record;
         $max_weight = max(@$sphinx_record['weight'], $max_weight);
     }
     $ids = array_keys($sphinx_matches);
     // Get result data from mysql
     $sql_generator = $this->_new_sql_generator($meta);
     $sphinx_key = 't.id';
     if (@$meta['search']['sphinx_key'] != '') {
         $sphinx_key = $meta['search']['sphinx_key'];
     }
     $sql = $sql_generator->to_sql(NULL, 'none') . " WHERE {$sphinx_key} IN(" . join(',', $ids) . ")";
     xlog(4, $sql, 'SPHINX');
     $r = $this->db->queryAll($sql, NULL, MDB2_FETCHMODE_ASSOC);
     if (PEAR::isError($r)) {
         return $ds->_set_error(500, 'Search: ' . $r->message . ' ' . $r->userinfo);
     }
     // Results come back from MySQL in arbritrary order so we need to resort them
     $sort_field = $sphinx_generator->sort_field();
     foreach ($r as $record) {
         $id = $record['id'];
         $sphinx_record = $sphinx_matches[$id];
         if (isset($sphinx_record['attrs']['facet_details'])) {
             $record['facet_details'] = $sphinx_record['attrs']['facet_details'];
         }
         // Handle sort field
         //### TODO: If not in aggregated search, we don't need this
         if ($sort_field == 'rel') {
             $record['_sort'] = $sphinx_record['weight'] / $max_weight;
         } else {
             if ($sort_field == 'date') {
                 $record['_sort'] = strftime('%Y-%m-%d %H:%M:%S', $sphinx_record['attrs'][$sort_field]);
             } else {
                 if (strrpos($sort_field, '_ord')) {
                     // check if the record contains a field matching the sort field (e.g. title_ord)
                     // otherwise look for a field without the _ord suffix (e.g. title)
                     if (isset($record[$sort_field])) {
                         $record['_sort'] = $record[$sort_field];
                     } else {
                         $record_field = substr($sort_field, 0, strrpos($sort_field, '_ord'));
                         $record['_sort'] = isset($record[$record_field]) ? $record[$record_field] : $sphinx_record['attrs'][$sort_field];
                     }
                 } else {
                     if ($sort_field != '') {
                         $record['_sort'] = $sphinx_record['attrs'][$sort_field];
                     }
                 }
             }
         }
         $sphinx_matches[$id] = $record;
     }
     $search_result['processed_results'] = array_values($sphinx_matches);
     // Make results array to return
     $r = @$search_result['processed_results'];
     $total = @$search_result['total'];
     $result = $ds->_make_search_results_array($r, $total, $offset, $max_count);
     $result['total_found'] = @$search_result['total_found'];
     // Add facets
     if (isset($facets_query_id)) {
         $result['facets'] = $this->_get_facet_summary($ds, $meta, $all_sphinx_results[$facets_query_id], $total);
     }
     return $result;
 }
Example #21
0
         set_session_message($STRINGS['item_create'], 'info-message');
         // set message
         xlog(2, 'Create: ' . $result['url'], 'EDIT');
         $redirect_url = $MODULE->url('edit', $result['url']);
     }
 } else {
     $result = $ds->update($RECORD['url'], $data);
     // update the item
     if (is_null($result)) {
         header("HTTP/1.0 400 Bad request");
         $MESSAGE = $STRINGS['error_update_record'];
         $error = true;
     } else {
         set_session_message($STRINGS['item_save'], 'info-message');
         // set message
         xlog(2, 'Update: ' . $result['url'], 'EDIT');
         $redirect_url = $MODULE->url('edit', $result['url']);
     }
 }
 // pass to module for any final processing
 $MODULE->finish_edit_process($_POST, $result, $error);
 // check for error from module
 if (@$_POST['error']) {
     header("HTTP/1.0 400 Bad request");
     $MESSAGE = $_POST['error'];
 } else {
     if (!$error) {
         // redirect to the item and return status 303
         $redirect_url .= isset($_POST['append_url']) ? $_POST['append_url'] : '';
         header("HTTP/1.1 303 See Other");
         header("Location: " . $redirect_url);
 function migrate()
 {
     // Check we have a valid migration setup
     if ($this->status <= 0 || $this->status >= 100) {
         $this->status = 999;
     } else {
         if (!$this->db) {
             $this->status = 999;
         } else {
             $this->_migrate_user_record();
             $this->_migrate_data();
             $this->_migrate_rights();
             $this->_migrate_orders();
         }
     }
     $this->status_message = $this->status_messages[$this->status];
     if ($this->status < 100) {
         xlog(1, "Migrated <{$this->email}>, old: {$this->old_user['id']} new: {$this->new_user['id']}", 'MIGRATE');
     } else {
         xlog(1, "Migrated <{$this->email}>, status: {$this->status} {$this->status_message}", 'MIGRATE');
     }
     return $this->status;
 }
 function load_data($name)
 {
     if (!$this->has_right('save_data')) {
         // check user right
         return NULL;
     }
     $result = $this->ds->retrieve($this->url);
     if (is_null($result)) {
         return NULL;
     }
     foreach ($result['user_data'] as $data) {
         if ($data['name'] == $name) {
             xlog(2, 'Load data: ' . $name . ' for ' . $this->login, 'USER');
             return @unserialize($data['value']);
         }
     }
     return NULL;
 }
        $scormsettings->maxattempt = 0;
        $scormsettings->forcecompleted = 1;
        $scormsettings->forcenewattempt = 1;
        $scormsettings->lastattemptlock = 0;
        $scormsettings->displayattemptstatus = 0;
        $scormsettings->displaycoursestructure = 0;
        $scormsettings->updatefreq = 0;
        $scormsettings->skipview = 2;
        $scormsettings->hidebrowse = 1;
        $scormsettings->hidetoc = 3;
        $DB->update_record('scorm', $scormsettings);
        xlog("SCORM module '{$scormname}' configured successfully");
    } else {
        $details = "SCORM .zip file '{$filename}' intended for SCORM module '{$scormname}' in course '{$coursename}' is missing";
        $notfound[] = $details;
        xlog($details);
    }
}
xlog('Scripting finished');
xlog(count($found) . ' files were found and processed successfully');
xlog(count($notfound) . ' files were not found');
function xlog($message)
{
    global $reportfile;
    // Output to screen
    mtrace($message);
    // Write to report file
    fwrite($reportfile, $message . "\n");
}
// Close the report file
fclose($reportfile);
Example #25
-1
             $channels[$channel_action] = TRUE;
             $MESSAGE = 'Channel added';
             xlog(2, 'Added channel: ' . $channel_action, 'LISTINGS');
         }
     }
 } else {
     if ($action == 'remove_channel') {
         if ($channel_action != '') {
             $channels = $is_logged_in ? @$USER->prefs['listings_channels'] : $QUERY['channel']->get_value();
             if (count($channels) == 0) {
                 $channels = $QUERY['channel']->get_default();
             }
             if (isset($channels[$channel_action])) {
                 unset($channels[$channel_action]);
                 $MESSAGE = 'Channel removed';
                 xlog(2, 'Removed channel: ' . $channel_action, 'LISTINGS');
             }
         }
     } else {
         if ($action == 'set_channels') {
             $channels = $channel_action;
             if (!is_array($channels)) {
                 $channel_list = explode(',', $channels);
                 $channels = array();
                 foreach ($channel_list as $channel) {
                     $channels[$channel] = TRUE;
                 }
             }
         }
     }
 }
 function new_query($criteria_values = NULL)
 {
     global $CONF, $USER;
     $result = new Query($this->module);
     $is_page_size_mandatory = TRUE;
     if (isset($this->config['is_page_size_mandatory'])) {
         $is_page_size_mandatory = $this->config['is_page_size_mandatory'];
     }
     // Table name
     if (@$this->config['table_name'] != '') {
         $result->table_name = $this->config['table_name'];
     }
     // Cache
     $cache_class = $this->config['cache_class'];
     $result->_cache = new $cache_class(@$CONF['query_cache_size']);
     // Encoder
     $encoder_class = $this->config['encoder_class'];
     $result->_encoder = new $encoder_class($result);
     // Filters
     if (@$this->config['filters']) {
         // Instantiate if necessary
         $filters = array();
         foreach ($this->config['filters'] as $f) {
             if (is_string($f)) {
                 if (class_exists($f)) {
                     $filters[] = new $f();
                 } else {
                     xlog(1, 'Filter not found: ' . $f, 'QUERY');
                 }
             } else {
                 $filters[] = $f;
             }
         }
         $result->filters = $filters;
     }
     // Lists
     if (@$this->config['query_lists']) {
         foreach ($this->config['query_lists'] as $list_name => $list) {
             $result->add_list($list_name, $list);
         }
     }
     $result->criteria_container = new QueryCriteria();
     if (@$this->config['criteria_defs']) {
         foreach ($this->config['criteria_defs'] as $criterion) {
             if ($criterion instanceof QueryCriterion) {
                 $result->add_criterion($criterion);
             } else {
                 if (is_array($criterion)) {
                     $result->add_criterion(QueryCriterionFactory::create($criterion));
                 }
             }
         }
         if ($criteria_values) {
             $result->set_criteria_values($criteria_values);
         }
     }
     // if no page size QC has been added, then add the default if required
     if ($is_page_size_mandatory && !isset($result['page_size'])) {
         $result->add_criterion($this->create_page_size_criterion());
     }
     // ask the criterion for any lists (date ranges for example)
     foreach ($result->criteria_container->get_lists() as $qs_key => $list) {
         $result->add_list($qs_key, $list);
     }
     // set default page size based on user prefs
     if (isset($result['page_size']) && isset($USER->prefs['page_size'])) {
         $result['page_size']->set_default($USER->prefs['page_size']);
     }
     return $result;
 }
Example #27
-2
function xsuccess($message)
{
    xlog('SUCCESS: ' . $message);
}