18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
40 Asset_Management::__construct($pm);
47 'description' =>
'The name of the bridge',
55 'description' =>
'The path the bridge is responsible for',
73 parent::_upgrade($current_version);
75 if (version_compare($current_version,
'0.2',
'<')) {
76 echo(
'UPGRADING SEARCH PAGE FROM '.$current_version.
"\n");
77 pre_echo(
'Updating File Bridge...');
81 $file_for_webpath = SQ_DATA_PATH.
'/private/asset_types/file_bridge/localised_screens/screen_paths.en';
82 if (is_file($file_for_webpath)) {
83 unlink($file_for_webpath);
86 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
87 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
90 $file_bridges = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'file_bridge', FALSE, TRUE);
93 foreach ($file_bridges as $id => $file_bridge) {
94 $bridge = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
95 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
96 if (!$bridge->saveWebPaths(Array(), FALSE)) {
97 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
98 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
100 pre_echo(
'UPGRADE FAILED - Could not save webpaths');
101 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
104 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bridge, TRUE);
110 pre_echo(
'Updated - '.$count.
' File Bridge(s)...');
112 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
113 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
116 pre_echo(
'FILE BRIDGES SUCCESSFULLY UPGRADED TO VERSION 0.2');
120 if (version_compare($current_version,
'0.3',
'<')) {
121 $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(),
'name'));
123 pre_echo(
'STARTING '.$asset_name.
' UPGRADE - TO VERSION 0.3');
124 $file_bridges = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($this->
getAssetType(), FALSE, TRUE);
126 foreach ($file_bridges as $assetid => $type_code) {
127 $asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
128 if (is_null($asset))
continue;
131 $path = $asset->attr(
'path');
133 echo(
'Detected File Bridge asset #'.$asset->id.
' with Path attribute "'.$asset->attr(
'path').
'"'.
"\n");
137 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
144 echo (
'******************************************************************************************************************'.
"\n");
145 echo (
"Security Updates\n");
146 echo(
'Paths of above assets are now restored to "data/public" for security purposes'.
"\n");
147 echo(
'If old paths are required and considered safe, please configure '.SQ_DATA_PATH.
'/private/conf/file_bridge.inc'.
"\n");
148 echo(
'******************************************************************************************************************'.
"\n");
150 pre_echo($asset_name.
' UPGRADE COMPLETE - FROM VERSION '.$current_version.
' TO 0.3');