Esempio n. 1
0
 /**
  * perform a ContentType upgrade on all modules
  * @param string $modname (optional and unused at the moment)
  */
 public function upgradecontenttypes($modname = null)
 {
     if ($modname == null) {
         $modules = ModUtil::getModules();
         $count = 0;
         foreach ($modules as $module) {
             // there is no need to upgrade Content ContentTypes because they are done on module upgrade.
             if ($module['name'] != 'Content') {
                 $count += Content_Installer::updateContentType($module['name']);
             }
         }
     } else {
         $count = Content_Installer::updateContentType($modname);
     }
     return $count;
 }
Esempio n. 2
0
 function upgrade($oldversion)
 {
     $prefix = System::getVar('prefix');
     $prefix = $prefix ? $prefix . '_' : '';
     switch ($oldversion) {
         case '1.0':
             $sql = "ALTER TABLE " . $prefix . "addressbook_address ADD adr_geodata VARCHAR( 180 ) NULL AFTER adr_country";
             if (!DBUtil::executeSQL($sql, -1, -1, false, true)) {
                 return false;
             }
             // Upgrade successfull
             ModUtil::setVar('Addressbook', 'google_api_key', '');
             ModUtil::setVar('Addressbook', 'google_zoom', 15);
             return AddressBook_upgrade(1.1);
         case '1.1':
             $this->_addressbook_migratecategories();
             $this->_addressbook_migrateprefixes();
             ModUtil::delVar('Addressbook', 'name_order');
             ModUtil::delVar('Addressbook', 'zipbeforecity');
             return AddressBook_upgrade(1.2);
         case '1.2':
             ModUtil::delVar('Addressbook', 'textareawidth');
             ModUtil::delVar('Addressbook', 'dateformat');
             ModUtil::delVar('Addressbook', 'numformat');
             $this->_addressbook_upgradeto_1_3();
             return true;
         case '1.3':
         case '1.3.1':
             // drop table prefix
             if ($prefix) {
                 $connection = Doctrine_Manager::getInstance()->getConnection('default');
                 $sqlStatements = array();
                 $sqlStatements[] = 'RENAME TABLE ' . $prefix . 'addressbook_address' . " TO `addressbook_address`";
                 $sqlStatements[] = 'RENAME TABLE ' . $prefix . 'addressbook_customfields' . " TO `addressbook_customfields`";
                 $sqlStatements[] = 'RENAME TABLE ' . $prefix . 'addressbook_favourites' . " TO `addressbook_favourites`";
                 $sqlStatements[] = 'RENAME TABLE ' . $prefix . 'addressbook_labels' . " TO `addressbook_labels`";
                 foreach ($sqlStatements as $sql) {
                     $stmt = $connection->prepare($sql);
                     try {
                         $stmt->execute();
                     } catch (Exception $e) {
                     }
                 }
             }
         case '1.3.2':
             // Register hooks
             $connection = Doctrine_Manager::getInstance()->getConnection('default');
             $sqlQueries = array();
             $sqlQueries[] = 'DELETE FROM `hook_area` WHERE `owner`="AddressBook"';
             $sqlQueries[] = 'DELETE FROM `hook_subscriber` WHERE `owner`="AddressBook"';
             foreach ($sqlQueries as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                 }
             }
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
         case '1.3.3':
             // Register event handlers
             if (ModUtil::available('Content')) {
                 Content_Installer::updateContentType('AddressBook');
             }
             EventUtil::registerPersistentModuleHandler('AddressBook', 'module.content.gettypes', array('AddressBook_EventHandler_Listeners', 'getContentTypes'));
             // default images directory and manager
             $this->setVar('images_dir', 'userdata/Addressbook');
             $this->setVar('images_manager', 'kcfinder');
         case '1.3.4':
             // Add language and status column
             DBUtil::changeTable('addressbook_address');
             // Assume language of created records is "All". Status set to active.
             $objArray = array('language' => '', 'status' => 1);
             DBUtil::updateObject($objArray, 'addressbook_address', 'WHERE 1');
             // Delete unused settings
             ModUtil::delVar('Addressbook', 'special_chars_1');
             ModUtil::delVar('Addressbook', 'special_chars_2');
             // Register new settings
             $this->setVar('addressbooktype', 1);
             // 1-people, 2-companies
             $this->setVar('showabcfilter', 1);
         case '1.3.5':
             // Register new settings
             $this->setVar('allowprivate', 0);
             return true;
         case '1.3.6':
             return true;
     }
 }
