@@ -5,7 +5,7 @@ class FolderController extends AppController
5
5
public $ _models =array ('Folder ' ,'Folder ' ,'Item ' ,'Folderpolicygroup ' ,'Folderpolicyuser ' );
6
6
public $ _daos =array ('Folder ' ,'Folder ' ,'Item ' );
7
7
public $ _components =array ('Utility ' ,'Date ' );
8
- public $ _forms =array ();
8
+ public $ _forms =array (' Folder ' );
9
9
10
10
/** Init Controller */
11
11
function init ()
@@ -19,6 +19,55 @@ function init()
19
19
}
20
20
$ this ->view ->activemenu = 'browse ' ; // set the active menu
21
21
} // 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
+ }
22
71
23
72
/** View Action*/
24
73
public function viewAction ()
0 commit comments