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

Commit 5adf0ca

Browse files
author
Charles Marion
committed
ENH: 0009638: Add uploaded link
1 parent c2d57bf commit 5adf0ca

File tree

11 files changed

+77
-27
lines changed

11 files changed

+77
-27
lines changed

core/AppController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function preDispatch()
7070
}
7171
$this->userSession = $user;
7272
$this->view->recentItems = array();
73+
$this->view->showUploadedLink = false;
7374
if($user->Dao != null && $user->Dao instanceof UserDao)
7475
{
7576
if($fc->getRequest()->getControllerName() != 'install' && $fc->getRequest()->getControllerName() != 'error' && $user->Dao->isAdmin() && $this->isUpgradeNeeded())
@@ -80,6 +81,11 @@ public function preDispatch()
8081
{
8182
$this->view->needUpgrade = false;
8283
}
84+
85+
if(!empty($user->uploaded))
86+
{
87+
$this->view->showUploadedLink = true;
88+
}
8389
$this->logged = true;
8490
$this->view->logged = true;
8591
$user->Dao->lastAction = date('c');

core/controllers/BrowseController.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,14 @@ public function movecopyAction()
8383
throw new Zend_Exception("Unable to load destination");
8484
}
8585

86-
//TODO
87-
/*
8886
foreach($folders as $folder)
89-
{
90-
91-
if(isset($copySubmit))
87+
{
88+
if(!isset($copySubmit))
9289
{
93-
94-
}
95-
else
96-
{
97-
90+
$this->Folder->move($folder, $destination);
9891
}
9992
}
100-
*/
93+
10194
foreach($items as $item)
10295
{
10396
if(isset($copySubmit))
@@ -325,6 +318,7 @@ public function uploadedAction()
325318
{
326319
$this->_redirect('/');
327320
}
321+
$this->view->activemenu = 'uploaded'; // set the active menu
328322
$this->view->items = array();
329323
$this->view->header = $this->t('Uploaded Files');
330324
$this->view->Date = $this->Component->Date;

core/controllers/CommunityController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ function manageAction()
148148
}//end ajax posts
149149

150150
//init forms
151-
$formInfo->setAction($this->view->webroot.'/community/manage?communityId = '.$communityId);
152-
$formCreateGroup->setAction($this->view->webroot.'/community/manage?communityId = '.$communityId);
151+
$formInfo->setAction($this->view->webroot.'/community/manage?communityId='.$communityId);
152+
$formCreateGroup->setAction($this->view->webroot.'/community/manage?communityId='.$communityId);
153153
$name = $formInfo->getElement('name');
154154
$name->setValue($communityDao->getName());
155155
$description = $formInfo->getElement('description');

core/controllers/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class UserController extends AppController
1010
/** Init Controller */
1111
function init()
1212
{
13-
$this->view->activemenu = 'user'; // set the active menu
1413
$actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
1514
if(isset($actionName) && (is_numeric($actionName) || strlen($actionName) == 32)) // This is tricky! and for Cassandra for now
1615
{
@@ -422,6 +421,7 @@ public function userpageAction()
422421
elseif(!isset($user_id))
423422
{
424423
$userDao = $this->userSession->Dao;
424+
$this->view->activemenu = 'user'; // set the active menu
425425
}
426426
else
427427
{

core/layouts/layout.phtml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,16 @@
160160
<li <?php if($this->activemenu=='browse') {echo 'class="active"';} ?> onclick="location.replace('<?php echo $this->webroot?>/browse');" ><a href="<?php echo $this->webroot?>/browse"><img alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/data.png" /><span> <?php echo $this->t('Data');?></span></a></li>
161161
<li <?php if($this->activemenu=='community') {echo 'class="active"';} ?> onclick="location.replace('<?php echo $this->webroot?>/community');" ><a href="<?php echo $this->webroot?>/community"><img alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/community.png" /><span> <?php echo $this->t('Communities');?></span></a></li>
162162
<li id="menuUserInfo" <?php if($this->activemenu=='user') {echo 'class="active"';} ?> ><a href="javascript:;"><img alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/upload.png" /><span> <?php echo $this->t('My Uploads');?></span></a></li>
163-
</ul>
163+
164+
<?php
165+
if($this->showUploadedLink)
166+
{
167+
?>
168+
<li <?php if($this->activemenu=='uploaded') {echo 'class="active"';} ?> onclick="location.replace('<?php echo $this->webroot?>/browse/uploaded');" ><a href="<?php echo $this->webroot?>/browse/uploaded"><img alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/addfile.png" /><span> <?php echo $this->t('Uploaded files');?></span></a></li>
169+
<?php
170+
}
171+
?>
172+
</ul>
164173
<hr/>
165174
<?php
166175
if(isset($this->recentItems)&&!empty($this->recentItems))

core/models/base/AssetstoreModelBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function delete($dao)
3232
}
3333
$bitreams = $dao->getBitstreams();
3434
$items = array();
35-
foreach ($bitreams as $key => $bitstream)
35+
foreach($bitreams as $key => $bitstream)
3636
{
3737
$revision = $bitstream->getItemrevision();
3838
if(empty($revision))
@@ -51,7 +51,7 @@ public function delete($dao)
5151

5252
$modelLoader = new MIDAS_ModelLoader();
5353
$item_model = $modelLoader->loadModel('Item');
54-
foreach ($items as $item)
54+
foreach($items as $item)
5555
{
5656
$item_model->delete($item);
5757
}

core/models/base/BitstreamModelBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct()
2020
'path' => array('type' => MIDAS_DATA),
2121
'assetstore_id' => array('type' => MIDAS_DATA),
2222
'date' => array('type' => MIDAS_DATA),
23-
'itemrevision' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'ItemRevision', 'parent_column'=> 'itemrevision_id', 'child_column' => 'itemrevision_id'),
23+
'itemrevision' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'ItemRevision', 'parent_column' => 'itemrevision_id', 'child_column' => 'itemrevision_id'),
2424
'assetstore' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Assetstore', 'parent_column' => 'assetstore_id', 'child_column' => 'assetstore_id'),
2525
);
2626
$this->initialize(); // required

