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

Commit

Permalink
BUG: Refs #0309. Use folderId instead of folderName to identify the d…
Browse files Browse the repository at this point in the history
…efault public and private folders.
  • Loading branch information
yuzhengZ committed Nov 21, 2011
1 parent 0f03b08 commit 2222334
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 36 deletions.
11 changes: 3 additions & 8 deletions core/controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,9 @@ public function getfolderscontentAction()
$tmp['folder_id'] = $folder->getFolderId();
$tmp['name'] = $folder->getName();
$tmp['date_update'] = $this->Component->Date->ago($folder->getDateUpdate(), true);
if($tmp['name'] == 'Public' || $tmp['name'] == 'Private')
{
$tmp['deletable'] = 'false';
}
else
{
$tmp['deletable'] = 'true';
}
// this ajax function is only used by treetable.js and it will handle all the other folders except for the top level folders.
// All the non-top level folders are deletable if users have correct permission
$tmp['deletable'] = 'true';
$tmp['policy'] = $folder->policy;
$tmp['privacy_status'] = $folder->privacy_status;
$jsonContent[$folder->getParentId()]['folders'][] = $tmp;
Expand Down
4 changes: 4 additions & 0 deletions core/controllers/CommunityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ function manageAction()
$this->view->userPersonalItems = $this->Folder->getItemsFiltered($this->view->userPersonalmainFolder, $this->userSession->Dao, MIDAS_POLICY_READ);

$this->view->isAdmin = $this->Community->policyCheck($communityDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
$this->view->privateFolderId = $communityDao->getPrivatefolderId();
$this->view->publicFolderId = $communityDao->getPublicfolderId();
$this->view->json['community'] = $communityDao->toArray();
$this->view->json['community']['moderatorGroup'] = $moderator_group->toArray();
$this->view->json['community']['memberGroup'] = $group_member->toArray();
Expand Down Expand Up @@ -311,6 +313,8 @@ function viewAction()
}
$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->privateFolderId = $communityDao->getPrivatefolderId();
$this->view->publicFolderId = $communityDao->getPublicfolderId();
$this->view->json['community'] = $communityDao->toArray();
$this->view->json['community']['sendInvitation'] = $this->t('Send invitation');

Expand Down
27 changes: 22 additions & 5 deletions core/controllers/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,33 @@ public function deleteAction()
}

$parent = $folder->getParent();
$folderName = $folder->getName();
$folderId = $folder->getFolderId();
// User cannot delete community's root folder, the default 'Public' folder and the default 'Private' folder
if(($this->Folder->getCommunity($parent) != false && ($folderName == 'Public' || $folderName == 'Private')) || $this->Folder->getCommunity($folder) != false)
if($this->Folder->getCommunity($folder) != false)
{
throw new Zend_Exception("Community Folder. You cannot delete it.");
throw new Zend_Exception("Community Root Folder. You cannot delete it.");
}
$communityDao = $this->Folder->getCommunity($parent);
if($communityDao != false)
{
if($communityDao->getPrivatefolderId() == $folderId || $communityDao->getPublicfolderId() == $folderId)
{
throw new Zend_Exception("Community Default Folder. You cannot delete it.");
}
}

// User cannot delete its root folder, the default 'Public' folder and the default 'Private' folder
if(($this->Folder->getUser($parent) != false && ($folderName == 'Public' || $folderName == 'Private')) || $this->Folder->getUser($folder) != false)
if($this->Folder->getUser($folder) != false)
{
throw new Zend_Exception("User Folder. You cannot delete it.");
throw new Zend_Exception("User Root Folder. You cannot delete it.");
}
$userDao = $this->Folder->getUser($parent);
if($userDao != false)
{
if($userDao->getPrivatefolderId() == $folderId || $userDao->getPublicfolderId() == $folderId)
{
throw new Zend_Exception("User Default Folder. You cannot delete it.");
}
}
$this->Folder->delete($folder, true);
$folderInfo = $folder->toArray();
Expand Down
4 changes: 4 additions & 0 deletions core/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ public function userpageAction()

