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

Commit afad056

Browse files
author
Charles Marion
committed
ENH: 0009587: Add user personnal file management
1 parent c6f4239 commit afad056

File tree

10 files changed

+273
-4
lines changed

10 files changed

+273
-4
lines changed

core/controllers/InstallController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function step2Action()
110110
$upgradeComponent->init = true;
111111
$sqlFile = $upgradeComponent->getNewestVersion(true);
112112
$sqlFile = BASE_PATH."/core/database/".$type."/".$sqlFile.'.sql';
113-
if(!isset($sqlFile) ||!file_exists($sqlFile))
113+
if(!isset($sqlFile) || !file_exists($sqlFile))
114114
{
115115
throw new Zend_Exception("Unable to find sql file");
116116
}

core/controllers/UserController.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,41 @@ public function userpageAction()
458458
$this->view->isViewAction = ($this->logged && ($this->userSession->Dao->getKey() == $userDao->getKey() || $this->userSession->Dao->isAdmin()));
459459
$this->view->information = array();
460460
}
461+
462+
/** manage files page action*/
463+
public function manageAction()
464+
{
465+
$this->view->Date = $this->Component->Date;
466+
$user_id = $this->_getParam("user_id");
467+
468+
if(!isset($user_id) && !$this->logged)
469+
{
470+
$this->view->header = $this->t("You should be logged in.");
471+
$this->_helper->viewRenderer->setNoRender();
472+
return false;
473+
}
474+
elseif(!isset($user_id))
475+
{
476+
$userDao = $this->userSession->Dao;
477+
$this->view->activemenu = 'user'; // set the active menu
478+
}
479+
else
480+
{
481+
$userDao = $this->User->load($user_id);
482+
if(!$this->userSession->Dao->isAdmin())
483+
{
484+
throw new Zend_Exception("Permission error");
485+
}
486+
}
487+
488+
if(!$userDao instanceof UserDao)
489+
{
490+
throw new Zend_Exception("Unable to find user");
491+
}
492+
493+
$this->view->user = $userDao;
494+
$this->view->folders = array();
495+
$this->view->folders[] = $userDao->getPublicFolder();
496+
$this->view->folders[] = $userDao->getPrivateFolder();
497+
}
461498
}//end class

core/database/upgrade/3.0.11.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function pgsql()
2727
CREATE TABLE communityinvitation (
2828
communityinvitation_id serial PRIMARY KEY,
2929
community_id bigint,
30-
user_id bigint,
30+
user_id bigint
3131
)
3232
; ";
3333
$this->db->query($sql);

core/public/css/community/community.manage.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
display:none;
2121
}
2222

23+
img.folderLoading{
24+
display:none;
25+
}
2326

