classes/install/Upgrade.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('install.Installer');
00018 
00019 class Upgrade extends Installer {
00020 
00026    function Upgrade($params, $installFile = 'upgrade.xml', $isPlugin = false) {
00027       parent::Installer($installFile, $params, $isPlugin);
00028    }
00029 
00030 
00035    function isUpgrade() {
00036       return true;
00037    }
00038 
00039    //
00040    // Upgrade actions
00041    //
00042 
00047    function rebuildSearchIndex() {
00048       import('search.PaperSearchIndex');
00049       PaperSearchIndex::rebuildIndex();
00050       return true;
00051    }
00052 
00057    function installBlockPlugins() {
00058       $pluginSettingsDao =& DAORegistry::getDAO('PluginSettingsDAO');
00059       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00060       $conferences =& $conferenceDao->getConferences();
00061 
00062       // Get conference IDs for insertion, including 0 for site-level
00063       $conferenceIds = array(0);
00064       while ($conference =& $conferences->next()) {
00065          $conferenceIds[] = $conference->getId();
00066          unset($conference);
00067       }
00068 
00069       $pluginNames = array(
00070          'DevelopedByBlockPlugin',
00071          'HelpBlockPlugin',
00072          'UserBlockPlugin',
00073          'RoleBlockPlugin',
00074          'LanguageToggleBlockPlugin',
00075          'NavigationBlockPlugin',
00076          'FontSizeBlockPlugin',
00077          'InformationBlockPlugin'
00078       );
00079       foreach ($conferenceIds as $conferenceId) {
00080          $i = 0;
00081          foreach ($pluginNames as $pluginName) {
00082             $pluginSettingsDao->updateSetting($conferenceId, 0, $pluginName, 'enabled', 'true', 'bool');
00083             $pluginSettingsDao->updateSetting($conferenceId, 0, $pluginName, 'seq', $i++, 'int');
00084             $pluginSettingsDao->updateSetting($conferenceId, 0, $pluginName, 'context', BLOCK_CONTEXT_RIGHT_SIDEBAR, 'int');
00085          }
00086       }
00087 
00088       return true;
00089    }
00090 
00096    function setConferencePrimaryLocales() {
00097       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00098       $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00099 
00100       // There was a bug in OCS 2.0 that resulted in a conference
00101       // primary locale setting of {$primaryLocale} (or truncated to
00102       // "{$pri"); in this case, the site primary locale should be
00103       // used as a fallback.
00104       $result =& $conferenceSettingsDao->retrieve('SELECT primary_locale FROM site');
00105       $siteLocale = 'en_US';
00106       while (!$result->EOF) {
00107          $row = $result->GetRowAssoc(false);
00108          $siteLocale = $row['primary_locale'];
00109          $result->MoveNext();
00110       }
00111       $result->Close();
00112       unset($result);
00113 
00114       $result =& $conferenceSettingsDao->retrieve('SELECT conference_id, setting_value FROM conference_settings WHERE setting_name = ?', array('primaryLocale'));
00115       while (!$result->EOF) {
00116          $row = $result->GetRowAssoc(false);
00117          $newLocale = $row['setting_value'];
00118 
00119          // Fix the bug mentioned above.
00120          if (empty($newLocale) || strpos($newLocale, '{$pr') === 0) {
00121             $newLocale = $siteLocale;
00122          }
00123 
00124          // Set the primary locale value in the conferences table.
00125          $conferenceDao->update('UPDATE conferences SET primary_locale = ? WHERE conference_id = ?', array($newLocale, $row['conference_id']));
00126          $result->MoveNext();
00127       }
00128       $conferenceDao->update('UPDATE conferences SET primary_locale = ? WHERE primary_locale IS NULL OR primary_locale = ?', array(INSTALLER_DEFAULT_LOCALE, ''));
00129       $result->Close();
00130       return true;
00131    }
00132 
00137    function migratePaperLocations() {
00138       $paperDao =& DAORegistry::getDAO('PaperDAO');
00139       $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00140       $roomDao =& DAORegistry::getDAO('RoomDAO');
00141 
00142       $lastSchedConfId = null;
00143       $buildingId = null;
00144 
00145       $result =& $paperDao->retrieve("SELECT p.paper_id, c.primary_locale, sc.sched_conf_id, p.location FROM papers p, published_papers pp, sched_confs sc, conferences c WHERE p.paper_id = pp.paper_id AND p.sched_conf_id = sc.sched_conf_id AND sc.conference_id = c.conference_id AND location IS NOT NULL AND location <> '' ORDER BY sched_conf_id");
00146       while (!$result->EOF) {
00147          $row = $result->GetRowAssoc(false);
00148 
00149          $paperId = $row['paper_id'];
00150          $schedConfId = $row['sched_conf_id'];
00151          $locale = $row['primary_locale'];
00152          $location = $row['location'];
00153 
00154          if ($schedConfId !== $lastSchedConfId) {
00155             // Create a default building
00156             $defaultText = __('common.default');
00157             $building = new Building();
00158             $building->setSchedConfId($schedConfId);
00159             $building->setName($defaultText, $locale);
00160             $building->setAbbrev($defaultText, $locale);
00161             $building->setDescription($defaultText, $locale);
00162             $buildingId = $buildingDao->insertBuilding($building);
00163             unset($building);
00164             $rooms = array();
00165          }
00166 
00167          if (!isset($rooms[$location])) {
00168             $room = new Room();
00169             $room->setBuildingId($buildingId);
00170             $room->setName($location, $locale);
00171             $room->setAbbrev($location, $locale);
00172             $room->setDescription($location, $locale);
00173             $roomId = $roomDao->insertRoom($room);
00174 
00175             $rooms[$location] =& $room;
00176             unset($room);
00177          } else {
00178             $room =& $rooms[$location];
00179             $roomId = $room->getId();
00180             unset($room);
00181          }
00182 
00183          $paperDao->update('UPDATE published_papers SET room_id = ? WHERE paper_id = ?', array($roomId, $paperId));
00184 
00185          $result->MoveNext();
00186          $lastSchedConfId = $schedConfId;
00187 
00188       }
00189       $result->Close();
00190       unset($result);
00191 
00192       return true;
00193    }
00194 
00200    function localizeConferenceSettings() {
00201       $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00202       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00203 
00204       $settingNames = array(
00205          // Setup page 1
00206          'title' => 'title',
00207          'conferenceDescription' => 'description',
00208          'archiveAccessPolicy' => 'archiveAccessPolicy',
00209          'copyrightNotice' => 'copyrightNotice',
00210          'privacyStatement' => 'privacyStatement',
00211          'customAboutItems' => 'customAboutItems',
00212          // Setup page 2
00213          'additionalHomeContent' => 'additionalHomeContent',
00214          'homepageImage' => 'homepageImage',
00215          'readerInformation' => 'readerInformation',
00216          'presenterInformation' => 'presenterInformation',
00217          'announcementsIntroduction' => 'announcementsIntroduction',
00218          // Setup page 3
00219          'homeHeaderLogoImage' => 'homeHeaderLogoImage',
00220          'homeHeaderTitleType' => 'homeHeaderTitleType',
00221          'homeHeaderTitle' => 'homeHeaderTitle',
00222          'homeHeaderTitleImage' => 'homeHeaderTitleImage',
00223          'pageHeaderTitleType' => 'pageHeaderTitleType',
00224          'pageHeaderTitle' => 'pageHeaderTitle',
00225          'pageHeaderTitleImage' => 'pageHeaderTitleImage',
00226          'navItems' => 'navItems',
00227          'conferencePageHeader' => 'conferencePageHeader',
00228          'conferencePageFooter' => 'conferencePageFooter',
00229          // Setup page 4
00230          // Setup page 5
00231          // Setup page 6
00232          'searchDescription' => 'searchDescription',
00233          'searchKeywords' => 'searchKeywords',
00234          'customHeaders' => 'customHeaders',
00235          // Registration policies
00236          'registrationAdditionalInformation' => 'registrationAdditionalInformation',
00237          'delayedOpenAccessPolicy' => 'delayedOpenAccessPolicy',
00238          'presenterSelfArchivePolicy' => 'presenterSelfArchivePolicy'
00239       );
00240 
00241       foreach ($settingNames as $oldName => $newName) {
00242          $result =& $conferenceDao->retrieve('SELECT c.conference_id, c.primary_locale FROM conferences c, conference_settings cs WHERE c.conference_id = cs.conference_id AND cs.setting_name = ? AND (cs.locale IS NULL OR cs.locale = ?)', array($oldName, ''));
00243          while (!$result->EOF) {
00244             $row = $result->GetRowAssoc(false);
00245             $conferenceSettingsDao->update('UPDATE conference_settings SET locale = ?, setting_name = ? WHERE conference_id = ? AND setting_name = ? AND (locale IS NULL OR locale = ?)', array($row['primary_locale'], $newName, $row['conference_id'], $oldName, ''));
00246             $result->MoveNext();
00247          }
00248          $result->Close();
00249          unset($result);
00250       }
00251 
00252       return true;
00253    }
00254 
00260    function localizeSchedConfSettings() {
00261       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00262       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00263 
00264       $settingNames = array(
00265          // Setup page 1
00266          'schedConfIntroduction' => 'introduction',
00267          'schedConfOverview' => 'overview',
00268          'emailSignature' => 'emailSignature',
00269          'sponsorNote' => 'sponsorNote',
00270          'contributorNote' => 'contributorNote',
00271          // Setup page 2
00272          'cfpMessage' => 'cfpMessage',
00273          'presenterGuidelines' => 'presenterGuidelines',
00274          'submissionChecklist' => 'submissionChecklist',
00275          'metaDisciplineExamples' => 'metaDisciplineExamples',
00276          'metaSubjectClassTitle' => 'metaSubjectClassTitle',
00277          'metaSubjectExamples' => 'metaSubjectExamples',
00278          'metaCoverageGeoExamples' => 'metaCoverageGeoExamples',
00279          'metaCoverageChronExamples' => 'metaCoverageChronExamples',
00280          'metaCoverageResearchSampleExamples' => 'metaCoverageResearchSampleExamples',
00281          'metaTypeExamples' => 'metaTypeExamples',
00282          'metaCitations' => 'metaCitations',
00283          // Setup page 3
00284          'reviewPolicy' => 'reviewPolicy',
00285          'reviewGuidelines' => 'reviewGuidelines'
00286       );
00287 
00288       foreach ($settingNames as $oldName => $newName) {
00289          $result =& $schedConfDao->retrieve('SELECT sc.sched_conf_id, c.primary_locale FROM sched_confs sc, conferences c, sched_conf_settings scs WHERE c.conference_id = sc.conference_id AND sc.sched_conf_id = scs.sched_conf_id AND scs.setting_name = ? AND (scs.locale IS NULL OR scs.locale = ?)', array($oldName, ''));
00290          while (!$result->EOF) {
00291             $row = $result->GetRowAssoc(false);
00292             $schedConfSettingsDao->update('UPDATE sched_conf_settings SET locale = ?, setting_name = ? WHERE sched_conf_id = ? AND setting_name = ? AND (locale IS NULL OR locale = ?)', array($row['primary_locale'], $newName, $row['sched_conf_id'], $oldName, ''));
00293             $result->MoveNext();
00294          }
00295          $result->Close();
00296          unset($result);
00297       }
00298 
00299       return true;
00300    }
00301 
00306    function setGalleyLocales() {
00307       $paperGalleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
00308       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00309 
00310       $result =& $conferenceDao->retrieve('SELECT g.galley_id, c.primary_locale FROM conferences c, sched_confs sc, papers p, paper_galleys g WHERE p.sched_conf_id = sc.sched_conf_id AND sc.conference_id = c.conference_id AND g.paper_id = p.paper_id AND (g.locale IS NULL OR g.locale = ?)', '');
00311       while (!$result->EOF) {
00312          $row = $result->GetRowAssoc(false);
00313          $paperGalleyDao->update('UPDATE paper_galleys SET locale = ? WHERE galley_id = ?', array($row['primary_locale'], $row['galley_id']));
00314          $result->MoveNext();
00315       }
00316       $result->Close();
00317       unset($result);
00318 
00319       return true;
00320    }
00321 
00326    function setReviewMode() {
00327       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00328       $paperDao =& DAORegistry::getDAO('PaperDAO');
00329 
00330       $schedConfs =& $schedConfDao->getSchedConfs();
00331       while ($schedConf =& $schedConfs->next()) {
00332          $papers =& $paperDao->getPapersBySchedConfId($schedConf->getId());
00333          $reviewMode = $schedConf->getSetting('reviewMode');
00334          $paperDao->update('UPDATE papers SET review_mode = ? WHERE sched_conf_id = ?', array((int) $reviewMode, $schedConf->getId()));
00335          unset($schedConf);
00336       }
00337       return true;
00338    }
00339 
00349    function dropAllIndexes() {
00350       $siteDao =& DAORegistry::getDAO('SiteDAO');
00351       $dict = NewDataDictionary($siteDao->_dataSource);
00352       $dropIndexSql = array();
00353 
00354       // This is a list of tables that were used in 2.0 (i.e.
00355       // before the way indexes were used was changed). All indexes
00356       // from these tables will be dropped.
00357       $tables = array(
00358          'versions', 'site', 'site_settings', 'scheduled_tasks',
00359          'sessions', 'conference_settings', 'sched_conf_settings',
00360          'plugin_settings', 'roles',
00361          'track_directors',
00362          'review_stages', 'paper_html_galley_images',
00363          'email_templates_default_data', 'email_templates_data',
00364          'paper_search_object_keywords', 'oai_resumption_tokens',
00365          'group_memberships'
00366       );
00367 
00368       // Assemble a list of indexes to be dropped
00369       foreach ($tables as $tableName) {
00370          $indexes = $dict->MetaIndexes($tableName);
00371          if (is_array($indexes)) foreach ($indexes as $indexName => $indexData) {
00372             $dropIndexSql = array_merge($dropIndexSql, $dict->DropIndexSQL($indexName, $tableName));
00373          }
00374       }
00375 
00376       // Execute the DROP INDEX statements.
00377       foreach ($dropIndexSql as $sql) {
00378          $siteDao->update($sql);
00379       }
00380 
00381       // Second run: Only return primary indexes. This is necessary
00382       // so that primary indexes can be dropped by MySQL.
00383       foreach ($tables as $tableName) {
00384          $indexes = $dict->MetaIndexes($tableName, true);
00385          if (!empty($indexes)) switch(Config::getVar('database', 'driver')) {
00386             case 'mysql':
00387                $siteDao->update("ALTER TABLE $tableName DROP PRIMARY KEY");
00388                break;
00389          }
00390       }
00391 
00392 
00393       return true;
00394    }
00395 
00400    function ensureSupportedLocales() {
00401       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00402       $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00403       $result =& $conferenceDao->retrieve(
00404          'SELECT  c.conference_id,
00405             c.primary_locale
00406          FROM  conferences c
00407             LEFT JOIN conference_settings cs ON (cs.conference_id = c.conference_id AND cs.setting_name = ?)
00408          WHERE cs.setting_name IS NULL',
00409          array('supportedLocales')
00410       );
00411       while (!$result->EOF) {
00412          $row = $result->GetRowAssoc(false);
00413          $conferenceSettingsDao->updateSetting(
00414             $row['conference_id'],
00415             'supportedLocales',
00416             array($row['primary_locale']),
00417             'object',
00418             false
00419          );
00420          $result->MoveNext();
00421       }
00422       $result->Close();
00423       unset($result);
00424       return true;
00425    }
00426 
00430    function changePresenterInUserEmailTemplates() {
00431       $emailTemplateDAO =& DAORegistry::getDAO('EmailTemplateDAO');
00432 
00433       // Reset email templates
00434       $result =& $emailTemplateDAO->retrieve('SELECT email_key, locale, body, subject FROM email_templates_data');
00435       while (!$result->EOF) {
00436          $row = $result->GetRowAssoc(false);
00437 
00438          $newBody = str_replace('{$presenterName}', '{$authorName}', $row['body']);
00439          $newBody = str_replace('{$presenterUsername}', '{$authorUsername}', $newBody);
00440          $newSubject = str_replace('{$presenterName}', '{$authorName}', $row['subject']);
00441          $newSubject = str_replace('{$presenterUsername}', '{$authorUsername}', $newSubject);
00442 
00443          $emailTemplateDAO->update('UPDATE email_templates_data SET body = ?, subject = ? WHERE email_key = ? AND locale = ?', array($newBody, $newSubject, $row['email_key'], $row['locale']));
00444          $result->MoveNext();
00445       }
00446       $result->Close();
00447       unset($result);
00448       
00449       // Reset default email templates
00450       $result =& $emailTemplateDAO->retrieve('SELECT email_key, locale, body, subject FROM email_templates_default_data');
00451       while (!$result->EOF) {
00452          $row = $result->GetRowAssoc(false);
00453 
00454          $newBody = str_replace('{$presenterName}', '{$authorName}', $row['body']);
00455          $newBody = str_replace('{$presenterUsername}', '{$authorUsername}', $newBody);
00456          $newSubject = str_replace('{$presenterName}', '{$authorName}', $row['subject']);
00457          $newSubject = str_replace('{$presenterUsername}', '{$authorUsername}', $newSubject);
00458 
00459          $emailTemplateDAO->update('UPDATE email_templates_default_data SET body = ?, subject = ? WHERE email_key = ? AND locale = ?', array($newBody, $newSubject, $row['email_key'], $row['locale']));
00460          $result->MoveNext();
00461       }
00462       $result->Close();
00463       unset($result);
00464 
00465 
00466       return true;
00467    }
00468 
00474    function upgradePaperType() {
00475       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00476       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00477       $paperTypeDao =& DAORegistry::getDAO('PaperTypeDAO');
00478       $paperTypeEntryDao =& DAORegistry::getDAO('PaperTypeEntryDAO');
00479 
00480       $conferences =& $conferenceDao->getConferences();
00481 
00482       while ($conference =& $conferences->next()) {
00483          $locales = array_keys($conference->getSupportedLocaleNames());
00484          $locales[] = $conference->getPrimaryLocale();
00485          $locales = array_unique($locales);
00486 
00487          foreach ($locales as $locale) AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_DEFAULT), $locale);
00488 
00489          $schedConfs =& $schedConfDao->getSchedConfsByConferenceId($conference->getId());
00490          while ($schedConf =& $schedConfs->next()) {
00491             $allowIndividualSubmissions = $schedConf->getSetting('allowIndividualSubmissions');
00492             $allowPanelSubmissions = $schedConf->getSetting('allowPanelSubmissions');
00493             if ($allowIndividualSubmissions || $allowPanelSubmissions) {
00494                $paperType =& $paperTypeDao->build($schedConf->getId());
00495             }
00496             if ($allowIndividualSubmissions) {
00497                $paperTypeEntry =& $paperTypeEntryDao->newDataObject();
00498                foreach ($locales as $locale) {
00499                   $paperTypeEntry->setName(__('default.paperType.individual.name', array(), $locale), $locale);
00500                   $paperTypeEntry->setDescription(__('default.paperType.individual.description', array(), $locale), $locale);
00501                }
00502                $paperTypeEntry->setControlledVocabId($paperType->getId());
00503                $paperTypeEntryDao->insertObject($paperTypeEntry);
00504                $schedConfDao->update(
00505                   'INSERT INTO paper_settings (setting_name, setting_type, paper_id, locale, setting_value) SELECT  ?, ?, paper_id, ?, ? FROM papers WHERE sched_conf_id = ? AND paper_type = ?',
00506                   array(
00507                      'sessionType',
00508                      'int',
00509                      '',
00510                      (int) $paperTypeEntry->getId(),
00511                      (int) $schedConf->getId(),
00512                      0 // SUBMISSION_TYPE_SINGLE (since removed)
00513                   )
00514                );
00515                unset($paperTypeEntry);
00516             }
00517             if ($allowPanelSubmissions) {
00518                $paperTypeEntry =& $paperTypeEntryDao->newDataObject();
00519                foreach ($locales as $locale) {
00520                   $paperTypeEntry->setName(__('default.paperType.panel.name', array(), $locale), $locale);
00521                   $paperTypeEntry->setDescription(__('default.paperType.panel.description', array(), $locale), $locale);
00522                }
00523                $paperTypeEntry->setControlledVocabId($paperType->getId());
00524                $paperTypeEntryDao->insertObject($paperTypeEntry);
00525                $schedConfDao->update(
00526                   'INSERT INTO paper_settings (setting_name, setting_type, paper_id, locale, setting_value) SELECT  ?, ?, paper_id, ?, ? FROM papers WHERE sched_conf_id = ? AND paper_type = ?',
00527                   array(
00528                      'sessionType',
00529                      'int',
00530                      '',
00531                      (int) $paperTypeEntry->getId(),
00532                      (int) $schedConf->getId(),
00533                      1 // SUBMISSION_TYPE_PANEL (since removed)
00534                   )
00535                );
00536                unset($paperTypeEntry);
00537             }
00538             unset($schedConf, $paperType);
00539          }
00540          unset($schedConfs, $conference);
00541       }
00542 
00543       return true;
00544    }
00545 
00550    function localizeProgramSettings() {
00551       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00552       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00553 
00554       $settings = array('program', 'programFile', 'programFileTitle');
00555 
00556       foreach ($settings as $setting) {
00557          $result =& $schedConfDao->retrieve('SELECT sc.sched_conf_id, c.primary_locale FROM sched_confs sc, conferences c, sched_conf_settings scs WHERE c.conference_id = sc.conference_id AND sc.sched_conf_id = scs.sched_conf_id AND scs.setting_name = ? AND (scs.locale IS NULL OR scs.locale = ?)', array($setting, ''));
00558          while (!$result->EOF) {
00559             $row = $result->GetRowAssoc(false);
00560             $schedConfSettingsDao->update('UPDATE sched_conf_settings SET locale = ? WHERE sched_conf_id = ? AND setting_name = ? AND (locale IS NULL OR locale = ?)', array($row['primary_locale'], $row['sched_conf_id'], $setting, ''));
00561             $result->MoveNext();
00562          }
00563          $result->Close();
00564          unset($result);
00565       }
00566 
00567       return true;
00568    }
00569 
00574    function updateReviewDeadlineSettings() {
00575       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00576       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00577 
00578 
00579       $result =& $schedConfDao->retrieve('SELECT scs.sched_conf_id FROM sched_conf_settings scs WHERE scs.setting_name = ?', array('numWeeksPerReview'));
00580       while (!$result->EOF) {
00581          $row = $result->GetRowAssoc(false);
00582          $schedConfSettingsDao->update('UPDATE sched_conf_settings SET setting_name = ? WHERE sched_conf_id = ? AND setting_name = ?',
00583                      array('numWeeksPerReviewRelative', $row['sched_conf_id'], 'numWeeksPerReview'));
00584          $schedConfDao->update(
00585             'INSERT INTO sched_conf_settings (sched_conf_id, locale, setting_name, setting_value, setting_type) VALUES (?, ?, ?, ?, ?)',
00586             array(
00587                $row['sched_conf_id'],
00588                '',
00589                'reviewDeadlineType',
00590                REVIEW_DEADLINE_TYPE_RELATIVE,
00591                'int',
00592             )
00593          );
00594          $result->MoveNext();
00595       }
00596       $result->Close();
00597       unset($result);
00598 
00599       return true;
00600    }
00601    
00606    function cleanTitles() {
00607       $paperDao =& DAORegistry::getDAO('PaperDAO');
00608       $punctuation = array ("\"", "\'", ",", ".", "!", "?", "-", "$", "(", ")");
00609 
00610       $result =& $paperDao->retrieve('SELECT paper_id, locale, setting_value FROM paper_settings WHERE setting_name = ?', "title");
00611       while (!$result->EOF) {
00612          $row = $result->GetRowAssoc(false);
00613          $cleanTitle = str_replace($punctuation, "", $row['setting_value']);
00614          $paperDao->update('INSERT INTO paper_settings (paper_id, locale, setting_name, setting_value, setting_type) VALUES (?, ?, ?, ?, ?)', array((int) $row['paper_id'], $row['locale'], "cleanTitle", $cleanTitle, "string"));
00615          $result->MoveNext();
00616       }
00617       $result->Close();
00618       unset($result);
00619       
00620       
00621       return true;
00622    }
00623 
00630    function cleanImageAlts() {
00631       $imageSettings = array(
00632          'homeHeaderTitleImage' => 'homeHeaderTitleImageAltText',
00633          'homeHeaderLogoImage' => 'homeHeaderLogoImageAltText',
00634          'homepageImage' => 'homepageImageAltText',
00635          'pageHeaderTitleImage' => 'pageHeaderTitleImageAltText',
00636          'pageHeaderLogoImage' => 'pageHeaderLogoImageAltText'
00637       );
00638       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00639       $conferences =& $conferenceDao->getConferences();
00640       while ($conference =& $conferences->next()) {
00641          foreach ($imageSettings as $imageSettingName => $newSettingName) {
00642             $imageSetting = $conference->getSetting($imageSettingName);
00643             $newSetting = array();
00644             if ($imageSetting) foreach ($imageSetting as $locale => $setting) {
00645                if (isset($setting['altText'])) $newSetting[$locale] = $setting['altText'];
00646             }
00647             if (!empty($newSetting)) {
00648                $conference->updateSetting($newSettingName, $newSetting, 'string', true);
00649             }
00650          }
00651          unset($conference);
00652       }
00653       return true;
00654    }
00655    
00660    function addPluginVersions() {
00661       $versionDao =& DAORegistry::getDAO('VersionDAO'); 
00662       import('site.VersionCheck');
00663       $categories = PluginRegistry::getCategories();
00664       foreach ($categories as $category) {
00665          PluginRegistry::loadCategory($category, true);
00666          $plugins = PluginRegistry::getPlugins($category);
00667          if (is_array($plugins)) foreach ($plugins as $plugin) {
00668             $versionFile = $plugin->getPluginPath() . '/version.xml';
00669             
00670             if (FileManager::fileExists($versionFile)) {
00671                $versionInfo =& VersionCheck::parseVersionXML($versionFile);
00672                $pluginVersion = $versionInfo['version'];    
00673                $pluginVersion->setCurrent(1);
00674                $versionDao->insertVersion($pluginVersion);
00675             }  else {
00676                $pluginVersion = new Version();
00677                $pluginVersion->setMajor(1);
00678                $pluginVersion->setMinor(0);
00679                $pluginVersion->setRevision(0);
00680                $pluginVersion->setBuild(0);
00681                $pluginVersion->setDateInstalled(Core::getCurrentDate());
00682                $pluginVersion->setCurrent(1);
00683                $pluginVersion->setProductType('plugins.' . $category);
00684                $pluginVersion->setProduct(basename($plugin->getPluginPath()));
00685                $versionDao->insertVersion($pluginVersion);
00686             }
00687          }
00688       }
00689       
00690       return true;
00691    }
00692 }
00693 
00694 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7