/** * Override EntityReferenceHandler::settingsForm(). */ public static function settingsForm($field, $instance) { $form = parent::settingsForm($field, $instance); $entity_type = $field['settings']['target_type']; $entity_info = entity_get_info($entity_type); $bundles = array(); foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { if (og_is_group_type($entity_type, $bundle_name)) { $bundles[$bundle_name] = $bundle_info['label']; } } if (!$bundles) { $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label']))); } else { $settings = $field['settings']['handler_settings']; $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT); $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.')); $options = array(); foreach (og_membership_type_load() as $og_membership) { $options[$og_membership->name] = $og_membership->description; } $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE); } return $form; }
function commons_origins_preprocess_page(&$variables) { $variables['pre_header_top'] = theme('grid_row', $variables['header_top'], 'header-top', 'full-width', $variables['grid_width']); $variables['pre_secondary_links'] = theme('grid_block', theme('links', $variables['secondary_links']), 'secondary-menu'); $variables['pre_search_box'] = theme('grid_block', $variables['search_box'], 'search-box'); $variables['pre_primary_links_tree'] = theme('grid_block', $variables['primary_links_tree'], 'primary-menu'); $variables['pre_breadcrumb'] = theme('grid_block', $variables['breadcrumb'], 'breadcrumbs'); $variables['pre_preface_top'] = theme('grid_row', $variables['preface_top'], 'preface-top', 'full-width', $variables['grid_width']); $variables['pre_sidebar_first'] = theme('grid_row', $variables['sidebar_first'], 'sidebar-first', 'nested', $variables['sidebar_first_width']); $variables['pre_preface_bottom'] = theme('grid_row', $variables['preface_bottom'], 'preface-bottom', 'nested'); $variables['pre_help'] = theme('grid_block', $variables['help'], 'content-help'); $variables['pre_messages'] = theme('grid_block', $variables['messages'], 'content-messages'); $variables['pre_tabs'] = theme('grid_block', $variables['tabs'], 'content-tabs'); $variables['pre_content_bottom'] = theme('grid_row', $variables['content_bottom'], 'content-bottom', 'nested'); $variables['pre_sidebar_last'] = theme('grid_row', $variables['sidebar_last'], 'sidebar-last', 'nested', $variables['sidebar_last_width']); $variables['pre_postscript_top'] = theme('grid_row', $variables['postscript_top'], 'postscript-top', 'nested'); $variables['pre_postscript_bottom'] = theme('grid_row', $variables['postscript_bottom'], 'postscript-bottom', 'full-width', $variables['grid_width']); $variables['pre_footer'] = theme('grid_row', $variables['footer'] . $variables['footer_message'], 'footer', 'full-width', $variables['grid_width']); //show group description if group node present if (isset($variables['node'])) { $node = $variables['node']; if (og_is_group_type($node->type)) { $variables['group_header_image'] = content_format('field_group_image', $node->field_group_image[0], 'user_picture_meta_default'); if (!empty($node->body)) { $variables['group_header_text'] = check_markup($node->body, $node->format); } else { $variables['group_header_text'] = check_plain($node->og_description); } } } }
/** * Override settings form(). */ public static function settingsForm($field, $instance) { $form = parent::settingsForm($field, $instance); $entity_type = $field['settings']['target_type']; $entity_info = entity_get_info($entity_type); $bundles = array(); foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { if (og_is_group_type($entity_type, $bundle_name)) { $bundles[$bundle_name] = $bundle_info['label']; } } if (!$bundles) { $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label']))); } else { $settings = $field['settings']['handler_settings']; $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT, 'reference_type' => 'my_groups', 'primary_field' => FALSE, 'hide_secondary_field' => TRUE); $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.')); $options = array(); foreach (og_membership_type_load() as $og_membership) { $options[$og_membership->name] = $og_membership->description; } $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE); $form['reference_type'] = array('#type' => 'select', '#title' => t('Reference'), '#options' => array('my_groups' => t('My groups'), 'other_groups' => t('Other groups'), 'all_groups' => t('All groups')), '#description' => t('What groups should be referenced.'), '#default_value' => $settings['reference_type']); $options = array('0' => t('None')); // Get all the other group audience fields in this bundle. $entity_type = $instance['entity_type']; $bundle = $instance['bundle']; $fields_info = field_info_fields(); foreach (field_info_instances($entity_type, $bundle) as $field_name => $field_instance) { if ($field_name == $field['field_name']) { // This is the current field. continue; } if ($fields_info[$field_name]['type'] != 'entityreference' || $fields_info[$field_name]['settings']['handler'] != 'og') { // This is not an Entity reference field. continue; } if (!empty($fields_info[$field_name]['settings']['handler_settings']['primary_field'])) { // Field is already a secondary field. continue; } $options[$field_name] = $field_instance['label'] . ' (' . $field_name . ')'; } $form['primary_field'] = array('#type' => 'select', '#title' => t('Primary field'), '#description' => t('Select a field that will be populated with the values of this field.'), '#options' => $options, '#default_value' => $settings['primary_field'], '#required' => TRUE, '#element_validate' => array('og_handler_primary_field_validate')); $form['hide_secondary_field'] = array('#type' => 'checkbox', '#title' => t('Hide secondary field'), '#description' => t('Show the secondary field only to users with "administer group" permission.'), '#default_value' => $settings['hide_secondary_field'], '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][primary_field]"]' => array('value' => 0)))); form_load_include($form_state, 'php', 'og', '/plugins/selection/og.class'); } return $form; }
/** * Check whether current user can perform tasks for given group. * We don't need to worry too much about performance here, as result * will normally be cached via _groupadmin_access() function. */ function _groupadmin_access_check($gid, $op) { // Initial checks: make sure $gid is a valid Group node. if (!_groupadmin_checkfunc('og_is_group_type')) { return FALSE; } if (!og_is_group_type(_groupadmin_get_group($gid, 'type'))) { return FALSE; } global $user; $node = _groupadmin_get_group($gid); switch ($op) { case 'administrate': $required = 'admins'; break; case 'show_all': $op = 'show_non-members'; // don't break // don't break default: $required = _groupadmin_settings('l_' . $op); } $access = _groupadmin_user_has_role($node, $user, $required); return $access; }
function arquideasprod_preprocess_block($variables) { global $user; $variables['template_files'][] = 'block-' . $variables['block']->region . '-' . $variables['block']->module; $variables['template_files'][] = 'block-' . $variables['block']->region . '-' . $variables['block']->module . '-' . $variables['block']->delta; if (isset($variables['block'])) { //Change the header login block if ($variables['block']->module == 'commons_core' && $variables['block']->delta == 'header_login') { if (module_exists('ajax_register')) { $variables['block']->content = t('!login Or !register', array('!login' => l(t('Login'), 'ajax_register/login', array('attributes' => array('class' => 'thickbox'))), '!register' => l(t('Register'), 'ajax_register/register', array('attributes' => array('class' => 'thickbox'))))); } else { $variables['block']->content = t('Already a member? !login', array('!login' => l(t('Login'), 'user'))); } } //Superheader menu block if ($variables['block']->module == 'menu' && $variables['block']->delta == 'menu-menu-superheader') { $variables['block']->subject = ''; $arrElem = explode('</li>', $variables['block']->content); if (count($arrElem) > 0) { foreach ($arrElem as $key => $elem) { if ($user->uid == 0) { $pattern1 = '/<a href="(\\/[a-z]{2})?\\/user"/'; $pattern2 = '/<a href="(\\/[a-z]{2})?\\/logout"/'; $match1 = preg_match($pattern1, $elem); $match2 = preg_match($pattern2, $elem); if ($match1 == 1 || $match2 == 1) { unset($arrElem[$key]); } } else { $pattern1 = '/<a href="(\\/[a-z]{2})?\\/ajax_register\\/login"/'; $pattern2 = '/<a href="(\\/[a-z]{2})?\\/ajax_register\\/register"/'; $match1 = preg_match($pattern1, $elem); $match2 = preg_match($pattern2, $elem); if ($match1 == 1 || $match2 == 1) { unset($arrElem[$key]); } } } } $variables['block']->content = implode('</li>', $arrElem); } //Superheader left menu block if ($variables['block']->module == 'menu' && $variables['block']->delta == 'menu-menu-superheader-left') { $variables['block']->subject = ''; } //Site Follow block if ($variables['block']->module == 'follow' && $variables['block']->delta == 'site') { $variables['block']->subject = ''; } //Language switcher if ($variables['block']->module == 'locale' && $variables['block']->delta == 0) { $variables['block']->subject = ''; } //Group Quick Tabs if ($variables['block']->module == 'quicktabs' && $variables['block']->delta == 'arqnetwork_group_quicktabs') { $obj = menu_get_object('node', 4); if (empty($obj)) { $obj = menu_get_object('node', 1); } if (!empty($obj) && og_is_group_type($obj->type)) { $variables['block']->subject = t('Wall of %s', array('%s' => $obj->title)); } } } }