Ejemplo n.º 1
0
*/
/* This page is used for both logged users and outsiders to */
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['userId'])) {
    echo "Sic";
    exit;
}
if (!isset($_REQUEST['diagramId'])) {
    echo "No diagram selected";
    exit;
}
$delegate = new Delegate();
$diagram = $delegate->diagramGetById($_REQUEST['diagramId']);
//print_r($diagram);
//exit();
$page = 'editDiagram';
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Diagramo - Edit diagram</title>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
        <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
        <link href="./assets/css/style.css" type="text/css" rel="stylesheet"/>
        
        <script type="text/javascript" src="./assets/javascript/dropdownmenu.js?<?php 
Ejemplo n.º 2
0
}
if (!isset($_REQUEST['hash'])) {
    echo 'No hash';
    exit;
}
if (strlen(trim($_REQUEST['hash'])) != 6) {
    print "Wrong hash";
    exit;
}
$delegate = new Delegate();
$diagram = $delegate->diagramGetByHash(trim($_REQUEST['hash']));
if (!is_object($diagram)) {
    print "No diagram";
    exit;
}
$diagram = $delegate->diagramGetById($diagram->id);
//GUARDIAN: see if we can display this diagram
$display = false;
if ($diagram->public) {
    $display = true;
} else {
    $loggedUser = $delegate->userGetById($_SESSION['userId']);
    //do we have a logged user
    if (is_object($loggedUser)) {
        $userdiagram = $delegate->userdiagramGetByIds($loggedUser->id, $diagram->id);
        //is he allocated to this diagram?
        if (is_object($userdiagram)) {
            $display = true;
        }
    }
}
Ejemplo n.º 3
0
<?php

require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (is_numeric($_REQUEST['diagramId'])) {
    $d = new Delegate();
    $diagram = $d->diagramGetById($_REQUEST['diagramId']);
    $d->close();
    if (is_numeric($_SESSION['userId']) || $diagram->public) {
        $filePath = dirname(__FILE__) . '/data/diagrams/' . $_REQUEST['diagramId'] . '.png';
        if (file_exists($filePath)) {
            $fileSize = filesize($filePath);
            $fh = fopen($filePath, 'rb');
            $data = fread($fh, $fileSize);
            fclose($fh);
            header('Content-Type: image/png');
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Content-Disposition: attachment; filename="' . $_REQUEST['diagramId'] . '.png' . '"');
            header('Pragma: public');
            header('Content-Length: ' . $fileSize);
            print $data;
            //print 'Alex';
            flush();
        } else {
            print "No file";
        }
    }
Ejemplo n.º 4
0
function acceptInvitationExe()
{
    if (!is_numeric($_SESSION['userId'])) {
        print "Wrong way";
        exit;
    }
    if (!isset($_REQUEST['invitationId'])) {
        print "Wrong Invitation";
        exit;
    }
    $d = new Delegate();
    $loggedUser = $d->userGetById($_SESSION['userId']);
    $invitation = $d->invitationGetById($_REQUEST['invitationId']);
    if ($invitation->email == $loggedUser->email) {
        //a match made in stars...how lovely :)
        $diagram = $d->diagramGetById($invitation->diagramId);
        //create userdiagram
        $userdiagram = new Userdiagram();
        $userdiagram->diagramId = $diagram->id;
        $userdiagram->invitedDate = $invitation->createdDate;
        $userdiagram->level = Userdiagram::LEVEL_EDITOR;
        $userdiagram->status = Userdiagram::STATUS_ACCEPTED;
        $userdiagram->userId = $loggedUser->id;
        //store it in DB
        $d->userdiagramCreate($userdiagram);
        //delete invitation
        $d->invitationDelete($invitation->id);
        addMessage("Invitation accepted");
        redirect('../editor.php?diagramId=' . $diagram->id);
    } else {
        addError("Nope");
        redirect('../myDiagrams.php');
    }
}
Ejemplo n.º 5
0
        }
    }
    return $diagrams;
}
function diagramDeleteById($dbhandle, $diagramId)
{
    $query = sprintf("delete FROM diagram where id=%d", $diagramId);
    $result = sqlite_query($dbhandle, $query);
    if ($result) {
    }
}
if (false && PHP_SAPI == 'cli') {
    //see http://php.net/manual/en/features.commandline.php
    print "\nOn the console";
    //test
    $d = new Delegate();
    $diagrams = $d->diagramGetAll();
    print_r($diagrams);
    $diagram = new Diagram();
    $diagram->title = 'Ana are mere';
    $diagram->description = 'Ana are foarte multe mere';
    $diagram->public = 0;
    $diagram->createdDate = gmdate('Y-m-d h:i:s');
    $diagram->lastUpdate = gmdate('Y-m-d h:i:s');
    $dId = $d->diagramCreate($diagram);
    print "Diagram Id: " + $dId;
    $nd = $d->diagramGetById($dId);
    $nd->title = 'Zzoz';
    $d->diagramUpdate($nd);
    $d->close();
}
Ejemplo n.º 6
0
                            <td width="200" align="right">&nbsp;</td>
                        </tr>
                    </table>
                </div>
                
                <table width="100%"> 
                    <tr>
                        <th>Date</th>
                        <th>Invited to</th>
                        <th>Invited by</th>
                        <th>Accept</th>
                        <th>Decline</th>
                    </tr>
                <?php 
    foreach ($invitations as $invitation) {
        $diagram = $delegate->diagramGetById($invitation->diagramId);
        $author = $delegate->usersGetAuthorForDiagram($diagram->id);
        ?>
                    
                    <tr>
                        <td><?php 
        echo $invitation->createdDate;
        ?>
</td>
                        <td><?php 
        echo $diagram->title;
        ?>
</td>
                        <td><?php 
        echo $author->email;
        ?>