2427
h1 { padding: .2em; margin: 0; }
2528
#products { float:left; width: 500px; margin-right: 2em; }
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
div.radioElement label{
3+
float: inherit!important;
4+
width: 600px!important;
5+
}
6+
7+
div.radioElement ul{
8+
list-style: none;
9+
margin: 0px 0px 0px 100px;
10+
padding: 0px 0px 0px 0px;
11+
width: 600px!important;
12+
}
13+
14+
div.radioElement h4{
15+
margin-bottom: 4px;
16+
}
17+
18+
19+
div.radioElement br{
20+
display:none;
21+
}
22+
23+
img.folderLoading{
24+
display:none;
25+
}
26+
27+
h1 { padding: .2em; margin: 0; }
28+
#products { float:left; width: 500px; margin-right: 2em; }
29+
#cart { width: 200px; float: left; }
30+
/* style the list to maximize the droppable hitarea */
31+
#cart ol { margin: 0; padding: 1em 0 1em 3em; }

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$(document).ready(function() {
1+
var disableElementSize=true;
2+
3+
$(document).ready(function() {
24

35
initCommunityPrivacy();
46

@@ -67,6 +69,7 @@
6769
//init tree
6870
$('img.tabsLoading').hide()
6971

72+
7073
$("#browseTable").treeTable();
7174
$("img.tableLoading").hide();
7275
$("table#browseTable").show();

core/public/js/layout/jquery.treeTable.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@
508508
var ajaxSizeRequest='';
509509
function getElementsSize()
510510
{
511+
if(typeof(disableElementSize) !== 'undefined')
512+
{
513+
return;
514+
}
511515
var elements='';
512516
var i = 0;
513517
$('img.folderLoading').each(function()

core/public/js/user/user.manage.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
var disableElementSize=true;
2+
3+
$(document).ready(function() {
4+
5+
//init tree
6+
$('img.tabsLoading').hide()
7+
8+
9+
$("#browseTable").treeTable();
10+
$("img.tableLoading").hide();
11+
$("table#browseTable").show();
12+
13+
initDragAndDrop();
14+
15+
});
16+
17+
18+
//dependance: common/browser.js
19+
var ajaxSelectRequest='';
20+
function callbackSelect(node)
21+
{
22+
$('div.genericAction').hide();
23+
$('div.genericCommunities').hide();
24+
$('div.genericStats').hide();
25+
$('div.viewInfo').show();
26+
$('div.viewAction').show()
27+
genericCallbackSelect(node);
28+
}
29+
30+
function callbackDblClick(node)
31+
{
32+
}
33+
34+
function callbackCheckboxes(node)
35+
{
36+
genericCallbackCheckboxes(node);
37+
}
38+
39+
function callbackCreateElement(node)
40+
{
41+
initDragAndDrop();
42+
}
43+
44+
function initDragAndDrop()
45+
{
46+
$("#browseTable .file, #browseTable .folder:not(.notdraggable)").draggable({
47+
helper: "clone",
48+
opacity: .75,
49+
refreshPositions: true, // Performance?
50+
revert: "invalid",
51+
revertDuration: 300,
52+
scroll: true
53+
});
54+
55+
// Configure droppable rows
56+
$("#browseTable .folder").each(function() {
57+
$(this).parents("tr").droppable({
58+
accept: ".file, .folder",
59+
drop: function(e, ui) {
60+
// Call jQuery treeTable plugin to move the branch
61+
var elements='';
62+
if($(ui.draggable).parents("tr").attr('type')=='folder')
63+
{
64+
elements=$(ui.draggable).parents("tr").attr('element')+';';
65+
}
66+
else
67+
{
68+
elements=';'+$(ui.draggable).parents("tr").attr('element');
69+
}
70+
var from;
71+
var classNames=$(ui.draggable).parents("tr").attr('class').split(' ');
72+
for(key in classNames) {
73+
if(classNames[key].match('child-of-')) {
74+
from= $("#" + classNames[key].substring(9)).attr('element');
75+
}
76+
}
77+
var destination_obj=this;
78+
$.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:from,ajax:true},
79+
function(data) {
80+
81+
jsonResponse = jQuery.parseJSON(data);
82+
if(jsonResponse==null)
83+
{
84+
createNotive('Error',4000);
85+
return;
86+
}
87+
if(jsonResponse[0])
88+
{
89+
createNotive(jsonResponse[1],1500);
90+
$($(ui.draggable).parents("tr")).appendBranchTo(destination_obj);
91+
$(destination_obj).reload();
92+
}
93+
else
94+
{
95+
createNotive(jsonResponse[1],4000);
96+
}
97+
});
98+
99+
},
100+
hoverClass: "accept",
101+
over: function(e, ui) {
102+
// Make the droppable branch expand when a draggable node is moved over it.
103+
if(this.id != $(ui.draggable.parents("tr")[0]).id && !$(this).is(".expanded")) {
104+
$(this).expand();
105+
}
106+
}
107+
});
108+
});
109+
}

core/views/community/manage.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ $this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.bro
179179

180180
foreach($this->folders as $folder)
181181
{
182-
echo "<tr id='node--$node' class='parent' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
182+
echo "<tr id='node--$node' class='parent' privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
183183
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>{$folder->getName()}</span></td>";
184184
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
185185
echo " <td>{$this->Date->ago($folder->getDate(),true)}</td>";

core/views/user/manage.phtml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
$this->headScript()->appendFile($this->coreWebroot . '/public/js/jquery/jquery.form.js');
3+
$this->headScript()->appendFile($this->coreWebroot . '/public/js/user/user.manage.js');
4+
$this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.browser.js');
5+
?>
6+
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/user/user.manage.css" />
7+
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/common/common.browser.css" />
8+
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/common/common.genericPage.css" />
9+
10+
<div class="viewMain">
11+
<div class="genericThumbnail">
12+
<?php
13+
$thumbnail=$this->user->getThumbnail();
14+
if(!empty($thumbnail))
15+
{
16+
echo "<img class='thumbnailSmall' src='{$this->webroot}/{$thumbnail}' alt=''/>";
17+
}
18+
else
19+
{
20+
echo "<img class='thumbnailSmall' src='{$this->coreWebroot}/public/images/icons/unknownUser.png' alt=''/>";
21+
}
22+
?>
23+
</div>
24+
<div class="genericInfo">
25+
<div class="genericName"><?php echo $this->user->getFullName();?></div>
26+
<div class="genericCompany"><?php echo $this->user->getCompany();?></div>
27+
</div>
28+
29+
<img class="tableLoading" alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/loading.gif" />
30+
Drag and drop to move elements.
31+
<table id="browseTable" class="midasTree">
32+
<thead>
33+
<th class="thData"><?php echo $this->t('Name');?></th>
34+
<th class="thSize"><?php echo $this->t('Size');?></th>
35+
<th class="thDate"><?php echo $this->t('Modified');?></th>
36+
<th class="thCheckbox"></th>
37+
</thead>
38+
<tbody>
39+
<?php
40+
$node=1;
41+
foreach($this->folders as $folder)
42+
{
43+
echo "<tr id='node--$node' class='parent' privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
44+
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>{$folder->getName()}</span></td>";
45+
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
46+
echo " <td>{$this->Date->ago($folder->getDate(),true)}</td>";
47+
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='{$folder->getFolderId()}' /></td>";
48+
echo "</tr>";
49+
$node++;
50+
}
51+
?>
52+
53+
</tbody>
54+
</table>
55+
56+
</div>
57+
58+
</div>
59+
<div class="viewSideBar">
60+
61+
<div class="sideElementFirst viewAction">
62+
<h1>Actions</h1>
63+
<ul>
64+
<li>
65+
66+
</li>
67+
</ul>
68+
</div>
69+
<div class="sideElement viewSelected" >
70+
<h1><?php echo $this->t('Selected')?></h1>
71+
<span></span>
72+
</div>
73+
<div class="sideElementLast viewInfo">
74+
<h1>Info</h1>
75+
<img class="infoLoading" style="display:none;" alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/loading.gif"/>
76+
<div class="ajaxInfoElement">
77+
</div>
78+
</div>
79+
</div>
80+
81+
82+

0 commit comments

Comments
 (0)