コード例 #1
0
ファイル: oauth.php プロジェクト: noackorama/source-talk-2012
 /**
  *
  **/
 public function authorize_action()
 {
     global $user, $auth;
     $auth->login_if($user->id == 'nobody');
     $user_id = OAuthUser::getMappedId($user->id);
     // Fetch the oauth store and the oauth server.
     $store = OAuthStore::instance();
     $server = new OAuthServer();
     try {
         // Check if there is a valid request token in the current request
         // Returns an array with the consumer key, consumer secret, token, token secret and token type.
         $rs = $server->authorizeVerify();
         if (isset($_POST['allow'])) {
             // See if the user clicked the 'allow' submit button (or whatever you choose)
             $authorized = array_key_exists('allow', $_POST);
             // Set the request token to be authorized or not authorized
             // When there was a oauth_callback then this will redirect to the consumer
             $server->authorizeFinish($authorized, $user_id);
             // No oauth_callback, show the user the result of the authorization
             // ** your code here **
             PageLayout::postMessage(Messagebox::success(_('Sie haben der Applikation Zugriff auf Ihre Daten gewährt.')));
             $this->redirect('user#' . $rs['consumer_key']);
         }
     } catch (OAuthException $e) {
         // No token to be verified in the request, show a page where the user can enter the token to be verified
         // **your code here**
         die('invalid');
     }
     PageLayout::disableHeader();
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox'));
     $this->rs = $rs;
 }
コード例 #2
0
ファイル: admin.php プロジェクト: noackorama/source-talk-2012
 /**
  *
  **/
 public function keys_action($key)
 {
     $details = $this->render_keys($key);
     if (Request::isXhr()) {
         $this->render_text(implode('<br>', $details));
     } else {
         PageLayout::postMessage(Messagebox::info(_('Die Schlüssel in den Details dieser Meldung sollten vertraulich behandelt werden!'), $details, true));
         $this->redirect('admin/index#' . $key);
     }
 }
コード例 #3
0
 /**
  *
  **/
 public static function onEnable($pluginId)
 {
     # TODO performance - use cache on success ?
     $role_persistence = new RolePersistence();
     $plugin_roles = $role_persistence->getAssignedPluginRoles($pluginId);
     $role_names = array_map(function ($role) {
         return $role->getRolename();
     }, $plugin_roles);
     if (!in_array('Nobody', $role_names)) {
         $message = _('Das OAuth-Plugin ist aktiviert, aber nicht für die Rolle "Nobody" freigegeben.');
         $details = array();
         $details[] = _('Dies behindert die Kommunikation externer Applikationen mit dem System.');
         $details[] = sprintf(_('Klicken Sie <a href="%s">hier</a>, um die Rollenzuweisung zu bearbeiten.'), URLHelper::getLink('dispatch.php/admin/role/assign_plugin_role/' . $pluginId));
         PageLayout::postMessage(Messagebox::info($message, $details));
     }
 }
コード例 #4
0
 function index_action($step = 'manifest')
 {
     $step = Request::option('step', $step);
     $this->previous = $this->next = $last = false;
     foreach ($this->actions as $action) {
         if ($last == $step) {
             $this->next = $action;
         }
         if ($action == $step) {
             $this->previous = $last;
         }
         $last = $action;
     }
     // if (Request::isPost()) {    # since Stud.IP 2.1
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $this->plugin = array_merge($this->plugin, $this->extract($step, $errors));
         $_SESSION['plugin-generator']['passed'][$step] = empty($errors);
     }
     if (!empty($errors)) {
         PageLayout::postMessage(Messagebox::error(_('Es sind Fehler aufgetreten:'), $errors));
     } elseif (Request::submitted('action')) {
         $action = Request::option('action');
         if (!in_array($action, array('display download install'))) {
             $generator = new Generator($this->dispatcher->plugin->getPluginPath(), '/templates', '/environments');
         }
         $generator->populate($this->plugin);
         $generator->{$action}();
         if ($action === 'install') {
             $this->redirect(URLHelper::getURL('dispatch.php/admin/plugin'));
             return;
         }
         #            PageLayout::postMessage(Messagebox::success('Jipp.'));
     } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if (Request::submitted('back')) {
             $step = Request::option('back', $this->previous);
         } else {
             if (Request::submitted('forward')) {
                 $step = Request::option('forward', $this->next);
             }
         }
         $this->redirect('generator/' . $step);
         return;
     }
     $this->step = $step;
     switch ($step) {
         case 'manifest':
             $this->interfaces = array('HomepagePlugin' => _('Homepage eines Nutzers'), 'PortalPlugin' => _('Startseite (Portalseite)'), 'StandardPlugin' => _('Veranstaltungen und Einrichtungen'), 'StudienmodulManagementPlugin' => _('Studienmodulsuche'), 'SystemPlugin' => _('Systemweite Erweiterungen'));
             $this->versions = words('2.0 2.1 2.2 2.3 2.4');
             break;
         case 'assets':
             $this->environments = array('default' => _('Standard'), 'trails' => _('Trails'));
             break;
         case 'polyfill':
             $this->polyfills = Polyfill::getVersions();
             break;
     }
     $variables = array('step' => $step, 'controller' => $this);
     $factory = new Flexi_TemplateFactory($this->dispatcher->plugin->getPluginPath() . '/app/views/');
     $progress = $factory->render('infobox-route', $variables);
     $this->setInfoboxImage($this->dispatcher->plugin->getPluginURL() . '/assets/images/puzzle.jpg')->addToInfobox(_('Fortschritt'), $progress)->addToInfobox(_('Aktionen'), sprintf('<a href="%s">Reset</a>', $this->url_for('generator/' . $step . '?reset=1')), Assets::image_path('icons/16/black/refresh.png'));
 }