function SLAM_saveAssetEdits(&$config, $db, &$user, $request)
{
    /*
    	saves values present in edit_ fields to a new entry or to existing entries as necessary
    	Returns a string, possibly containing a description of the error
    */
    /* get asset values from fields that start with "edit_" */
    $asset = array();
    foreach ($_REQUEST as $key => $value) {
        if ($value != $config->values['multiple_value']) {
            if (preg_match('/^edit_(.+)$/', $key, $m) > 0) {
                $asset[base64_decode($m[1])] = stripslashes($value);
            }
        }
    }
    /* go through all the tables we need to insert into */
    foreach ($request->categories as $category => $identifiers) {
        /* if permissions field is the multiple field value, don't overwrite asset's existing permissions */
        if ($_REQUEST['permissions'] && $_REQUEST['permissions'] == $config->values['multiple_value']) {
            $asset['permissions'] = false;
        } elseif ($_REQUEST['permissions']) {
            $asset['permissions'] = json_decode(base64_decode($_REQUEST['permissions']));
        }
        /* are we creating a new entry? */
        if ($_REQUEST['new']) {
            if (($s = insertNewAsset($config, $db, $user, $category, $asset)) !== True) {
                return $s;
            } else {
                SLAM_updateArchiveFileList($config, $db, $category, $asset['Identifier']);
            }
        } elseif (is_array($identifiers)) {
            /* go through all the assets we have and update the changed fields */
            foreach ($identifiers as $identifier) {
                /* replace the insertion statement identifier with the correct one */
                $asset['Identifier'] = $identifier;
                if (($s = replaceExistingAsset($config, $db, $user, $category, $asset)) !== True) {
                    return $s;
                }
            }
        } else {
            $config->errors[] = "No identifier was provided for saving edits";
        }
    }
    $user->savePrefs($config, $db);
    # returns nothing on success (maybe a status message in the future?)
    return '';
}
示例#2
0
        }
    } else {
        echo "<div id='fileEmpty'>No files to show</div>\n";
    }
} else {
    echo "<div id='fileEmpty'>You do not have access to this asset's files.</div>\n";
}
if (!empty($config->values['debug'])) {
    echo "<div class='error'>\n";
    for ($i = 0; $i < count($config->errors); $i++) {
        echo "{$i}) {$config->errors[$i]}<br />\n";
    }
    echo "</div>\n";
}
if ($access > 1) {
    SLAM_updateArchiveFileList($config, $db, $category, $identifier);
} else {
    echo "</div>\n</body>\n</html>\n";
    exit;
}
?>
</form>
		</div>
		<div id='fileUploadContainer'>
			<form name="assetFileUpload" id="assetFileUpload" method="POST" action="upload.php" enctype="multipart/form-data">
				<input type="hidden" name="i" value="<?php 
echo $identifier;
?>
" />
				<table id='fileUploadTable'>
					<tr>