diff --git a/modules/forum.module b/modules/forum.module index 3fd910da0dcf62c644381a04ff70c1563911afa7..280ab5b844784ccd103e027d6f2bb25a9b32f1fb 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -91,27 +91,38 @@ function forum_admin() { break; } else { + $name = $edit['name']; $edit['name'] = 0; } case t('Submit'): - list($status, $object) = array_values(taxonomy_save_term($edit)); + $status = taxonomy_save_term($edit); if (arg(3) == 'container') { - $containers = variable_get('forum_containers', array()); - $containers[] = $edit['tid']; - variable_set('forum_containers', $containers); - if ($status == SAVED_NEW) { - drupal_set_message(t('Created new forum container %term.', array('%term' => theme('placeholder', $edit['name'])))); - } - else { - drupal_set_message(t('The forum container %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + switch ($status) { + case SAVED_NEW: + $containers = variable_get('forum_containers', array()); + $containers[] = $edit['tid']; + variable_set('forum_containers', $containers); + drupal_set_message(t('Created new forum container %term.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum container %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum container %term has been deleted.', array('%term' => theme('placeholder', $name)))); + break; } } else { - if ($status == SAVED_NEW) { - drupal_set_message(t('Created new forum %term.', array('%term' => theme('placeholder', $edit['name'])))); - } - else { - drupal_set_message(t('The forum %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + switch ($status) { + case SAVED_NEW: + drupal_set_message(t('Created new forum %term.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_DELETED: + drupal_set_message(t('The forum %term has been deleted.', array('%term' => theme('placeholder', $name)))); + break; } } drupal_goto('admin/forum'); @@ -293,8 +304,9 @@ function _forum_get_vid() { // Check to see if a forum vocabulary exists $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='%s'", 'forum')); if (!$vid) { - list($status, $object) = array_values(taxonomy_save_vocabulary(array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum')))); - $vid = $object['vid']; + $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum')); + taxonomy_save_vocabulary($edit); + $vid = $edit['vid']; } variable_set('forum_nav_vocabulary', $vid); } diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 3fd910da0dcf62c644381a04ff70c1563911afa7..280ab5b844784ccd103e027d6f2bb25a9b32f1fb 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -91,27 +91,38 @@ function forum_admin() { break; } else { + $name = $edit['name']; $edit['name'] = 0; } case t('Submit'): - list($status, $object) = array_values(taxonomy_save_term($edit)); + $status = taxonomy_save_term($edit); if (arg(3) == 'container') { - $containers = variable_get('forum_containers', array()); - $containers[] = $edit['tid']; - variable_set('forum_containers', $containers); - if ($status == SAVED_NEW) { - drupal_set_message(t('Created new forum container %term.', array('%term' => theme('placeholder', $edit['name'])))); - } - else { - drupal_set_message(t('The forum container %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + switch ($status) { + case SAVED_NEW: + $containers = variable_get('forum_containers', array()); + $containers[] = $edit['tid']; + variable_set('forum_containers', $containers); + drupal_set_message(t('Created new forum container %term.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum container %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum container %term has been deleted.', array('%term' => theme('placeholder', $name)))); + break; } } else { - if ($status == SAVED_NEW) { - drupal_set_message(t('Created new forum %term.', array('%term' => theme('placeholder', $edit['name'])))); - } - else { - drupal_set_message(t('The forum %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + switch ($status) { + case SAVED_NEW: + drupal_set_message(t('Created new forum %term.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_UPDATED: + drupal_set_message(t('The forum %term has been updated.', array('%term' => theme('placeholder', $edit['name'])))); + break; + case SAVED_DELETED: + drupal_set_message(t('The forum %term has been deleted.', array('%term' => theme('placeholder', $name)))); + break; } } drupal_goto('admin/forum'); @@ -293,8 +304,9 @@ function _forum_get_vid() { // Check to see if a forum vocabulary exists $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='%s'", 'forum')); if (!$vid) { - list($status, $object) = array_values(taxonomy_save_vocabulary(array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum')))); - $vid = $object['vid']; + $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum')); + taxonomy_save_vocabulary($edit); + $vid = $edit['vid']; } variable_set('forum_nav_vocabulary', $vid); } diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 4bbfbe36c0c12f81cdc9e6955e86455cdd517304..311cba35ae7e66cf9d89ebcd310c7c4fec6492e8 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -131,7 +131,7 @@ function taxonomy_form_vocabulary($edit = array()) { return form($form); } -function taxonomy_save_vocabulary($edit) { +function taxonomy_save_vocabulary(&$edit) { $edit['nodes'] = ($edit['nodes']) ? $edit['nodes'] : array(); $edit['weight'] = ($edit['weight']) ? $edit['weight'] : 0; @@ -160,7 +160,7 @@ function taxonomy_save_vocabulary($edit) { cache_clear_all(); - return array('status' => $status, 'object' => $edit); + return $status; } function taxonomy_del_vocabulary($vid) { @@ -246,7 +246,7 @@ function taxonomy_form_term($edit = array()) { return form($form); } -function taxonomy_save_term($edit) { +function taxonomy_save_term(&$edit) { if ($edit['tid'] && $edit['name']) { $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']); @@ -302,7 +302,7 @@ function taxonomy_save_term($edit) { cache_clear_all(); - return array('status' => $status, 'object' => $edit); + return $status; } function taxonomy_del_term($tid) { @@ -603,8 +603,9 @@ function taxonomy_node_save($nid, $terms) { } if (!$typed_term_tid) { - list($status, $object) = array_values(taxonomy_save_term(array('vid' => $vid, 'name' => $typed_term))); - $typed_term_tid = $object['tid']; + $edit = array('vid' => $vid, 'name' => $typed_term); + $status = taxonomy_save_term($edit); + $typed_term_tid = $edit['tid']; } db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); @@ -1155,8 +1156,7 @@ function taxonomy_admin() { } case t('Submit'): if (arg(3) == 'vocabulary') { - list($status, $object) = array_values(taxonomy_save_vocabulary($edit)); - switch ($status) { + switch (taxonomy_save_vocabulary($edit)) { case SAVED_NEW: drupal_set_message(t('Created new vocabulary %name.', array('%name' => theme('placeholder', $edit['name'])))); break; @@ -1169,8 +1169,7 @@ function taxonomy_admin() { } } else { - list($status, $object) = array_values(taxonomy_save_term($edit)); - switch ($status) { + switch (taxonomy_save_term($edit)) { case SAVED_NEW: drupal_set_message(t('Created new term %term.', array('%term' => theme('placeholder', $edit['name'])))); break; diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 4bbfbe36c0c12f81cdc9e6955e86455cdd517304..311cba35ae7e66cf9d89ebcd310c7c4fec6492e8 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -131,7 +131,7 @@ function taxonomy_form_vocabulary($edit = array()) { return form($form); } -function taxonomy_save_vocabulary($edit) { +function taxonomy_save_vocabulary(&$edit) { $edit['nodes'] = ($edit['nodes']) ? $edit['nodes'] : array(); $edit['weight'] = ($edit['weight']) ? $edit['weight'] : 0; @@ -160,7 +160,7 @@ function taxonomy_save_vocabulary($edit) { cache_clear_all(); - return array('status' => $status, 'object' => $edit); + return $status; } function taxonomy_del_vocabulary($vid) { @@ -246,7 +246,7 @@ function taxonomy_form_term($edit = array()) { return form($form); } -function taxonomy_save_term($edit) { +function taxonomy_save_term(&$edit) { if ($edit['tid'] && $edit['name']) { $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']); @@ -302,7 +302,7 @@ function taxonomy_save_term($edit) { cache_clear_all(); - return array('status' => $status, 'object' => $edit); + return $status; } function taxonomy_del_term($tid) { @@ -603,8 +603,9 @@ function taxonomy_node_save($nid, $terms) { } if (!$typed_term_tid) { - list($status, $object) = array_values(taxonomy_save_term(array('vid' => $vid, 'name' => $typed_term))); - $typed_term_tid = $object['tid']; + $edit = array('vid' => $vid, 'name' => $typed_term); + $status = taxonomy_save_term($edit); + $typed_term_tid = $edit['tid']; } db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); @@ -1155,8 +1156,7 @@ function taxonomy_admin() { } case t('Submit'): if (arg(3) == 'vocabulary') { - list($status, $object) = array_values(taxonomy_save_vocabulary($edit)); - switch ($status) { + switch (taxonomy_save_vocabulary($edit)) { case SAVED_NEW: drupal_set_message(t('Created new vocabulary %name.', array('%name' => theme('placeholder', $edit['name'])))); break; @@ -1169,8 +1169,7 @@ function taxonomy_admin() { } } else { - list($status, $object) = array_values(taxonomy_save_term($edit)); - switch ($status) { + switch (taxonomy_save_term($edit)) { case SAVED_NEW: drupal_set_message(t('Created new term %term.', array('%term' => theme('placeholder', $edit['name'])))); break;