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

Commit 39f09be

Browse files
author
Charles Marion
committed
ENH: Changed import policies
Changed display
1 parent cc11283 commit 39f09be

26 files changed

+449
-147
lines changed

application/AppController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,27 @@ public function preDispatch()
7575
"contentUploadLogin"=>utf8_encode($this->t('You need to be logged in to be able to upload files.'))
7676
);
7777

78+
$browse=array(
79+
'view'=>$this->t('View'),
80+
'download'=>$this->t('Download'),
81+
'edit'=>$this->t('Edit'),
82+
'delete'=>$this->t('Delete'),
83+
'share'=>$this->t('Share'),
84+
'rename'=>$this->t('Rename'),
85+
'move'=>$this->t('Move'),
86+
'copy'=>$this->t('Copy'),
87+
'community' => array(
88+
'invit'=>$this->t('Invite collaborators'),
89+
'advanced'=>$this->t('Advanced properties'),
90+
)
91+
);
92+
7893
$feed=array(
7994
"deleteFeed"=>$this->t('Do you really want to delete the feed')
8095
);
8196

8297
$this->view->json=array(
83-
"global"=>$jsonGlobal,"login"=>$login,'feed'=>$feed
98+
"global"=>$jsonGlobal,"login"=>$login,'feed'=>$feed,"browse"=>$browse
8499
);
85100
Zend_Loader::loadClass("JsonComponent",BASE_PATH.'/application/controllers/components');
86101
} // end preDispatch()

application/controllers/BrowseController.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,21 @@ public function indexAction()
3939

4040
$this->view->communities=$communities;
4141
$this->view->header=$header;
42-
43-
$javascriptText=array();
44-
$javascriptText['view']=$this->t('View');
45-
$javascriptText['download']=$this->t('Download');
46-
$javascriptText['edit']=$this->t('Edit');
47-
$javascriptText['delete']=$this->t('Delete');
48-
$javascriptText['share']=$this->t('Share');
49-
$javascriptText['rename']=$this->t('Rename');
50-
$javascriptText['move']=$this->t('Move');
51-
$javascriptText['copy']=$this->t('Copy');
52-
53-
$javascriptText['community']['invit']=$this->t('Invite collaborators');
54-
$javascriptText['community']['advanced']=$this->t('Advanced properties');
55-
$this->view->json['browse']=$javascriptText;
42+
43+
$this->view->itemThumbnails=$this->Item->getRandomItems($this->userSession->Dao,0,12,true);
44+
$this->view->nUsers=$this->User->getCountAll();
45+
$this->view->nCommunities=$this->Community->getCountAll();
46+
$this->view->nItems=$this->Item->getCountAll();
47+
$this->view->notifications=array();
5648
}
5749

5850
/** get getfolders content (ajax function for the treetable) */
5951
public function getfolderscontentAction()
6052
{
61-
/* if(!$this->getRequest()->isXmlHttpRequest())
53+
if(!$this->getRequest()->isXmlHttpRequest())
6254
{
6355
throw new Zend_Exception("Why are you here ? Should be ajax.");
64-
}*/
56+
}
6557

6658
$this->_helper->layout->disableLayout();
6759
$this->_helper->viewRenderer->setNoRender();

