18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
40 Asset_Management::__construct($pm);
47 'description' =>
'The name of the file (eg. myfile.zip)',
51 'allow_unrestricted' => Array(
55 'description' =>
'Allows the use of the __data URL if true',
56 'parameters' => Array(
'allow_empty' => FALSE),
64 'description' =>
'Friendly name for the file',
65 'is_contextable' => TRUE,
83 if (!parent::_upgrade($current_version))
return FALSE;
85 if (version_compare($current_version,
'0.4',
'<')) {
86 pre_echo(
'UPGRADING FILE ASSETS - FROM VERSION '.$current_version);
87 $children = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($this->
getAssetType(), FALSE);
88 foreach ($children as $assetid) {
89 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
90 $attr = $asset->attr(
'title');
92 $asset->setAttrValue(
'title', $asset->attr(
'name'));
93 $asset->saveAttributes();
95 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset, TRUE);
99 if (version_compare($current_version,
'0.5',
'<')) {
100 pre_echo(
'UPGRADING FILE ASSETS - FROM VERSION '.$current_version);
101 $where =
'type_code IN (
104 WHERE inhd_type_code = :type_code
106 $where .=
' AND (status = \''.SQ_STATUS_EDITING.
'\' OR status = \
''.SQ_STATUS_EDITING_APPROVAL.
'\' OR status = \
''.SQ_STATUS_EDITING_APPROVED.
'\')
';
107 $sql = 'SELECT assetid FROM
'.SQ_TABLE_RUNNING_PREFIX.'ast WHERE
'.$where;
108 $query = MatrixDAL::preparePdoQuery($sql);
109 MatrixDAL::bindValueToPdo($query, 'type_code
', $this->getAssetType());
110 $children = MatrixDAL::executePdoAssoc($query, 0);
111 if(!empty($children)) {
112 foreach ($children as $assetid) {
113 $asset = $GLOBALS['SQ_SYSTEM
']->am->getAsset($assetid);
114 $url = $asset->getURL();
115 if(empty($asset)) continue;
116 if(empty($url)) continue;
117 pre_echo('FILE #
'.$asset->id.' UPDATED
');
118 $asset->updateLookups();
119 $GLOBALS['SQ_SYSTEM
']->am->forgetAsset($asset, TRUE);
122 pre_echo('FILE ASSETS UPGRADE COMPLETE - VERSION 0.5
');
123 }//end if version 0.5