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

Commit

Permalink
ENH: users can now join a community
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Marion committed Mar 28, 2011
1 parent 614a031 commit c862fb5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
18 changes: 18 additions & 0 deletions core/controllers/CommunityController.php
Expand Up @@ -50,6 +50,12 @@ function viewAction()
{
throw new Zend_Exception("This community doesn't exist or you don't have the permissions.");
}
$joinCommunity=$this->_getParam('joinCommunity');
if($this->userSession->Dao!=null&&isset($joinCommunity)&&$communityDao->getPrivacy()==MIDAS_COMMUNITY_PUBLIC)
{
$member_group=$communityDao->getMemberGroup();
$this->Group->addUser($member_group,$this->userSession->Dao);
}

$this->view->communityDao=$communityDao;
$this->view->information=array();
Expand All @@ -62,6 +68,18 @@ function viewAction()
$this->view->folders[]=$communityDao->getPublicFolder();
$this->view->folders[]=$communityDao->getPrivateFolder();

$this->view->isMember=false;
if($this->userSession->Dao!=null)
{
foreach($this->view->members as $member)
{
if($member->getKey()==$this->userSession->Dao->getKey())
{
$this->view->isMember=true;
break;
}
}
}
$this->view->isModerator=$this->Community->policyCheck($communityDao, $this->userSession->Dao,MIDAS_POLICY_WRITE);
$this->view->isAdmin=$this->Community->policyCheck($communityDao, $this->userSession->Dao,MIDAS_POLICY_ADMIN);
$this->view->json['community']=$communityDao->_toArray();
Expand Down
29 changes: 25 additions & 4 deletions core/views/community/view.phtml
Expand Up @@ -83,15 +83,30 @@ $this->headScript()->appendFile($this->webroot.'/public/js/common/common.browser

</div>
<div class="viewSideBar">

<?php
if($this->isModerator||$this->isAdmin)
if(!$this->isMember&&$this->communityDao->getPrivacy()==MIDAS_COMMUNITY_PUBLIC)
{
echo "
<form type='post' action=''>
<input name='joinCommunity' type='submit' class='globalButton' value='{$this->t('Join the community')}' />
</form>
";
}
else if(!$this->isMember&&$this->communityDao->getPrivacy()==MIDAS_COMMUNITY_SEMIPRIVATE)
{
echo "
<input type='button' class='globalButton' value='{$this->t('Request to join the community')}' />
";
}

if($this->isModerator||$this->isAdmin||$this->isMember)
{
echo "
<div class='sideElementFirst genericAction'>
<h1>Actions</h1>
<ul>";
if($this->isAdmin)
if($this->isModerator)
{
echo "
<li><a href=''>{$this->t('Manage Groups and Members')}</a></li>
Expand All @@ -105,12 +120,18 @@ $this->headScript()->appendFile($this->webroot.'/public/js/common/common.browser
<li><a href='javascript:;' id='communityDeleteLink'>{$this->t('Delete')}</a></li>
";
}
if($this->isMember)
{
echo "
<li><a href=''>{$this->t('Leave the community')}</a></li>
";
}
echo
" </ul>
</div>";
}
?>
<div class="sideElement<?php echo (!$this->isModerator&&!$this->isAdmin)?'First':''?> genericCommunities">
<div class="sideElement<?php echo (!$this->isModerator&&!$this->isAdmin&&!$this->isMember)?'First':''?> genericCommunities">
<h1><?php echo $this->t('Members')?></h1>
<ul>
<?php
Expand Down
3 changes: 2 additions & 1 deletion public/css/community/community.index.css
Expand Up @@ -15,4 +15,5 @@ div.communityList a{

div.communityList span{
padding-left: 15px;
}
}

3 changes: 3 additions & 0 deletions public/css/community/community.view.css
@@ -0,0 +1,3 @@
input.globalButton{
margin-left: 0px!important;
}
5 changes: 4 additions & 1 deletion translation/fr-main.csv
Expand Up @@ -113,4 +113,7 @@ Administration;Administration
member;membre
Manage Groups and Members;G�rer les Groupes et les Members
Manage Files;G�rer les fichiers
Do you really want to delete this community? It cannot be undo.; Voulez vous vraiment supprimer cette communit�? Cette action est irr�versible.
Do you really want to delete this community? It cannot be undo.; Voulez vous vraiment supprimer cette communit�? Cette action est irr�versible.
Join the community;Rejoindre la communaut�
Request to join the community;Demander � �tre membre de la communaut�
Leave the community;Quitter la communaut�

0 comments on commit c862fb5

Please sign in to comment.