asset_batch_process()vpx_beheer_mm/asset/asset_batch.inc, line 497
<?php
function asset_batch_process() {
global $user;
if (!isset($user->profile_group_id)) {
profile_load_profile($user);
}
$output = '';
$vpx = new vpx_connector();
if (!isset($_SESSION['asset_batch_post_values'])) {
drupal_set_message(t('No batch information supplied!'), 'error');
drupal_goto('asset/batch');
}
$assets = $_SESSION['asset_batch_post_values']['assets'];
$collections = $_SESSION['asset_batch_post_values']['collections'];
$acl = $_SESSION['asset_batch_post_values']['acl'];
$apps = $_SESSION['asset_batch_post_values']['apps'];
unset($_SESSION['asset_batch_post_values']);
// count the assets
if (count($assets) < 1) {
drupal_set_message(t('No assets selected!'), 'error');
drupal_goto('asset/batch');
}
// the header as used in the tables
$header = array(t('Task'), t('Result'));
// collection actions
$rows = array();
$success = TRUE;
$assets_string = 'asset_id[]='. implode('&asset_id[]=', $assets);
foreach ($collections as $coll_id) {
$url = sprintf('/collection/%s/asset_relation?user_id=%s&group_id=%s', $coll_id, $user->name, $user->profile_group_id);
$data = $assets_string;
$result = $vpx->request('POST', $url .'&'. $data); // TODO: asset_id[] moet POST zijn???
$success = (isset($result->header->request_result_id) && $result->header->request_result_id == '601');
foreach ($result->items->item as $item) {
$item_success = ($item->result_id == '601');
$rows[] = array(
'data' => array(
t('Add the asset with id: %asset_id to collection with id: %coll_id', array('%asset_id' => $item->asset_id, '%coll_id' => $item->coll_id)),
($item_success) ? t('Success') : t((string)$item->result_description),
),
'class' => ($item_success) ? '' : 'error',
);
}
}
$output .= theme(
'fieldset',
array(
'#type' => 'fieldset',
'#title' => t('Collections'),
'#value' => theme('table', $header, $rows),
'#collapsible' => TRUE,
'#collapsed' => $success,
)
);
$rows = array();
$collapsed = TRUE;
$data = array();
foreach ($acl as $ac) {
$data[] = (strpos($ac, '@') !== FALSE) ? 'aut_realm[]='. $ac : 'aut_domain[]='. $ac; // acl's containing a '@' are supposed to be 'realms'
}
foreach ($apps as $app) {
$data[] = 'aut_app[]='. $app;
}
$data = implode('&', $data); // .'&replace=FALSE'; // tijdelijk uit gezet
$url = sprintf('/asset/mediafile/acl?user_id=%s&group_id=%s&%s', $user->name, $user->profile_group_id, $assets_string);
$result = $vpx->request('POST', $url, $data);
$success = (isset($result->header->request_result_id) && $result->header->request_result_id == '601');
if (!$success) {
$collapsed = FALSE;
}
foreach ($result->items->item as $item) {
$item_success = ($item->result_id == '601');
$rows[] = array(
'data' => array(
t('Replacing access rules for the mediafile with id: %mediafile_id (asset id: %asset_id)', array('%mediafile_id' => $item->mediafile_id, '%asset_id' => $item->asset_id)),
($item_success) ? t('Success') : t((string)$item->result_description),
),
'class' => ($item_success) ? '' : 'error',
);
}
$output .= theme(
'fieldset',
array(
'#type' => 'fieldset',
'#title' => t('Access Rules'),
'#description' => t('Adding domains and realms: !acl; foreign apps: !app.', array('!acl' => implode(', ', $acl), '!app' => implode(', ', $apps))),
'#value' => theme('table', $header, $rows),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
)
);
return $output;
}
?>