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

Commit

Permalink
ENH : added sharing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Marion committed Apr 22, 2011
1 parent ae29187 commit 51042ae
Show file tree
Hide file tree
Showing 13 changed files with 734 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/AppController.php
Expand Up @@ -122,7 +122,7 @@ public function preDispatch()
'edit'=>$this->t('Edit'),
'delete'=>$this->t('Delete'),
'deleteMessage'=>$this->t('Do you really want to delete the folder'),
'share'=>$this->t('Share'),
'share'=>$this->t('Sharing settings'),
'rename'=>$this->t('Rename'),
'move'=>$this->t('Move'),
'copy'=>$this->t('Copy'),
Expand Down
84 changes: 72 additions & 12 deletions core/controllers/SearchController.php
Expand Up @@ -5,7 +5,7 @@
*/
class SearchController extends AppController
{
public $_models=array('ItemKeyword','Item','Folder','User','Community');
public $_models=array('ItemKeyword','Item','Folder','User','Community','Group');
public $_daos=array('ItemKeyword','Item','Folder','User','Community');
public $_components=array('Sortdao','Date');

Expand Down Expand Up @@ -157,23 +157,61 @@ public function liveAction()
$this->_helper->viewRenderer->setNoRender();

$search = $this->getRequest()->getParam('term');
$shareSearch = $this->getRequest()->getParam('shareSearch'); //return user group and communities

// Search for the items
$ItemsDao = $this->ItemKeyword->getItemsFromSearch($search,$this->userSession->Dao);

// Search for the folders
$FoldersDao = $this->Folder->getFoldersFromSearch($search,$this->userSession->Dao);

// Search for the communities
$CommunitiesDao = $this->Community->getCommunitiesFromSearch($search,$this->userSession->Dao);

// Search for the users
$UsersDao = $this->User->getUsersFromSearch($search,$this->userSession->Dao);
if(isset ($shareSearch))
{
$ItemsDao = array();
$FoldersDao = array();

// Search for the communities
$CommunitiesDao = $this->Community->getCommunitiesFromSearch($search,$this->userSession->Dao);

// Search for the groups
$GroupsDao = $this->Group->getGroupFromSearch($search);
foreach($GroupsDao as $key=>$group)
{
if(strpos($group->getName(), 'group of community')!=false)
{
unset($GroupsDao[$key]);
continue;
}
if(isset($this->userSession->Dao)&&$this->userSession->Dao->isAdmin())
{
continue;
}
$community=$group->getCommunity();
$GroupsDao[$key]->community=$community;
if(!$this->Community->policyCheck($community,$this->userSession->Dao))
{
unset($GroupsDao[$key]);
}
}
// Search for the users
$UsersDao = $this->User->getUsersFromSearch($search,$this->userSession->Dao);
}
else
{
// Search for the items
$ItemsDao = $this->ItemKeyword->getItemsFromSearch($search,$this->userSession->Dao);

// Search for the folders
$FoldersDao = $this->Folder->getFoldersFromSearch($search,$this->userSession->Dao);

// Search for the communities
$CommunitiesDao = $this->Community->getCommunitiesFromSearch($search,$this->userSession->Dao);

// Search for the users
$UsersDao = $this->User->getUsersFromSearch($search,$this->userSession->Dao);
$GroupsDao=array();
}


// Compute how many of each we should display
$nitems = count($ItemsDao);
$nfolders = count($FoldersDao);
$ncommunities = count($CommunitiesDao);
$ngroups = count($GroupsDao);
$nusers = count($UsersDao);

$nmaxfolders = ($nfolders < 3) ? $nfolders : 3;
Expand Down Expand Up @@ -238,6 +276,28 @@ public function liveAction()
$n++;
echo '}';
}
// Groups
foreach($GroupsDao as $groupDao)
{
if($n == $ngroups)
{
break;
}
if($id>1)
{
echo ',';
}
echo '{';
echo '"id":"'.$id.'"';
echo ', "label":"'.$groupDao->getName();
echo '"';
echo ', "value":"'.$groupDao->getName().'"';
echo ', "groupid":"'.$groupDao->getKey().'"';
echo ', "category":"Groups"';
$id++;
$n++;
echo '}';
}

// Folder
$n=0;
Expand Down

0 comments on commit 51042ae

Please sign in to comment.