Dotclear

Changeset 3613:c49075201a42 for admin


Ignore:
Timestamp:
12/08/17 16:45:49 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Dotclear core update check is now done by async js (via services.php) - a forced check may still be done on <admin>/update.php page

Location:
admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r3557 r3613  
    210210     ) 
    211211); 
    212  
    213 # Dotclear updates notifications 
    214 if ($core->auth->isSuperAdmin() && !DC_NOT_UPDATE && is_readable(DC_DIGESTS) && !$core->auth->user_prefs->dashboard->nodcupdate) 
    215 { 
    216      $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
    217      $new_v = $updater->check(DC_VERSION); 
    218      $version_info = $new_v ? $updater->getInfoURL() : ''; 
    219  
    220      if ($updater->getNotify() && $new_v) { 
    221           // Check PHP version required 
    222           if (version_compare(phpversion(),$updater->getPHPVersion()) >= 0) { 
    223                echo 
    224                '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '. 
    225                '<p><a class="button submit" href="'.$core->adminurl->get("admin.update").'">'.sprintf(__('Upgrade now'),$new_v).'</a> '. 
    226                '<a class="button" href="'.$core->adminurl->get("admin.update", array('hide_msg' => 1)).'">'.__('Remind me later').'</a>'. 
    227                ($version_info ? ' </p>'. 
    228                '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'. 
    229                '</div>'; 
    230           } else { 
    231                echo '<p class="info">'. 
    232                     sprintf(__('A new version of Dotclear is available but needs PHP version ≥ %s, your\'s is currently %s'), 
    233                          $updater->getPHPVersion(),phpversion()). 
    234                     '</p>'; 
    235           } 
    236      } else { 
    237           if (version_compare(phpversion(),DC_NEXT_REQUIRED_PHP,'<')) { 
    238                echo '<p class="info">'. 
    239                     sprintf(__('The next versions of Dotclear will not support PHP version < %s, your\'s is currently %s'), 
    240                          DC_NEXT_REQUIRED_PHP,phpversion()). 
    241                     '</p>'; 
    242           } 
    243      } 
    244 } 
    245212 
    246213if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) { 
  • admin/js/_index.js

    r2929 r3613  
    8080          user_pref: 'dcx_quick_entry' 
    8181     }); 
     82 
     83     // check if core update available 
     84     var params = { 
     85          f: 'checkCoreUpdate', 
     86          xd_check: dotclear.nonce 
     87     }; 
     88     $.post('services.php',params,function(data) { 
     89          if ($('rsp[status=failed]',data).length > 0) { 
     90               // Silently fail as a forced checked my be done with admin update page 
     91          } else { 
     92               if ($('rsp>update',data).attr('check') == 1) { 
     93                    // Something has to be displayed 
     94                    xml = $('rsp>update',data).attr('ret'); 
     95                    $('#content h2').after(xml); 
     96               } 
     97          } 
     98     }); 
     99 
    82100}); 
  • admin/services.php

    r2572 r3613  
    1717require dirname(__FILE__).'/../inc/admin/prepend.php'; 
    1818 
     19$core->rest->addFunction('checkCoreUpdate',array('dcRestMethods','checkCoreUpdate')); 
    1920$core->rest->addFunction('getPostById',array('dcRestMethods','getPostById')); 
    2021$core->rest->addFunction('getCommentById',array('dcRestMethods','getCommentById')); 
     
    3435class dcRestMethods 
    3536{ 
     37     public static function checkCoreUpdate($core,$get) 
     38     { 
     39          # Dotclear updates notifications 
     40 
     41          $rsp = new xmlTag('update'); 
     42          $rsp->check = false; 
     43          $ret = __('Dotclear update not avalaible'); 
     44 
     45          if ($core->auth->isSuperAdmin() && !DC_NOT_UPDATE && is_readable(DC_DIGESTS) && 
     46               !$core->auth->user_prefs->dashboard->nodcupdate) 
     47          { 
     48               $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
     49               $new_v = $updater->check(DC_VERSION); 
     50               $version_info = $new_v ? $updater->getInfoURL() : ''; 
     51 
     52               if ($updater->getNotify() && $new_v) { 
     53                    // Check PHP version required 
     54                    if (version_compare(phpversion(),$updater->getPHPVersion()) >= 0) { 
     55                         $ret = 
     56                         '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '. 
     57                         '<p><a class="button submit" href="'.$core->adminurl->get("admin.update").'">'.sprintf(__('Upgrade now'),$new_v).'</a> '. 
     58                         '<a class="button" href="'.$core->adminurl->get("admin.update", array('hide_msg' => 1)).'">'.__('Remind me later').'</a>'. 
     59                         ($version_info ? ' </p>'. 
     60                         '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'. 
     61                         '</div>'; 
     62                    } else { 
     63                         $ret = '<p class="info">'. 
     64                              sprintf(__('A new version of Dotclear is available but needs PHP version ≥ %s, your\'s is currently %s'), 
     65                                   $updater->getPHPVersion(),phpversion()). 
     66                              '</p>'; 
     67                    } 
     68                    $rsp->check = true; 
     69               } else { 
     70                    if (version_compare(phpversion(),DC_NEXT_REQUIRED_PHP,'<')) { 
     71                         $ret = '<p class="info">'. 
     72                              sprintf(__('The next versions of Dotclear will not support PHP version < %s, your\'s is currently %s'), 
     73                                   DC_NEXT_REQUIRED_PHP,phpversion()). 
     74                              '</p>'; 
     75                         $rsp->check = true; 
     76                    } 
     77               } 
     78          } 
     79          $rsp->ret = $ret; 
     80          return $rsp; 
     81     } 
     82 
    3683     public static function getPostById($core,$get) 
    3784     { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map