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

Commit 22c7e15

Browse files
author
Charles Marion
committed
ENH: Now we can edit a folder: bug: 9583
1 parent a653908 commit 22c7e15

File tree

12 files changed

+197
-3
lines changed

12 files changed

+197
-3
lines changed

core/controllers/FolderController.php

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class FolderController extends AppController
55
public $_models=array('Folder','Folder','Item','Folderpolicygroup','Folderpolicyuser');
66
public $_daos=array('Folder','Folder','Item');
77
public $_components=array('Utility','Date');
8-
public $_forms=array();
8+
public $_forms=array('Folder');
99

1010
/** Init Controller */
1111
function init()
@@ -19,6 +19,55 @@ function init()
1919
}
2020
$this->view->activemenu = 'browse'; // set the active menu
2121
} // end init()
22+
23+
24+
/** Edit Folder (ajax) */
25+
function editAction()
26+
{
27+
$this->_helper->layout->disableLayout();
28+
$folder_id=$this->_getParam('folderId');
29+
$folder=$this->Folder->load($folder_id);
30+
if(!isset($folder_id))
31+
{
32+
throw new Zend_Exception("Please set the folderId.");
33+
}
34+
elseif($folder===false)
35+
{
36+
throw new Zend_Exception("The folder doesn t exist.");
37+
}
38+
elseif(!$this->Folder->policyCheck($folder, $this->userSession->Dao, MIDAS_POLICY_WRITE))
39+
{
40+
throw new Zend_Exception("Permissions error.");
41+
}
42+
43+
if($this->_request->isPost())
44+
{
45+
$name=$this->_getParam('name');
46+
$description=$this->_getParam('description');
47+
$teaser=$this->_getParam('teaser');
48+
49+
if(strlen($name)>0)
50+
{
51+
$folder->setName($name);
52+
}
53+
$folder->setDescription($description);
54+
if(strlen($teaser)<251)
55+
{
56+
$folder->setTeaser($teaser);
57+
}
58+
59+
$this->Folder->save($folder);
60+
$this->_redirect('/folder/'.$folder->getKey());
61+
}
62+
63+
$this->view->folderDao=$folder;
64+
$form = $this->Form->Folder->createEditForm();
65+
$formArray = $this->getFormAsArray($form);
66+
$formArray['name']->setValue($folder->getName());
67+
$formArray['description']->setValue($folder->getDescription());
68+
$formArray['teaser']->setValue($folder->getTeaser());
69+
$this->view->form = $formArray;
70+
}
2271

2372
/** View Action*/
2473
public function viewAction()

