37 parent::initializeAttributes();
39 $this->attributes[
'type'] =
"site";
41 $this->tables_split = 2;
55 'description' =>
null,
79 if (
$row instanceof \stdClass) {
82 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
83 throw new \IOException($msg);
87 elgg_deprecated_notice(
'This type of usage of the \ElggSite constructor was deprecated. Please use the clone method.', 1.7);
91 }
else if (strpos(
$row,
"http") !==
false) {
98 }
else if (is_numeric(
$row)) {
102 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
105 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
119 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'site', $this->attributes);
120 $attr_loader->requires_access_control = !($this instanceof \ElggPlugin);
121 $attr_loader->secondary_loader =
'get_site_entity_as_row';
123 $attrs = $attr_loader->getRequiredAttributes(
$guid);
128 $this->attributes =
$attrs;
129 $this->tables_loaded = 2;
142 $guid = parent::create();
148 $query =
"INSERT into {$CONFIG->dbprefix}sites_entity
149 (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
160 $this->
getDatabase()->updateData(
"UPDATE {$CONFIG->dbprefix}entities
161 SET site_guid = $guid WHERE guid = $guid");
173 if (!parent::update()) {
177 $guid = (int)$this->guid;
182 $query =
"UPDATE {$CONFIG->dbprefix}sites_entity
183 SET name='$name', description='$description', url='$url' WHERE guid=$guid";
185 return $this->
getDatabase()->updateData($query) !==
false;
196 public function delete() {
199 throw new \SecurityException(
'You cannot delete the current site');
216 public function disable($reason =
"", $recursive =
true) {
219 if (
$CONFIG->site->getGUID() == $this->guid) {
220 throw new \SecurityException(
'You cannot disable the current site');
223 return parent::disable($reason, $recursive);
246 $this->
name = $displayName;
273 'relationship' =>
'member_of_site',
274 'relationship_guid' => $this->
getGUID(),
275 'inverse_relationship' =>
true,
296 elgg_deprecated_notice(
'\ElggSite::listMembers() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
299 'relationship' =>
'member_of_site',
300 'relationship_guid' => $this->
getGUID(),
301 'inverse_relationship' =>
true,
353 $options[
'relationship'] =
'member_of_site';
355 $options[
'inverse_relationship'] =
true;
470 return array_merge(parent::getExportableValues(), array(
484 $breakdown = parse_url($this->
url);
485 return $breakdown[
'host'];
500 if (PHP_SAPI ===
'cli') {
509 'access:collections:write',
511 '_elgg_walled_garden_remove_public_access',
546 if ($pos = strpos(
$url,
'?')) {
565 'ajax/view/js/languages',
569 'cache/[0-9]+/\w+/js|css/.*',
579 $pattern =
"`^{$CONFIG->url}$public/*$`i";
580 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
$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.
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.
$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)
Log 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