application/controllers/CommunityController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CommunityController extends AppController
44
{
55
public $_models=array('Community','Folder','Group','Folderpolicygroup','Group','User','Feed',"Feedpolicygroup","Feedpolicyuser");
66
public $_daos=array('Community','Folder','Group','Folderpolicygroup','Group','User');
7-
public $_components=array('Sortdao');
7+
public $_components=array('Sortdao','Date');
88
public $_forms=array('Community');
99

1010
/** Init Controller */
@@ -39,9 +39,8 @@ function indexAction()
3939
/** view a community*/
4040
function viewAction()
4141
{
42-
42+
$this->view->Date=$this->Component->Date;
4343
//TODO: add policy check
44-
$this->view->header=$this->t("Communities");
4544
$communityId=$this->_getParam("communityId");
4645
if(!isset($communityId)||!is_numeric($communityId))
4746
{
@@ -54,7 +53,12 @@ function viewAction()
5453
}
5554

5655
$this->view->communityDao=$communityDao;
56+
$this->view->information=array();
5757
$this->view->feeds=$this->Feed->getFeedsByCommunity($this->userSession->Dao,$communityDao);
58+
59+
$this->view->folders=array();
60+
$this->view->folders[]=$communityDao->getPublicFolder();
61+
$this->view->folders[]=$communityDao->getPrivateFolder();
5862
}//end index
5963

6064

application/controllers/FolderController.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class FolderController extends AppController
44
{
55
public $_models=array('Folder','Folder','Item');
66
public $_daos=array('Folder','Folder','Item');
7-
public $_components=array();
7+
public $_components=array('Utility','Date');
88
public $_forms=array();
99

1010
/** Init Controller */
@@ -22,6 +22,7 @@ function init()
2222
/** View Action*/
2323
public function viewAction()
2424
{
25+
$this->view->Date=$this->Component->Date;
2526
$folder_id=$this->_getParam('folderId');
2627
$folder=$this->Folder->load($folder_id);
2728
$folders=array();
@@ -39,6 +40,10 @@ public function viewAction()
3940
{
4041
$folders=$this->Folder->getChildrenFoldersFiltered($folder,$this->userSession->Dao,MIDAS_POLICY_READ);
4142
$items=$this->Folder->getItemsFiltered($folder,$this->userSession->Dao,MIDAS_POLICY_READ);
43+
foreach($items as $key=>$i)
44+
{
45+
$items[$key]->size=$this->Component->Utility->formatSize($i->getSizebytes());
46+
}
4247
$header.=" <li class='pathFolder'><a href='{$this->view->webroot}/folder/{$folder->getKey()}'>{$folder->getName()}</a></li>";
4348
$parent=$folder->getParent();
4449
while($parent!==false)
@@ -58,22 +63,11 @@ public function viewAction()
5863
<li class='pathData'><a href='{$this->view->webroot}/browse'>Data</a></li>".$header;
5964
$header.="</ul>";
6065
}
66+
$this->view->mainFolder=$folder;
6167
$this->view->folders=$folders;
6268
$this->view->items=$items;
6369
$this->view->header=$header;
6470

65-
$javascriptText=array();
66-
$javascriptText['view']=$this->t('View');
67-
$javascriptText['edit']=$this->t('Edit');
68-
$javascriptText['delete']=$this->t('Delete');
69-
$javascriptText['share']=$this->t('Share');
70-
$javascriptText['rename']=$this->t('Rename');
71-
$javascriptText['move']=$this->t('Move');
72-
$javascriptText['copy']=$this->t('Copy');
73-
74-
$javascriptText['community']['invit']=$this->t('Invite collaborators');
75-
$javascriptText['community']['advanced']=$this->t('Advanced properties');
76-
$this->view->json['browse']=$javascriptText;
7771
}// end View Action
7872

7973
}//end class

application/controllers/ImportController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
*/
77
class ImportController extends AppController
88
{
9-
10-
public $_models=array('Item','Folder','ItemRevision','Assetstore','Folderpolicyuser','Itempolicyuser','ItemKeyword');
9+
public $_models=array('Item','Folder','ItemRevision','Assetstore','Folderpolicyuser','Itempolicyuser','ItemKeyword','Itempolicygroup','Group','Folderpolicygroup');
1110
public $_daos=array('Item','Folder','ItemRevision','Bitstream','Assetstore','ItemKeyword');
1211
public $_components=array('Upload','Utility');
1312
public $_forms=array('Import','Assetstore');
@@ -115,8 +114,11 @@ private function _recursiveParseDirectory($path,$currentdir)
115114
$child = new FolderDao;
116115
$child->setName($fileInfo->getFilename());
117116
$child->setParentId($currentdir->getFolderId());
117+
$child->setDate(date('c'));
118118
$this->Folder->save($child);
119-
$this->Folderpolicyuser->createPolicy($this->userSession->Dao,$child,MIDAS_POLICY_ADMIN);
119+
$this->Folderpolicyuser->createPolicy($this->userSession->Dao,$child,MIDAS_POLICY_ADMIN);
120+
$anonymousGroup=$this->Group->load(MIDAS_GROUP_ANONYMOUS_KEY);
121+
$this->Folderpolicygroup->createPolicy($anonymousGroup,$child,MIDAS_POLICY_READ);
120122
}
121123
$this->_recursiveParseDirectory($fileInfo->getPathName(),$child);
122124
}
@@ -140,7 +142,9 @@ private function _recursiveParseDirectory($path,$currentdir)
140142
$this->Item->addKeyword($item,$keyword);
141143

