/**
     @return should Boolean
     In [1] we noted, that things that can be public and/or featured should be displayed under the following conditions:
     * The thing is public and featured.
     * The thing is featured and a user is logged in.
     [1]: https://github.com/runjak/TranscriptionDesk/blob/master/notes/2015-06-19.md
 */
 public function shouldDisplay()
 {
     //¬featured -> ¬shouldDisplay():
     if (!$this->isFeatured()) {
         return false;
     }
     //public && featured -> shouldDisplay():
     if ($this->isPublic()) {
         return true;
     }
     //Depends on login:
     $user = Config::getUserManager()->verify();
     return $user !== null;
 }
*/
require_once 'config.php';
//Fail method:
$fail = function ($reason) {
    echo json_encode(array('error' => $reason));
    die;
};
//Casual check of POST parameters:
$expecteds = array('scanRectangleMap', 'type', 'typeText');
foreach ($expecteds as $expected) {
    if (!isset($_POST[$expected])) {
        $fail("Post parameter '{$expected}' is missing!");
    }
}
//Checking user login:
$user = Config::getUserManager()->verify();
if ($user === null) {
    $fail('User not logged in.');
}
//Checking correct type and typeText parameters:
require_once 'database/areaOfInterest.php';
$type = $_POST['type'];
$typeText = $_POST['typeText'];
if (!AreaOfInterestType::validType($type)) {
    $fail("Invalid type: '{$type}'");
}
if (AreaOfInterestType::hasText($type)) {
    if (!is_string($typeText) || $typeText === '') {
        $fail("Type text must be a non empty string, and not '{$typeText}'.");
    }
} else {
<?php 
/**
    This file is concerend with displaying a single OmekaFile.
    To do so, it expects a urn GET parameter to be given.
    If the urn parameter is missing, errors/noGet.php will be required.
    If the urn parameter is invalid, errors/invalidUrn.php will be required.
    Else the page will be displayed as expected.
*/
require_once 'config.php';
if (!isset($_GET['urn']) || !$_GET['urn']) {
    require 'errors/noGet.php';
} else {
    if (is_null(Config::getUserManager()->verify())) {
        require 'errors/loginRequired.php';
    } else {
        $file = OmekaFile::getFileFromDb($_GET['urn']);
        if ($file === null) {
            require 'errors/invalidUrn.php';
        } else {
            //We need to hand out some file info as JSON:
            $json = array();
            //Function to add an OmekaFile $file to a $field String in the $json array.
            $addFile = function ($field, $file) use(&$json) {
                $arr = array('urn' => $file->getUrn(), 'img' => $file->getFullsizeFileUrl(), 'aois' => array());
                foreach ($file->getAOIs() as $aoi) {
                    $urn = $aoi->getUrn();
                    $arr['aois'][$urn] = $aoi->toArray();
                }
                $json[$field] = $arr;
            };
Example #4
0
<?php

require_once '../config.php';
Config::getUserManager()->logout();
header('LOCATION: ..');
Example #5
0
        $isNew = false;
        //Tracking if $user is new.
        $auth = $response['auth'];
        $authMethod = $auth['provider'] . ':' . $auth['uid'];
        $user = User::fromAuthenticationMethod($authMethod);
        if ($user === null) {
            //Create new User:
            $isNew = true;
            $displayName = '';
            $avatarUrl = null;
            if (array_key_exists('info', $auth)) {
                $info = $auth['info'];
                if (array_key_exists('name', $info)) {
                    $displayName = $info['name'];
                }
                if (array_key_exists('image', $info)) {
                    $avatarUrl = $info['image'];
                }
            }
            $user = User::registerNew($authMethod, $displayName, $avatarUrl);
        }
        Config::getUserManager()->login($user);
        if ($isNew) {
            //Redirect to profile?
            header('LOCATION: ../profile.php');
        } else {
            //Redirect to main page:
            header('LOCATION: ..');
        }
    }
}
Example #6
0
<?php

require_once '../config.php';
Config::getUserManager()->getOpauth()->run();