Skip to content

Commit

Permalink
Added Update to ensure support with later versions of the SBL
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Feb 17, 2010
1 parent 257a333 commit 4260a56
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions extension.driver.php
Expand Up @@ -13,7 +13,7 @@ public function about(){
)
);
}

public function getSubscribedDelegates() {
return array(
array(
Expand All @@ -23,31 +23,59 @@ public function getSubscribedDelegates() {
)
);
}

public function initializeAdmin($context) {
$page = $context['parent']->Page;
$assets_path = '/extensions/referencelink/assets/';

// load autocomplete JS
$page->addScriptToHead(URL . $assets_path . 'referencelink.js', 200);

// load autocomplete styles
$page->addStylesheetToHead(URL . $assets_path . 'referencelink.css', 'screen', 100);
}

public function uninstall(){
$this->_Parent->Database->query("DROP TABLE `tbl_fields_referencelink`");
}

public function update($previousVersion){

public function update($previousVersion){

if(version_compare($previousVersion, '1.3', '<')){
try{
$fields = Symphony::Database()->fetchCol('field_id',
"SELECT `field_id` FROM `tbl_fields_referencelink`"
);
}
catch(Exception $e){
// Discard
}

if(is_array($fields) && !empty($fields)){
foreach($fields as $field_id){
try{
Symphony::Database()->query(
"ALTER TABLE `tbl_entries_data_{$field_id}`
CHANGE `relation_id` `relation_id` INT(11) UNSIGNED NULL DEFAULT NULL"
);
}
catch(Exception $e){
// Discard
}
}
}
}

if(version_compare($previousVersion, '1.2', '<')){
$this->_Parent->Database->query("ALTER TABLE `tbl_fields_referencelink` ADD `limit` INT(4) UNSIGNED NOT NULL DEFAULT '20'");
$this->_Parent->Database->query("ALTER TABLE `tbl_fields_referencelink` CHANGE `related_field_id` `related_field_id` VARCHAR(255) NOT NULL");
Symphony::Database()->query("ALTER TABLE `tbl_fields_referencelink` ADD `limit` INT(4) UNSIGNED NOT NULL DEFAULT '20'");
Symphony::Database()->query("ALTER TABLE `tbl_fields_referencelink` CHANGE `related_field_id` `related_field_id` VARCHAR(255) NOT NULL");
}



return true;
}

public function install(){
return $this->_Parent->Database->query(
"CREATE TABLE `tbl_fields_referencelink` (
Expand Down

0 comments on commit 4260a56

Please sign in to comment.