142144
// Set the policy of the item
143-
$this->Itempolicyuser->createPolicy($this->userSession->Dao,$item,MIDAS_POLICY_ADMIN);
145+
$this->Itempolicyuser->createPolicy($this->userSession->Dao,$item,MIDAS_POLICY_ADMIN);
146+
$anonymousGroup=$this->Group->load(MIDAS_GROUP_ANONYMOUS_KEY);
147+
$this->Itempolicygroup->createPolicy($anonymousGroup,$item,MIDAS_POLICY_READ);
144148

145149
// Add the item to the current directory
146150
$this->Folder->addItem($currentdir,$item);

application/controllers/SearchController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public function indexAction()
2626

2727
// Get the items corresponding to the search
2828
$items = $this->ItemKeyword->getItemsFromSearch($keyword,$this->userSession->Dao);
29-
30-
var_dump($items);
29+
$this->view->items=$items;
3130
}
3231

3332
/** search live Action */

application/controllers/UserController.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UserController extends AppController
88
public $_daos=array(
99
'User','Folder','Folderpolicygroup','Folderpolicyuser','Group'
1010
);
11-
public $_components=array();
11+
public $_components=array('Date');
1212
public $_forms=array(
1313
'User'
1414
);
@@ -168,6 +168,7 @@ public function validentryAction()
168168
/** user page action*/
169169
public function userpageAction()
170170
{
171+
$this->view->Date=$this->Component->Date;
171172
$user_id=$this->_getParam("user_id");
172173
if(!isset($user_id) && !$this->logged)
173174
{
@@ -183,7 +184,7 @@ public function userpageAction()
183184
{
184185
$userDao=$this->User->load($user_id);
185186
}
186-
187+
187188
if(!$userDao instanceof UserDao)
188189
{
189190
throw new Zend_Exception("Unable to find user");
@@ -193,23 +194,12 @@ public function userpageAction()
193194
$this->view->userCommunities=$this->User->getUserCommunities($userDao);
194195
$this->view->folders=array();
195196
$this->view->folders[]=$userDao->getPublicFolder();
196-
if($userDao->getKey() == $this->userSession->Dao->getKey())
197+
if(!empty($this->userSession->Dao)&& $userDao->getKey() == $this->userSession->Dao->getKey())
197198
{
198199
$this->view->folders[]=$userDao->getPrivateFolder();
199200
}
200201
$this->view->feeds=$this->Feed->getFeedsByUser($this->userSession->Dao,$userDao);
201202

202-
$javascriptText=array();
203-
$javascriptText['view']=$this->t('View');
204-
$javascriptText['edit']=$this->t('Edit');
205-
$javascriptText['delete']=$this->t('Delete');
206-
$javascriptText['share']=$this->t('Share');
207-
$javascriptText['rename']=$this->t('Rename');
208-
$javascriptText['move']=$this->t('Move');
209-
$javascriptText['copy']=$this->t('Copy');
210-
211-
$javascriptText['community']['invit']=$this->t('Invite collaborators');
212-
$javascriptText['community']['advanced']=$this->t('Advanced properties');
213-
$this->view->json['browse']=$javascriptText;
203+
$this->view->information=array();
214204
}
215205
}//end class

application/models/pdo/ItemKeywordModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ function getItemsFromSearch($searchterm,$userDao)
5858
->join(array('i2k' => 'item2keyword'),'i.item_id=i2k.item_id')
5959
->join(array('k' => 'itemkeyword'),'k.keyword_id=i2k.keyword_id')
6060
->where('k.value LIKE ?','%'.$searchterm.'%')
61-
->where('i.item_id IN ('.$subqueryUser.')' )
62-
->orWhere('i.item_id IN ('.$subqueryGroup.')' )
61+
->where('( i.item_id IN ('.$subqueryUser.') OR
62+
i.item_id IN ('.$subqueryGroup.'))' )
6363
->group('i.name')
6464
->setIntegrityCheck(false)
6565
->limit(14);
66-
66+
6767
$rowset = $this->fetchAll($sql);
6868
$return = array();
6969
foreach($rowset as $row)

application/views/browse/index.phtml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
$this->headScript()->appendFile($this->webroot.'/public/js/common/common.browser.js');
44
?>
55

6+
67
<link type="text/css" rel="stylesheet" href="<?php echo $this->webroot?>/public/css/common/common.browser.css" />
8+
<link type="text/css" rel="stylesheet" href="<?php echo $this->webroot?>/public/css/browse/browse.index.css" />
79
<div class="viewMain">
810
<img class="tableLoading" alt="" src="<?php echo $this->webroot?>/public/images/icons/loading.gif"/>
911
<table id="browseTable" class="midasTree">
@@ -29,26 +31,63 @@
2931
echo "</tr>";
3032
$node++;
3133
}
32-
?>
33-
34+
?>
3435
</tbody>
3536
</table>
3637
</div>
3738
<div class="viewSideBar">
38-
<div class="sideElementFirst viewAction">
39+
<div class="sideElementFirst viewAction" >
3940
<h1>Actions</h1>
4041
<ul>
4142
<li>
4243

