Ignore:
Timestamp:
Jun 29, 2009, 1:55:17 PM (15 years ago)
Author:
Criss
Message:

Add obsolete files management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/CommentEditor/include/ce_functions.inc.php

    r3462 r3473  
    11<?php
    2 /* $Id: ce_functions.inc.php,v 1.6 2009/06/26 08:56:32 Criss Exp $ */
     2/* $Id: ce_functions.inc.php,v 1.7 2009/06/29 11:43:18 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
     
    1010function ce_require_class($aClassName) {
    1111  require_once CE_CLASSES .strtolower($aClassName) . '.class.php';
     12}
     13
     14function ce_clean_obsolete_files($obsolete_file_list) {
     15  if (!file_exists(CE_PATH.$obsolete_file_list)) {
     16    return TRUE;
     17  }
     18  $obsolete = file(CE_PATH.$obsolete_file_list);
     19  array_push($obsolete, $obsolete_file_list);
     20  return ce_clean_obsolete_list($obsolete);
     21}
     22
     23function ce_clean_obsolete_list($file_list = array(), &$errors = array()) {
     24  if (!function_exists('unlink')) {
     25      // No unlink available...
     26      array_push($errors, l10n('ce_no_unlink'));
     27      return FALSE;
     28  }
     29  $success = TRUE;
     30  foreach ($file_list as $file) {
     31    $file = CE_PATH . $file;
     32    if (file_exists($file)) {
     33      // Remove obsolete file
     34      $success &= unlink($file);
     35    }
     36  }
     37  if (!$success) {
     38      array_push($errors, l10n('ce_unlink_errors'));
     39  }
     40  return $success;
    1241}
    1342
Note: See TracChangeset for help on using the changeset viewer.