Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 1ddd729

Browse files
committed
ENH: refs #0290. Adding a default assetstore by convention not config.
1 parent 55f2188 commit 1ddd729

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

core/controllers/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function indexAction()
153153
}
154154

155155
// get assetstore data
156-
$defaultAssetStoreId = Zend_Registry::get('configGlobal')->defaultassetstore->id;
156+
$defaultAssetStoreId = $this->Assetstore->getDefault()->getKey();
157157
$assetstores = $this->Assetstore->getAll();
158158
$defaultSet = false;
159159
foreach($assetstores as $key => $assetstore)

core/controllers/components/UploadComponent.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ public function createLinkItem($userDao, $name, $url, $parent = null)
162162
$bitstreamDao->setSizebytes(0);
163163
$bitstreamDao->setChecksum(' ');
164164

165-
$defaultAssetStoreId = Zend_Registry::get('configGlobal')->defaultassetstore->id;
166-
$bitstreamDao->setAssetstoreId($defaultAssetStoreId);
167-
$assetstoreDao = $assetstoreModel->load($defaultAssetStoreId);
165+
$assetstoreDao = $assetstoreModel->getDefault();
166+
$bitstreamDao->setAssetstoreId($assetstoreDao->getKey());
168167

169168
$itemRevisionModel->addBitstream($itemRevisionDao, $bitstreamDao);
170169

@@ -238,9 +237,8 @@ public function createUploadedItem($userDao, $name, $path, $parent = null, $lice
238237
$bitstreamDao->setChecksum($filemd5);
239238
$bitstreamDao->fillPropertiesFromPath();
240239

241-
$defaultAssetStoreId = Zend_Registry::get('configGlobal')->defaultassetstore->id;
242-
$bitstreamDao->setAssetstoreId($defaultAssetStoreId);
243-
$assetstoreDao = $assetstoreModel->load($defaultAssetStoreId);
240+
$assetstoreDao = $assetstoreModel->getDefault();
241+
$bitstreamDao->setAssetstoreId($assetstoreDao->getKey());
244242

245243
if($assetstoreDao == false)
246244
{
@@ -347,9 +345,8 @@ public function createNewRevision($userDao, $name, $path, $item_revision, $chang
347345
$bitstreamDao->setChecksum($filemd5);
348346
$bitstreamDao->fillPropertiesFromPath();
349347

350-
$defaultAssetStoreId = Zend_Registry::get('configGlobal')->defaultassetstore->id;
351-
$bitstreamDao->setAssetstoreId($defaultAssetStoreId);
352-
$assetstoreDao = $assetstoreModel->load($defaultAssetStoreId);
348+
$assetstoreDao = $assetstoreModel->getDefault();
349+
$bitstreamDao->setAssetstoreId($assetstoreDao->getKey());
353350

354351
// Upload the bitstream if necessary (based on the assetstore type)
355352
$this->uploadBitstream($bitstreamDao, $assetstoreDao);

core/models/base/AssetstoreModelBase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,17 @@ public function delete($dao)
149149
parent::delete($dao);
150150
}// delete
151151

152+
/**
153+
* This function returns the default assetstore in the database. This
154+
* is assumed to be named "Default" and is selected as such. If there
155+
* is no assetsore we fail misserably, if there are more than one then
156+
* we only return the "first."
157+
* @return the default assetstore
158+
*/
159+
public function getDefault()
160+
{
161+
$found = $this->findBy('name', 'Default');
162+
return $found[0];
163+
} // end getDefault
164+
152165
} // end class AssetstoreModelBase

core/public/js/admin/admin.index.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@
77
$("#tabsGeneric").show();
88
$('img.tabsLoading').hide()
99

10-
$('a.defaultAssetstoreLink').click(function(){
11-
$.post(json.global.webroot+'/assetstore/defaultassetstore', {submitDefaultAssetstore: true, element: $(this).attr('element')},
12-
function(data) {
13-
jsonResponse = jQuery.parseJSON(data);
14-
if(jsonResponse==null)
15-
{
16-
createNotive('Error',4000);
17-
return;
18-
}
19-
createNotive(jsonResponse[1],1500);
20-
window.location.replace(json.global.webroot+'/admin#tabs-assetstore');
21-
window.location.reload();
22-
});
23-
});
24-
2510
$('a.removeAssetstoreLink').click(function()
2611
{
2712
var element = $(this).attr('element');

core/views/admin/index.phtml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,7 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/jquery/jquery.c
7878
{
7979
echo "<div class='assetstoreElement'>
8080
<b><span class='assetstoreName'>{$assetstore->getName()}</span></b>
81-
(";
82-
if($assetstore->default)
83-
{
84-
echo "<span class='defaultAssetstore' element='{$assetstore->getKey()}'>default assetstore</span>";
85-
}
86-
else
87-
{
88-
echo "<a class='defaultAssetstoreLink' element='{$assetstore->getKey()}'>set as default</a>";
89-
}
90-
echo ")<br/>";
81+
<br/>";
9182
if($assetstore->totalSpaceText==false)
9283
{
9384
echo "<b>Unable to access assetstore</b>";

0 commit comments

Comments
 (0)