Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     if ($this->entity instanceof Message) {
         $this->message_hash = $this->entity->getHash();
         $this->message_type = $this->entity->getMessageType();
     } else {
         if (!$this->message_type) {
             $this->message_type = Message::TYPE_PRIVATE;
         }
     }
     // files being uploaded via $_FILES
     $uploads = UploadHandler::handle('attachments');
     if ($uploads) {
         foreach ($uploads as $upload) {
             if ($upload instanceof ElggFile) {
                 $this->attachment_guids[] = $upload->guid;
             }
         }
     }
     $this->attachments = Group::create($this->attachment_guids)->entities();
     $access_id = AccessCollection::create(array($this->sender_guid, $this->recipient_guids))->getCollectionId();
     foreach ($this->attachments as $attachment) {
         $attachment->origin = 'messages';
         $attachment->access_id = $access_id;
         $attachment->save();
     }
     $guid = Message::factory(array('sender' => $this->sender_guid, 'recipients' => $this->recipient_guids, 'subject' => $this->subject, 'body' => $this->body, 'message_hash' => $this->message_hash, 'attachments' => $this->attachments))->send();
     $this->entity = $guid ? get_entity($guid) : false;
     if (!$this->entity) {
         // delete attachment if message failed to send
         foreach ($this->attachments as $attachment) {
             $attachment->delete();
         }
         $this->result->addError(elgg_echo('inbox:send:error:generic'));
         return;
     }
     $sender = $this->entity->getSender();
     $this->message_type = $this->entity->getMessageType();
     $this->message_hash = $this->entity->getHash();
     $ruleset = hypeInbox()->config->getRuleset($this->message_type);
     $this->attachments = array_map(array(hypeInbox()->model, 'getLinkTag'), $this->attachments);
     $body = array_filter(array($ruleset->hasSubject() ? $this->entity->subject : '', $this->entity->getBody(), implode(', ', array_filter($this->attachments))));
     $notification_body = implode(PHP_EOL, $body);
     foreach ($this->recipient_guids as $recipient_guid) {
         $recipient = get_entity($recipient_guid);
         if (!$recipient) {
             continue;
         }
         $type_label = strtolower($ruleset->getSingularLabel($recipient->language));
         $subject = elgg_echo('inbox:notification:subject', array($type_label), $recipient->language);
         $notification = elgg_echo('inbox:notification:body', array($type_label, $sender->name, $notification_body, elgg_view('output/url', array('href' => $this->entity->getURL())), $sender->name, elgg_view('output/url', array('href' => elgg_normalize_url("messages/thread/{$this->message_hash}#reply")))), $recipient->language);
         $summary = elgg_echo('inbox:notification:summary', array($type_label), $recipient->language);
         notify_user($recipient->guid, $sender->guid, $subject, $notification, array('action' => 'send', 'object' => $this->entity, 'summary' => $summary));
     }
     $this->result->addMessage(elgg_echo('inbox:send:success'));
     $this->result->setForwardURL($this->entity->getURL());
 }
