Exemplo n.º 1
0
 function update($id, $fields, $values = false, $ignore_cache = false)
 {
     $id = sqlescape($id);
     // Turn a key => value array into pairs
     if ($values === false && is_array($fields)) {
         $values = $fields;
         $fields = array_keys($fields);
     }
     // Multiple columns to update
     if (is_array($fields)) {
         $query_parts = array();
         foreach ($fields as $key) {
             $val = current($values);
             if (is_array($val)) {
                 $val = BigTree::json(BigTree::translateArray($val));
             } else {
                 $val = BigTreeAdmin::autoIPL($val);
             }
             $query_parts[] = "`{$key}` = '" . sqlescape($val) . "'";
             next($values);
         }
         sqlquery("UPDATE `" . $this->Table . "` SET " . implode(", ", $query_parts) . " WHERE id = '{$id}'");
         // Single column to update
     } else {
         if (is_array($values)) {
             $val = json_encode(BigTree::translateArray($values));
         } else {
             $val = BigTreeAdmin::autoIPL($values);
         }
         sqlquery("UPDATE `" . $this->Table . "` SET `{$fields}` = '" . sqlescape($val) . "' WHERE id = '{$id}'");
     }
     if (!$ignore_cache) {
         BigTreeAutoModule::recacheItem($id, $this->Table);
     }
 }
Exemplo n.º 2
0
 static function updatePendingItemField($id, $field, $value)
 {
     $id = sqlescape($id);
     $item = sqlfetch(sqlquery("SELECT * FROM bigtree_pending_changes WHERE id = '{$id}'"));
     $changes = json_decode($item["changes"], true);
     if (is_array($value)) {
         $value = BigTree::translateArray($value);
     }
     $changes[$field] = $value;
     $changes = sqlescape(json_encode($changes));
     sqlquery("UPDATE bigtree_pending_changes SET changes = '{$changes}' WHERE id = '{$id}'");
 }
Exemplo n.º 3
0
        } else {
            $field["output"] = BigTree::safeEncode($bigtree["post_data"][$field["key"]]);
        }
    }
    // Backwards compatibility with older custom field types
    if (!isset($field["output"]) && isset($value)) {
        $field["output"] = $value;
    }
    if (!BigTreeAutoModule::validate($field["output"], $field["options"]["validation"])) {
        $error = $field["options"]["error_message"] ? $field["options"]["error_message"] : BigTreeAutoModule::validationErrorMessage($field["output"], $field["options"]["validation"]);
        $bigtree["errors"][] = array("field" => $field["options"]["title"], "error" => $error);
    }
    if (!$field["ignore"]) {
        // Translate internal link information to relative links.
        if (is_array($field["output"])) {
            $field["output"] = BigTree::translateArray($field["output"]);
        } else {
            $field["output"] = $admin->autoIPL($field["output"]);
        }
        $bigtree["entry"][$field["key"]] = $field["output"];
    }
}
// See if we added anything in pre-processing that wasn't a field in the form.
if (is_array($bigtree["preprocessed"])) {
    foreach ($bigtree["preprocessed"] as $key => $val) {
        if (!isset($bigtree["entry"][$key])) {
            $bigtree["entry"][$key] = $val;
        }
    }
}
// Sanitize the form data so it fits properly in the database (convert dates to MySQL-friendly format and such)
Exemplo n.º 4
0
 static function updateSettingValue($id, $value)
 {
     global $bigtree, $admin;
     $item = static::getSetting($id, false);
     $id = sqlescape(BigTreeCMS::extensionSettingCheck($id));
     if (is_array($value)) {
         $value = BigTree::translateArray($value);
     } else {
         $value = static::autoIPL($value);
     }
     $value = BigTree::json($value, true);
     if ($item["encrypted"]) {
         sqlquery("UPDATE bigtree_settings SET `value` = AES_ENCRYPT('{$value}','" . sqlescape($bigtree["config"]["settings_key"]) . "') WHERE id = '{$id}'");
     } else {
         sqlquery("UPDATE bigtree_settings SET `value` = '{$value}' WHERE id = '{$id}'");
     }
     if ($admin && !$item["system"]) {
         // Audit trail.
         $admin->track("bigtree_settings", $id, "updated");
     }
 }
Exemplo n.º 5
0
 function updateSettingValue($id, $value)
 {
     global $bigtree;
     $item = $this->getSetting($id, false);
     $id = sqlescape($id);
     if (is_array($value)) {
         $value = BigTree::translateArray($value);
     } else {
         $value = $this->autoIPL($value);
     }
     // Prefer to keep this an object, but we need PHP 5.3
     if (strnatcmp(phpversion(), '5.3') >= 0) {
         $value = sqlescape(json_encode($value, JSON_FORCE_OBJECT));
     } else {
         $value = sqlescape(json_encode($value));
     }
     if ($item["encrypted"]) {
         sqlquery("UPDATE bigtree_settings SET `value` = AES_ENCRYPT('{$value}','" . sqlescape($bigtree["config"]["settings_key"]) . "') WHERE id = '{$id}'");
     } else {
         sqlquery("UPDATE bigtree_settings SET `value` = '{$value}' WHERE id = '{$id}'");
     }
     // Audit trail
     $this->track("bigtree_settings", $id, "updated-value");
 }