Esempio n. 1
0
elgg_register_plugin_hook_handler('permissions_check', 'all', 'elgg_override_permissions');
elgg_register_plugin_hook_handler('container_permissions_check', 'all', 'elgg_override_permissions');
$success_count = 0;
$error_count = 0;
do {
    $annotations_to_delete = array();
    $annotations = elgg_get_annotations(array('annotation_names' => 'group_topic_post', 'limit' => $limit, 'offset' => $offset, 'order_by' => 'n_table.id DESC'));
    if (!$annotations) {
        // no annotations left
        break;
    }
    $db_prefix = elgg_get_config('dbprefix');
    $container_guids = array();
    // Create a new object for each annotation
    foreach ($annotations as $annotation) {
        $object = new ElggDiscussionReply();
        $object->owner_guid = $annotation->owner_guid;
        $object->container_guid = $annotation->entity_guid;
        $object->description = $annotation->value;
        $object->access_id = $annotation->access_id;
        // make sure disabled replies stay disabled
        $object->enabled = $annotation->enabled;
        $object->time_created = $annotation->time_created;
        $object->save(false);
        $container_guids[] = $object->container_guid;
        $guid = $object->getGUID();
        if ($guid) {
            /**
             * Update the entry in river table for this reply
             *
             * - Update the view path
Esempio n. 2
0
 // copy all answers on the question to topic replies
 foreach ($answers as $answer) {
     // move awnser to reply
     $reply = new ElggDiscussionReply();
     $reply->owner_guid = $answer->getOwnerGUID();
     $reply->container_guid = $topic->getGUID();
     $reply->access_id = $topic->access_id;
     $reply->description = $answer->description;
     if ($reply->save()) {
         questions_backdate_entity($reply->getGUID(), $answer->time_created);
     }
     // copy all comments on the answer to topic replies
     $comment_options['container_guid'] = $answer->getGUID();
     $comments = new ElggBatch('elgg_get_entities', $comment_options);
     foreach ($comments as $comment) {
         $reply = new ElggDiscussionReply();
         $reply->owner_guid = $comment->getOwnerGUID();
         $reply->container_guid = $topic->getGUID();
         $reply->access_id = $topic->access_id;
         $reply->description = $comment->description;
         if ($reply->save()) {
             questions_backdate_entity($reply->getGUID(), $comment->time_created);
         }
         $comment->delete();
     }
     $answer->delete();
 }
 // last changes to the topic
 // backdate the discussion
 $topic->time_created = $entity->time_created;
 // set correct owner of the topic
Esempio n. 3
0
    $reply = get_entity($reply_guid);
    if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
        register_error(elgg_echo('discussion:reply:error:notfound'));
        forward(REFERER);
    }
    if (!$reply->canEdit()) {
        register_error(elgg_echo('discussion:reply:error:cannot_edit'));
        forward(REFERER);
    }
    $reply->description = $text;
    if ($reply->save()) {
        system_message(elgg_echo('discussion:reply:edited'));
    } else {
        register_error(elgg_echo('discussion:reply:error'));
    }
} else {
    // add the reply to the forum topic
    $reply = new ElggDiscussionReply();
    $reply->description = $text;
    $reply->access_id = $topic->access_id;
    $reply->container_guid = $topic->getGUID();
    $reply->owner_guid = $user->getGUID();
    $reply_guid = $reply->save();
    if ($reply_guid == false) {
        register_error(elgg_echo('discussion:post:failure'));
        forward(REFERER);
    }
    elgg_create_river_item(array('view' => 'river/object/discussion_reply/create', 'action_type' => 'reply', 'subject_guid' => $user->guid, 'object_guid' => $reply->guid, 'target_guid' => $topic->guid));
    system_message(elgg_echo('discussion:post:success'));
}
forward(REFERER);
Esempio n. 4
0
File: save.php Progetto: elgg/elgg
        register_error(elgg_echo('discussion:reply:error:notfound'));
        forward(REFERER);
    }
    if (!$reply->canEdit()) {
        register_error(elgg_echo('discussion:reply:error:cannot_edit'));
        forward(REFERER);
    }
    $reply->description = $text;
    if ($reply->save()) {
        system_message(elgg_echo('discussion:reply:edited'));
    } else {
        register_error(elgg_echo('discussion:reply:error'));
    }
} else {
    // add the reply to the forum topic
    $reply = new ElggDiscussionReply();
    $reply->description = $text;
    $reply->access_id = $topic->access_id;
    $reply->container_guid = $topic->getGUID();
    $reply->owner_guid = $user->getGUID();
    $reply_guid = $reply->save();
    if ($reply_guid == false) {
        register_error(elgg_echo('discussion:post:failure'));
        forward(REFERER);
    }
    elgg_create_river_item(array('view' => 'river/object/discussion_reply/create', 'action_type' => 'reply', 'subject_guid' => $user->guid, 'object_guid' => $reply->guid, 'target_guid' => $topic->guid));
    system_message(elgg_echo('discussion:post:success'));
}
// return to activity page if posted from there
if (!empty($_SERVER['HTTP_REFERER'])) {
    // don't redirect to URLs from client without verifying within site
Esempio n. 5
0
        $discussion->__faker = true;
        if ($discussion->save()) {
            $success++;
            if ($discussion->status == 'published') {
                elgg_create_river_item(array('view' => 'river/object/discussion/create', 'action_type' => 'create', 'subject_guid' => $owner->guid, 'object_guid' => $discussion->guid));
            }
            if ($container instanceof ElggGroup) {
                $members = $container->getMembers(['limit' => 10]);
            } else {
                if ($container instanceof ElggUser) {
                    $members = $container->getFriends(['limit' => 10]);
                }
            }
            for ($k = 0; $k < $count; $k++) {
                $replier = $members[array_rand($members, 1)];
                $reply = new ElggDiscussionReply();
                $reply->description = $faker->text();
                $reply->owner_guid = $replier->guid;
                $reply->container_guid = $discussion->guid;
                $reply->save();
                elgg_create_river_item(array('view' => 'river/object/discussion_reply/create', 'action_type' => 'reply', 'subject_guid' => $replier->guid, 'object_guid' => $reply->guid, 'target_guid' => $discussion->guid));
            }
        } else {
            $error++;
        }
    }
}
if ($error) {
    system_message(elgg_echo('faker:gen_discussions:error', array($success, $error)));
} else {
    system_message(elgg_echo('faker:gen_discussions:success', array($success)));