Пример #1
0
 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);
         }
     }
 }
 /**
  * Enable the specified feature.
  *
  * @param $feature
  *   A feature's name, e.g. 'atrium_blog'
  * @param $space_type
  *   Optional: The space type that this feature should be enabled for.
  * @param $space_id
  *   Optional: If the space type was specified, the ID of the space.
  */
 function atriumEnableFeature($feature, $space_type = NULL, $space_id = NULL)
 {
     if (isset($space_type, $space_id)) {
         $space = spaces_load($space_type, $space_id);
         $features = $space->controllers->variable->get('spaces_features');
         $features[$feature] = TRUE;
         $space->controllers->variable->set('spaces_features', $features);
     } else {
         if (!isset($space_type)) {
             $features = variable_get('spaces_features', array());
             $features[$feature] = TRUE;
             variable_set('spaces_features', $features);
         }
     }
 }
/**
 * Preset editor form.
 */
function spaces_preset_editor(&$form, &$form_state)
{
    $preset = $form_state['item'];
    $form['info']['#type'] = 'fieldset';
    $form['info']['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $preset->title, '#maxlength' => 64);
    $form['info']['description'] = array('#type' => 'textfield', '#title' => t('Description'), '#default_value' => $preset->description);
    $types = array();
    foreach (spaces_types(TRUE) as $type => $info) {
        $types[$type] = $info['title'];
    }
    $form['info']['space_type'] = array('#title' => t('Type'), '#type' => 'select', '#options' => $types, '#default_value' => $preset->space_type, '#disabled' => $form_state['op'] === 'edit');
    $space = spaces_load($preset->space_type, 0);
    $stack = array('preset');
    if ($space && !empty($preset->value)) {
        foreach ($preset->value as $controller => $overrides) {
            if (!empty($overrides) && is_array($overrides)) {
                foreach ($overrides as $key => $value) {
                    $form['revert'][$controller][$key] = array('#type' => 'checkbox', '#title' => $key, '#disabled' => FALSE, '#description' => $space->controllers->{$controller}->summary($key, $value));
                }
            }
        }
        if (element_children($form['revert'])) {
            $form['revert']['#tree'] = TRUE;
            $form['revert']['#theme'] = 'spaces_overrides_form';
            $form['revert']['revert'] = array('#type' => 'item', '#title' => t('Remove'), '#description' => t('Remove the selected overrides from this preset.'));
            $form['revert']['revert']['revert'] = array('#type' => 'submit', '#value' => t('Remove overrides'), '#submit' => array('spaces_preset_editor_remove_overrides'));
        }
    }
    return $form;
}
Пример #4
0
 /**
  * Verify the user's request has access CRUD in the current group.
  */
 public function checkGroupAccess()
 {
     $this->getObject();
     if (!($this->space = spaces_load('og', $this->object->vsite))) {
         // No vsite context.
         $this->throwException('The vsite ID is missing.');
     }
     // Set up the space.
     spaces_set_space($this->space);
     $this->group = entity_metadata_wrapper('node', $this->space->og);
     if (user_access('administer group', $this->getAccount())) {
         return TRUE;
     }
 }
Пример #5
0
 /**
  * Set the URL to the one specified by Purl so that we can avoid a
  * redirection.
  *
  * @param int|NULL $nid
  *   Node id if present, NULL otherwise.
  */
 public static function setSpacesOGPurlURL($nid = NULL)
 {
     // If URL is not correct, purl forwards the user to the correct page. In
     // order to avoid this, we set the correct URL here.
     if (!empty($nid) && module_exists('spaces_og') && ($space = spaces_load('og', $nid))) {
         // Most of the following code is copied from activate() function in space_type_purl.inc
         $space->purge_request_destination();
         // @TODO: This will drop other PURL providers. Probably not the desired behavior!
         $purl_params = array('query' => drupal_get_query_parameters($_GET, array('q')), 'purl' => array('provider' => "spaces_{$space->type}", 'id' => $space->id), 'absolute' => TRUE);
         $_GET['q'] = url($_GET['q'], $purl_params);
     }
 }
Пример #6
0
 /**
  * Get the uid of the owner of a group.
  *
  * @param $group
  *   The group for which to get the owner's uid.
  */
 public static function GetVsiteOwnerUid($group)
 {
     drupal_static_reset();
     $nid = static::GetNodeId($group);
     $space = spaces_load('og', $nid);
     return $space->group->uid;
 }