1
1
<?php
2
2
3
+ /** api config controller */
3
4
class Api_ConfigController extends Api_AppController
4
5
{
5
- public $ _moduleForms =array ('Config ' );
6
- public $ _components =array ('Utility ' , 'Date ' );
7
- public $ _moduleModels =array ('Userapi ' );
6
+ public $ _moduleForms = array ('Config ' );
7
+ public $ _components = array ('Utility ' , 'Date ' );
8
+ public $ _moduleModels = array ('Userapi ' );
9
+
10
+ /** user config*/
11
+ function usertabAction ()
12
+ {
13
+ $ this ->_helper ->layout ->disableLayout ();
14
+ if (!$ this ->logged )
15
+ {
16
+ throw new Zend_Exception ('Please Log in ' );
17
+ }
8
18
9
- /** user config*/
10
- function usertabAction ()
11
- {
12
- $ this ->_helper ->layout ->disableLayout ();
13
- if (!$ this ->logged )
14
- {
15
- throw new Zend_Exception ('Please Log in ' );
16
- }
17
-
18
19
$ this ->view ->Date = $ this ->Component ->Date ;
19
20
20
21
$ form = $ this ->ModuleForm ->Config ->createKeyForm ();
@@ -29,7 +30,7 @@ function usertabAction()
29
30
$ this ->_helper ->viewRenderer ->setNoRender ();
30
31
$ applicationName = $ this ->_getParam ('appplication_name ' );
31
32
$ tokenExperiationTime = $ this ->_getParam ('expiration ' );
32
- $ userapiDao = $ this ->Api_Userapi ->createKey ($ this ->userSession ->Dao ,$ applicationName ,$ tokenExperiationTime );
33
+ $ userapiDao = $ this ->Api_Userapi ->createKey ($ this ->userSession ->Dao , $ applicationName , $ tokenExperiationTime );
33
34
if ($ userapiDao != false )
34
35
{
35
36
echo JsonComponent::encode (array (true , $ this ->t ('Changes saved ' )));
@@ -45,7 +46,7 @@ function usertabAction()
45
46
$ element = $ this ->_getParam ('element ' );
46
47
$ userapiDao = $ this ->Api_Userapi ->load ($ element );
47
48
// Make sure the key belongs to the user
48
- if ($ userapiDao !=false && ($ userapiDao ->getUserId () == $ this ->userSession ->Dao ->getKey () ||$ this ->userSession ->Dao ->isAdmin ()))
49
+ if ($ userapiDao != false && ($ userapiDao ->getUserId () == $ this ->userSession ->Dao ->getKey () || $ this ->userSession ->Dao ->isAdmin ()))
49
50
{
50
51
$ this ->Api_Userapi ->delete ($ userapiDao );
51
52
echo JsonComponent::encode (array (true , $ this ->t ('Changes saved ' )));
@@ -61,15 +62,15 @@ function usertabAction()
61
62
$ userapiDaos = $ this ->Api_Userapi ->getByUser ($ this ->userSession ->Dao );
62
63
$ this ->view ->userapiDaos = $ userapiDaos ;
63
64
}
64
-
65
- /** index action*/
66
- function indexAction ()
65
+
66
+ /** index action*/
67
+ function indexAction ()
67
68
{
68
- if (!$ this ->logged || !$ this ->userSession ->Dao ->getAdmin ()== 1 )
69
+ if (!$ this ->logged || !$ this ->userSession ->Dao ->getAdmin () == 1 )
69
70
{
70
71
throw new Zend_Exception ("You should be an administrator " );
71
72
}
72
-
73
+
73
74
if (file_exists (BASE_PATH ."/core/configs/api.local.ini " ))
74
75
{
75
76
$ applicationConfig = parse_ini_file (BASE_PATH ."/core/configs/api.local.ini " , true );
@@ -79,12 +80,12 @@ function indexAction()
79
80
$ applicationConfig = parse_ini_file (BASE_PATH .'/modules/api/configs/module.ini ' , true );
80
81
}
81
82
$ configForm = $ this ->ModuleForm ->Config ->createConfigForm ();
82
-
83
- $ formArray = $ this ->getFormAsArray ($ configForm );
83
+
84
+ $ formArray = $ this ->getFormAsArray ($ configForm );
84
85
$ formArray ['methodprefix ' ]->setValue ($ applicationConfig ['global ' ]['methodprefix ' ]);
85
-
86
+
86
87
$ this ->view ->configForm = $ formArray ;
87
-
88
+
88
89
if ($ this ->_request ->isPost ())
89
90
{
90
91
$ this ->_helper ->layout ->disableLayout ();
@@ -98,13 +99,13 @@ function indexAction()
98
99
}
99
100
if (file_exists (BASE_PATH ."/core/configs/api.local.ini " ))
100
101
{
101
- rename (BASE_PATH ."/core/configs/api.local.ini " ,BASE_PATH ."/core/configs/api.local.ini.old " );
102
+ rename (BASE_PATH ."/core/configs/api.local.ini " , BASE_PATH ."/core/configs/api.local.ini.old " );
102
103
}
103
104
$ applicationConfig ['global ' ]['methodprefix ' ] = $ this ->_getParam ('methodprefix ' );
104
105
$ this ->Component ->Utility ->createInitFile (BASE_PATH ."/core/configs/api.local.ini " , $ applicationConfig );
105
106
echo JsonComponent::encode (array (true , 'Changed saved ' ));
106
107
}
107
108
}
108
- }
109
-
109
+ }
110
+
110
111
}//end class
0 commit comments