Permalink
Browse files

update vsite_menu_link_save to work when no override exists, should g…

…rab the default links from the ML table
  • Loading branch information...
1 parent ea23e30 commit 8df8942b665ec60163a53e8a20d81bbe89caaf0b @rbran100 rbran100 committed May 16, 2012
@@ -80,6 +80,16 @@ function vsite_menu_menu_link_save(&$item) {
//Retrieve the existing menu data
$existing_menu = $vsite->controllers->menus->get($menu);
+ //If there is no menu override avalible get the default links from the menu_link table
+ if(!is_array($existing_menu)){
+ $sql = "SELECT ml.* FROM {menu_links} ml WHERE ml.menu_name = :menu ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
+ $result = db_query($sql, array(':menu' => $menu), array('fetch' => PDO::FETCH_ASSOC));
+ $existing_menu = array();
+ foreach ($result as $ml) {
+ $existing_menu[$ml['mlid']] = $ml;
+ }
+ }
+
if (isset($item['mlid']) && array_key_exists($item['mlid'], $existing_menu)) {
$existing_item = $existing_menu[$item['mlid']];
}
@@ -192,7 +192,7 @@ function vsite_get_group_fields(){
$fields["node-{$bundle}-og_group_ref"] = array(
'field_config' => array(
'active' => '1',
- 'cardinality' => '-1',
+ 'cardinality' => '1',
'deleted' => '0',
'entity_types' => array(),
'field_name' => 'og_group_ref',
@@ -10,6 +10,28 @@ include_once ('vsite.features.inc');
*/
/**
+ * Implements hook_BASE_ID_form_alter().
+ *
+ * Runs on every node form
+ */
+function vsite_form_node_form_alter(&$form, &$form_state, $form_id){
+ $vsite = spaces_get_space();
+ $os_bundles = os_get_bundles();
+
+ if($vsite && in_array($form['#bundle'],$os_bundles)){
+ //Set the og_group_ref value to automatically be the current active site
+ $form[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = array(
+ '#type' => 'value',
+ '#default_value' => $vsite->group->nid,
+ '#field_name' => OG_AUDIENCE_FIELD,
+ '#language' => LANGUAGE_NONE,
+ '#entity_type' => 'node',
+ '#bundle' => $form['#bundle']
+ );
+ }
+}
+
+/**
* Alter the space presets to add vsite specific information
*
* @param $presets

0 comments on commit 8df8942

Please sign in to comment.