37 parent::initializeAttributes();
39 $this->attributes[
'type'] =
"site";
54 'description' =>
null,
75 if (
$row instanceof \stdClass) {
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) {
210 if (
$CONFIG->site->getGUID() == $this->guid) {
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(
451 $breakdown = parse_url($this->
url);
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)) {
if(! $site) if(!($site instanceof ElggSite)) $site url
if(! $site) if(!($site instanceof ElggSite)) $site description
if($guid==elgg_get_logged_in_user_guid()) $name
$user_guid
Avatar remove action.
getDatabase()
Provides a pointer to the database object.
loadAdditionalSelectValues(array $data)
Stores non-attributes from the loading of the entity as volatile data.
getGUID()
Returns the guid.
getExportableValues()
Return an array of fields which can be exported.
getMembers($options=array())
Gets an array of \ElggUser entities who are members of the site.
isPublicPage($url='')
Returns if a URL is public for this site when in Walled Garden mode.
getEntities(array $options=array())
Get an array of entities that belong to the site.
static getExternalAttributes()
Get default values for attributes stored in a separate table.
listMembers($options=array())
List the members of this site.
removeEntity($entity)
Removes an entity from this site.
create()
{Create a new entry in the entities table.Saves the base information in the entities table for the en...
__construct($row=null)
Create a new \ElggSite.
removeObject($object_guid)
Remvoes an object from the site.
prepareObject($object)
{Prepare an object copy for toObject()Object representation of the entity \stdClass}
disable($reason="", $recursive=true)
Disable the site.
addUser($user_guid)
Adds a user to the site.
getURL()
Returns the URL for this site.
update()
{Update the entity in the database.bool Whether the update was successful.}
addEntity(\ElggEntity $entity)
Adds an entity to the site.
addObject($object_guid)
Adds an object to the site.
getObjects($subtype="", $limit=10, $offset=0)
Returns an array of \ElggObject entities that belong to the site.
initializeAttributes()
Initialize the attributes array.
getDomain()
Get the domain for this site.
checkWalledGarden()
Halts bootup and redirects to the site front page if site is in walled garden mode,...
setDisplayName($displayName)
{Sets the title or name of this entity.The title or name of this entity. void}
removeUser($user_guid)
Removes a user from the site.
getDisplayName()
{Get the entity's display name.string The title or name of this entity.}
load($guid)
Loads the full \ElggSite when given a guid.
$CONFIG site_guid
The guid of the current site object.
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$guid
Removes an admin notice.
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
remove_site_object($site_guid, $object_guid)
Remove an object from a site.
add_site_object($site_guid, $object_guid)
Add an object to a site.
add_site_user($site_guid, $user_guid)
Add a user to a site.
get_site_objects($site_guid, $subtype="", $limit=10, $offset=0)
Get the objects belonging to a site.
const ELGG_ENTITIES_ANY_VALUE
register_error($error)
Display an error on next page load.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
forward($location="", $reason='system')
Forward to $location.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
sanitize_string($string)
Sanitizes a string for use in a query.
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an \ElggEntity and optionally for type and subtype.
$object
These two snippets demonstrates triggering an event and how to register for that event.
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
if($categories) $description
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
get_site_by_url($url)
Return the site via a url.