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

Commit b36e7e5

Browse files
author
Charles Marion
committed
ENH: Added owned by me and shared to me:
https://www.kitware.com/Bug/view.php?id=9588
1 parent 51042ae commit b36e7e5

27 files changed

+418
-117
lines changed

core/controllers/CommunityController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class CommunityController extends AppController
44
{
5-
public $_models=array('Community','Folder','Group','Folderpolicygroup','Group','User','Feed',"Feedpolicygroup","Feedpolicyuser");
5+
public $_models=array('Community','Folder','Group','Folderpolicygroup','Group','User','Feed',"Feedpolicygroup","Feedpolicyuser",'Item');
66
public $_daos=array('Community','Folder','Group','Folderpolicygroup','Group','User');
77
public $_components=array('Sortdao','Date');
88
public $_forms=array('Community');
@@ -273,6 +273,11 @@ function viewAction()
273273
$this->view->isModerator=$this->Community->policyCheck($communityDao, $this->userSession->Dao,MIDAS_POLICY_WRITE);
274274
$this->view->isAdmin=$this->Community->policyCheck($communityDao, $this->userSession->Dao,MIDAS_POLICY_ADMIN);
275275
$this->view->json['community']=$communityDao->_toArray();
276+
277+
if($this->view->isMember)
278+
{
279+
$this->view->shareItems=$this->Item->getSharedToCommunity($communityDao);
280+
}
276281
}//end view
277282

278283
/** Delete a community*/

