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

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

[file_uploader] pdf2tab update

  • Property svn:eol-style set to LF
File size: 2.0 KB
Line 
1<?php
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
7function file_uploader_update_db() {
8        global $conf;
9        include(dirname(__FILE__).'/config_default.inc.php');
10
11        $config = array();
12        if (isset($conf['file_uploader']))
13                $conf_file_uploader = unserialize($conf['file_uploader']);
14       
15        if (isset($conf_file_uploader)) {
16                foreach ($config_default as $key => $value) {
17                        if (isset($conf_file_uploader[$key]))
18                                $config[$key] = $conf_file_uploader[$key];
19                        else
20                                $config[$key] = $config_default[$key];
21                }
22                file_uploader_delete_conf("file_uploader");
23                file_uploader_install($config);
24        } else {
25                file_uploader_install($config_default);
26        }
27}
28
29function file_uploader_delete_conf($where) {
30        $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE (param="'.$where.'");';
31        pwg_query($query);
32}
33
34function file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir) {
35        //If the directory does not exist, we create it
36        if (!file_exists($file_uploader_galleries_dir))
37                if(!mkdir($file_uploader_galleries_dir))
38                        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){
41                        $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
42                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
43                        $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);');
45                }
46}
47?>
Note: See TracBrowser for help on using the repository browser.