Beispiel #1
0
 /**
  * Export API
  *
  * @param $api ServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array.
  * @param $args array The arguments array passed in from the API
  * @return String
  */
 public function export(ServiceBase $api, array $args)
 {
     $seed = BeanFactory::newBean($args['module']);
     if (!$seed->ACLAccess('export')) {
         throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']);
     }
     ob_start();
     global $sugar_config;
     global $current_user;
     global $app_list_strings;
     $theModule = clean_string($args['module']);
     if ($sugar_config['disable_export'] || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($theModule) && ACLAction::getUserAccessLevel($current_user->id, $theModule, 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $theModule, 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $theModule, 'admin') == ACL_ALLOW_ADMIN_DEV))) {
         throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']);
     }
     //check to see if this is a request for a sample or for a regular export
     if (!empty($args['sample'])) {
         //call special method that will create dummy data for bean as well as insert standard help message.
         $content = exportSampleFromApi($args);
     } else {
         $content = exportFromApi($args);
     }
     $filename = $args['module'];
     //use label if one is defined
     if (!empty($app_list_strings['moduleList'][$args['module']])) {
         $filename = $app_list_strings['moduleList'][$args['module']];
     }
     //strip away any blank spaces
     $filename = str_replace(' ', '', $filename);
     if (isset($args['members']) && $args['members'] == true) {
         $filename .= '_' . 'members';
     }
     ///////////////////////////////////////////////////////////////////////////////
     ////	BUILD THE EXPORT FILE
     ob_end_clean();
     return $this->doExport($api, $filename, $content);
 }
Beispiel #2
0
/**
 * to export sample records
 * @param boolean args api argument
 * @return string delimited string and description
 */
function exportSampleFromApi($args)
{
    global $app_strings;
    $args['all'] = true;
    //retrieve the export content
    $content = exportFromApi($args, true);
    //add details on removing the sample data
    return $content . $app_strings['LBL_IMPORT_SAMPLE_FILE_TEXT'];
}