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

Commit a653908

Browse files
author
Charles Marion
committed
ENH: Added community policies bug :9580
Added check style library
1 parent 1ae6c2c commit a653908

File tree

112 files changed

+63715
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+63715
-197
lines changed

core/Bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function _initConfig()
169169
protected function _initRouter()
170170
{
171171
$router = Zend_Controller_Front::getInstance()->getRouter();
172-
172+
/*
173173
$route1 = new Zend_Controller_Router_Route(
174174
Zend_Registry::get('configGlobal')->webdav->path.'/:action/*',
175175
array(
@@ -178,7 +178,7 @@ protected function _initRouter()
178178
'action' => ':action'
179179
)
180180
);
181-
$router->addRoute('webdav', $route1);
181+
$router->addRoute('webdav', $route1); */
182182

183183
//Init Modules
184184
$frontController = Zend_Controller_Front::getInstance();

core/constant/community.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
define("MIDAS_COMMUNITY_PUBLIC", 0);
3-
define("MIDAS_COMMUNITY_SEMIPRIVATE", 1);
4-
define("MIDAS_COMMUNITY_PRIVATE", 2);
3+
define("MIDAS_COMMUNITY_PRIVATE", 1);
4+
define("MIDAS_COMMUNITY_CAN_JOIN", 1);
5+
define("MIDAS_COMMUNITY_INVITATION_ONLY", 0);
56
?>

core/controllers/AdminController.php

Lines changed: 129 additions & 126 deletions
Large diffs are not rendered by default.

core/controllers/CommunityController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function manageAction()
9595
$communityDao->setName($formInfo->getValue('name'));
9696
$communityDao->setDescription($formInfo->getValue('description'));
9797
$communityDao->setPrivacy($formInfo->getValue('privacy'));
98+
$communityDao->setCanJoin($formInfo->getValue('canJoin'));
9899
$this->Community->save($communityDao);
99100
echo JsonComponent::encode(array(true,$this->t('Changes saved'),$formInfo->getValue('name')));
100101
}
@@ -155,6 +156,8 @@ function manageAction()
155156
$description->setValue($communityDao->getDescription());
156157
$privacy=$formInfo->getElement('privacy');
157158
$privacy->setValue($communityDao->getPrivacy());
159+
$canJoin=$formInfo->getElement('canJoin');
160+
$canJoin->setValue($communityDao->getCanJoin());
158161
$submit=$formInfo->getElement('submit');
159162
$submit->setLabel($this->t('Save'));
160163
$this->view->infoForm=$this->getFormAsArray($formInfo);
@@ -240,7 +243,9 @@ function viewAction()
240243
throw new Zend_Exception("This community doesn't exist or you don't have the permissions.");
241244
}
242245
$joinCommunity=$this->_getParam('joinCommunity');
243-
if($this->userSession->Dao!=null&&isset($joinCommunity)&&$communityDao->getPrivacy()==MIDAS_COMMUNITY_PUBLIC)
246+
$canJoin=$communityDao->getCanJoin()==MIDAS_COMMUNITY_CAN_JOIN;
247+
$this->view->canJoin=$canJoin;
248+
if($canJoin&&$this->userSession->Dao!=null&&isset($joinCommunity)&&$communityDao->getPrivacy()==MIDAS_COMMUNITY_PUBLIC)
244249
{
245250
$member_group=$communityDao->getMemberGroup();
246251
$this->Group->addUser($member_group,$this->userSession->Dao);
@@ -315,8 +320,9 @@ function createAction()
315320
$name = $form->getValue('name');
316321
$description = $form->getValue('description');
317322
$privacy = $form->getValue('privacy');
323+
$canJoin = $form->getValue('canJoin');
318324

319-
$communityDao = $this->Community->createCommunity($name,$description,$privacy,$this->userSession->Dao);
325+
$communityDao = $this->Community->createCommunity($name,$description,$privacy,$this->userSession->Dao,$canJoin);
320326
$this->_redirect("/community/".$communityDao->getKey());
321327
}
322328
else

core/controllers/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public function userpageAction()
359359
}
360360
else
361361
{
362-
$this->User->plusOneView($userDao);
362+
$this->User->incrementViewCount($userDao);
363363
}
364364
$this->view->feeds=$this->Feed->getFeedsByUser($this->userSession->Dao,$userDao);
365365

core/controllers/forms/CommunityForm.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,24 @@ public function createCreateForm()
1616
$description = new Zend_Form_Element_Textarea('description');
1717

