Exemplo n.º 1
0
Arquivo: start.php Projeto: elgg/elgg
/**
 * Listen to group ownership changes and update group icon ownership
 * This will only move the source file, the actual icons are moved by
 * _elgg_filestore_move_icons()
 *
 * This operation is performed in an event listener to ensure that icons
 * are moved when ownership changes outside of the groups/edit action flow.
 *
 * @todo #4683 proposes that icons are owned by groups and not group owners
 * @see _elgg_filestore_move_icons()
 *
 * @param string    $event "update:after"
 * @param string    $type  "group"
 * @param ElggGroup $group Group entity
 * @return void
 */
function groups_update_event_listener($event, $type, $group)
{
    /* @var $group \ElggGroup */
    $original_attributes = $group->getOriginalAttributes();
    if (empty($original_attributes['owner_guid'])) {
        return;
    }
    $previous_owner_guid = $original_attributes['owner_guid'];
    // In addition to standard icons, groups plugin stores a copy of the original upload
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $previous_owner_guid;
    $filehandler->setFilename("groups/{$group->guid}.jpg");
    $filehandler->transfer($group->owner_guid);
}