Elgg  Version 3.0
ElggObject.php
Go to the documentation of this file.
1 <?php
15 class ElggObject extends \ElggEntity {
16 
20  public function getType() {
21  return 'object';
22  }
23 
27  protected function prepareObject(\Elgg\Export\Entity $object) {
28  $object = parent::prepareObject($object);
29  $object->title = $this->getDisplayName();
30  $object->description = $this->description;
31  $object->tags = $this->tags ? $this->tags : [];
32  return $object;
33  }
34 
38  public function getDisplayName() {
39  return $this->title;
40  }
41 
45  public function setDisplayName($display_name) {
46  $this->title = $display_name;
47  }
48 
60  public function canComment($user_guid = 0, $default = null) {
61  $result = parent::canComment($user_guid, $default);
62  if ($result !== null) {
63  return $result;
64  }
65 
66  if ($user_guid == 0) {
67  $user_guid = _elgg_services()->session->getLoggedInUserGuid();
68  }
69 
70  // must be logged in to comment
71  if (!$user_guid) {
72  return false;
73  }
74 
75  // must be member of group
76  $container = $this->getContainerEntity();
77  if ($container instanceof \ElggGroup) {
78  if (!$container->canWriteToContainer($user_guid)) {
79  return false;
80  }
81  }
82 
83  // no checks on read access since a user cannot see entities outside his access
84  return true;
85  }
86 }
$display_name
Definition: delete.php:19
getType()
{}
Definition: ElggObject.php:20
if(!$item instanceof ElggRiverItem) $object
Definition: responses.php:23
setDisplayName($display_name)
{}
Definition: ElggObject.php:45
$user_guid
Validate a user.
Definition: validate.php:6
Configuration exception.
canComment($user_guid=0, $default=null)
Can a user comment on this object?
Definition: ElggObject.php:60
$title
Definition: user.php:20
$container
Definition: delete.php:23
prepareObject(\Elgg\Export\Entity $object)
{}
Definition: ElggObject.php:27
$default
Definition: checkbox.php:35
getDisplayName()
{}
Definition: ElggObject.php:38
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
getContainerEntity()
Get the container entity for this object.
if(elgg_view_exists("plugins/{$plugin_id}/settings")) $description
Definition: full.php:179