Exemplo n.º 1
0
<?php

/**
* ODT file collab session deletion action
*
* @package odt_collabeditor
*/
// Get variables
$file_guid = (int) get_input('file_guid');
// load original file object
// TODO: what if somebody deleted the file while the session was running?
$file = new ElggFile($file_guid);
if (!$file) {
    register_error(elgg_echo('file:cannotload'));
    forward(REFERER);
}
// user must be able to edit file
if (!$file->canEdit()) {
    register_error(elgg_echo('file:noaccess'));
    forward(REFERER);
}
$reply = odt_collabeditor_call_typist("delete_session", array("sessionId" => $file_guid));
if (!$reply->success) {
    register_error(elgg_echo('Deleting the collab session failed.'));
    error_log('Deleting the collab session failed: ' . $reply->errorString);
    forward(REFERER);
}
system_message(elgg_echo("Collab session has been deleted."));
// TODO: where should this forward to? file manager list? which url?
// forward();
Exemplo n.º 2
0
/**
 * Edit an odt file collaboratively
 */
// need to be logged in
gatekeeper();
//only for group members
group_gatekeeper();
$file_guid = get_input('guid');
$file = get_entity($file_guid);
$title = $file->title;
$canSave = $file->canEdit();
// first try to simply register a user
$user = elgg_get_logged_in_user_entity();
$sessionId = $file_guid;
$userData = array("guid" => $user->guid, "username" => $user->username, "fullName" => $user->name, "avatarUrl" => $user->getIconURL('large'), "color" => "blue", "sessionId" => $sessionId);
$reply = odt_collabeditor_call_typist("register_user", $userData);
// if no such session, then simply create one
if (!$reply->success) {
    if ($reply->error !== "ENOSESSION") {
        register_error(elgg_echo('Error on talking to Collab server.'));
        error_log('Error on talking to Collab server: ' . $reply->errorString);
        forward(REFERRER);
    }
    // user must be able to edit file to create a session
    if (!$canSave) {
        register_error(elgg_echo('file:noaccess'));
        forward(REFERER);
    }
    $filepath = $file->getFilenameOnFilestore();
    $reply = odt_collabeditor_call_typist2("create_session", array("sessionId" => $file_guid, "filename" => $genesisFilename, "title" => $title, "user" => $userData), $filepath, "application/vnd.oasis.opendocument.text", $title);
    if (!$reply->success) {