core/models/base/FolderModelBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ abstract function getSizeFiltered($folders, $userDao = null, $policy = 0);
3737
abstract function getCommunity($folder);
3838
abstract function getUser($folder);
3939
abstract function addItem($folder, $item);
40+
abstract function move($folder, $parent);
4041
abstract function removeItem($folder, $item);
4142
abstract function policyCheck($folderDao, $userDao = null, $policy = 0);
4243
abstract function getFolderExists($name, $description);

core/models/pdo/FolderModel.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,51 @@ function delete($folder, $recursive = false)
228228
$folder->saved = false;
229229
return true;
230230
} //end delete
231+
232+
/** move a folder*/
233+
public function move($folder, $parent)
234+
{
235+
if($folder->getKey() == $parent->getKey())
236+
{
237+
throw new Zend_Exception("Folder == Parent");
238+
}
239+
240+
$tmpParent = $parent->getParent();
241+
while($tmpParent != false)
242+
{
243+
if($tmpParent->getKey() == $folder->getKey())
244+
{
245+
throw new Zend_Exception("Parent is a child of Folder");
246+
}
247+
$tmpParent = $tmpParent->getParent();
248+
}
249+
250+
if(!$folder instanceof FolderDao)
251+
{
252+
throw new Zend_Exception("Error parameter.");
253+
}
254+
if(!$parent instanceof FolderDao)
255+
{
256+
throw new Zend_Exception("Error parameter.");
257+
}
258+
$leftIndice = $folder->getLeftIndice();
259+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice - 2')),
260+
array('left_indice >= ?' => $leftIndice));
261+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice - 2')),
262+
array('right_indice >= ?' => $leftIndice));
263+
$folder->setParentId($parent->getKey());
264+
$rightParent = $parent->getRightIndice();
265+
266+
$folder->setRightIndice($rightParent + 1);
267+
$folder->setLeftIndice($rightParent);
268+
269+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('2 + right_indice')),
270+
array('right_indice >= ?' => $rightParent));
271+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('2 + left_indice')),
272+
array('left_indice >= ?' => $rightParent));
273+
274+
parent::save($folder);
275+
}//end move
231276

232277
/** Custom save function*/
233278
public function save($folder)

core/public/js/community/community.manage.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,17 +399,11 @@ function successGroupChange(responseText, statusText, xhr, form)
399399
}
400400
else
401401
{
402-
var content="<li><a class='groupLink' groupid='"+jsonResponse[2].group_id+"' href='javascript:;'>"+jsonResponse[2].name+"</a> [<a class='editGroupLink' groupid='"+jsonResponse[2].group_id+"' href='javascript:;'>Edit</a>][<a class='deleteGroupLink' groupid='"+jsonResponse[2].group_id+"' href='javascript:;'>Delete</a>]<span/> </li>";
403-
$('div#groupsList ul').append(content);
404402

405-
var content="<div style='display:none;' class='groupList' id='groupList_"+jsonResponse[2].group_id+"'>";
406-
content+="<h4>"+$('div.groupMemberList h4:first').html()+"</h4>";
407-
content+='<table cellpadding="0" cellspacing="0" border="0" class="display dataTable">';
408-
content+="</table>";
409-
content+="</div>";
410-
$('div.groupMemberList').append(content);
411403
}
412404
init();
405+
window.location.replace(json.global.webroot+'/community/manage?communityId='+json.community['community_id']+'#tabs-2');
406+
window.location.reload();
413407
}
414408
else
415409
{

0 commit comments

Comments
 (0)