1818
$privacy = new Zend_Form_Element_Radio('privacy');
19-
$privacy->addMultiOptions( array(
20-
MIDAS_COMMUNITY_PUBLIC => $this->t("Public (Folders are public. Everyone can join the community)"),
21-
MIDAS_COMMUNITY_PRIVATE => $this->t("Private (Folders are private. Only invited users can join the community)"),
22-
MIDAS_COMMUNITY_SEMIPRIVATE => $this->t("Semi-private (Contain public and private folders. Only invited users can join the community)")
19+
$privacy->addMultiOptions( array(
20+
MIDAS_COMMUNITY_PRIVATE => $this->t("Private, only member can see the community"),
21+
MIDAS_COMMUNITY_PUBLIC => $this->t("Public, everyone can see the community"),
2322
))
2423
->setRequired(true)
2524
->setValue(MIDAS_COMMUNITY_PUBLIC);
25+
26+
$canJoin = new Zend_Form_Element_Radio('canJoin');
27+
$canJoin->addMultiOptions( array(
28+
MIDAS_COMMUNITY_CAN_JOIN => $this->t("Everyone can join the community"),
29+
MIDAS_COMMUNITY_INVITATION_ONLY => $this->t("Only invited users can join the community"),
30+
))
31+
->setValue(MIDAS_COMMUNITY_CAN_JOIN);
2632

2733
$submit = new Zend_Form_Element_Submit('submit');
2834
$submit ->setLabel($this->t("Create"));
2935

30-
$form->addElements(array($name,$description,$privacy,$submit));
36+
$form->addElements(array($name,$description,$privacy,$submit,$canJoin));
3137
return $form;
3238
}
3339

core/database/upgrade/3.0.3.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
class Upgrade_3_0_3 extends MIDASUpgrade
4+
{
5+
public function preUpgrade()
6+
{
7+
8+
}
9+
10+
public function mysql()
11+
{
12+
$sql = "ALTER TABLE community ADD COLUMN can_join integer DEFAULT 0; ";
13+
$this->db->query($sql);
14+
}
15+
16+
public function pgsql()
17+
{
18+
$sql = "ALTER TABLE community ADD COLUMN can_join tinyint(4) NOT NULL DEFAULT '0', ; ";
19+
$this->db->query($sql);
20+
}
21+
22+
public function postUpgrade()
23+
{
24+
25+
}
26+
}
27+
?>

core/models/base/CommunityModelBase.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct()
1818
'admingroup_id' => array('type' => MIDAS_DATA),
1919
'moderatorgroup_id' => array('type' => MIDAS_DATA),
2020
'membergroup_id' => array('type' => MIDAS_DATA),
21+
'can_join' => array('type' => MIDAS_DATA),
2122
'view' => array('type' => MIDAS_DATA),
2223
'folder' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Folder', 'parent_column' => 'folder_id', 'child_column' => 'folder_id'),
2324
'public_folder' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Folder', 'parent_column' => 'publicfolder_id', 'child_column' => 'folder_id'),
@@ -47,22 +48,35 @@ function incrementViewCount($communityDao)
4748
} //end incrementViewCount
4849

4950
/** Create a community.
50-
* privacy: MIDAS_COMMUNITY_PUBLIC, MIDAS_COMMUNITY_SEMIPRIVATE, MIDAS_COMMUNITY_PRIVATE
51+
* privacy: MIDAS_COMMUNITY_PUBLIC, MIDAS_COMMUNITY_PRIVATE
5152
* */
52-
function createCommunity($name,$description,$privacy,$user)
53+
function createCommunity($name,$description,$privacy,$user,$canJoin=null)
5354
{
5455
$name = ucfirst($name);
5556
if($this->getByName($name)!==false)
5657
{
5758
throw new Zend_Exception("Community already exists.");
5859
}
5960

61+
if($canJoin==null||$privacy==MIDAS_COMMUNITY_PRIVATE)
62+
{
63+
if($privacy==MIDAS_COMMUNITY_PRIVATE)
64+
{
65+
$canJoin=MIDAS_COMMUNITY_INVITATION_ONLY;
66+
}
67+
else
68+
{
69+
$canJoin=MIDAS_COMMUNITY_CAN_JOIN;
70+
}
71+
}
72+
6073
$this->loadDaoClass('CommunityDao');
6174
$communityDao=new CommunityDao();
6275
$communityDao->setName($name);
6376
$communityDao->setDescription($description);
6477
$communityDao->setPrivacy($privacy);
6578
$communityDao->setCreation(date('c'));
79+
$communityDao->setCanJoin($canJoin);
6680
$this->save($communityDao);
6781

6882
$modelLoad = new MIDAS_ModelLoader();

core/models/pdo/FeedModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function _getFeeds($loggedUserDao,$userDao=null,$communityDao=null,$po
148148
$this->database->getDB()->quoteInto('f2c.community_id = ? ',$communityDao->getKey())
149149
.' AND f.feed_id = f2c.feed_id' ,array());
150150
}
151-
151+
$sql->order(array('f.date DESC'));
152152
$rowset = $this->database->fetchAll($sql);
153153
$rowsetAnalysed=array();
154154
foreach ($rowset as $keyRow=>$row)

core/public/css/community/community.create.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ form#createCommunityForm label{
44

55
form#createCommunityForm div.radioElement label{
66
float: inherit!important;
7-
width: 300px!important;
7+
width: 400px!important;
88
}
99

1010
form#createCommunityForm div.radioElement ul{
@@ -13,3 +13,16 @@ form#createCommunityForm div.radioElement ul{
1313
padding: 0px 0px 0px 0px;
1414
width: 300px!important;
1515
}
16+
form#createCommunityForm div.radioElement br{
17+
display:none;
18+
}
19+
form#createCommunityForm div.radioElement h4{
20+
margin-bottom: 4px;
21+
}
22+
23+
form#createCommunityForm div.radioElement #canJoinDiv{
24+
margin-left: 10px;
25+
color: grey;
26+
}
27+
28+

0 commit comments

Comments
 (0)