core/controllers/ShareController.php

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function dialogAction()
5555
else
5656
{
5757
$policyCheck=$this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_WRITE);
58-
$isAdmin=$this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_WRITE);
58+
$isAdmin=$this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
5959
}
6060
if($policyCheck==false)
6161
{
@@ -96,14 +96,24 @@ function dialogAction()
9696
{
9797
if ($changeType=='group')
9898
{
99-
$policyDao=$this->Folderpolicyuser->getPolicy($changePolicy, $element);
99+
$policyDao=$this->Folderpolicyuser->getPolicy($changePolicy, $element);
100+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
101+
{
102+
echo JsonComponent::encode(array(false,$this->t('Error')));
103+
return;
104+
}
100105
$this->Folderpolicygroup->delete($policyDao);
101106
$policyDao->setPolicy($changeVal);
102107
$this->Folderpolicygroup->save($policyDao);
103108
}
104109
else
105110
{
106-
$policyDao=$this->Folderpolicyuser->getPolicy($changePolicy, $element);
111+
$policyDao=$this->Folderpolicyuser->getPolicy($changePolicy, $element);
112+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
113+
{
114+
echo JsonComponent::encode(array(false,$this->t('Error')));
115+
return;
116+
}
107117
$this->Folderpolicygroup->delete($policyDao);
108118
$policyDao->setPolicy($changeVal);
109119
$this->Folderpolicygroup->save($policyDao);
@@ -113,14 +123,24 @@ function dialogAction()
113123
{
114124
if ($changeType=='group')
115125
{
116-
$policyDao=$this->Itempolicygroup->getPolicy($changePolicy, $element);
126+
$policyDao=$this->Itempolicygroup->getPolicy($changePolicy, $element);
127+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
128+
{
129+
echo JsonComponent::encode(array(false,$this->t('Error')));
130+
return;
131+
}
117132
$this->Itempolicygroup->delete($policyDao);
118133
$policyDao->setPolicy($changeVal);
119134
$this->Itempolicygroup->save($policyDao);
120135
}
121136
else
122137
{
123-
$policyDao=$this->Itempolicyuser->getPolicy($changePolicy, $element);
138+
$policyDao=$this->Itempolicyuser->getPolicy($changePolicy, $element);
139+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
140+
{
141+
echo JsonComponent::encode(array(false,$this->t('Error')));
142+
return;
143+
}
124144
$this->Itempolicyuser->delete($policyDao);
125145
$policyDao->setPolicy($changeVal);
126146
$this->Itempolicyuser->save($policyDao);
@@ -146,11 +166,21 @@ function dialogAction()
146166
if ($removeType=='group')
147167
{
148168
$policyDao=$this->Folderpolicyuser->getPolicy($removePolicy, $element);
169+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
170+
{
171+
echo JsonComponent::encode(array(false,$this->t('Error')));
172+
return;
173+
}
149174
$this->Folderpolicygroup->delete($policyDao);
150175
}
151176
else
152177
{
153178
$policyDao=$this->Folderpolicyuser->getPolicy($removePolicy, $element);
179+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
180+
{
181+
echo JsonComponent::encode(array(false,$this->t('Error')));
182+
return;
183+
}
154184
$this->Folderpolicygroup->delete($policyDao);
155185
}
156186
}
@@ -159,11 +189,21 @@ function dialogAction()
159189
if ($removeType=='group')
160190
{
161191
$policyDao=$this->Itempolicygroup->getPolicy($removePolicy, $element);
192+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
193+
{
194+
echo JsonComponent::encode(array(false,$this->t('Error')));
195+
return;
196+
}
162197
$this->Itempolicygroup->delete($policyDao);
163198
}
164199
else
165200
{
166201
$policyDao=$this->Itempolicyuser->getPolicy($removePolicy, $element);
202+
if(!$isAdmin&&$policyDao->getPolicy()>=MIDAS_POLICY_ADMIN)
203+
{
204+
echo JsonComponent::encode(array(false,$this->t('Error')));
205+
return;
206+
}
167207
$this->Itempolicyuser->delete($policyDao);
168208
}
169209
}

core/controllers/UserController.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

33
class UserController extends AppController
44
{
5-
public $_models=array(
6-
'User','Folder','Folderpolicygroup','Folderpolicyuser','Group','Feed','Feedpolicygroup','Feedpolicyuser','Group'
7-
);
8-
public $_daos=array(
9-
'User','Folder','Folderpolicygroup','Folderpolicyuser','Group'
10-
);
5+
public $_models=array('User','Folder','Folderpolicygroup','Folderpolicyuser','Group','Feed','Feedpolicygroup','Feedpolicyuser','Group','Item' );
6+
public $_daos=array( 'User','Folder','Folderpolicygroup','Folderpolicyuser','Group' );
117
public $_components=array('Date','Filter','Sortdao');
12-
public $_forms=array(
13-
'User'
14-
);
8+
public $_forms=array( 'User' );
159

1610
/** Init Controller */
1711
function init()
@@ -357,9 +351,11 @@ public function userpageAction()
357351
$this->view->userCommunities=$this->User->getUserCommunities($userDao);
358352
$this->view->folders=array();
359353
$this->view->folders[]=$userDao->getPublicFolder();
360-
if(!empty($this->userSession->Dao)&& $userDao->getKey() == $this->userSession->Dao->getKey())
354+
if(!empty($this->userSession->Dao)&& ($userDao->getKey() == $this->userSession->Dao->getKey()||$this->userSession->Dao->isAdmin()))
361355
{
362356
$this->view->folders[]=$userDao->getPrivateFolder();
357+
$this->view->ownedItems=$this->Item->getOwnedByUser($userDao);
358+
$this->view->shareItems=$this->Item->getSharedToUser($userDao);
363359
}
364360
else
365361
{

core/controllers/components/UpgradeComponent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function getNewestVersion($text=false)
4848
throw new Zend_Exception("Please init the component first");
4949
}
5050
$files=$this->getMigrationFiles();
51-
5251
if(empty($files))
5352
{
5453
return 0;

core/database/mysql/3.0.0.sql renamed to core/database/mysql/3.0.1.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ CREATE TABLE IF NOT EXISTS `folderpolicygroup` (
116116
`folder_id` bigint(20) NOT NULL,
117117
`group_id` bigint(20) NOT NULL,
118118
`policy` tinyint(4) NOT NULL,
119+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
119120
UNIQUE KEY `folder_id` (`folder_id`,`group_id`)
120121
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
121122

@@ -129,6 +130,7 @@ CREATE TABLE IF NOT EXISTS `folderpolicyuser` (
129130
`folder_id` bigint(20) NOT NULL,
130131
`user_id` bigint(20) NOT NULL,
131132
`policy` tinyint(4) NOT NULL,
133+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
132134
UNIQUE KEY `folder_id` (`folder_id`,`user_id`)
133135
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
134136

@@ -176,6 +178,7 @@ CREATE TABLE IF NOT EXISTS `itempolicygroup` (
176178
`item_id` bigint(20) NOT NULL,
177179
`group_id` bigint(20) NOT NULL,
178180
`policy` tinyint(4) NOT NULL,
181+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
179182
UNIQUE KEY `item_id` (`item_id`,`group_id`)
180183
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
181184

@@ -189,6 +192,7 @@ CREATE TABLE IF NOT EXISTS `itempolicyuser` (
189192
`item_id` bigint(20) NOT NULL,
190193
`user_id` bigint(20) NOT NULL,
191194
`policy` tinyint(4) NOT NULL,
195+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
192196
UNIQUE KEY `item_id` (`item_id`,`user_id`)
193197
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
194198

@@ -385,6 +389,7 @@ CREATE TABLE IF NOT EXISTS `feedpolicygroup` (
385389
`feed_id` bigint(20) NOT NULL,
386390
`group_id` bigint(20) NOT NULL,
387391
`policy` tinyint(4) NOT NULL,
392+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
388393
UNIQUE KEY `feed_id` (`feed_id`,`group_id`)
389394
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
390395

@@ -398,5 +403,6 @@ CREATE TABLE IF NOT EXISTS `feedpolicyuser` (
398403
`feed_id` bigint(20) NOT NULL,
399404
`user_id` bigint(20) NOT NULL,
400405
`policy` tinyint(4) NOT NULL,
406+
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP(),
401407
UNIQUE KEY `feed_id` (`feed_id`,`user_id`)
402408
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

core/database/pgsql/3.0.0.sql renamed to core/database/pgsql/3.0.1.sql

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ CREATE TABLE folderpolicygroup (
107107
id serial PRIMARY KEY,
108108
folder_id bigint NOT NULL,
109109
group_id bigint NOT NULL,
110-
policy smallint NOT NULL
110+
policy smallint NOT NULL,
111+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
111112
) ;
112113

113114
-- --------------------------------------------------------
@@ -120,7 +121,8 @@ CREATE TABLE folderpolicyuser (
120121
id serial PRIMARY KEY,
121122
folder_id bigint NOT NULL,
122123
user_id bigint NOT NULL,
123-
policy smallint NOT NULL
124+
policy smallint NOT NULL,
125+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
124126
) ;
125127

126128
-- --------------------------------------------------------
@@ -166,7 +168,8 @@ CREATE TABLE itempolicygroup (
166168
id serial PRIMARY KEY,
167169
item_id bigint NOT NULL,
168170
group_id bigint NOT NULL,
169-
policy smallint NOT NULL
171+
policy smallint NOT NULL,
172+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
170173
) ;
171174

172175
-- --------------------------------------------------------
@@ -179,7 +182,8 @@ CREATE TABLE itempolicyuser (
179182
id serial PRIMARY KEY,
180183
item_id bigint NOT NULL,
181184
user_id bigint NOT NULL,
182-
policy smallint NOT NULL
185+
policy smallint NOT NULL,
186+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
183187
);
184188

185189
-- --------------------------------------------------------
@@ -360,7 +364,8 @@ CREATE TABLE feedpolicygroup (
360364
id serial PRIMARY KEY,
361365
feed_id bigint NOT NULL,
362366
group_id bigint NOT NULL,
363-
policy smallint NOT NULL
367+
policy smallint NOT NULL,
368+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
364369
);
365370

366371
-- --------------------------------------------------------
@@ -373,5 +378,6 @@ CREATE TABLE feedpolicyuser (
373378
id serial PRIMARY KEY,
374379
feed_id bigint NOT NULL,
375380
user_id bigint NOT NULL,
376-
policy smallint NOT NULL
381+
policy smallint NOT NULL,
382+
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
377383
) ;

core/database/upgrade/3.0.1.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
class Upgrade_3_0_1 extends MIDASUpgrade
4+
{
5+
public function preUpgrade()
6+
{
7+
8+
}
9+
10+
public function mysql()
11+
{
12+
$sql = "ALTER TABLE folderpolicygroup ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
13+
$this->db->query($sql);
14+
$sql = "ALTER TABLE folderpolicyuser ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
15+
$this->db->query($sql);
16+
$sql = "ALTER TABLE itempolicygroup ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
17+
$this->db->query($sql);
18+
$sql = "ALTER TABLE itempolicyuser ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
19+
$this->db->query($sql);
20+
$sql = "ALTER TABLE feedpolicygroup ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
21+
$this->db->query($sql);
22+
$sql = "ALTER TABLE feedpolicyuser ADD COLUMN date timestamp DEFAULT CURRENT_TIMESTAMP(); ";
23+
$this->db->query($sql);
24+
}
25+
26+
public function pgsql()
27+
{
28+
$sql = "ALTER TABLE folderpolicygroup ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
29+
$this->db->query($sql);
30+
$sql = "ALTER TABLE folderpolicyuser ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
31+
$this->db->query($sql);
32+
$sql = "ALTER TABLE itempolicygroup ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
33+
$this->db->query($sql);
34+
$sql = "ALTER TABLE itempolicyuser ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
35+
$this->db->query($sql);
36+
$sql = "ALTER TABLE feedpolicygroup ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
37+
$this->db->query($sql);
38+
$sql = "ALTER TABLE feedpolicyuser ADD COLUMN date TIMESTAMP DEFAULT CURRENT_TIMESTAMP; ";
39+
$this->db->query($sql);
40+
}
41+
42+
public function postUpgrade()
43+
{
44+
45+
}
46+
}
47+
?>

core/models/base/CommunityModelBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct()
3333
abstract function getPublicCommunities($limit=20);
3434
abstract function getByName($name);
3535
abstract function getAll();
36+
3637

3738
/** plus one view*/
3839
function plusOneView($communityDao)

core/models/base/FeedpolicygroupModelBase.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@ public function __construct()
77
$this->_name='feedpolicygroup';
88

99
$this->_mainData=array(
10-
'feed_id'=>array(
11-
'type'=>MIDAS_DATA
12-
),'group_id'=>array(
13-
'type'=>MIDAS_DATA
14-
),'policy'=>array(
15-
'type'=>MIDAS_DATA
16-
),'feed'=>array(
17-
'type'=>MIDAS_MANY_TO_ONE,'model'=>'Feed','parent_column'=>'feed_id','child_column'=>'feed_id'
18-
),'group'=>array(
19-
'type'=>MIDAS_MANY_TO_ONE,'model'=>'Group','parent_column'=>'group_id','child_column'=>'group_id'
20-
)
10+
'feed_id'=>array('type'=>MIDAS_DATA),
11+
'group_id'=>array('type'=>MIDAS_DATA),
12+
'policy'=>array('type'=>MIDAS_DATA),
13+
'date'=>array('type'=>MIDAS_DATA),
14+
'feed'=>array('type'=>MIDAS_MANY_TO_ONE,'model'=>'Feed','parent_column'=>'feed_id','child_column'=>'feed_id'),
15+
'group'=>array('type'=>MIDAS_MANY_TO_ONE,'model'=>'Group','parent_column'=>'group_id','child_column'=>'group_id')
2116
);
2217
$this->initialize(); // required
2318
} // end __construct()

core/models/base/FeedpolicyuserModelBase.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ public function __construct()
66
parent::__construct();
77
$this->_name='feedpolicyuser';
88
$this->_mainData=array(
9-
'feed_id'=>array(
10-
'type'=>MIDAS_DATA
11-
),'user_id'=>array(
12-
'type'=>MIDAS_DATA
13-
),'policy'=>array(
14-
'type'=>MIDAS_DATA
15-
),'feed'=>array(
16-
'type'=>MIDAS_MANY_TO_ONE,'model'=>'Feed','parent_column'=>'feed_id','child_column'=>'feed_id'
17-
),'user'=>array(
18-
'type'=>MIDAS_MANY_TO_ONE,'model'=>'User','parent_column'=>'user_id','child_column'=>'user_id'
19-
)
9+
'feed_id'=>array('type'=>MIDAS_DATA),
10+
'user_id'=>array('type'=>MIDAS_DATA),
11+
'policy'=>array('type'=>MIDAS_DATA),
12+
'date'=>array('type'=>MIDAS_DATA),
13+
'feed'=>array('type'=>MIDAS_MANY_TO_ONE,'model'=>'Feed','parent_column'=>'feed_id','child_column'=>'feed_id'),
14+
'user'=>array('type'=>MIDAS_MANY_TO_ONE,'model'=>'User','parent_column'=>'user_id','child_column'=>'user_id')
2015
);
2116
$this->initialize(); // required
2217
} // end __construct()

0 commit comments

Comments
 (0)