Inheritance: implements Loggable, implements Iterator, implements ArrayAccess, implements Exportable
 /**
  * Create a site notification
  *
  * @param ElggUser   $recipient Recipient of the notification
  * @param string     $message   Notification message
  * @param ElggUser   $actor     User who caused the notification event
  * @param ElggData   $object    Optional object involved in the notification event
  * @return SiteNotification|null
  */
 public static function create($recipient, $message, $actor, $object = null)
 {
     $note = new SiteNotification();
     $note->owner_guid = $recipient->guid;
     $note->container_guid = $recipient->guid;
     $note->access_id = ACCESS_PRIVATE;
     $note->description = $message;
     if ($object) {
         // TODO Add support for setting an URL for a notification about a new relationship
         switch ($object->getType()) {
             case 'annotation':
                 // Annotations do not have an URL so we use the entity URL
                 $note->setURL($object->getEntity()->getURL());
                 break;
             default:
                 $note->setURL($object->getURL());
         }
     }
     $note->setRead(false);
     if ($note->save()) {
         $note->setActor($actor);
         return $note;
     } else {
         return null;
     }
 }
Beispiel #2
0
 /**
  * Initialize the attributes array.
  *
  * This is vital to distinguish between metadata and base parameters.
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['guid'] = NULL;
     $this->attributes['type'] = NULL;
     $this->attributes['subtype'] = NULL;
     $this->attributes['owner_guid'] = elgg_get_logged_in_user_guid();
     $this->attributes['container_guid'] = elgg_get_logged_in_user_guid();
     $this->attributes['site_guid'] = NULL;
     $this->attributes['access_id'] = ACCESS_PRIVATE;
     $this->attributes['time_created'] = NULL;
     $this->attributes['time_updated'] = NULL;
     $this->attributes['last_action'] = NULL;
     $this->attributes['enabled'] = "yes";
     // There now follows a bit of a hack
     /* Problem: To speed things up, some objects are split over several tables,
      * this means that it requires n number of database reads to fully populate
      * an entity. This causes problems for caching and create events
      * since it is not possible to tell whether a subclassed entity is complete.
      *
      * Solution: We have two counters, one 'tables_split' which tells whatever is
      * interested how many tables are going to need to be searched in order to fully
      * populate this object, and 'tables_loaded' which is how many have been
      * loaded thus far.
      *
      * If the two are the same then this object is complete.
      *
      * Use: isFullyLoaded() to check
      */
     $this->attributes['tables_split'] = 1;
     $this->attributes['tables_loaded'] = 0;
 }
Beispiel #3
0
 /**
  * (non-PHPdoc)
  *
  * @see \ElggData::initializeAttributes()
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['id'] = null;
     $this->attributes['guid_one'] = null;
     $this->attributes['relationship'] = null;
     $this->attributes['guid_two'] = null;
 }
 /**
  * Create a site notification
  * 
  * @param ElggUser   $recipient Recipient of the notification
  * @param string     $message   Notification message
  * @param ElggUser   $actor     User who caused the notification event
  * @param ElggData   $object    Optional object involved in the notification event
  * @return SiteNotification|null
  */
 public static function create($recipient, $message, $actor, $object = null)
 {
     $note = new SiteNotification();
     $note->owner_guid = $recipient->guid;
     $note->container_guid = $recipient->guid;
     $note->access_id = ACCESS_PRIVATE;
     $note->description = $message;
     if ($object) {
         $note->setURL($object->getURL());
     }
     $note->setRead(false);
     if ($note->save()) {
         $note->setActor($actor);
         return $note;
     } else {
         return null;
     }
 }
Beispiel #5
0
 /**
  * (non-PHPdoc)
  *
  * @see \ElggData::initializeAttributes()
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['type'] = null;
     $this->attributes['id'] = null;
     $this->attributes['entity_guid'] = null;
     $this->attributes['owner_guid'] = null;
     $this->attributes['access_id'] = ACCESS_PRIVATE;
     $this->attributes['enabled'] = 'yes';
 }
Beispiel #6
0
 /**
  * Initialize the attributes array.
  *
  * This is vital to distinguish between metadata and base parameters.
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['guid'] = null;
     $this->attributes['type'] = null;
     $this->attributes['subtype'] = null;
     $this->attributes['owner_guid'] = _elgg_services()->session->getLoggedInUserGuid();
     $this->attributes['container_guid'] = _elgg_services()->session->getLoggedInUserGuid();
     $this->attributes['access_id'] = ACCESS_PRIVATE;
     $this->attributes['time_updated'] = null;
     $this->attributes['last_action'] = null;
     $this->attributes['enabled'] = "yes";
 }
Beispiel #7
0
 /**
  * Add a notification event to the queue
  * 
  * @param string   $action Action name
  * @param string   $type   Type of the object of the action
  * @param \ElggData $object The object of the action 
  * @return void
  * @access private
  */
 public function enqueueEvent($action, $type, $object)
 {
     if ($object instanceof \ElggData) {
         $object_type = $object->getType();
         $object_subtype = $object->getSubtype();
         $registered = false;
         if (isset($this->events[$object_type]) && isset($this->events[$object_type][$object_subtype]) && in_array($action, $this->events[$object_type][$object_subtype])) {
             $registered = true;
         }
         if ($registered) {
             $params = array('action' => $action, 'object' => $object);
             $registered = $this->hooks->trigger('enqueue', 'notification', $params, $registered);
         }
         if ($registered) {
             $this->queue->enqueue(new \Elgg\Notifications\Event($object, $action));
         }
     }
 }
Beispiel #8
0
 /**
  * (non-PHPdoc)
  *
  * @see ElggData::initializeAttributes()
  *
  * @return void
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['type'] = NULL;
 }