/** * Helper function to get the Box id number from the node. Includes * a check to see if the node is an organic group or not. */ public static function getBoxFolderID($gid) { // Is session active self::isSessionActive(); $node = node_load($gid); // ->soc_boxgroup_folder // if not group if (!og_is_group('node', $node)) { $msg = t('@node_title is not an Group', ['@node_title' => $node->title]); watchdog(self::BOX_OPERATIONS_NAME, $msg); drupal_set_message($msg, 'error'); return FALSE; } // return URL if we can $ent = entity_metadata_wrapper('node', $node); $box_id = $ent->soc_boxgroup_folder->value(); // if field is blank if (is_null($box_id)) { $msg = t('@node_title does not have a box folder url assigned to it', ['@node_title' => $node->title]); watchdog(SOC_BOXGROUP_MODULE_NAME, $msg); drupal_set_message($msg, 'error'); return FALSE; } // is it not numeric if (!is_numeric($box_id)) { watchdog(SOC_BOXGROUP_MODULE_NAME, t('@node_title (@nid) does not have a numeric folder id assigned to it', ['@node_title' => $node->title, '@nid' => $node->nid])); return FALSE; } // Lastly, if we get this far, just return the value; return $ent->soc_boxgroup_folder->value(); }
protected function checkEntityAccess($op, $entity_type, $entity) { $request = $this->getRequest(); if ($request['vsite']) { spaces_set_space(spaces_load('og', $request['vsite'])); } if (empty($entity->nid)) { // This is still a new node. Skip. return; } if ($is_group = og_is_group($entity_type, $entity)) { $group = $entity; } else { $wrapper = entity_metadata_wrapper('node', $entity); $group = $wrapper->{OG_AUDIENCE_FIELD}->get(0)->value(); } if (empty($request['vsite'])) { spaces_set_space(spaces_load('og', $group->nid)); } $manager = og_user_access('node', $group->nid, 'administer users', $this->getAccount()); if ($is_group) { // In addition to the node access check, we need to see if the user can // manage groups. return $manager && !vsite_access_node_access($group, 'view', $this->getAccount()) == NODE_ACCESS_DENY; } else { $app = os_get_app_by_bundle($entity->type); $space = spaces_get_space(); $application_settings = $space->controllers->variable->get('spaces_features'); switch ($application_settings[$app]) { case OS_DISABLED_APP: return FALSE; case OS_PRIVATE_APP: return og_is_member('node', $group->nid, 'user', $this->getAccount()) && parent::checkEntityAccess($op, $entity_type, $entity); default: case OS_PUBLIC_APP: return parent::checkEntityAccess($op, $entity_type, $entity); } } }
/** * Determine if the user has access to the panelizer operation for this type. */ function panelizer_access($op, $bundle, $view_mode) { $og_access = FALSE; if (is_object($bundle)) { $entity = $bundle; list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); // Additional support for Organic Groups. // @todo move to og_panelizer_access(); if (module_exists('og')) { if (og_is_group($this->entity_type, $entity)) { $og_access = og_user_access($this->entity_type, $entity_id, "administer panelizer og_group {$op}"); } else { $og_groups = og_get_entity_groups($this->entity_type, $entity); foreach ($og_groups as $og_group_type => $og_gids) { foreach ($og_gids as $og_gid) { if (og_user_access($og_group_type, $og_gid, "administer panelizer {$this->entity_type} {$bundle} {$op}")) { $og_access = TRUE; } } } } } // If there is an $op, this must actually be panelized in order to pass. // If there is no $op, then the settings page can provide us a "panelize // it!" page even if there is no display. if ($op && $op != 'overview' && $op != 'settings' && $op != 'choice' && empty($entity->panelizer[$view_mode])) { return FALSE; } } // Invoke hook_panelizer_access(). $panelizer_access = module_invoke_all('panelizer_access', $op, $this->entity_type, $bundle, $view_mode); array_unshift($panelizer_access, user_access('administer panelizer'), user_access("administer panelizer {$this->entity_type} {$bundle} {$op}")); $panelizer_access[] = $og_access; // Trigger hook_panelizer_access_alter(). // We can't pass this many parameters to drupal_alter, so stuff them into // an array. $options = array('op' => $op, 'entity_type' => $this->entity_type, 'bundle' => $bundle, 'view_mode' => $view_mode); drupal_alter('panelizer_access', $panelizer_access, $options); foreach ($panelizer_access as $access) { if ($access) { return $access; } } return FALSE; }
/** * Override or insert variables for the page templates. */ function commons_beehive_preprocess_page(&$variables, $hook) { if (module_exists('page_manager')) { $p = page_manager_get_current_page(); if (isset($p['name']) && $p['name'] == 'node_view') { $node = $p['contexts']['argument_entity_id:node_1']->data; if (module_exists('og') && !og_is_group('node', $node)) { $variables['hide_panelized_title'] = 1; } } } $variables['header_attributes_array']['class'][] = 'container'; $cf_pos = in_array('clearfix', $variables['branding_attributes_array']['class']); unset($variables['branding_attributes_array']['class'][$cf_pos]); // Only load the media styles if Commons Media is enabled. if (module_exists('commons_media')) { drupal_add_css(drupal_get_path('theme', 'commons_beehive') . '/css/commons-media.css', array('media' => 'screen', 'group' => CSS_THEME)); } }
/** * Determine if the user has access to the panelizer operation for this type. */ function panelizer_access($op, $bundle, $view_mode) { $og_access = FALSE; if (is_object($bundle)) { $entity = $bundle; list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); // Additional support for Organic Groups. if (module_exists('og')) { if (og_is_group($this->entity_type, $entity)) { $og_access = og_user_access($this->entity_type, $entity_id, "administer panelizer og_group {$op}"); } else { $og_groups = og_get_entity_groups($this->entity_type, $entity); foreach ($og_groups as $og_group_type => $og_gids) { foreach ($og_gids as $og_gid) { if (og_user_access($og_group_type, $og_gid, "administer panelizer {$this->entity_type} {$bundle} {$op}")) { $og_access = TRUE; } } } } } // If there is an $op, this must actually be panelized in order to pass. // If there is no $op, then the settings page can provide us a "panelize // it!" page even if there is no panel. if ($op && $op != 'overview' && $op != 'settings' && $op != 'choice' && empty($entity->panelizer[$view_mode])) { return FALSE; } } return user_access('administer panelizer') || user_access("administer panelizer {$this->entity_type} {$bundle} {$op}") || $og_access; }
/** * Implements template_preprocess_html(). */ function humanitarianresponse_preprocess_html(&$variables) { if ($node = menu_get_object()) { if (og_is_group('node', $node->nid)) { $variables['classes_array'][] = 'hr-group-context'; } } }
/** * Implements hook_preprocess_node(). */ function shelter_preprocess_node(&$variables) { $node = $variables['node']; $variables['edit_link'] = FALSE; // Add an edit link users having the appropriate permission. if (node_access('update', $node)) { $variables['edit_link'] = l(t('Edit'), 'node/' . $node->nid . '/edit', array('attributes' => array('class' => array('edit-link')))); } $view_mode = $variables['view_mode']; $is_group = og_is_group('node', $node); if ($is_group) { $variables['theme_hook_suggestions'][] = 'node__group'; } // Adding view mode based theme suggestions and preprocesses. $variables['theme_hook_suggestions'][] = 'node__' . $node->type . '__' . $variables['view_mode']; $view_mode_based_preprocess = 'shelter_preprocess_node' . $node->type . '_' . $variables['view_mode']; if (function_exists($view_mode_based_preprocess)) { $view_mode_based_preprocess($variables); } if ($is_group && $view_mode == 'full') { if ($variables['content']['featured_documents']) { } try { $group_wrapper = entity_metadata_wrapper('node', $node); if ($group_image = $group_wrapper->field_image->value()) { $variables['group_image'] = theme('image_style', array('style_name' => 'large', 'path' => $group_image['uri'], 'width' => 290, 'alt' => t('A picture representing @group_name', array('@group_name' => $group_wrapper->title->value())), 'attributes' => array('class' => array('operation-image')))); } } catch (EntityMetadataWrapperException $exception) { _log_entity_metadata_wrapper_error($exception, 'shelter'); } } if ($view_mode == 'full') { if (og_is_group('node', $node)) { $variables['theme_hook_suggestions'][] = 'node__group'; } } else { // Adding view mode based theme suggestions and preprocesses. $variables['theme_hook_suggestions'][] = 'node__partial__' . $variables['view_mode']; $view_mode_based_preprocess = 'shelter_preprocess_node_partial__' . $variables['view_mode']; if (function_exists($view_mode_based_preprocess)) { $view_mode_based_preprocess($variables); } } }
/** * Implements hook_preprocess_page(). */ function platon_preprocess_page(&$vars) { $path = drupal_get_path('theme', 'platon'); _platon_inject_css_override(); drupal_add_library('system', 'jquery.cookie'); // Prepare the site header attributes. $site_header_attributes = array(); // Change the header image. if (theme_get_setting('platon_use_header_background') && theme_get_setting('platon_header_image_path')) { if (!isset($site_header_attributes['style'])) { $site_header_attributes['style'] = ''; } $site_header_attributes['style'] .= 'background-image: url("' . file_create_url('public://' . theme_get_setting('platon_header_image_path')) . '");'; } elseif (module_exists('color') && ($scheme = theme_get_setting('scheme'))) { // We generate header images, but there not as "clean" as when generated through Photoshop. // If one of the provided schemes was chosen, use one of our own header images. if (!empty($scheme)) { if (!isset($site_header_attributes['style'])) { $site_header_attributes['style'] = ''; } $site_header_attributes['style'] .= 'background-image: url("' . base_path() . $path . '/img/' . ($scheme != 'default' ? "{$scheme}-" : '') . 'header-background.jpg")'; } } // Set default value. $vars['is_og_node'] = FALSE; // Add the search form to the page. if (module_exists('search') && user_access('search content')) { $vars['search_form'] = drupal_get_form('search_form'); } // Flag if we can show the "register" link. $register_setting = variable_get('user_register', USER_REGISTER_ADMINISTRATORS_ONLY); $vars['can_register'] = $register_setting != USER_REGISTER_ADMINISTRATORS_ONLY; // Render the main navigation. $vars['main_navigation'] = _platon_get_main_navigation(); // Create the OG context tabs. if (module_exists('og_context')) { $group = og_context('node'); if (!empty($group['gid'])) { $tabs = array(); foreach (array("node/{$group['gid']}" => array('title' => "", 'class' => 'platon-og-context-view-tab platon-og-context-home-tab'), "node/{$group['gid']}/edit" => array('class' => 'platon-og-context-view-tab platon-og-context-settings-tab', 'query' => array('destination' => current_path())), "node/{$group['gid']}/group" => array('class' => 'platon-og-context-view-tab platon-og-context-users-tab'), "node/{$group['gid']}/tools" => array('class' => 'platon-og-context-view-tab platon-og-context-tools-tab'), "node/{$group['gid']}/sort_courses" => array('class' => 'platon-og-context-view-tab platon-og-context-sort-tab')) as $path => $override) { $link = menu_get_item($path); if (!empty($link) && $link['access']) { if (!empty($override['title'])) { $link['title'] = $override['title']; } if (!empty($override['class'])) { $link['options']['attributes']['class'][] = $link['localized_options']['attributes']['class'][] = $override['class']; } if (!empty($override['query'])) { if (!isset($link['options']['query'])) { $link['options']['query'] = array(); } if (!isset($link['localized_options']['query'])) { $link['localized_options']['query'] = array(); } $link['localized_options']['query'] += $override['query']; $link['options']['query'] += $override['query']; } $link['options']['attributes']['title'] = $link['localized_options']['attributes']['title'] = $link['title']; //Ajout Axel $link['title'] = ''; //Ajout Axel $tabs[] = array('#theme' => 'menu_local_task', '#link' => $link, '#active' => TRUE); } } // Modificaton 10.09.14 - Cédric Carrard // // Ajout des tools avec des icons dans le menu en haut à droite // // if (isset($vars['node']) && og_is_group('node', $vars['node'])) { $groups = $vars['node']; foreach (opigno_get_node_tools($groups) as $tool) { $link = menu_get_item($tool['path']); if (!empty($link) && $link['access']) { if (!empty($tool['name'])) { $link['title'] = ''; //$tool['name']; Ajout Axel } if (!empty($tool['machine_name'])) { $link['options']['attributes']['class'][] = $link['localized_options']['attributes']['class'][] = 'platon-og-context-view-tab platon-og-context-' . $tool['machine_name'] . '-tab'; } if (!empty($tool['query'])) { if (!isset($link['options']['query'])) { $link['options']['query'] = array(); } if (!isset($link['localized_options']['query'])) { $link['localized_options']['query'] = array(); } $link['localized_options']['query'] += $tool['query']; $link['options']['query'] += $tool['query']; } $link['options']['attributes']['title'] = $link['localized_options']['attributes']['title'] = $tool['name']; //Ajout Axel $tabs[] = array('#theme' => 'menu_local_task', '#link' => $link, '#active' => TRUE); } } } else { $group = og_context('node'); if (current_path() !== "node/{$group['gid']}") { $node = node_load($group['gid']); foreach (opigno_get_node_tools($node) as $tool) { $link = menu_get_item($tool['path']); if (!empty($link) && opigno_tool_access($tool)) { if (!empty($tool['name'])) { $link['title'] = ''; //$tool['name']; Ajout Axel } if (!empty($tool['machine_name'])) { $link['options']['attributes']['class'][] = $link['localized_options']['attributes']['class'][] = 'platon-og-context-view-tab platon-og-context-' . $tool['machine_name'] . '-tab'; } if (!empty($tool['query'])) { if (!isset($link['options']['query'])) { $link['options']['query'] = array(); } if (!isset($link['localized_options']['query'])) { $link['localized_options']['query'] = array(); } $link['localized_options']['query'] += $tool['query']; $link['options']['query'] += $tool['query']; } $link['options']['attributes']['title'] = $link['localized_options']['attributes']['title'] = $tool['name']; //Ajout Axel $tabs[] = array('#theme' => 'menu_local_task', '#link' => $link, '#active' => TRUE); } } } } // Modificaton 10.09.14 - Cédric Carrard // // On enleve le menu primary sur le page des utilisateur // if (!empty($tabs)) { if (isset($vars['node']) && !platon_display_tabs($vars['node'])) { unset($vars['tabs']['#primary']); } $vars['og_context_navigation'] = render($tabs); } if (isset($vars['node']) && $vars['node']->nid == $group['gid']) { // $vars['hide_tabs'] = TRUE; $vars['is_og_node'] = TRUE; } } } // Show the number of unread messages. if (function_exists('privatemsg_unread_count')) { global $user; $unread = privatemsg_unread_count($user); drupal_add_js(array('platon' => array('unreadMessages' => $unread)), 'setting'); } // Use a custom markup for the front page if anonymous ? $settings = theme_get_setting('platon_home_page_settings'); empty($settings) ? $settings = variable_get('theme_platon_settings') : null; if (empty($vars['user']->uid) && $vars['is_front'] && $settings['platon_use_home_page_markup']) { drupal_add_js(path_to_theme() . '/js/vendor/slick.js'); drupal_add_css(path_to_theme() . '/css/vendor/slick.css'); $html = '<ul class="homepage-slider">'; $i = 0; foreach ($settings as $key => $value) { if (is_array($value) && $key != 'platon_home_page_markup') { if (!empty($value['platon_home_page_markup']['value'])) { $markupValue = $value['platon_home_page_markup']['value']; } else { $markupValue = $value['platon_home_page_markup_wrapper']['platon_home_page_markup']['value']; } if (!empty($value['platon_home_page_markup']['format'])) { $markupFormat = $value['platon_home_page_markup']['format']; } else { $markupFormat = $value['platon_home_page_markup_wrapper']['platon_home_page_markup']['format']; } if (!empty($value['platon_home_page_markup']['background'])) { $markupBackground = $value['platon_home_page_markup']['background']; } else { $markupBackground = $value['platon_home_page_image_path']; } if (!empty($markupValue)) { $i++; $value = check_markup($markupValue, $markupFormat); if (!empty($value)) { $html .= '<li style="background-image: url(' . base_path() . 'sites/default/files/' . $markupBackground . ');"><div class="content">' . $value . '</div></li>'; } } } } $html .= '</ul><div class="slider-footer"><div class="slider-counter"><div class="top">1</div><div class="bottom">' . $i . '</div></div></div>'; drupal_set_title($vars['site_name']); $vars['page']['content'] = $html; $vars['page']['content'] = $html; } // Render the site header attributes. $vars['site_header_attributes'] = drupal_attributes($site_header_attributes); if (variable_get('platon_group_style', 1) == 1) { if (isset($vars['group_state'])) { $vars['group_state'] = platon_render_group_state($vars['group_state']); } } }
/** * Override or insert variables for the page templates. */ function commons_origins_preprocess_page(&$vars) { if (module_exists('page_manager')) { $p = page_manager_get_current_page(); if (isset($p['name']) && $p['name'] == 'node_view') { $node = $p['contexts']['argument_entity_id:node_1']->data; if (module_exists('og') && !og_is_group('node', $node)) { $vars['hide_panelized_title'] = 1; } } } }