Ignore:
Timestamp:
Jan 6, 2013, 1:53:17 AM (11 years ago)
Author:
julien1311
Message:

[file_uploader] lots of bug fixes

Location:
extensions/File_Uploader/install
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/File_Uploader/install/config_default.inc.php

    r19821 r19875  
    11<?php
    22$file_uploader_galleries_folder = 'file_uploader';
     3$file_uploader_galleries_folder_name = 'File Uploader';
    34$file_uploader_galleries_dir = PHPWG_ROOT_PATH.'galleries/'.$file_uploader_galleries_folder.'/';
    45
     
    3233);
    3334
    34 $config_default = array(
    35         'new_tab' => 1,
    36         'overwrite' => 0,
     35$file_uploader_default_config = array(
     36        'new_tab' => '1',
     37        'overwrite' => '0',
    3738        'pdf2tab_extensions' => array('pdf', 'docx', 'doc', 'odt', 'xlsx', 'xls', 'ods', 'pptx', 'ppt', 'odp'),
    3839);
  • extensions/File_Uploader/install/functions.inc.php

    r19821 r19875  
    55}
    66
    7 function file_uploader_update_db() {
     7function file_uploader_update_db($file_uploader_default_config) {
    88        global $conf;
    9         include(dirname(__FILE__).'/config_default.inc.php');
    10 
     9       
    1110        $config = array();
    12         if (isset($conf['file_uploader']))
     11       
     12        if (isset($conf['file_uploader'])) {
    1313                $conf_file_uploader = unserialize($conf['file_uploader']);
    14        
    15         if (isset($conf_file_uploader)) {
    16                 foreach ($config_default as $key => $value) {
     14                foreach ($file_uploader_default_config as $key => $value) {
    1715                        if (isset($conf_file_uploader[$key]))
    1816                                $config[$key] = $conf_file_uploader[$key];
    1917                        else
    20                                 $config[$key] = $config_default[$key];
     18                                $config[$key] = $file_uploader_default_config[$key];
    2119                }
    2220                file_uploader_delete_conf("file_uploader");
    2321                file_uploader_install($config);
    2422        } else {
    25                 file_uploader_install($config_default);
     23                file_uploader_install($file_uploader_default_config);
    2624        }
    2725}
     
    3230}
    3331
    34 function file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir) {
     32function file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir, $file_uploader_galleries_folder_name) {
    3533        //If the directory does not exist, we create it
    3634        if (!file_exists($file_uploader_galleries_dir))
    3735                if(!mkdir($file_uploader_galleries_dir))
    3836                        array_push($page['errors'], l10n('Unable to create folder ').$file_uploader_galleries_dir);
    39                 //If the physical category si not in database, we add it
    40                 else if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_galleries_folder.'";')) == 0){
     37                //If the physical category is not in database, we add it
     38                else if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE dir = "'.$file_uploader_galleries_folder.'";')) == 0){
    4139                        $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
    4240                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
    4341                        $category_rank = $category_rank['MAX(rank)'] + 1;
    44                         pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank, site_id) VALUES ('.$next_id.', "'.$file_uploader_galleries_folder.'", "'.$file_uploader_file_category.'", '.$category_rank.', "private", "true", "'.$next_id.'", '.$category_rank.', 1);');
     42                        pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, comment, dir, rank, status, visible, uppercats, global_rank, site_id) VALUES ('.$next_id.', "'.$file_uploader_galleries_folder_name.'", "Created by the File Uploader plugin", "'.$file_uploader_galleries_folder.'", '.$category_rank.', "private", "true", "'.$next_id.'", '.$category_rank.', 1);');
    4543                }
    4644}
Note: See TracChangeset for help on using the changeset viewer.