37 parent::initializeAttributes();
39 $this->attributes[
'type'] =
"site";
40 $this->attributes[
'name'] =
null;
41 $this->attributes[
'description'] =
null;
42 $this->attributes[
'url'] =
null;
43 $this->tables_split = 2;
65 if (
$row instanceof \stdClass) {
68 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
69 throw new \IOException($msg);
73 elgg_deprecated_notice(
'This type of usage of the \ElggSite constructor was deprecated. Please use the clone method.', 1.7);
77 }
else if (strpos(
$row,
"http") !==
false) {
84 }
else if (is_numeric(
$row)) {
88 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
91 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
105 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'site', $this->attributes);
106 $attr_loader->requires_access_control = !($this instanceof \ElggPlugin);
107 $attr_loader->secondary_loader =
'get_site_entity_as_row';
109 $attrs = $attr_loader->getRequiredAttributes(
$guid);
114 $this->attributes =
$attrs;
115 $this->tables_loaded = 2;
128 $guid = parent::create();
134 $query =
"INSERT into {$CONFIG->dbprefix}sites_entity
135 (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
146 $this->
getDatabase()->updateData(
"UPDATE {$CONFIG->dbprefix}entities
147 SET site_guid = $guid WHERE guid = $guid");
159 if (!parent::update()) {
163 $guid = (int)$this->guid;
168 $query =
"UPDATE {$CONFIG->dbprefix}sites_entity
169 SET name='$name', description='$description', url='$url' WHERE guid=$guid";
171 return $this->
getDatabase()->updateData($query) !==
false;
182 public function delete() {
185 throw new \SecurityException(
'You cannot delete the current site');
202 public function disable($reason =
"", $recursive =
true) {
205 if (
$CONFIG->site->getGUID() == $this->guid) {
206 throw new \SecurityException(
'You cannot disable the current site');
209 return parent::disable($reason, $recursive);
232 $this->
name = $displayName;
259 'relationship' =>
'member_of_site',
260 'relationship_guid' => $this->
getGUID(),
261 'inverse_relationship' =>
true,
282 elgg_deprecated_notice(
'\ElggSite::listMembers() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
285 'relationship' =>
'member_of_site',
286 'relationship_guid' => $this->
getGUID(),
287 'inverse_relationship' =>
true,
339 $options[
'relationship'] =
'member_of_site';
341 $options[
'inverse_relationship'] =
true;
456 return array_merge(parent::getExportableValues(), array(
470 $breakdown = parse_url($this->
url);
471 return $breakdown[
'host'];
486 if (PHP_SAPI ===
'cli') {
495 'access:collections:write',
497 '_elgg_walled_garden_remove_public_access',
532 if ($pos = strpos(
$url,
'?')) {
551 'ajax/view/js/languages',
555 'cache/[0-9]+/\w+/js|css/.*',
565 $pattern =
"`^{$CONFIG->url}$public/*$`i";
566 if (preg_match($pattern,
$url)) {
if(! $site) if(!($site instanceof ElggSite)) $site url
if(! $site) if(!($site instanceof ElggSite)) $site description
elgg_is_xhr()
Checks whether the request was requested via ajax.
if($guid==elgg_get_logged_in_user_guid()) $name
if(! $autoload_available) _elgg_services()
$user_guid
Avatar remove action.
getDatabase()
Provides a pointer to the database object.
initialise_attributes($pre18_api=true)
Initialise the attributes array.
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.
getCollections($subtype="", $limit=10, $offset=0)
Get the collections associated with a site.
getMembers($options=array(), $offset=0)
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.
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.
$guid
Removes an admin notice.
get_site_collections($site_guid, $subtype="", $limit=10, $offset=0)
Get the collections belonging to a site.
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)
Sends a notice about deprecated use of a function, view, etc.
forward($location="", $reason='system')
Forward to $location.
sanitize_string($string)
Sanitize a string for database use.
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an \ElggEntity and optionally for type and subtype.
_elgg_cache_entity(\ElggEntity $entity)
Cache an entity.
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
if($screenshots) $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.
elgg menu widget elgg menu item delete