$this->view->mainFolder = $userDao->getFolder();
$this->view->folders = $this->Folder->getChildrenFoldersFiltered($this->view->mainFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
$this->view->privateFolderId = $userDao->getPrivatefolderId();
$this->view->publicFolderId = $userDao->getPublicfolderId();
$this->view->items = $this->Folder->getItemsFiltered($this->view->mainFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
$this->view->feeds = $this->Feed->getFeedsByUser($this->userSession->Dao, $userDao);

Expand Down Expand Up @@ -727,6 +729,8 @@ public function manageAction()
$this->view->user = $userDao;
$this->view->mainFolder = $userDao->getFolder();
$this->view->folders = $this->Folder->getChildrenFoldersFiltered($this->view->mainFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
$this->view->privateFolderId = $userDao->getPrivatefolderId();
$this->view->publicFolderId = $userDao->getPublicfolderId();
$this->view->items = $this->Folder->getItemsFiltered($this->view->mainFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
$this->view->userCommunities = $communities;
$this->view->userCommunityFolders = $communityFolders;
Expand Down
12 changes: 6 additions & 6 deletions core/views/community/manage.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,20 @@ $this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.bro

foreach($this->folders as $folder)
{
$folderName = $folder->getName();
if ($folderName == 'Public' || $folderName == 'Private')
$folderId = $folder->getFolderId();
if ($folderId == $this->privateFolderId || $folderId == $this->publicFolderId)
{
$deletableStatus = 'false';
}
else
{
$deletableStatus = 'true';
}
echo "<tr id='node--$node' class='parent' deletable=$deletableStatus privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>$folderName</span></td>";
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo "<tr id='node--$node' class='parent' deletable=$deletableStatus privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='$folderId' ajax='$folderId'>";
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>{$folder->getName()}</span></td>";
echo " <td><img class='folderLoading' element='$folderId' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo " <td>{$this->Date->ago($folder->getDateUpdate(),true)}</td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='{$folder->getFolderId()}' /></td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='$folderId' /></td>";
echo "</tr>";
$node++;
}
Expand Down
10 changes: 5 additions & 5 deletions core/views/community/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ foreach($this->customCSSs as $Uris)
$node=1;
foreach($this->folders as $folder)
{
$folderName = $folder->getName();
if ($folderName == 'Public' || $folderName == 'Private')
$folderId = $folder->getFolderId();
if ($folderId == $this->privateFolderId || $folderId == $this->publicFolderId)
{
$deletableStatus = 'false';
}
else
{
$deletableStatus = 'true';
}
echo "<tr id='node--$node' policy='{$folder->policy}' deletable=$deletableStatus class='parent' privacy='{$folder->getPrivacyStatus()}' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
echo "<tr id='node--$node' policy='{$folder->policy}' deletable=$deletableStatus class='parent' privacy='{$folder->getPrivacyStatus()}' type='folder' element='$folderId' ajax='$folderId'>";
echo " <td class='treeBrowseElement'><span class='folder'>{$folder->getName()}</span></td>";
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo " <td><img class='folderLoading' element='$folderId' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo " <td>{$this->Date->ago($folder->getDateUpdate(),true)}</td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='{$folder->getFolderId()}' /></td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='$folderId' /></td>";
echo "</tr>";
$node++;
}
Expand Down
12 changes: 6 additions & 6 deletions core/views/user/manage.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ $this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.bro

foreach($this->folders as $folder)
{
$folderName = $folder->getName();
if ($folderName == 'Public' || $folderName == 'Private')
$folderId = $folder->getFolderId();
if ($folderId == $this->privateFolderId || $folderId == $this->publicFolderId)
{
$deletableStatus = 'false';
}
else
{
$deletableStatus = 'true';
}
echo "<tr id='node--$node' class='parent' deletable=$deletableStatus privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>$folderName</span></td>";
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo "<tr id='node--$node' class='parent' deletable=$deletableStatus privacy='{$folder->getPrivacyStatus()}' policy='".MIDAS_POLICY_ADMIN."' type='folder' element='$folderId' ajax='$folderId'>";
echo " <td class='treeBrowseElement'><span class='notdraggable folder'>{$folder->getName()}</span></td>";
echo " <td><img class='folderLoading' element='$folderId' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo " <td>{$this->Date->ago($folder->getDateUpdate(),true)}</td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='{$folder->getFolderId()}' /></td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='$folderId' /></td>";
echo "</tr>";
$node++;
}
Expand Down
12 changes: 6 additions & 6 deletions core/views/user/userpage.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ $this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.bro
$node=1;
foreach($this->folders as $folder)
{
$folderName = $folder->getName();
if ($folderName == 'Public' || $folderName == 'Private')
$folderId = $folder->getFolderId();
if ($folderId == $this->privateFolderId || $folderId == $this->publicFolderId)
{
$deletableStatus = 'false';
}
else
{
$deletableStatus = 'true';
}
echo "<tr id='node--$node' policy='{$folder->policy}' deletable=$deletableStatus class='parent' privacy='{$folder->getPrivacyStatus()}' type='folder' element='{$folder->getFolderId()}' ajax='{$folder->getFolderId()}'>";
echo " <td class='treeBrowseElement'><span class='folder'>$folderName</span></td>";
echo " <td><img class='folderLoading' element='{$folder->getFolderId()}' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo "<tr id='node--$node' policy='{$folder->policy}' deletable=$deletableStatus class='parent' privacy='{$folder->getPrivacyStatus()}' type='folder' element='$folderId' ajax='$folderId'>";
echo " <td class='treeBrowseElement'><span class='folder'>{$folder->getName()}</span></td>";
echo " <td><img class='folderLoading' element='$folderId' alt='' src='{$this->coreWebroot}/public/images/icons/loading.gif'/></td>";
echo " <td>{$this->Date->ago($folder->getDateUpdate(),true)}</td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='{$folder->getFolderId()}' /></td>";
echo " <td><input type='checkbox' class='treeCheckbox' type='folder' element='$folderId' /></td>";
echo "</tr>";
$node++;
}
Expand Down

0 comments on commit 2222334

Please sign in to comment.