Api

Version

mediamosa-30

Class

mediamosa_rest_call_group_get

Code

File: /sites/all/modules/mediamosa/modules/user/group/mediamosa_user_group.rest.class.inc
<?php?php
// $Id$

/**
 * MediaMosa is Open Source Software to build a Full Featured, Webservice
 * Oriented Media Management and Distribution platform (http://mediamosa.org)
 *
 * Copyright (C) 2011 SURFnet BV (http://www.surfnet.nl) and Kennisnet
 * (http://www.kennisnet.nl)
 *
 * MediaMosa is based on the open source Drupal platform and
 * was originally developed by Madcap BV (http://www.madcap.nl)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, you can find it at:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

/**
 * @file
 * User group specific REST calls.
 */
/**
 * URI: /group/$group_id
 *
 * Method: GET
 *
 * 1.x: user_management_get_group
 *
 */
class mediamosa_rest_call_group_get extends mediamosa_rest_call {
  
// ------------------------------------------------------------------ Consts.
  // Rest vars;
  
const GROUP_ID 'group_id';

  
// ------------------------------------------------------------------ Get Var Setup.
  
public function get_var_setup() {
    
$a_var_setup = array();

    
$a_var_setup = array(
      
self::VARS => array(
        
self::GROUP_ID => array(
          
self::VAR_TYPE => mediamosa_sdk::TYPE_GROUP_ID,
          
self::VAR_DESCRIPTION => 'The group to retrieve.',
          
self::VAR_IS_REQUIRED => self::VAR_IS_REQUIRED_YES,
          
self::VAR_RANGE_END => mediamosa_user_group_db::GROUP_ID_LENGTH,
        ),
      )
    );

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

  
// ------------------------------------------------------------------ Do Call.
  
public function do_call() {
    
$o_mediamosa mediamosa::get();

    
$a_app_ids $this->get_param_value_app();
    
$app_id reset($a_app_ids);

    
$group_id $this->get_param_value(self::GROUP_ID);

    
// Get the group quota.
    
$result mediamosa_user_group::get_user_group_quota($app_id$group_id);

    if (isset(
$result[mediamosa_user_group_db::CREATED])) {
      
$result[mediamosa_user_group_db::CREATED] = mediamosa::utcdate2appdate($result[mediamosa_user_group_db::CREATED]);
    }

    if (isset(
$result[mediamosa_user_group_db::CHANGED])) {
      
$result[mediamosa_user_group_db::CHANGED] = mediamosa::utcdate2appdate($result[mediamosa_user_group_db::CHANGED]);
    }

    
// Add to response.
    
$o_mediamosa->add_item($result);
  }
}