Esempio n. 3
0
    /**
     * upgrade the News module from an old version
     *
     * @return       bool       true on success, false otherwise
     */
    public function upgrade($oldversion)
    {
        // Upgrade dependent on old version number
        switch ($oldversion)
        {
            case '1.3':
            case '1.4':
                $this->setVar('storyhome', System::getVar('storyhome'));
                System::delVar('storyhome');
                $this->setVar('storyorder', System::getVar('storyorder'));
                System::delVar('storyorder');
                $this->setVar('itemsperpage', 25);

            case '1.5':
                $tables = DBUtil::getTables();
                $shorturlsep = System::getVar('shorturlsseparator');
                // move the data from the author uid to creator and updator uid
                $sqls = array();
                $sqls[] = "UPDATE $tables[stories] SET pn_cr_uid = pn_aid";
                $sqls[] = "UPDATE $tables[stories] SET pn_lu_uid = pn_aid";
                // move the data from the time field to the creation and update datestamp
                $sqls[] = "UPDATE $tables[stories] SET pn_cr_date = pn_time";
                $sqls[] = "UPDATE $tables[stories] SET pn_lu_date = pn_time";
                $sqls[] = "UPDATE $tables[stories] SET pn_urltitle = REPLACE(pn_title, ' ', '{$shorturlsep}')";
                foreach ($sqls as $sql) {
                    if (!DBUtil::executeSQL($sql)) {
                        LogUtil::registerError($this->__('Error! Could not update table.'));
                        return '1.5';
                    }
                }
                // drop the old columns
                DBUtil::dropColumn('stories', array('pn_aid'));
                DBUtil::dropColumn('stories', array('pn_time'));
                $this->setVar('permalinkformat', '%year%/%monthnum%/%day%/%storytitle%');

            case '2.0':
            // import autonews and queue articles
                if (!$this->_import_autonews_queue()) {
                    LogUtil::registerError($this->__('Error! Could not update articles.'));
                    return '2.0';
                }
                // migrate the comments to ezcomments
                if (ModUtil::available('Comments') || defined('_PNINSTALLVER')) {
                    // check for the ezcomments module
                    if (!ModUtil::available('EZComments')) {
                        LogUtil::registerError(__f('Error! The \'%s\' module is not installed.', 'EZComments'));
                        return '2.0';
                    }
                    //  drop the comments table if successful
                    if (ModUtil::apiFunc('EZComments', 'migrate', 'news')) {
                        // drop comments table after migration has succeeded
                        if (!DBUtil::dropTable('comments')) {
                            LogUtil::registerError($this->__('Error! Could not delete table.'));
                            return '2.0';
                        }
                        // remove the Comments module
                        ModUtil::apiFunc('Modules', 'admin', 'remove', array('id' => ModUtil::getIdFromName('Comments')));
                    }
                }
                // drop the autonews and queue tables, articles are already imported
                if (!DBUtil::dropTable('autonews')) {
                    LogUtil::registerError($this->__('Error! Could not delete table.'));
                    return '2.0';
                }
                if (!DBUtil::dropTable('queue')) {
                    LogUtil::registerError($this->__('Error! Could not delete table.'));
                    return '2.0';
                }
                // remove the AddStory and Submit_News modules
                ModUtil::apiFunc('Modules', 'admin', 'remove', array('id' => ModUtil::getIdFromName('AddStory')));
                ModUtil::apiFunc('Modules', 'admin', 'remove', array('id' => ModUtil::getIdFromName('Submit_News')));

            case '2.1':
                $this->setVar('enablecategorization', true);
                ModUtil::dbInfoLoad('News', 'News', true);

                if (!$this->_news_migratecategories()) {
                    LogUtil::registerError($this->__('Error! Could not migrate categories.'));
                    return '2.1';
                }

            case '2.2':
                $this->setVar('refereronprint', System::getVar('refereronprint', 0));

            case '2.3':
                $prefix = System::getVar('prefix');
                // when from is not set, put it to the creation date
                $sqls = array();
                $sqls[] = "UPDATE {$prefix}_stories SET pn_from = pn_cr_date WHERE pn_from IS NULL";
                // make sure we dont have an NULL hometext, since the tables permitted this before 2.4
                $sqls[] = "UPDATE {$prefix}_stories SET pn_hometext = '' WHERE pn_hometext IS NULL";
                foreach ($sqls as $sql) {
                    if (!DBUtil::executeSQL($sql)) {
                        LogUtil::registerError($this->__('Error! Could not update table.'));
                        return '2.3';
                    }
                }
                $this->setVar('enableattribution', false);
                // import the topicimagepath, variable tipath deletion is up to Topics module
                $this->setVar('catimagepath', System::getVar('tipath'));
                $this->setVar('enableajaxedit', false);
                // drop old legacy columns
                DBUtil::dropColumn('stories', 'pn_comments');
                DBUtil::dropColumn('stories', 'pn_themeoverride');
                // clear compiled templates and News cache (see #74)
                ModUtil::apiFunc('view', 'user', 'clear_compiled');
                ModUtil::apiFunc('view', 'user', 'clear_cache', array('module' => 'News'));

            case '2.4':
            case '2.4.1':
            // rename the database table from stories to news
                if (!DBUtil::renameTable('stories', 'news')) {
                    LogUtil::registerError($this->__('Error! Could not rename table.'));
                    return '2.4.1';
                }
            case '2.4.2':
            // rename several columns, tables holds the old names for backwards compatibility still
                $columns = array_keys(DBUtil::metaColumns('news', true));

                if (in_array('PN_WITHCOMM', $columns) && !DBUtil::renameColumn('news', 'pn_withcomm', 'disallowcomments')) {
                    LogUtil::registerError($this->__('Error! Could not rename column.'));
                    return '2.4.2';
                }
                if (in_array('PN_INFORMANT', $columns) && !DBUtil::renameColumn('news', 'pn_informant', 'contributor')) {
                    LogUtil::registerError($this->__('Error! Could not rename column.'));
                    return '2.4.2';
                }
                if (in_array('PN_IHOME', $columns) && !DBUtil::renameColumn('news', 'pn_ihome', 'hideonindex')) {
                    LogUtil::registerError($this->__('Error! Could not rename column.'));
                    return '2.4.2';
                }
            case '2.4.3':
            // update table for missing fields etc
                if (!DBUtil::changeTable('news')) {
                    return '2.4.3';
                }
                // update permissions with new scheme News::
                ModUtil::dbInfoLoad('Categories');
                $tables  = DBUtil::getTables();
                $grperms = $tables['group_perms_column'];

                $sqls   = array();
                $sqls[] = "UPDATE $tables[group_perms] SET $grperms[component] = 'News::' WHERE $grperms[component] = 'Stories::Story'";
                // update categories_mapobj and categories_registry with new tablename (categories tables not in $tables ?)
                $sqls[] = "UPDATE $tables[categories_mapobj] SET cmo_table='news' WHERE cmo_table='stories'";
                $sqls[] = "UPDATE $tables[categories_registry] SET crg_table='news' WHERE crg_table='stories'";
                foreach ($sqls as $sql) {
                    if (!DBUtil::executeSQL($sql)) {
                        LogUtil::registerError($this->__('Error! Could not update table.'));
                        return '2.4.3';
                    }
                }
                // Add new variable(s)
                $this->setVar('enablemorearticlesincat', false);
                $this->setVar('morearticlesincat', 0);
                $this->setVar('notifyonpending', false);
                $this->setVar('notifyonpending_fromname', '');
                $this->setVar('notifyonpending_fromaddress', '');
                $this->setVar('notifyonpending_toname', '');
                $this->setVar('notifyonpending_toaddress', '');
                $this->setVar('notifyonpending_subject', $this->__('A News Publisher article has been submitted for review'));
                $this->setVar('notifyonpending_html', true);
                $this->setVar('pdflink', false);
                $this->setVar('pdflink_tcpdfpath', 'config/classes/tcpdf/tcpdf.php');
                $this->setVar('pdflink_tcpdflang', 'config/classes/tcpdf/config/lang/eng.php');
                $this->setVar('pdflink_headerlogo', 'tcpdf_logo.jpg');
                $this->setVar('pdflink_headerlogo_width', '30');

                // clear compiled templates and News cache
                ModUtil::apiFunc('view', 'user', 'clear_compiled');
                ModUtil::apiFunc('view', 'user', 'clear_cache', array('module' => 'News'));

            case '2.5':
                // update table
                if (!DBUtil::changeTable('news')) {
                    return '2.5';
                }
            case '2.5.1':
            case '2.5.2':
                // add the new picture column and update the table
                if (!DBUtil::changeTable('news')) {
                    return '2.5.2';
                }
                // add new picture uploading variables
                $this->setVar('picupload_enabled', false);
                $this->setVar('picupload_allowext', 'jpg, gif, png');
                $this->setVar('picupload_index_float', 'left');
                $this->setVar('picupload_article_float', 'left');
                $this->setVar('picupload_maxfilesize', '500000');
                $this->setVar('picupload_maxpictures', '3');
                $this->setVar('picupload_sizing', '0');
                $this->setVar('picupload_picmaxwidth', '600');
                $this->setVar('picupload_picmaxheight', '600');
                $this->setVar('picupload_thumbmaxwidth', '150');
                $this->setVar('picupload_thumbmaxheight', '150');
                $this->setVar('picupload_thumb2maxwidth', '200');
                $this->setVar('picupload_thumb2maxheight', '200');
                $this->setVar('picupload_uploaddir', 'images/news_picupload');
                // add new category parameter
                $this->setVar('enablecategorybasedpermissions', true);

                // permalink format change story to article
                $this->setVar('permalinkformat', str_replace(array('storytitle', 'storyid'), array('articletitle', 'articleid'), $this->getVar('permalinkformat')));

                // clear compiled templates and News cache
                ModUtil::apiFunc('view', 'user', 'clear_compiled');
                ModUtil::apiFunc('view', 'user', 'clear_cache', array('module' => 'News'));

            case '2.6.0':
            case '2.6.1':
                $this->setVar('enabledescriptionvar', false);
                $this->setVar('descriptionvarchars', 250);
            case '2.6.2':
            case '2.6.3':
                // register handlers
                EventUtil::registerPersistentModuleHandler('News', 'get.pending_content', array('News_Handlers', 'pendingContent'));
                EventUtil::registerPersistentModuleHandler('News', 'module.content.gettypes', array('News_Handlers', 'getTypes'));
                $prefix = $this->serviceManager['prefix'];
                $connection = Doctrine_Manager::getInstance()->getConnection('default');
                $sqlStatements = array();
                // N.B. statements generated with PHPMyAdmin
                $sqlStatements[] = 'RENAME TABLE ' . $prefix . '_news' . " TO `news`";
                // this removes the prefixes but also changes hideonindex to displayonindex and disallowcomments to allowcomments
                // because 'from' and 'to' are reserved sql words, the column names are changed to ffrom and tto respectively
                $sqlStatements[] = "ALTER TABLE `news` 
CHANGE `pn_sid` `sid` INT( 11 ) NOT NULL AUTO_INCREMENT ,
CHANGE `pn_title` `title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `pn_hometext` `hometext` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `pn_bodytext` `bodytext` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `pn_counter` `counter` INT( 11 ) NULL DEFAULT '0',
CHANGE `pn_contributor` `contributor` VARCHAR( 25 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `pn_notes` `notes` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `pn_hideonindex` `displayonindex` TINYINT( 4 ) NOT NULL DEFAULT '0',
CHANGE `pn_language` `language` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `pn_disallowcomments` `allowcomments` TINYINT( 4 ) NOT NULL DEFAULT '0' , 
CHANGE `pn_format_type` `format_type` TINYINT( 4 ) NOT NULL DEFAULT '0',
CHANGE `pn_urltitle` `urltitle` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `pn_published_status` `published_status` TINYINT( 4 ) NULL DEFAULT '0',
CHANGE `pn_from` `ffrom` DATETIME NULL DEFAULT NULL ,
CHANGE `pn_to` `tto` DATETIME NULL DEFAULT NULL ,
CHANGE `pn_obj_status` `obj_status` VARCHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A',
CHANGE `pn_cr_date` `cr_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00' , 
CHANGE `pn_cr_uid` `cr_uid` INT( 11 ) NOT NULL DEFAULT '0',
CHANGE `pn_lu_date` `lu_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
CHANGE `pn_lu_uid` `lu_uid` INT( 11 ) NOT NULL DEFAULT '0',
CHANGE `pn_approver` `approver` INT( 11 ) NULL DEFAULT '0',
CHANGE `pn_weight` `weight` TINYINT( 4 ) NULL DEFAULT '0',
CHANGE `pn_pictures` `pictures` INT( 11 ) NULL DEFAULT '0'";
                foreach ($sqlStatements as $sql) {
                    $stmt = $connection->prepare($sql);
                    try {
                        $stmt->execute();
                    } catch (Exception $e) {
                    }   
                }

                if (!DBUtil::changeTable('news')) {
                    return '2.6.3';
                }
                HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
                $this->delVar('pdflink_tcpdfpath');
                $this->delVar('pdflink_tcpdflang');
                $this->setVar('itemsperadminpage', 15);
                $this->setVar('pdflink_enablecache', true);
				// enable variable for old shorturl scheme (display and main func not shown)
				$this->setVar('shorturls26x', true);
                if (ModUtil::available('Content')) {
                    Content_Installer::updateContentType('News');
                }
                $this->_invertHideAndComments();
                $this->fixStartSettings();
            case '3.0.0':
                // nothing to do
            case '3.0.1':
                // future plans
        }

        // Update successful
        return true;
    }