/** * Get the path of the vsite which the vocab belong. * * @param $tid * The term ID. * * @return * The path of the vsite. */ function os_taxonomy_vsite_path($tid) { $term = taxonomy_term_load($tid); $purls =& drupal_static(__FUNCTION__, array()); if (in_array($term->vid, $purls)) { // We already found purl for this vocab. Return the purl from the static // cache. return $purls[$term->vid]; } $relation = og_vocab_relation_get($term->vid); $vsite = vsite_get_vsite($relation->gid); $purls[$term->vid] = $vsite->group->purl; return $vsite->group->purl; }
/** * {@inheritdoc} */ protected function setPropertyValues(EntityMetadataWrapper $wrapper, $null_missing_fields = FALSE) { $request = $this->getRequest(); self::cleanRequest($request); $wrapper->type->set($request['type']); parent::setPropertyValues($wrapper, $null_missing_fields); $id = $wrapper->getIdentifier(); if (!($space = vsite_get_vsite($id))) { return; } // Set the preset on the object. if ($request['preset']) { $space->controllers->variable->set('spaces_preset_og', $request['preset']); } if ($purl = $wrapper->domain->value()) { $modifier = array('provider' => 'spaces_og', 'id' => $id, 'value' => $purl); purl_save($modifier); } }
protected function setPropertyValues(EntityMetadataWrapper $wrapper, $null_missing_fields = FALSE) { $request = $this->getRequest(); static::cleanRequest($request); $save = FALSE; $original_request = $request; if ($space = $wrapper->{OG_AUDIENCE_FIELD}->value()) { $vsite = vsite_get_vsite($space[0]->nid); $vsite->activate_user_roles(); } foreach ($this->getPublicFields() as $public_field_name => $info) { if (empty($info['property']) && empty($info['saveCallback'])) { // We may have for example an entity with no label property, but with a // label callback. In that case the $info['property'] won't exist, so // we skip this field. continue; } if (isset($info['saveCallback'])) { $save = call_user_func($info['saveCallback'], $wrapper) || $save; if ($save) { unset($original_request[$public_field_name]); } } elseif ($info['property']) { $property_name = $info['property']; if (!isset($request[$public_field_name])) { // No property to set in the request. if ($null_missing_fields && $this->checkPropertyAccess('edit', $public_field_name, $wrapper->{$property_name}, $wrapper)) { // We need to set the value to NULL. $wrapper->{$property_name}->set(NULL); } continue; } if (!$this->checkPropertyAccess('edit', $public_field_name, $wrapper->{$property_name}, $wrapper)) { throw new RestfulBadRequestException(format_string('Property @name cannot be set.', array('@name' => $public_field_name))); } $field_value = $this->propertyValuesPreprocess($property_name, $request[$public_field_name], $public_field_name); $wrapper->{$property_name}->set($field_value); unset($original_request[$public_field_name]); $save = TRUE; } } if ($this->getErrors()) { $e = new RestfulBadRequestException("The following errors occured when attempting to save this file.\n" . implode("\n", $this->getErrors())); throw $e; } if (!$save) { // No request was sent. throw new RestfulBadRequestException('No values were sent with the request'); } if ($original_request) { // Request had illegal values. $error_message = format_plural(count($original_request), 'Property @names is invalid.', 'Property @names are invalid.', array('@names' => implode(', ', array_keys($original_request)))); throw new RestfulBadRequestException($error_message); } // Allow changing the entity just before it's saved. For example, setting // the author of the node entity. $this->entityPreSave($wrapper); $this->entityValidate($wrapper); $wrapper->save(); }
/** * Overrides the default validate method. * * @param bool $validate_request * Determine if we need to validate the sent request values. In case of * delete we don't need to validate the sent request values. */ public function validate($validate_request = TRUE) { $this->getObject(); $this->object->group_type = 'node'; if (empty($this->object->gid)) { $this->object->gid = 0; } else { // Set up the space. spaces_set_space(vsite_get_vsite($this->object->gid)); } $this->object->gid = (int) $this->object->gid; $this->setRequest((array) $this->object); if ($validate_request) { parent::validate(); } $function = $this->object->gid ? 'og_user_access' : 'user_access'; $params = $this->object->gid ? array('node', $this->object->gid, 'administer users', $this->getAccount()) : array('administer users', $this->getAccount()); if (!call_user_func_array($function, $params)) { throw new \RestfulForbiddenException('You are not allowed to manage roles.'); } }
/** * @Given /^I define "([^"]*)" domain to "([^"]*)"$/ */ public function iDefineDomainTo($vsite, $domain) { $this->domains[] = $vsite; $nid = FeatureHelp::getNodeId($vsite); if ($group = vsite_get_vsite($nid)) { $group->controllers->variable->set('vsite_domain_name', $domain); $group->controllers->variable->set('vsite_domain_shared', $domain); } }
/** * Set the variable $name to $value for the site $vsite. */ public static function VsiteSetVariable($vsite, $name, $value) { $query = new entityFieldQuery(); $result = $query->entityCondition('entity_type', 'node')->propertyCondition('title', $vsite)->range(0, 1)->execute(); if (empty($result['node'])) { return; } $nid = array_keys($result['node']); $vsite = vsite_get_vsite(reset($nid)); $vsite->controllers->variable->set($name, $value); }