Exemplo n.º 2
0
    register_error('gallery:upload:error:noalbum');
    forward(REFERER);
}
// create timestamp reference for the river entry
$posted = get_input('batch_upload_time', time());
// images are being uploaded via collaborative function thus require approval
if (!$album->canEdit()) {
    $requires_approval = true;
}
// guids of files uploaded using filedrop
$guids = get_input('filedrop_guids', array());
if (!is_array($guids)) {
    $guids = array();
}
// files being uploaded via $_FILES
$uploads = UploadHandler::handle('gallery_files', array('subtype' => hjAlbumImage::SUBTYPE, 'container_guid' => $album->guid));
if ($uploads && count($uploads)) {
    foreach ($uploads as $upload) {
        if ($upload->guid) {
            $guids[] = $upload->guid;
        } else {
            if ($upload->error && $upload->size) {
                $failed++;
            }
        }
    }
}
$metadata = elgg_get_metadata(array('guid' => $album->guid, 'limit' => 0));
if ($guids) {
    foreach ($guids as $guid) {
        $image = get_entity($guid);
Exemplo n.º 3
0
<?php

namespace hypeJunction\Gallery;

use hypeJunction\Filestore\UploadHandler;
$album_guid = get_input('container_guid');
$album = get_entity($album_guid);
$uploads = UploadHandler::handle('dropzone', array('subtype' => hjAlbumImage::SUBTYPE, 'container_guid' => $album->guid, 'icon_sizes' => get_icon_sizes(new hjAlbumImage())));
$output = array();
if (elgg_is_xhr()) {
    $name = get_input('input_name');
    foreach ($uploads as $upload) {
        $messages = array();
        $success = true;
        if ($upload->error) {
            $messages[] = $upload->error;
            $success = false;
            $guid = false;
        } else {
            $messages[] = elgg_echo('gallery:upload:success');
        }
        $image = $upload->file;
        if (!elgg_instanceof($image)) {
            $messages[] = elgg_echo('gallery:upload:error');
            $success = false;
            $guid = false;
        } else {
            if ($image->simpletype !== 'image') {
                $image->delete();
                $messages[] = elgg_echo('gallery:upload:unsupportedtype');
                $success = false;
Exemplo n.º 4
0
             if (!in_array($access_id, array(ACCESS_PRIVATE, ACCESS_LOGGED_IN, ACCESS_PUBLIC))) {
                 $river_access_id = elgg_get_plugin_user_setting('river_access_id', $friend_guid, PLUGIN_ID);
                 if (!is_null($river_access_id) && $river_access_id !== ACCESS_PRIVATE) {
                     $river_id = elgg_create_river_item(array('view' => 'river/relationship/tagged/create', 'action_type' => 'tagged', 'subject_guid' => $friend_guid, 'object_guid' => $wall_post->getGUID(), 'target_guid' => $wall_post->getContainerGUID(), 'access_id' => $river_access_id));
                 }
             }
         }
     }
 }
 if ($attachment_guids) {
     foreach ($attachment_guids as $attachment_guid) {
         add_entity_relationship($attachment_guid, 'attached', $wall_post->guid);
     }
 }
 // files being uploaded via $_FILES
 $uploads = UploadHandler::handle('upload_guids');
 if ($uploads) {
     foreach ($uploads as $upload) {
         if ($upload->guid) {
             $upload_guids[] = $upload->guid;
         }
     }
 }
 if (count($upload_guids)) {
     foreach ($upload_guids as $upload_guid) {
         $upload = get_entity($upload_guid);
         $upload->description = $wall_post->description;
         $upload->origin = 'wall';
         $upload->access_id = $wall_post->access_id;
         $upload->container_guid = $container->canWriteToContainer($poster->guid, 'object', 'file') ? $container->guid : ELGG_ENTITIES_ANY_VALUE;
         $upload->save();
 /**
  * Static counterpart of makeFiles, but returns data for processed uploads
  *
  * @param string $input      Name of the file input
  * @param array  $attributes Key value pairs, such as subtype, owner_guid, metadata.
  * @param array  $config     Additional config
  * @return array An array of file entities created
  */
 public static function handle($input, array $attributes = array(), array $config = array())
 {
     $handler = new UploadHandler();
     $handler->makeFiles($input, $attributes, $config);
     return self::$uploads[$input];
 }
Exemplo n.º 6
0
<?php

namespace hypeJunction\Gallery;

use hypeJunction\Filestore\UploadHandler;
$album_guid = get_input('container_guid');
$album = get_entity($album_guid);
$uploads = UploadHandler::handle('dropzone', array('subtype' => hjAlbumImage::SUBTYPE, 'container_guid' => $album->guid));
$output = array();
if (elgg_is_xhr()) {
    $name = get_input('input_name');
    foreach ($uploads as $upload) {
        $messages = array();
        $success = true;
        if ($upload->error) {
            $messages[] = $upload->error;
            $success = false;
            $guid = false;
        } else {
            $messages[] = elgg_echo('gallery:upload:success');
        }
        $image = $upload->file;
        if (!elgg_instanceof($image)) {
            $messages[] = elgg_echo('gallery:upload:error');
            $success = false;
            $guid = false;
        } else {
            if ($image->simpletype !== 'image') {
                $image->delete();
                $messages[] = elgg_echo('gallery:upload:unsupportedtype');
                $success = false;