37 parent::initializeAttributes();
39 $this->attributes[
'type'] =
"site";
40 $this->attributes += self::getExternalAttributes();
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) {
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(
485 return $breakdown[
'host'];
500 if (PHP_SAPI ===
'cli') {
504 if ($CONFIG->walled_garden) {
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)) {
static getExternalAttributes()
Get default values for attributes stored in a separate table.
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
getDatabase()
Provides a pointer to the database object.
elgg_is_xhr()
Checks whether the request was requested via ajax.
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.
get_site_collections($site_guid, $subtype="", $limit=10, $offset=0)
Get the collections belonging to a 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.
_elgg_cache_entity(\ElggEntity $entity)
Cache an entity.
removeUser($user_guid)
Removes a user from the site.
add_site_object($site_guid, $object_guid)
Add an object to a site.
if($screenshots) $description
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)
Sanitize a string for database use.
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.
isPublicPage($url= '')
Returns if a URL is public for this site when in Walled Garden mode.
getCollections($subtype="", $limit=10, $offset=0)
Get the collections associated with a site.
elgg menu widget elgg menu item delete
initialise_attributes($pre18_api=true)
Initialise the attributes array.
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.
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
getMembers($options=array(), $offset=0)
Gets an array of entities who are members of the site.
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.