Esempio n. 1
0
 public static function getSettings($tenant)
 {
     if (self::$settings) {
         return self::$settings;
     } else {
         try {
             $result = self::$tableRestProxy->getEntity(self::$table, $tenant, 'settings');
         } catch (ServiceException $e) {
             $code = $e->getCode();
             if ($code == 404) {
                 return null;
             } else {
                 $error_message = $e->getMessage();
                 $app->error("Something went wrong. Please try again later.");
             }
         }
         $entity = $result->getEntity();
         self::$settings = $entity;
         return $entity;
     }
 }
Esempio n. 2
0
<?php

$tenantDomain = API::getTenantDomain();
$settings = appStorage::getSettings($tenantDomain);
$webstore = json_decode($settings->getPropertyValue("webstore"));
$app->render('settings/webstore.twig', ['webstore' => $webstore]);
<?php

$logoutUri = $_POST["logoutUri"];
if ($logoutUri == "" || filter_var($logoutUri, FILTER_VALIDATE_URL)) {
    $tenantDomain = API::getTenantDomain();
    $settings = appStorage::getSettings($tenantDomain);
    $organization = json_decode($settings->getPropertyValue('organization'));
    $organization->logoutUri = $logoutUri;
    appStorage::setSettings($tenantDomain, ['organization' => json_encode($organization)]);
    $app->flash("success", "Your organization settings were successfuly updated!");
} else {
    $app->flash("error", "The logoutUri you entered isn't a valid URL.");
}
$app->redirect($app->request->getResourceUri());
Esempio n. 4
0
 public static function getAcademicStatus()
 {
     $tenantDomain = self::getTenantDomain();
     $settings = appStorage::getSettings($tenantDomain);
     $access = $settings->getPropertyValue("access");
     if ($access == "everyone") {
         return "students";
     } else {
         $memberOf = self::memberOf();
         $accessGroups = json_decode($settings->getPropertyValue("accessGroups"));
         foreach ($memberOf as $group) {
             if (in_array($group['objectId'], $accessGroups->students)) {
                 return "students";
             } else {
                 if (in_array($group['objectId'], $accessGroups->faculty)) {
                     return "faculty";
                 } else {
                     if (in_array($group['objectId'], $accessGroups->staff)) {
                         return "staff";
                     }
                 }
             }
         }
         return false;
     }
 }
Esempio n. 5
0
<?php

//if(PHP_SAPI !== 'cli') die('Server side only.');
ini_set('display_errors', 1);
require_once '../vendor/autoload.php';
require_once "includes/API.php";
require_once "includes/app.storage.php";
appStorage::connect();
$entities = appStorage::getAllSettings();
$app = new stdClass();
$app->OAuth2 = new stdClass();
$app->OAuth2->provider = new TheNetworg\OAuth2\Client\Provider\Azure(['clientId' => getenv("Auth_appId"), 'clientSecret' => getenv("Auth_appSecret"), 'redirectUri' => getenv("Auth_redirectUri")]);
foreach ($entities as $entity) {
    $tenantDomain = $entity->getPartitionKey();
    $app->OAuth2->provider->tenant = $tenantDomain;
    $app->OAuth2->token = $app->OAuth2->provider->getAccessToken('client_credentials', ['resource' => "https://graph.windows.net/"]);
    $accessGroups = json_decode($entity->getPropertyValue("accessGroups"));
    $groups = $accessGroups->students + $accessGroups->faculty + $accessGroups->staff;
    API::assignToApplication($tenantDomain, false, $groups);
}
Esempio n. 6
0
<?php

if (getenv("ENVIRONMENT") == "DEV") {
    ini_set('display_errors', 1);
}
require_once '../vendor/autoload.php';
require_once "/templates/base.php";
require_once "includes/API.php";
require_once "includes/app.storage.php";
require_once "includes/DreamSpark.php";
session_cache_limiter(false);
session_start();
$app = new \Slim\Slim([]);
if (getenv("ENVIRONMENT") != "DEV") {
    $app->config('debug', false);
}
appStorage::connect();
$app->OAuth2 = new stdClass();
$app->OAuth2->provider = new TheNetworg\OAuth2\Client\Provider\Azure(['clientId' => getenv("Auth_appId"), 'clientSecret' => getenv("Auth_appSecret"), 'redirectUri' => getenv("Auth_redirectUri")]);
require_once "includes/app.errors.php";
require_once "includes/app.oauth2.php";
require_once "includes/app.router.php";
require_once "includes/app.applicationinsights.php";
\Slim\ApplicationInsights::init();
$app->run();
<?php

$access = $_POST["access"];
$students = isset($_POST["students"]) ? $_POST["students"] : [];
$faculty = isset($_POST["faculty"]) ? $_POST["faculty"] : [];
$staff = isset($_POST["staff"]) ? $_POST["staff"] : [];
//validate that all are valid UUIDs
if ($access == "everyone") {
    $students = $faculty = $staff = [];
}
if (array_search($access, ["everyone", "groups"]) !== FALSE) {
    $tenantDomain = API::getTenantDomain();
    $settings = appStorage::getSettings($tenantDomain);
    appStorage::setSettings($tenantDomain, ['accessGroups' => json_encode(["students" => $students, "faculty" => $faculty, "staff" => $staff]), 'access' => $access]);
    $app->flash("success", "Your permissions were successfuly updated! If you changed permissions, please note that it may take up to 12 hours for users to see the application in their app launcher.");
} else {
    $app->flash("error", "Something went wrong! Please refresh the page and try again.");
}
$app->redirect($app->request->getResourceUri());
<?php

$account = $_POST["account"];
$key = $_POST["key"];
if ($account && $key) {
    $tenantDomain = API::getTenantDomain();
    $settings = appStorage::getSettings($tenantDomain);
    $webstore = json_decode($settings->getPropertyValue('webstore'));
    $webstore->account = $account;
    $webstore->key = $key;
    appStorage::setSettings($tenantDomain, ['webstore' => json_encode($webstore)]);
    $app->flash("success", "Your Webstore settings were sucessfully updated!");
} else {
    $app->flash("error", "You have to fill out both your Webstore account number and key!");
}
$app->redirect($app->request->getResourceUri());