Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

process_edit_form()

Parameters

ColumnTypeDefaultDescription
$ref
$resource

Location

include/resource_functions.php lines 6556 to 6622

Definition

 
function process_edit_form($ref$resource)
    {
    global 
$multiple$lang$embedded_data_user_select$embedded_data_user_select_fields$data_only_resource_types,
    
$check_edit_checksums$uploadparams$resource_type_force_selection$relate_on_upload$enable_related_resources
    
$is_template$upload_collection_name_required$upload_review_mode$userref$userref$collection_add$baseurl_short,
    
$no_exif$autorotate;

    
# save data
    # 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!="" && $resource_type!=$resource["resource_type"] && !checkperm("XU{$resource_type}") && $autosave_field=="")     // only if resource type specified and user has permission for that resource type
        
{
        
// Check if resource type has been changed between form being loaded and submitted                
        
$post_cs getval("resource_type_checksum","");
        
$current_cs $resource["resource_type"];            
        if(
$check_edit_checksums && $post_cs != "" && $post_cs != $current_cs)
            {
            
$save_errors = array("resource_type"=>$lang["resourcetype"] . ": " $lang["save-conflict-error"]);
            }
        else
            {
            
update_resource_type($ref,$resource_type);
            }
        }       
    
$resource=get_resource_data($ref,false); # Reload resource data.
   
    
if(in_array($resource['resource_type'], $data_only_resource_types))
        {
        
$single=true;
        }
    else
        {
        unset(
$uploadparams['forcesingle']);
        unset(
$uploadparams['noupload']);
        }

    if(!isset(
$save_errors))
        {
        
# Perform the save
        
$save_errors=save_resource_data($ref,$multiple,$autosave_field);
        }

    if(
$relate_on_upload && $enable_related_resources && getval("relateonupload""") != "")
        {
        
$uploadparams['relateonupload'] = 'yes';
        }

    if(
$ref && $resource_type_force_selection && $resource_type=="")
        {
        if (!
is_array($save_errors)){$save_errors=array();} 
        
$save_errors['resource_type'] = $lang["resourcetype"] . ": " $lang["requiredfield"];
        }
      
    if (
$upload_collection_name_required)
        {
        if (
getvalescaped("entercolname","")=="" && getval("collection_add","")=="new")
              { 
              if (!
is_array($save_errors)){$save_errors=array();} 
              
$save_errors['collectionname'] = $lang["collectionname"] . ": " .$lang["requiredfield"];
              }
       }

    return 
$save_errors;
  }

This article was last updated 26th November 2020 04:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.