Subversion Repositories oidplus

Rev

Rev 310 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. // TODO: should this be a different plugin type? A page without gui is weird!
  21. class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic {
  22.  
  23.         public function action($actionID, $params) {
  24.  
  25.                 // Action:     delete_ra
  26.                 // Method:     POST
  27.                 // Parameters: email
  28.                 // Outputs:    Text
  29.                 if ($actionID == 'delete_ra') {
  30.                         $email = $params['email'];
  31.  
  32.                         $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email);
  33.  
  34.                         if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) {
  35.                                 throw new OIDplusException('Authentication error. Please log in.');
  36.                         }
  37.  
  38.                         if ($ra_logged_in) OIDplus::authUtils()->raLogout($email);
  39.  
  40.                         $ra = new OIDplusRA($email);
  41.                         if (!$ra->existing()) {
  42.                                 throw new OIDplusException("RA '$email' does not exist.");
  43.                         }
  44.                         $ra->delete();
  45.                         $ra = null;
  46.  
  47.                         OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted");
  48.  
  49.                         echo json_encode(array("status" => 0));
  50.                 } else {
  51.                         throw new OIDplusException("Unknown action ID");
  52.                 }
  53.  
  54.         }
  55.  
  56.         public function init($html=true) {
  57.                 // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101
  58.                 OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
  59.                         if (!is_numeric($value) || ($value < 1)) {
  60.                                 throw new OIDplusException("Please enter a valid password length.");
  61.                         }
  62.                 });
  63.         }
  64.  
  65.         public function gui($id, &$out, &$handled) {
  66.         }
  67.  
  68.         public function publicSitemap(&$out) {
  69.         }
  70.  
  71.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  72.         }
  73.  
  74.         public function tree_search($request) {
  75.                 return false;
  76.         }
  77. }
  78.