core/controllers/components/NotifyErrorComponent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function fatalEror($logger,$mailer)
3434
if(!is_null($e = error_get_last()))
3535
{
3636
$environment = Zend_Registry::get('configGlobal')->environment;
37-
3837
switch ($environment) {
3938
case 'production':
4039
$message .= "It seems you have just encountered an unknown issue.";
@@ -45,6 +44,7 @@ public function fatalEror($logger,$mailer)
4544
elseif($e['type']==E_WARNING )$e['typeText']='E_WARNING';
4645
elseif($e['type']==E_PARSE) $e['typeText ']='E_PARSE';
4746
elseif($e['type']==E_RECOVERABLE_ERROR) $e['typeText ']='E_RECOVERABLE_ERROR';
47+
elseif($e['type']==E_COMPILE_ERROR) $e['typeText ']='E_COMPILE_ERROR';
4848
else return;
4949
echo $message;
5050
$this->_mailer=$mailer;
@@ -58,6 +58,7 @@ public function fatalEror($logger,$mailer)
5858
elseif($e['type']==E_WARNING )$e['typeText']='E_WARNING';
5959
elseif($e['type']==E_PARSE) $e['typeText ']='E_PARSE';
6060
elseif($e['type']==E_RECOVERABLE_ERROR) $e['typeText ']='E_RECOVERABLE_ERROR';
61+
elseif($e['type']==E_COMPILE_ERROR) $e['typeText ']='E_COMPILE_ERROR';
6162
else return;
6263
header('content-type: text/plain');
6364
echo $this->getFatalErrorMessage($e);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
class FolderForm extends AppForm
3+
{
4+
/** create edit folder form */
5+
public function createEditForm()
6+
{
7+
$form = new Zend_Form;
8+
9+
$form->setAction($this->webroot.'/folder/edit')
10+
->setMethod('post');
11+
12+
$name = new Zend_Form_Element_Text('name');
13+
$name ->setRequired(true)
14+
->addValidator('NotEmpty', true);
15+
16+
$description = new Zend_Form_Element_Textarea('description');
17+
$teaser = new Zend_Form_Element_Text('teaser');
18+
$teaser->setAttrib('MAXLENGTH', '250');
19+
$submit = new Zend_Form_Element_Submit('submit');
20+
$submit ->setLabel($this->t("Save"));
21+
22+
$form->addElements(array($name,$description,$submit,$teaser));
23+
return $form;
24+
}
25+
26+
} // end class
27+
?>

core/database/upgrade/3.0.4.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_4 extends MIDASUpgrade
4+
{
5+
public function preUpgrade()
6+
{
7+
8+
}
9+
10+
public function mysql()
11+
{
12+
$sql = "ALTER TABLE folder ADD COLUMN teaser varchar(250) DEFAULT ''; ";
13+
$this->db->query($sql);
14+
}
15+
16+
public function pgsql()
17+
{
18+
$sql = "ALTER TABLE folder ADD COLUMN teaser varying(250) DEFAULT '', ; ";
19+
$this->db->query($sql);
20+
}
21+
22+
public function postUpgrade()
23+
{
24+
25+
}
26+
}
27+
?>

core/models/base/FolderModelBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct()
1818
'description' => array('type'=>MIDAS_DATA),
1919
'date' => array('type'=>MIDAS_DATA),
2020
'view' => array('type'=>MIDAS_DATA),
21+
'teaser' => array('type'=>MIDAS_DATA),
2122
'items' => array('type'=>MIDAS_MANY_TO_MANY, 'model'=>'Item', 'table' => 'item2folder', 'parent_column'=> 'folder_id', 'child_column' => 'item_id'),
2223
'folderpolicygroup' => array('type'=>MIDAS_ONE_TO_MANY, 'model' => 'Folderpolicygroup', 'parent_column'=> 'folder_id', 'child_column' => 'folder_id'),
2324
'folderpolicyuser' => array('type'=>MIDAS_ONE_TO_MANY, 'model' => 'Folderpolicyuser', 'parent_column'=> 'folder_id', 'child_column' => 'folder_id'),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
form#editFolderForm input[type="text"], form#editFolderForm input[type="password"] ,form#editFolderForm textarea
2+
{
3+
width: 350px!important;
4+
}
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
div.defaultSideTrigger{
22
display:none;
3+
}
4+
5+
div.viewAction{
6+
display:inherit!important;
7+
}
8+
9+
div.viewInfo{
10+
display:inherit!important;
311
}

core/public/js/common/common.browser.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@
133133
});
134134

135135
}
136+
137+
138+
function editFolder(id)
139+
{
140+
loadDialog("editFolder"+id,"/folder/edit?folderId="+id);
141+
showDialog(json.browse.edit,false);
142+
}
143+
136144
function removeItem(id)
137145
{
138146
var html='';
@@ -209,9 +217,10 @@
209217
{
210218
html+='<li><a onclick="createNewFolder('+element+');">'+json.browse.createFolder+'</a></li>';
211219
html+='<li><a rel="'+json.global.webroot+'/upload/simpleupload/?parent='+element+'" class="uploadInFolder">'+json.browse.uploadIn+'</a></li>';
220+
html+='<li><a onclick="editFolder('+element+');">'+json.browse.edit+'</a></li>';
212221
if(node.attr('deletable')!=undefined && node.attr('deletable')=='true')
213222
{
214-
html+='<li><a type="folder" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
223+
html+='<li><a type="folder" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
215224
html+='<li><a onclick="deleteFolder('+element+');">'+json.browse['delete']+'</a></li>';
216225
}
217226
}
@@ -310,6 +319,15 @@
310319
html+=' </tr>';
311320

312321
}
322+
323+
if(arrayElement['type']=='folder')
324+
{
325+
html+=' <tr>';
326+
html+=' <td colspan="2">';
327+
html+=arrayElement['teaser'];
328+
html+= '</td>';
329+
html+=' </tr>';
330+
}
313331
html+='</table>';
314332
if(arrayElement['type']=='community'&&arrayElement['privacy']==2)
315333
{

core/public/js/folder/folder.edit.js

Whitespace-only changes.

core/public/js/folder/folder.view.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
$("table#browseTable").show();
66
genericCallbackSelect($('div.defaultSideTrigger'));
77

8+
$( "#tabsGeneric" ).tabs();
9+
$("#tabsGeneric").show();
810
});
911

1012
//dependance: common/browser.js

0 commit comments

Comments
 (0)