4344
</li>
4445
</ul>
4546
</div>
46-
<div class="sideElementLast viewInfo">
47+
<div class="sideElementLast viewInfo" >
4748
<h1>Info</h1>
4849
<img class="infoLoading" style="display:none;" alt="" src="<?php echo $this->webroot?>/public/images/icons/loading.gif"/>
4950
<div class="ajaxInfoElement">
5051
</div>
5152
</div>
53+
54+
55+
<div class="defaultSide" >
56+
BlaBla
57+
<br/>
58+
<?php
59+
if(!empty($this->notifications))
60+
{
61+
echo "<div class='sideElementFirst feedNotification'>
62+
<h1>Notifications</h1>
63+
</div>";
64+
}
65+
?>
66+
<?php
67+
if(!empty($this->itemThumbnails))
68+
{
69+
echo '<div class="'.(empty($this->notifications)?'sideElementFirst':'sideElement').' feedThumbnail">';
70+
echo '<h1>Thumbnails</h1>';
71+
foreach($this->itemThumbnails as $item)
72+
{
73+
echo "<a href='{$this->webroot}/item/{$item->getKey()}'>";
74+
echo "<img src='{$this->webroot}/{$item->getThumbnail()}' alt=''/>";
75+
echo "</a>";
76+
}
77+
echo '</div>';
78+
}
79+
?>
80+
<div class="sideElementLast feedStats">
81+
<h1>Stats</h1>
82+
<?php
83+
echo "<ul>";
84+
echo " <li>{$this->nUsers} user".(($this->nUsers>1)?'s':'')."</li>";
85+
echo " <li>{$this->nCommunities} ".(($this->nCommunities>1)?'communities':'community')."</li>";
86+
echo " <li>{$this->nItems} item".(($this->nItems>1)?'s':'')."</li>";
87+
echo "</ul>";
88+
?>
89+
</div>
90+
</div>
5291
</div>
5392

5493

application/views/community/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</div>
2424
<div class="sideElementLast viewInfo">
2525
<h1>Info</h1>
26-
bla
26+
To do
2727
</div>
2828
</div>
2929

0 commit comments

Comments
 (0)