Пример #1
0
function cookieVar($name)
{
    global $HTTP_COOKIE_VARS;
    if (!isset($HTTP_COOKIE_VARS[$name])) {
        return;
    }
    return undoMagic($HTTP_COOKIE_VARS[$name]);
}
Пример #2
0
function requestVar($name)
{
    if (array_key_exists($name, $_REQUEST)) {
        return undoMagic($_REQUEST[$name]);
    } elseif (array_key_exists($name, $_GET)) {
        return undoMagic($_GET[$name]);
    } elseif (array_key_exists($name, $_POST)) {
        return undoMagic($_POST[$name]);
    } else {
        return;
    }
}
Пример #3
0
 /**
  * @param $aOptions: array ( 'oid' => array( 'contextid' => 'value'))
  *        (taken from request using requestVar())
  * @param $newContextid: integer (accepts a contextid when it is for a new
  *        contextid there was no id available at the moment of writing the
  *        formcontrols into the page (by ex: itemOptions for new item)
  * @static
  */
 function _applyPluginOptions(&$aOptions, $newContextid = 0)
 {
     global $manager;
     if (!is_array($aOptions)) {
         return;
     }
     foreach ($aOptions as $oid => $values) {
         // get option type info
         $query = 'SELECT opid, oname, ocontext, otype, oextra, odef FROM ' . sql_table('plugin_option_desc') . ' WHERE oid=' . intval($oid);
         $res = sql_query($query);
         if ($o = sql_fetch_object($res)) {
             foreach ($values as $key => $value) {
                 // avoid overriding the key used by foreach statement
                 $contextid = $key;
                 // retreive any metadata
                 $meta = NucleusPlugin::getOptionMeta($o->oextra);
                 // if the option is readonly or hidden it may not be saved
                 if ($meta['access'] != 'readonly' && $meta['access'] != 'hidden') {
                     $value = undoMagic($value);
                     // value comes from request
                     switch ($o->otype) {
                         case 'yesno':
                             if ($value != 'yes' && $value != 'no') {
                                 $value = 'no';
                             }
                             break;
                         default:
                             break;
                     }
                     // check the validity of numerical options
                     if ($meta['datatype'] == 'numerical' && !is_numeric($value)) {
                         //the option must be numeric, but the it isn't
                         //use the default for this option
                         $value = $o->odef;
                     }
                     // decide wether we are using the contextid of newContextid
                     if ($newContextid != 0) {
                         $contextid = $newContextid;
                     }
                     //trigger event PrePluginOptionsUpdate to give the plugin the
                     //possibility to change/validate the new value for the option
                     $manager->notify('PrePluginOptionsUpdate', array('context' => $o->ocontext, 'plugid' => $o->opid, 'optionname' => $o->oname, 'contextid' => $contextid, 'value' => &$value));
                     // delete the old value for the option
                     sql_query('DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid=' . intval($oid) . ' AND ocontextid=' . intval($contextid));
                     sql_query('INSERT INTO ' . sql_table('plugin_option') . " (oid, ocontextid, ovalue) VALUES (" . intval($oid) . "," . intval($contextid) . ",'" . sql_real_escape_string($value) . "')");
                 }
             }
         }
         // clear option value cache if the plugin object is already loaded
         if (is_object($o)) {
             $plugin =& $manager->pidLoaded($o->opid);
             if ($plugin) {
                 $plugin->clearOptionValueCache();
             }
         }
     }
 }
Пример #4
0
function passVar($key, $value)
{
    // array ?
    if (is_array($value)) {
        for ($i = 0; $i < sizeof($value); $i++) {
            passVar($key . '[' . $i . ']', $value[$i]);
        }
        return;
    }
    // other values: do stripslashes if needed
    ?>
<input type="hidden" name="<?php 
    echo htmlspecialchars($key);
    ?>
" value="<?php 
    echo htmlspecialchars(undoMagic($value));
    ?>
" /><?php 
}