Api

Version

mediamosa-30

Class

mediamosa_rest_call_acl_collection_delete_rights

Code

File: /sites/all/modules/mediamosa/modules/acl/mediamosa_acl.rest.class.inc
<?php

/**
 * URI: /collection/$coll_id/acl/delete
 * Method: POST
 */
class mediamosa_rest_call_acl_collection_delete_rights extends mediamosa_rest_call {

  
// ------------------------------------------------------------------- Consts.
  // Rest vars;
  
const COLL_ID 'coll_id';
  const 
USER_ID 'user_id';

  
// ------------------------------------------------------- Functions (public).
  
public function get_var_setup() {
    
$var_setup = array();

    
$var_setup[self::VARS][self::COLL_ID] = array(
      
self::VAR_TYPE => mediamosa_sdk::TYPE_COLLECTION_ID,
      
self::VAR_IS_REQUIRED => self::VAR_IS_REQUIRED_YES,
      
self::VAR_DESCRIPTION => 'Collection id, unique identifier of the collection.',

    );

    
$var_setup[self::VARS][self::USER_ID] = array(
      
self::VAR_TYPE => mediamosa_sdk::TYPE_USER_ID,
      
self::VAR_IS_REQUIRED => self::VAR_IS_REQUIRED_YES,
      
self::VAR_DESCRIPTION => 'User id, to determine whether the applicant has the right to remove authorization or not.',
    );

    
// Enrich with required REST vars.
    
return self::get_var_setup_default($var_setup);
  }

  public function 
do_call() {
    
$mediamosa mediamosa::get();

    
// Get the app id(s).
    
$app_ids $this->get_param_value_app();
    
$coll_id $this->get_param_value(self::COLL_ID);
    
$user_id $this->get_param_value(self::USER_ID);

    
// First is always the main app.
    
$app_id reset($app_ids);

    
// Make sure the media file exists.
    
mediamosa_db::db_must_exists(mediamosa_collection_db::TABLE_NAME, array(mediamosa_collection_db::APP_ID => $app_idmediamosa_collection_db::ID => $coll_id));

    
// Get the media file
    
$collection mediamosa_collection::get($coll_id$app_id);

    
// Remove rights.
    
mediamosa_acl::rights_clear($app_id$user_idmediamosa_acl::ACL_TYPE_COLLECTION$collection);

    
// All ok.
    
$mediamosa->set_result_okay();
  }
}