Subversion Repositories oidplus

Rev

Rev 635 | Rev 1086 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2021 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. namespace ViaThinkSoft\OIDplus;
  21.  
  22. // TODO: should this be a different plugin type? A page without gui is weird!
  23. class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic {
  24.  
  25.         public function action($actionID, $params) {
  26.  
  27.                 // Action:     delete_ra
  28.                 // Method:     POST
  29.                 // Parameters: email
  30.                 // Outputs:    Text
  31.                 if ($actionID == 'delete_ra') {
  32.                         _CheckParamExists($params, 'email');
  33.  
  34.                         $email = $params['email'];
  35.  
  36.                         $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email);
  37.  
  38.                         if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) {
  39.                                 throw new OIDplusException(_L('Authentication error. Please log in.'));
  40.                         }
  41.  
  42.                         if ($ra_logged_in) OIDplus::authUtils()->raLogout($email);
  43.  
  44.                         $ra = new OIDplusRA($email);
  45.                         if (!$ra->existing()) {
  46.                                 throw new OIDplusException(_L('RA "%1" does not exist.',$email));
  47.                         }
  48.                         $ra->delete();
  49.                         $ra = null;
  50.  
  51.                         OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted");
  52.  
  53.                         return array("status" => 0);
  54.                 } else {
  55.                         throw new OIDplusException(_L('Unknown action ID'));
  56.                 }
  57.  
  58.         }
  59.  
  60.         public function init($html=true) {
  61.                 // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101
  62.                 OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
  63.                         if (!is_numeric($value) || ($value < 1)) {
  64.                                 throw new OIDplusException(_L('Please enter a valid password length.'));
  65.                         }
  66.                 });
  67.         }
  68.  
  69.         public function gui($id, &$out, &$handled) {
  70.         }
  71.  
  72.         public function publicSitemap(&$out) {
  73.         }
  74.  
  75.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  76.         }
  77.  
  78.         public function tree_search($request) {
  79.                 return false;
  80.         }
  81. }