37 parent::initializeAttributes();
39 $this->attributes[
'type'] =
"site";
40 $this->attributes += self::getExternalAttributes();
54 'description' => null,
78 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
79 throw new \IOException($msg);
81 }
else if (strpos(
$row,
"http") !==
false) {
88 }
else if (is_numeric(
$row)) {
92 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
95 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
109 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'site', $this->attributes);
110 $attr_loader->requires_access_control = !($this instanceof \ElggPlugin);
111 $attr_loader->secondary_loader =
'get_site_entity_as_row';
113 $attrs = $attr_loader->getRequiredAttributes(
$guid);
118 $this->attributes =
$attrs;
131 $guid = parent::create();
137 $query =
"INSERT into {$CONFIG->dbprefix}sites_entity 138 (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
149 $this->
getDatabase()->updateData(
"UPDATE {$CONFIG->dbprefix}entities 150 SET site_guid = $guid WHERE guid = $guid");
162 if (!parent::update()) {
166 $guid = (int)$this->guid;
171 $query =
"UPDATE {$CONFIG->dbprefix}sites_entity 172 SET name='$name', description='$description', url='$url' WHERE guid=$guid";
174 return $this->
getDatabase()->updateData($query) !==
false;
187 public function delete($recursive =
true) {
190 throw new \SecurityException(
'You cannot delete the current site');
207 public function disable($reason =
"", $recursive =
true) {
211 throw new \SecurityException(
'You cannot disable the current site');
214 return parent::disable($reason, $recursive);
237 $this->
name = $displayName;
255 'relationship' =>
'member_of_site',
256 'relationship_guid' => $this->
getGUID(),
257 'inverse_relationship' =>
true,
278 elgg_deprecated_notice(
'\ElggSite::listMembers() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
281 'relationship' =>
'member_of_site',
282 'relationship_guid' => $this->
getGUID(),
283 'inverse_relationship' =>
true,
335 $options[
'relationship'] =
'member_of_site';
337 $options[
'inverse_relationship'] =
true;
437 return array_merge(parent::getExportableValues(), array(
452 return $breakdown[
'host'];
465 if (PHP_SAPI ===
'cli') {
506 if ($pos = strpos(
$url,
'?')) {
525 'ajax/view/languages.js',
529 'cache/[0-9]+/\w+/.*',
539 $plugins =
_elgg_services()->hooks->trigger(
'public_pages',
'walled_garden', null, array());
542 foreach (array_merge(
$defaults, $plugins) as $public) {
543 $pattern =
"`^{$CONFIG->url}$public/*$`i";
544 if (preg_match($pattern,
$url)) {
static getExternalAttributes()
Get default values for attributes stored in a separate table.
$object
These two snippets demonstrates triggering an event and how to register for that event.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
getDatabase()
Provides a pointer to the database object.
getMembers($options=array())
Gets an array of entities who are members of the site.
remove_site_object($site_guid, $object_guid)
Remove an object from a site.
__construct($row=null)
Create a new .
get_site_objects($site_guid, $subtype="", $limit=10, $offset=0)
Get the objects belonging to a site.
loadAdditionalSelectValues(array $data)
Stores non-attributes from the loading of the entity as volatile data.
removeEntity($entity)
Removes an entity from this site.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
if($guid==elgg_get_logged_in_user_guid()) $name
addObject($object_guid)
Adds an object to the site.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
checkWalledGarden()
Halts bootup and redirects to the site front page if site is in walled garden mode, no user is logged in, and the URL is not a public page.
$CONFIG site_guid
The guid of the current site object.
getObjects($subtype="", $limit=10, $offset=0)
Returns an array of entities that belong to the site.
removeUser($user_guid)
Removes a user from the site.
add_site_object($site_guid, $object_guid)
Add an object to a site.
addUser($user_guid)
Adds a user to the site.
getGUID()
Returns the guid.
$guid
Removes an admin notice.
elgg parse_url
Parse a URL into its parts.
add_site_user($site_guid, $user_guid)
Add a user to a site.
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
get_site_by_url($url)
Return the site via a url.
listMembers($options=array())
List the members of this site.
sanitize_string($string)
Sanitizes a string for use in a query.
disable($reason="", $recursive=true)
Disable the site.
if(!$site) if(!($site instanceof ElggSite)) $site description
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
setDisplayName($displayName)
{}
addEntity(\ElggEntity $entity)
Adds an entity to the site.
if($categories) $description
isPublicPage($url= '')
Returns if a URL is public for this site when in Walled Garden mode.
elgg_set_config($name, $value)
Set an Elgg configuration value.
const ELGG_ENTITIES_ANY_VALUE
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
load($guid)
Loads the full when given a guid.
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
getURL()
Returns the URL for this site.
elgg register_error
Wrapper function for system_messages.
getExportableValues()
Return an array of fields which can be exported.
if(!$site) if(!($site instanceof ElggSite)) $site url
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
$user_guid
Avatar remove action.
getDomain()
Get the domain for this site.
removeObject($object_guid)
Remvoes an object from the site.
getEntities(array $options=array())
Get an array of entities that belong to the site.
initializeAttributes()
Initialize the attributes array.