summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apk_browser.module22
1 files changed, 16 insertions, 6 deletions
diff --git a/apk_browser.module b/apk_browser.module
index f478e82..5e86f08 100644
--- a/apk_browser.module
+++ b/apk_browser.module
@@ -80,8 +80,14 @@ function apk_browser_settings($form) {
}
function apk_browser_repository_delete_form($form, &$form_state, $rid) {
- $form['repo_id'] = array('#type' => 'hidden', '#value' => $rid);
- return confirm_form($form, t('Are you sure you want to delete repository with ID @ID?', array('@ID' => $rid)), 'admin/config/apk_browser/repositories', t('This action cannot be undone.'), t('Delete repository'), t('Cancel'));
+ $repos = variable_get('apk_repositories', array());
+ if (array_key_exists($rid, $repos)) {
+ $form['repo_id'] = array('#type' => 'hidden', '#value' => $rid);
+ return confirm_form($form, t('Are you sure you want to delete repository with ID @ID?', array('@ID' => $rid)), 'admin/config/apk_browser/repositories', t('This action cannot be undone.'), t('Delete repository'), t('Cancel'));
+ } else {
+ drupal_set_message(t('Please select an existing repository ID'), 'error');
+ drupal_goto('admin/config/apk_browser/repositories');
+ }
}
function apk_browser_repository_delete_form_submit($form, &$form_state) {
@@ -93,14 +99,18 @@ function apk_browser_repository_delete_form_submit($form, &$form_state) {
}
function apk_browser_repository_edit_form($form, &$form_state, $rid = array()) {
+ $repos = variable_get('apk_repositories', array());
if (!empty($rid)) {
$form['repo_id'] = array('#type' => 'hidden', '#value' => $rid);
+ if (!array_key_exists($rid, $repos)) {
+ drupal_set_message(t('Please select an existing repository ID'), 'error');
+ drupal_goto('admin/config/apk_browser/repositories');
+ }
}
$repo = taxonomy_vocabulary_machine_name_load('apk_repo');
$repo_tree = taxonomy_get_tree($repo->vid);
$arch = taxonomy_vocabulary_machine_name_load('apk_arch');
$arch_tree = taxonomy_get_tree($arch->vid);
- $repos = variable_get('apk_repositories', array());
if (empty($arch_tree) || empty($repo_tree)) {
$form['warning'] = array(
'#type' => 'item',
@@ -116,7 +126,7 @@ function apk_browser_repository_edit_form($form, &$form_state, $rid = array()) {
'#type' => 'textfield',
'#title' => t('Repository URL'),
'#size' => '100',
- '#default_value' => (isset($rid)) ? $repos[$rid]['url'] : '',
+ '#default_value' => (isset($rid['url'])) ? $repos[$rid]['url'] : '',
'#description' => t('Link to the APKINDEX.tar.gz file inside the repository'),
'#required' => TRUE,
);
@@ -128,7 +138,7 @@ function apk_browser_repository_edit_form($form, &$form_state, $rid = array()) {
'#type' => 'select',
'#options' => $repo_options,
'#title' => 'Select repository',
- '#default_value' => (isset($rid)) ? $repos[$rid]['repo'] : '',
+ '#default_value' => (isset($rid['repo'])) ? $repos[$rid]['repo'] : '',
'#description' => t('Please make sure you select the correct repository.
Preventing to do so will break package listing')
);
@@ -138,7 +148,7 @@ function apk_browser_repository_edit_form($form, &$form_state, $rid = array()) {
$form['settings']['arch'] = array(
'#type' => 'select',
'#options' => $arch_options,
- '#default_value' => (isset($rid)) ? $repos[$rid]['arch'] : '',
+ '#default_value' => (isset($rid['arch'])) ? $repos[$rid]['arch'] : '',
'#title' => 'Select architecture',
'#description' => t('Please make sure you select the correct architecture.
Preventing to dox so will break package listing')