function apps_profile_apps_select_form_validate in Apps 7
Validate function for apps_profile_apps_select_form.
File
- ./
apps.profile.inc, line 211 - The install functions for the Apps module.
Code
function apps_profile_apps_select_form_validate($form, &$form_state) {
if (empty($form_state['values']['op']) || $form_state['values']['op'] == t('Install Apps')) {
// See if any the apps conflict with each other and cannot be used togeather.
$apps = array_keys(array_filter($form_state['values']['apps']));
foreach ($apps as $app_name) {
$app = $_SESSION['apps_manifest'][$app_name];
if (!empty($app['conflicts'])) {
$app_conflicts = array();
// Find any apps that would conflict with apps of this server.
foreach ($app['conflicts'] as $conflict) {
if ($conflict['server'] == $_SESSION['apps_server']['machine name']) {
$app_conflicts[] = $conflict['name'];
}
}
// Error out if conflicting apps were selected.
if ($conflicts = array_intersect($app_conflicts, $apps)) {
$names = array();
foreach ($conflicts as $conflict) {
$names[] = $_SESSION['apps_manifest'][$conflict]['name'] . ' (' . $conflict . ')';
}
form_set_error('apps', t('Conflict found with @app (@machine), not compatible with @apps', array(
'@app' => $app['name'],
'@apps' => implode(', ', $names),
'@machine' => $app_name,
)));
}
}
// Don't enable any apps who's parent apps aren't being enabled.
if (!empty($app['parent_apps'])) {
if (array_diff($app['parent_apps'], $apps)) {
unset($form_state['values']['apps'][$app_name]);
}
}
}
}
}