Ignore:
Timestamp:
Jul 7, 2013, 1:28:12 PM (11 years ago)
Author:
mistic100
Message:

bug:2898 make some updates methods static + factorize code from plugins, themes & languages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/updates.class.php

    r16179 r23821  
    3434  }
    3535
    36   function check_piwigo_upgrade()
     36  static function check_piwigo_upgrade()
    3737  {
    3838    $_SESSION['need_update'] = null;
     
    243243  }
    244244
    245   function deltree($path, $move_to_trash=false)
    246   {
    247     if (is_dir($path))
    248     {
    249       $fh = opendir($path);
    250       while ($file = readdir($fh))
    251       {
    252         if ($file != '.' and $file != '..')
    253         {
    254           $pathfile = $path . '/' . $file;
    255           if (is_dir($pathfile))
    256           {
    257             self::deltree($pathfile, $move_to_trash);
    258           }
    259           else
    260           {
    261             @unlink($pathfile);
    262           }
    263         }
    264       }
    265       closedir($fh);
    266       if (@rmdir($path))
    267       {
    268         return true;
    269       }
    270       elseif ($move_to_trash)
    271       {
    272         $trash = PHPWG_ROOT_PATH.'_trash';
    273         if (!is_dir($trash))
    274         {
    275           @mkgetdir($trash);
    276         }
    277         return @rename($path, $trash . '/'.md5(uniqid(rand(), true)));
    278       }
    279       else
    280       {
    281         return false;
    282       }
    283     }
    284   }
    285 
    286   function process_obsolete_list($file)
     245  static function process_obsolete_list($file)
    287246  {
    288247    if (file_exists(PHPWG_ROOT_PATH.$file)
     
    300259        elseif (is_dir($path))
    301260        {
    302           self::deltree($path, true);
    303         }
    304       }
    305     }
    306   }
    307 
    308   function dump_database($include_history=false)
     261          deltree($path, PHPWG_ROOT_PATH.'_trash');
     262        }
     263      }
     264    }
     265  }
     266
     267  static function dump_database($include_history=false)
    309268  {
    310269    global $page, $conf, $cfgBase;
     
    351310
    352311      @readfile($backupFile);
    353       self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
     312      deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
    354313      exit();
    355314    }
     
    360319  }
    361320
    362   function upgrade_to($upgrade_to, &$step, $check_current_version=true)
     321  static function upgrade_to($upgrade_to, &$step, $check_current_version=true)
    363322  {
    364323    global $page, $conf, $template;
     
    450409          {
    451410            self::process_obsolete_list($obsolete_list);
    452             self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
     411            deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
    453412            invalidate_user_cache(true);
    454413            $template->delete_compiled_templates();
     
    478437        else
    479438        {
    480           self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
     439          deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
    481440          array_push($page['errors'], l10n('An error has occured during upgrade.'));
    482441        }
Note: See TracChangeset for help on using the changeset viewer.