root/afridex/plugins/Flutter/RCCWP_Application.php @ 23

Revision 21, 19.1 kB (checked in by admin, 18 years ago)
Line 
1<?php
2class RCCWP_Application
3{
4       
5       
6        function GetWpCategories()
7        {
8                global $wpdb;
9                //$sql = "SELECT cat_ID, cat_name FROM $wpdb->categories ORDER BY cat_name";
10
11                if( $wpdb->terms != '' )
12                {
13                        $sql = "SELECT t.term_id AS cat_ID, t.name AS cat_name FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'category' ORDER BY t.name";
14                }
15                else
16                {
17                        $sql = "SELECT cat_ID, cat_name FROM $wpdb->categories ORDER BY cat_name";
18                }
19
20                $results = $wpdb->get_results($sql);
21                if (!isset($results))
22                        $results = array();
23                return $results;
24        }
25
26       
27
28
29        /**
30        * Check whether this is wordpress mu and the logged in user is the top admin and it is the main blog
31        */
32        function is_mu_top_admin(){
33                global $wpdb;
34
35                if ($wpdb->prefix != $wpdb->base_prefix.'1_') {
36                        return false;
37                }
38
39                return true;
40        }
41
42        /**
43        * Import modules in default_modules folder
44        */
45        function import_default_modules(){
46
47                $modsFolder = dirname(__FILE__)."/default_modules/without_panel";
48                if ($handle = opendir($modsFolder)) {
49                        while (false !== ($file = readdir($handle))) {
50                                if (is_file($modsFolder.'/'.$file))
51                                        RCCWP_CustomWriteModule::Import($modsFolder.'/'.$file); 
52                        }
53                }
54
55                $modsFolder = dirname(__FILE__)."/default_modules/with_panel";
56                if ($handle = opendir($modsFolder)) {
57                        while (false !== ($file = readdir($handle))) {
58                                if (is_file($modsFolder.'/'.$file))
59                                        RCCWP_CustomWriteModule::Import($modsFolder.'/'.$file, false, true);
60                        }
61                }
62
63        }
64
65        function ContinueInstallation(){
66                //if (RCCWP_Application::IsWordpressMu()) {
67                        RCCWP_Application::SetCaps();
68                //}
69        }
70
71        function SetCaps(){
72
73                // Create capabilities if they are not installed
74                if (!current_user_can(FLUTTER_CAPABILITY_PANELS)){
75                        $role = get_role('administrator');
76                        if (!(RCCWP_Application::IsWordpressMu()) || is_site_admin()){
77                                $role->add_cap(FLUTTER_CAPABILITY_PANELS);
78                                $role->add_cap(FLUTTER_CAPABILITY_MODULES);
79                        }
80                        $role->add_cap(FLUTTER_CAPABILITY_LAYOUT);
81                        $role->add_cap(FLUTTER_CAPABILITY_STYLE);
82                }
83        }
84
85        function Install()
86        {
87               
88                include_once('RCCWP_Options.php');
89                global $wpdb;
90       
91                // First time installation
92                if (get_option(RC_CWP_OPTION_KEY) === false){
93       
94                        // Giving full rights to folders.
95                        @chmod(FLUTTER_UPLOAD_FILES_DIR, 777);
96                        @chmod(FLUTTER_IMAGES_CACHE_DIR, 777);
97                        @chmod(FLUTTER_MODULES_DIR, 777);
98                        @chmod(FLUTTER_PURIFIER_CACHE_DIR, 777);
99                       
100                        //Initialize options
101                        $options['hide-write-post'] = 0;
102                        $options['hide-write-page'] = 0;
103                        $options['prompt-editing-post'] = 0;
104                        $options['assign-to-role'] = 0;
105                        $options['use-snipshot'] = 1;
106                        $options['enable-editnplace'] = 1;
107                        $options['enable-swfupload'] = 1 ;
108                        $options['default-custom-write-panel'] = "";
109                        if (version_compare(PHP_VERSION, '5.0.0') === 1)
110                                $options['enable-HTMLPurifier'] = 1;
111                        else
112                                $options['enable-HTMLPurifier'] = 0;
113                        $options['tidy-level'] = "medium";
114                        $options['canvas_show_instructions'] = 1;
115                        $options['canvas_show_zone_name'] = 0;
116                        $options['canvas_show'] = 1;
117                        $options['ink_show'] = 0;
118
119                        RCCWP_Options::Update($options);
120                       
121                }
122               
123               
124
125                // Check blog database
126                if (get_option("RC_CWP_BLOG_DB_VERSION") == '') update_option("RC_CWP_BLOG_DB_VERSION", 0);
127               
128                if (get_option("RC_CWP_BLOG_DB_VERSION") < RC_CWP_DB_VERSION) 
129                        $BLOG_DBChanged = true;
130                else
131                        $BLOG_DBChanged = false;
132                               
133                       
134                // Install blog tables
135                if (!$wpdb->get_var("SHOW TABLES LIKE '".RC_CWP_TABLE_POST_META."'") == RC_CWP_TABLE_POST_META ||
136                                $BLOG_DBChanged){       
137                        $blog_tables[] = "CREATE TABLE " . RC_CWP_TABLE_POST_META . " (
138                                id integer NOT NULL,
139                                group_count integer NOT NULL,
140                                field_count integer NOT NULL,
141                                post_id integer NOT NULL,
142                                field_name text NOT NULL,
143                                PRIMARY KEY (id) )" ;
144
145                        // try to get around
146                        // these includes like http://trac.mu.wordpress.org/ticket/384
147                        // and http://www.quirm.net/punbb/viewtopic.php?pid=832#p832
148                        if (file_exists(ABSPATH . 'wp-includes/pluggable.php')) {
149                                require_once(ABSPATH . 'wp-includes/pluggable.php');
150                        } else {
151                                require_once(ABSPATH . 'wp-includes/pluggable-functions.php');
152                        }
153                        require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
154                       
155                        foreach($blog_tables as $blog_table)
156                                dbDelta($blog_table);
157                }
158                canvas_install($BLOG_DBChanged);
159               
160                // Upgrade Blog
161                if ($BLOG_DBChanged)    RCCWP_Application::UpgradeBlog();
162
163                               
164                if (RCCWP_Application::IsWordpressMu()){       
165                        if (get_site_option("RC_CWP_DB_VERSION") == '') update_site_option("RC_CWP_DB_VERSION", 0);
166                        if (get_site_option("RC_CWP_DB_VERSION") < RC_CWP_DB_VERSION) 
167                                $DBChanged = true;
168                        else
169                                $DBChanged = false;
170                }
171                else{
172                        if (get_option("RC_CWP_DB_VERSION") == '') update_option("RC_CWP_DB_VERSION", 0);
173                        if (get_option("RC_CWP_DB_VERSION") < RC_CWP_DB_VERSION) 
174                                $DBChanged = true;
175                        else
176                                $DBChanged = false;
177                }
178               
179               
180                // -- Create Tables if they don't exist or the database changed
181                if(!$wpdb->get_var("SHOW TABLES LIKE '".RC_CWP_TABLE_PANELS."'") == RC_CWP_TABLE_PANELS)        $not_installed = true;
182
183                if( $not_installed ||
184                        $DBChanged){ 
185
186                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANELS . " (
187                                id int(11) NOT NULL auto_increment,
188                                name varchar(50) NOT NULL,
189                                description varchar(255),
190                                display_order tinyint,
191                                capability_name varchar(50) NOT NULL,
192                                type varchar(50) NOT NULL,
193                                PRIMARY KEY (id) )";
194                       
195                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " (
196                                id tinyint(11) NOT NULL auto_increment,
197                                name varchar(50) NOT NULL,
198                                description varchar(100),
199                                has_options enum('true', 'false') NOT NULL,
200                                has_properties enum('true', 'false') NOT NULL,
201                                allow_multiple_values enum('true', 'false') NOT NULL,
202                                PRIMARY KEY (id) )";
203                               
204                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_GROUP_FIELDS . " (
205                                id int(11) NOT NULL auto_increment,
206                                group_id int(11) NOT NULL,
207                                name varchar(50) NOT NULL,
208                                description varchar(255),
209                                display_order tinyint,
210                                display_name enum('true', 'false') NOT NULL,
211                                display_description enum('true', 'false') NOT NULL,
212                                type tinyint NOT NULL,
213                                CSS varchar(100),
214                                required_field tinyint,
215                                duplicate boolean NOT NULL,
216                                PRIMARY KEY (id) )";
217                               
218                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS . " (
219                                custom_field_id int(11) NOT NULL,
220                                options text,
221                                default_option text,
222                                PRIMARY KEY (custom_field_id) )";
223                       
224                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_CATEGORY . " (
225                                panel_id int(11) NOT NULL,
226                                cat_id int(11) NOT NULL,
227                                PRIMARY KEY (panel_id, cat_id) )";
228                               
229                        /*$qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_STANDARD_FIELDS . " (
230                                id int(11) NOT NULL AUTO_INCREMENT,
231                                name VARCHAR(50) NOT NULL,
232                                css_id VARCHAR(50) NOT NULL,
233                                default_inclusion ENUM('true', 'false') NOT NULL,
234                                advanced_field ENUM('true', 'false') NOT NULL,
235                                exclude_version float(11) NOT NULL,
236                                for_post ENUM('true', 'false') NOT NULL,
237                                PRIMARY KEY  (id)
238                                );";*/
239                       
240                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_STANDARD_FIELD . " (
241                                panel_id int(11) NOT NULL,
242                                standard_field_id int(11) NOT NULL,
243                                PRIMARY KEY (panel_id, standard_field_id) )";
244                       
245                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " (
246                                custom_field_id int(11) NOT NULL AUTO_INCREMENT,
247                                properties TEXT,
248                                PRIMARY KEY (custom_field_id)
249                                );";
250                       
251                        /*$qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_HIDDEN_EXTERNAL_FIELD . " (
252                                panel_id int(11) NOT NULL,
253                                css_id varchar(50) NOT NULL,
254                                PRIMARY KEY (panel_id, css_id) )";*/
255       
256                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_MODULES . " (
257                                id int(11) NOT NULL auto_increment,
258                                name varchar(50) NOT NULL,
259                                description text,
260                                PRIMARY KEY (id) )";
261       
262                        $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_GROUPS . " (
263                                id int(11) NOT NULL auto_increment,
264                                panel_id int(11) NOT NULL,
265                                name varchar(50) NOT NULL,
266                                duplicate boolean NOT NULL,
267                                at_right boolean NOT NULL,
268                                PRIMARY KEY (id) )";
269       
270                        /*$qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_MODULES . " (
271                                id int(11) NOT NULL auto_increment,
272                                panel_id int(11) NOT NULL,
273                                module_id int(11) NOT NULL,
274                                PRIMARY KEY (id) )";*/
275
276                        // try to get around
277                        // these includes like http://trac.mu.wordpress.org/ticket/384
278                        // and http://www.quirm.net/punbb/viewtopic.php?pid=832#p832
279                        if (file_exists(ABSPATH . 'wp-includes/pluggable.php')) {
280                                require_once(ABSPATH . 'wp-includes/pluggable.php');
281                        } else {
282                                require_once(ABSPATH . 'wp-includes/pluggable-functions.php');
283                        }
284                        require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
285                       
286                        foreach($qst_tables as $qst_table)
287                                dbDelta($qst_table);
288
289                        if (RCCWP_Application::IsWordpressMu()) {
290                                        update_site_option('RC_CWP_DB_VERSION', RC_CWP_DB_VERSION);
291                        }
292                        else{
293                                        update_option('RC_CWP_DB_VERSION', RC_CWP_DB_VERSION);
294                        }
295               
296                }
297
298                // Insert standard fields definition
299                if($not_installed){
300               
301                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (1, 'Textbox', NULL, 'false', 'true', 'false')";
302                        $wpdb->query($sql6);
303                       
304                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (2, 'Multiline Textbox', NULL, 'false', 'true', 'false')";
305                        $wpdb->query($sql6);
306                       
307                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (3, 'Checkbox', NULL, 'false', 'false', 'false')";
308                        $wpdb->query($sql6);
309                       
310                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (4, 'Checkbox List', NULL, 'true', 'false', 'true')";
311                        $wpdb->query($sql6);
312                       
313                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (5, 'Radiobutton List', NULL, 'true', 'false', 'false')";
314                        $wpdb->query($sql6);
315                       
316                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (6, 'Dropdown List', NULL, 'true', 'false', 'false')";
317                        $wpdb->query($sql6);
318                       
319                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (7, 'Listbox', NULL, 'true', 'true', 'true')";
320                        $wpdb->query($sql6);
321                       
322                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (8, 'File', NULL, 'false', 'false', 'false')";
323                        $wpdb->query($sql6);
324                       
325                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (9, 'Image', NULL, 'false', 'true', 'false')";
326                        $wpdb->query($sql6);
327       
328                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (10, 'Date', NULL, 'false', 'true', 'false')";
329                        $wpdb->query($sql6);
330       
331                        $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (11, 'Audio', NULL, 'false', 'false', 'false')";
332                        $wpdb->query($sql6);
333                       
334                       
335                        // -- Panel standard fields
336                       
337                        //$sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (1, 'Title', 'titlediv', 'true', 'false', 1000)";
338                        //$wpdb->query($sql9);
339                       
340                        /*$sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (12, 'Post/Page', 'postdivrich', 'true', 'false', 1000)";
341                        $wpdb->query($sql9);
342                       
343                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (2, 'Categories', 'categorydiv', 'false', 'false', 1000)";
344                        $wpdb->query($sql9);
345                       
346                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (3, 'Discussion', 'commentstatusdiv', 'true', 'true', 1000)";
347                        $wpdb->query($sql9);
348                       
349                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (4, 'Post Password', 'passworddiv', 'true', 'true', 1000)";
350                        $wpdb->query($sql9);
351                       
352                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (5, 'Post Slug', 'slugdiv', 'false', 'false', 2.5)";
353                        $wpdb->query($sql9);
354                       
355                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (6, 'Post Status', 'poststatusdiv', 'false', 'false', 2.5)";
356                        $wpdb->query($sql9);
357                       
358                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (7, 'Post Timestamp', 'posttimestampdiv', 'false', 'false', 2.5)";
359                        $wpdb->query($sql9);
360                       
361                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (8, 'Upload', 'uploading', 'false', 'false', 2.5)";
362                        $wpdb->query($sql9);
363                       
364                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (9, 'Optional Excerpt', 'postexcerpt', 'true', 'true', 1000)";
365                        $wpdb->query($sql9);
366                       
367                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (10, 'Trackbacks', 'trackbacksdiv', 'true', 'true', 1000)";
368                        $wpdb->query($sql9);
369                       
370                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (11, 'Custom Fields', 'postcustom', 'true', 'true', 1000)";
371                        $wpdb->query($sql9);
372                       
373                       
374                       
375                        $sql9 = "INSERT IGNORE INTO " . RC_CWP_TABLE_STANDARD_FIELDS . " VALUES (13, 'Post Author', 'authordiv', 'false', 'false', 2.5)";
376                        $wpdb->query($sql9);*/
377                }
378               
379                // Upgrade Blog site
380                if ($DBChanged) RCCWP_Application::UpgradeBlogSite();
381               
382               
383               
384                //Import Default modules
385                if (RCCWP_Application::IsWordpressMu()){
386                        if (get_site_option('FLUTTER_fist_time') == ''){
387                                RCCWP_Application::import_default_modules();
388                                update_site_option('FLUTTER_fist_time', '1');
389                        }
390                }
391                else{
392                        if (get_option('FLUTTER_fist_time') == ''){
393                                RCCWP_Application::import_default_modules();
394                                update_option('FLUTTER_fist_time', '1');
395                        }
396                }
397               
398        }
399       
400        function UpgradeBlog(){
401                global $wpdb;
402                if (RC_CWP_DB_VERSION == 26){
403                        // Migrate database from previous versions after introducing models/panels
404                        // separation concept
405                        // The following code adds the field name to RC_CWP_TABLE_POST_META.
406                       
407                        $fieldMetaIDs = $wpdb->get_results("SELECT id FROM " . RC_CWP_TABLE_POST_META);
408                        foreach($fieldMetaIDs as $fieldMetaID){
409                                $metakey = $wpdb->get_var( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_id = '{$fieldMetaID->id}'" );
410                                $wpdb->query("UPDATE ". RC_CWP_TABLE_POST_META .
411                                                         " SET field_name = '$metakey'".
412                                                         " WHERE id = '{$fieldMetaID->id}'");
413                                       
414                        }
415               
416                }
417               
418        }
419
420        function UpgradeBlogSite(){
421                global $wpdb;
422                if (RC_CWP_DB_VERSION == 26){
423                       
424                        // Migrate database from previous versions after introducing models/panels
425                        // separation concept
426                        // The following code transfers fields/groups fomr modules to panels.
427                       
428                        require_once("RCCWP_CustomWritePanel.php");
429                        if (RCCWP_Application::IsWordpressMu()) {
430                                $RC_CWP_TABLE_PANEL_MODULES = $wpdb->base_prefix . 'rc_cwp_panel_modules';
431                        }
432                        else{
433                                $RC_CWP_TABLE_PANEL_MODULES = $wpdb->prefix . 'rc_cwp_panel_modules';
434                        }
435                       
436                        $writePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
437                       
438                        foreach($writePanels as $writePanel){
439                                $sql = "SELECT module_id FROM " . $RC_CWP_TABLE_PANEL_MODULES .
440                                        " WHERE panel_id = " . $writePanel->id;
441                                $panelModules =$wpdb->get_results($sql);
442                               
443                                foreach($panelModules as $panelModule){
444                                        $wpdb->query("UPDATE ". RC_CWP_TABLE_PANEL_GROUPS .
445                                                         " SET panel_id = '{$writePanel->id}'".
446                                                         " WHERE module_id = '{$panelModule->module_id}'");
447                                }
448                        }
449                }
450        }
451       
452        function Uninstall()
453        {
454                global $wpdb;
455
456                // Delete blog tables
457                $sql = "DROP TABLE " . RC_CWP_TABLE_POST_META;
458                $wpdb->query($sql);
459                include_once "canvas-install.php";
460                canvas_clean_deactivate();
461
462                // Remove options
463                delete_option(RC_CWP_OPTION_KEY);
464
465                // Delete meta data
466                $sql = "DELETE FROM $wpdb->postmeta WHERE meta_key = '" . RC_CWP_POST_WRITE_PANEL_ID_META_KEY . "'";
467                $wpdb->query($sql);
468
469                if (get_option("Flutter_notTopAdmin")) return;
470
471
472               
473                RCCWP_Application::DeleteModulesFolders();     
474
475                $sql = "DROP TABLE " . RC_CWP_TABLE_PANELS;
476                $wpdb->query($sql);
477               
478                $sql = "DROP TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES;
479                $wpdb->query($sql);
480               
481                $sql = "DROP TABLE " . RC_CWP_TABLE_GROUP_FIELDS;
482                $wpdb->query($sql);
483               
484                $sql = "DROP TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS;
485                $wpdb->query($sql);
486               
487                $sql = "DROP TABLE " . RC_CWP_TABLE_PANEL_CATEGORY;
488                $wpdb->query($sql);
489               
490                $sql = "DROP TABLE " . RC_CWP_TABLE_STANDARD_FIELDS;
491                $wpdb->query($sql);
492               
493                $sql = "DROP TABLE " . RC_CWP_TABLE_PANEL_STANDARD_FIELD;
494                $wpdb->query($sql);
495               
496                $sql = "DROP TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES;
497                $wpdb->query($sql);
498
499                $sql = "DROP TABLE " . RC_CWP_TABLE_MODULES;
500                $wpdb->query($sql);
501               
502                $sql = "DROP TABLE " . RC_CWP_TABLE_PANEL_GROUPS;
503                $wpdb->query($sql);
504
505                $sql = "DROP TABLE " . RC_CWP_TABLE_PANEL_HIDDEN_EXTERNAL_FIELD; 
506                $wpdb->query($sql);
507
508                $sql = "DROP TABLE " . RC_CWP_TABLE_PANEL_MODULES; 
509                $wpdb->query($sql);
510               
511                global $canvas;
512                $wpdb->query("DROP TABLE IF EXISTS ".$canvas->duplicates."");
513
514                if (RCCWP_Application::is_mu_top_admin()){
515                        update_site_option('FLUTTER_fist_time', '');
516                }
517                else{
518                        update_option('FLUTTER_fist_time', '');
519                }
520       
521               
522        }
523
524        function DeleteModulesFolders()
525        {
526                $customModules = RCCWP_CustomWriteModule::GetCustomModules();
527                foreach($customModules as $customModule)
528                        RCCWP_CustomWriteModule::Delete($customModule->id);
529        }
530       
531        function InCustomWritePanel()
532        {
533                return RCCWP_Application::InWritePostPanel() && isset($_REQUEST['custom-write-panel-id']);
534        }
535       
536        function InWritePostPanel()
537        {
538                return (strstr($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php') ||
539                        strstr($_SERVER['REQUEST_URI'], '/wp-admin/post.php') ||
540                        strstr($_SERVER['REQUEST_URI'], '/wp-admin/page-new.php') ||
541                        strstr($_SERVER['REQUEST_URI'], '/wp-admin/page.php'));
542        }
543
544        function IsWordpressMu(){
545                global $is_wordpress_mu; //$wpdb, $wp_version, $wpmu_version;
546
547                if  ($is_wordpress_mu){      // (isset($wpmu_version)) || (strpos($wp_version, 'wordpress-mu')) ) {
548                        return true;
549                }
550
551                return false;
552        }
553
554        function CheckInstallation(){
555       
556                if (stripos($_GET['page'], "flutter") === false && $_GET['page'] != "RCCWP_OptionsPage.php" && !isset($_GET['custom-write-panel-id'])) return;
557               
558                $dir_list = "";
559
560                if (!is_writable(FLUTTER_IMAGES_CACHE_DIR)){
561                        $dir_list.= "<li>".FLUTTER_IMAGES_CACHE_DIR . "</li>";
562                }
563
564                if (!is_writable(FLUTTER_UPLOAD_FILES_DIR)){
565                        $dir_list.= "<li>".FLUTTER_UPLOAD_FILES_DIR . "</li>";
566                }
567
568
569                if (!is_writable(FLUTTER_MODULES_DIR)){
570                        $dir_list.= "<li>".FLUTTER_MODULES_DIR . "</li>";
571                }
572
573                if (!is_writable(FLUTTER_PURIFIER_CACHE_DIR)){
574                        $dir_list.= "<li>".FLUTTER_PURIFIER_CACHE_DIR . "</li>";
575                }
576
577                if ($dir_list != ""){
578                        echo "<div id='flutter-install-error-message' class='error'><p><strong>".__('Flutter is not ready yet.')."</strong> ".__('The following folders must be writable (usually chmod 777 is neccesary):')."</p><ul>";
579                        echo $dir_list;
580                        echo "</ul></div>";
581                }
582
583        }
584       
585       
586        /**
587         * Checks for the existance of unzip
588         *
589         * @access private
590         */
591
592        function CheckDecompressionProgramUnzip() {
593
594                $return = exec("unzip -help", $output, $returnValue);
595                if ( 0 != $returnValue ) return false;
596
597                return true;
598        }
599       
600        /*
601         * Checks for the existance of zip
602         */
603
604        function CheckCompressionProgramZip() {
605
606                $return = exec("zip -help", $output, $returnValue);
607                if ( 0 != $returnValue ) return false;
608
609                return true;
610        }
611       
612       
613}
614?>
Note: See TracBrowser for help on using the browser.