Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

update_resource_lock()

Parameters

ColumnTypeDefaultDescription
$ref
$lockaction
$newlockuser null
$accesschecked false

Location

include/resource_functions.php lines 8036 to 8072

Definition

 
function update_resource_lock($ref,$lockaction,$newlockuser=null,$accesschecked false)
    {
    global 
$userref;
    
    if(((string)(int)
$ref != (string)$ref)
     || 
$ref <= 0
     
|| !in_array($lockaction,array(0,1))
        )
        {
        return 
false;
        }

    if(
is_null($newlockuser) || ((string)(int)$newlockuser != (string)$newlockuser))
        {
        
$newlockuser $userref;
        }

    if(!
$accesschecked)
        {
        
$resource_data  get_resource_data($resource);
        
$lockeduser     =  $resource_data["lock_user"];
        
$edit_access    get_edit_access($resource,false,$resource_data);
        if(!
checkperm("a")
            &&
            
$lockeduser != $userref
            
&&
            !(
$edit_access && $lockeduser == && !checkperm("nolock"))
            )
            {
            return 
false;
            }
        }

    
sql_query("UPDATE resource SET lock_user='" . ($lockaction $newlockuser "0") . "' WHERE ref='" . (int)$ref "'");
    
resource_log($ref,($lockaction LOG_CODE_LOCKED LOG_CODE_UNLOCKED),0);
    return 
true;
    }

This article was last updated 14th July 2020 04:35 Europe/London time based on the source file dated 13th July 2020 14:40 Europe/London time.