示例#1
0
 public function procede()
 {
     try {
         if ($this->oRequest->existParam('user') && !$this->oRequest->existParam('edit')) {
             $this->add();
         }
         if ($this->oRequest->existParam('edit')) {
             $oApiKey = new ApiKey($this->oRequest->getParam('edit', 'string'), $this->oRequest->getParam('user', 'int'), $this->oRequest->getParam('read', 'boolean'), $this->oRequest->getParam('write', 'boolean'));
             if ($this->oRequest->existParam('delete') && $this->oRequest->getParam('delete', 'boolean')) {
                 $oApiKey->delete();
                 Logger::log('admin', Language::translate('API_ADMIN_KEY_DELLOG') . $this->oRequest->getParam('edit', 'string') . ' [' . $this->oCurrentUser->getLogin() . ']');
                 $this->oView->addAlert(Language::translate('API_ADMIN_KEY_DEL'), 'success');
             } else {
                 $oApiKey->update();
                 Logger::log('admin', Language::translate('API_ADMIN_KEY_UPDATELOG') . $this->oRequest->getParam('edit', 'string') . ' [' . $this->oCurrentUser->getLogin() . ']');
                 $this->oView->addAlert(Language::translate('API_ADMIN_KEY_UPDATE'), 'success');
             }
         }
     } catch (Exception $e) {
         $this->oView->addAlert($e, 'danger');
     } finally {
         $this->createView();
     }
 }
示例#2
0
<?php

require_once 'runtime.php';
require_once ROOT_DIR . '/lib/core/ApiKeyList.class.php';
require_once ROOT_DIR . '/lib/core/Router.class.php';
require_once ROOT_DIR . '/lib/core/User.class.php';
if ($_GET['section'] == "insert_add") {
    //add new api key
    do {
        $api_key = new ApiKey(false, ApiKey::generateApiKey(), (int) $_GET['object_id'], $_GET['object_type'], $_POST['description']);
        $api_key_id = $api_key->store();
    } while (!$api_key_id);
    $message[] = array("Es wurde ein neuer API-Key " . $api_key->getApiKey() . " generiert und gespeichert.", 1);
    Message::setMessage($message);
    header('Location: ./api_key_list.php?object_id=' . $_GET['object_id'] . '&object_type=' . $_GET['object_type']);
} elseif ($_GET['section'] == "delete") {
    $api_key = new ApiKey((int) $_GET['api_key_id']);
    $api_key->fetch();
    $message[] = array("Der API-Key " . $api_key->getApiKey() . " wurde gelöscht.", 1);
    $api_key->delete();
    Message::setMessage($message);
    header('Location: ./api_key_list.php?object_id=' . $_GET['object_id'] . '&object_type=' . $_GET['object_type']);
}