Exemplo n.º 1
0
                break;
            case 'letter':
                if ($hook != 'ALL' and $hook != 'SPECIAL') {
                    $where = 'AND ' . sql_substr() . '(upper(concept),1,' . $textlib->strlen($hook) . ') = \'' . $textlib->strtoupper($hook) . '\'';
                }
                if ($hook == 'SPECIAL') {
                    //Create appropiate IN contents
                    $alphabet = explode(",", get_string("alphabet"));
                    $sqlalphabet = '';
                    for ($i = 0; $i < count($alphabet); $i++) {
                        if ($i != 0) {
                            $sqlalphabet .= ',';
                        }
                        $sqlalphabet .= '\'' . $alphabet[$i] . '\'';
                    }
                    $where = 'AND ' . sql_substr() . '(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet) . ')';
                }
                break;
        }
        $sqlwhere = "WHERE (ge.glossaryid = '{$glossary->id}' or ge.sourceglossaryid = '{$glossary->id}') AND\n                             (ge.approved != 0 {$userid})\n                              {$where}";
        switch ($tab) {
            case GLOSSARY_DATE_VIEW:
                $sqlorderby = "ORDER BY {$sqlsortkey} {$sqlsortorder}";
                break;
            case GLOSSARY_STANDARD_VIEW:
                $sqlorderby = "ORDER BY ge.concept";
            default:
                break;
        }
        break;
}
Exemplo n.º 2
0
/**
 * Update the path field of the context and
 * all the dependent subcontexts that follow
 * the move. 
 *
 * The most important thing here is to be as
 * DB efficient as possible. This op can have a
 * massive impact in the DB.
 *
 * @param obj current   context obj
 * @param obj newparent new parent obj
 *
 */
function context_moved($context, $newparent)
{
    global $CFG;
    $frompath = $context->path;
    $newpath = $newparent->path . '/' . $context->id;
    $setdepth = '';
    if ($newparent->depth + 1 != $context->depth) {
        $setdepth = ", depth= depth + ({$newparent->depth} - {$context->depth}) + 1";
    }
    $sql = "UPDATE {$CFG->prefix}context \n            SET path='{$newpath}'\n                {$setdepth}\n            WHERE path='{$frompath}'";
    execute_sql($sql, false);
    $len = strlen($frompath);
    /// MDL-16655 - Substring MSSQL function *requires* 3rd parameter
    $substr3rdparam = '';
    if ($CFG->dbfamily == 'mssql') {
        $substr3rdparam = ', len(path)';
    }
    $sql = "UPDATE {$CFG->prefix}context\n            SET path = " . sql_concat("'{$newpath}'", sql_substr() . '(path, ' . $len . ' +1' . $substr3rdparam . ')') . "\n                {$setdepth}\n            WHERE path LIKE '{$frompath}/%'";
    execute_sql($sql, false);
    mark_context_dirty($frompath);
    mark_context_dirty($newpath);
}