Dotclear

Changeset 3066:aa297059d2a0 for inc


Ignore:
Timestamp:
08/10/15 15:31:48 (10 years ago)
Author:
Dsls
Branch:
default
Message:

Disable plugins with unmetdependencies, in admin home and plugins.php admin page. See #1842, fixed partially (need to see how to cope with themes now)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.modules.php

    r3008 r3066  
    2929     protected $disabled_mode = false; 
    3030     protected $disabled_meta = array(); 
     31     protected $to_disable = array(); 
    3132 
    3233     protected $id; 
     
    6162      */ 
    6263     public function checkDependencies() { 
    63           $to_disable = array(); 
     64          $this->to_disable = array(); 
    6465          foreach ($this->all_modules as $k => &$m) { 
    6566               if (isset($m['requires'])) { 
     
    8586                         $m['cannot_enable']=$missing; 
    8687                         if ($m['enabled']) { 
    87                               $to_disable[]=array('name' => $k,'reason'=> $missing); 
     88                              $this->to_disable[]=array('name' => $k,'reason'=> $missing); 
    8889                         } 
    8990                    } 
     
    100101               } 
    101102          } 
    102           return $to_disable; 
     103     } 
     104 
     105     /** 
     106      * Checks all modules dependencies, and disable unmet dependencies 
     107      * @param  string $redir_url URL to redirect if modules are to disable 
     108      * @return boolea, true if a redirection has been performed 
     109      */ 
     110     public function disableDepModules($redir_url) { 
     111          if (isset($_GET['dep'])) { 
     112               // Avoid infinite redirects 
     113               return false; 
     114          } 
     115          $reason = array(); 
     116          foreach ($this->to_disable as $module) { 
     117                    try{ 
     118                         $this->deactivateModule($module['name']); 
     119                         $reason[] = sprintf("<li>%s : %s</li>",$module['name'],join(',',$module['reason'])); 
     120                    } catch (Exception $e) { 
     121                    } 
     122          } 
     123          if (count($reason)) { 
     124               $message = sprintf ("<p>%s</p><ul>%s</ul>", 
     125                    __("The following extensions have been disabled :"), 
     126                    join('',$reason) 
     127               ); 
     128               dcPage::addWarningNotice($message,array('divtag'=>true,'with_ts' => false)); 
     129               if (strpos($redir_url,"?")) { 
     130                    $url = $redir_url."&"."dep=1"; 
     131               } else { 
     132                    $url = $redir_url."?"."dep=1"; 
     133               } 
     134               http::redirect($url); 
     135               return true; 
     136          } 
     137          return false; 
    103138     } 
    104139 
Note: See TracChangeset for help on using the changeset viewer.

Sites map