} if ($exif_override) { $uploadparams .= "&exif_override=true"; } } hook("editbeforesave"); # save data if (!$multiple) { # Upload template: Change resource type $resource_type = getvalescaped("resource_type", ""); if ($resource_type != "" && !checkperm("XU{$resource_type}")) { update_resource_type($ref, $resource_type); $resource = get_resource_data($ref, false); # Reload resource data. } $save_errors = save_resource_data($ref, $multiple); if ($embedded_data_user_select) { $no_exif = getval("exif_option", ""); } else { $no_exif = getval("no_exif", ""); } $autorotate = getval("autorotate", ""); if ($upload_collection_name_required) { if (getvalescaped("entercolname", "") == "" && getval("collection_add", "") == -1) { if (!is_array($save_errors)) { $save_errors = array(); } $save_errors['collectionname'] = $lang["requiredfield"]; } } if (($save_errors === true || $is_template) && getval("tweak", "") == "") {
# Fetch resource data. $resource = get_resource_data($ref); # Load resource data $proposefields = get_resource_field_data($ref, false, true); // Save data if (getval("save", "") != "") { if ($editaccess) { // Set a list of the fields we actually want to change - otherwise any fields we don't submit will get wiped $acceptedfields = array(); foreach ($proposed_changes as $proposed_change) { if (getval("accept_change_" . $proposed_change["resource_type_field"], "") == "on" && !getval("delete_change_" . $proposed_change["resource_type_field"], "") == "on") { $acceptedfields[] = $proposed_change["resource_type_field"]; } } // Actually save the data save_resource_data($ref, false, $acceptedfields); daily_stat("Resource edit", $ref); // send email to change proposer with link $acceptedchanges = array(); $acceptedchangescount = 0; $deletedchanges = array(); $deletedchangescount = 0; $proposefields = get_resource_field_data($ref, false, true); // Get updated data after save so we can send email with values for ($n = 0; $n < count($proposefields); $n++) { # Has this field been accepted? if (getval("accept_change_" . $proposefields[$n]["ref"], "") != "") { debug("propose_changes - accepted proposed change for field " . $proposefields[$n]["title"]); $acceptedchanges[$acceptedchangescount]["field"] = $proposefields[$n]["title"]; $acceptedchanges[$acceptedchangescount]["value"] = $proposefields[$n]["value"]; $acceptedchangescount++;
if ($editaccess) { $userproposals = sql_query("select pc.user, u.username from propose_changes_data pc left join user u on u.ref=pc.user where resource='{$ref}' group by pc.user order by u.username asc"); $view_user = getvalescaped("proposeuser", count($userproposals) == 0 ? $userref : $userproposals[0]["user"]); $proposed_changes = get_proposed_changes($ref, $view_user); } else { $proposed_changes = get_proposed_changes($ref, $userref); } # Fetch resource data. $resource = get_resource_data($ref); # Load resource data $proposefields = get_resource_field_data($ref, false, true); // Save data if (getval("save", "") != "") { if ($editaccess) { // Actually save the data save_resource_data($ref, false); daily_stat("Resource edit", $ref); // send email to change proposer with link $acceptedchanges = array(); $acceptedchangescount = 0; $deletedchanges = array(); $deletedchangescount = 0; $proposefields = get_resource_field_data($ref, false, true); // Get updated data after save so we can send email with values for ($n = 0; $n < count($proposefields); $n++) { # Has this field been accepted? if (getval("accept_change_" . $proposefields[$n]["ref"], "") != "") { $acceptedchanges[$acceptedchangescount]["field"] = $proposefields[$n]["title"]; $acceptedchanges[$acceptedchangescount]["value"] = $proposefields[$n]["value"]; $acceptedchangescount++; // remove this from the list of proposed changes
{ # When auto saving, pass forward the field so only this is saved. $autosave_field=getvalescaped("autosave_field",""); # Upload template: Change resource type $resource_type=getvalescaped("resource_type",""); if ($resource_type!="" && !checkperm("XU{$resource_type}") && $autosave_field=="") // only if resource specified and user has permission for that resource type { update_resource_type($ref,$resource_type); $resource=get_resource_data($ref,false); # Reload resource data. } # Perform the save $save_errors=save_resource_data($ref,$multiple,$autosave_field); if($embedded_data_user_select) { $no_exif=getval("exif_option",""); } else { $no_exif=getval("no_exif",""); } if($relate_on_upload && $enable_related_resources && getval("relateonupload","")!="") { $uploadparams.="&relateonupload=yes"; } $autorotate = getval("autorotate","");