source: extensions/File_Uploader/install/functions.inc.php @ 19875

Last change on this file since 19875 was 19875, checked in by julien1311, 11 years ago

[file_uploader] lots of bug fixes

  • Property svn:eol-style set to LF
File size: 2.0 KB
RevLine 
[19775]1<?php
[19821]2function file_uploader_install($config) {
3        $query = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("file_uploader" ,"'.pwg_db_real_escape_string(serialize($config)).'", "File Uploader plugin parameters");';
4        pwg_query($query);
5}
6
[19875]7function file_uploader_update_db($file_uploader_default_config) {
[19821]8        global $conf;
[19875]9       
[19821]10        $config = array();
[19875]11       
12        if (isset($conf['file_uploader'])) {
[19821]13                $conf_file_uploader = unserialize($conf['file_uploader']);
[19875]14                foreach ($file_uploader_default_config as $key => $value) {
[19821]15                        if (isset($conf_file_uploader[$key]))
16                                $config[$key] = $conf_file_uploader[$key];
17                        else
[19875]18                                $config[$key] = $file_uploader_default_config[$key];
[19821]19                }
20                file_uploader_delete_conf("file_uploader");
21                file_uploader_install($config);
22        } else {
[19875]23                file_uploader_install($file_uploader_default_config);
[19821]24        }
25}
26
27function file_uploader_delete_conf($where) {
28        $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE (param="'.$where.'");';
29        pwg_query($query);
30}
31
[19875]32function file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir, $file_uploader_galleries_folder_name) {
[19775]33        //If the directory does not exist, we create it
34        if (!file_exists($file_uploader_galleries_dir))
35                if(!mkdir($file_uploader_galleries_dir))
36                        array_push($page['errors'], l10n('Unable to create folder ').$file_uploader_galleries_dir);
[19875]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){
[19775]39                        $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
40                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
41                        $category_rank = $category_rank['MAX(rank)'] + 1;
[19875]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);');
[19775]43                }
44}
45?>
Note: See TracBrowser for help on using the repository browser.