13
13
class Communityagreement_ConfigController extends Communityagreement_AppController
14
14
{
15
15
public $ _models = array ('Community ' );
16
- public $ _components =array ('Utility ' );
17
- public $ _moduleModels =array ('Agreement ' );
16
+ public $ _moduleModels = array ('Agreement ' );
18
17
public $ _moduleForms = array ('Config ' );
19
18
20
19
/** index */
@@ -26,77 +25,87 @@ function indexAction()
26
25
}
27
26
}
28
27
29
- /**
28
+ /**
30
29
* @method agreementtabAction()
31
30
* community agreement tab. It is shown in the community manage page when the 'community agreement' module is enabled
32
31
*/
33
- function agreementtabAction ()
34
- {
32
+ function agreementtabAction ()
33
+ {
35
34
36
- if (!$ this ->logged )
35
+ if (!$ this ->logged )
37
36
{
38
37
$ this ->haveToBeLogged ();
39
38
return false ;
40
39
}
40
+ if ($ this ->_helper ->hasHelper ('layout ' ))
41
+ {
42
+ $ this ->_helper ->layout ->disableLayout ();
43
+ }
41
44
42
- $ this ->_helper ->layout ->disableLayout ();
43
-
44
- $ communityId = $ this ->_getParam ("communityId " );
45
+ $ communityId = $ this ->_getParam ("communityId " );
45
46
if (!isset ($ communityId ) || (!is_numeric ($ communityId ) && strlen ($ communityId ) != 32 )) // This is tricky! and for Cassandra for now
46
47
{
47
48
throw new Zend_Exception ("Community ID should be a number " );
48
49
}
49
-
50
+
50
51
$ agreementDao = $ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId );
51
52
52
53
// If community agreement does not exist, show an emtpy string to the cummunity administrator
53
54
if ($ agreementDao == false )
54
55
{
55
- $ agreement = '' ;
56
- $ agreementDao = $ this ->Communityagreement_Agreement ->createAgreement ($ communityId , $ agreement );
56
+ $ agreement = '' ;
57
+ $ agreementDao = $ this ->Communityagreement_Agreement ->createAgreement ($ communityId , $ agreement );
57
58
}
58
59
59
60
$ formAgreement = $ this ->ModuleForm ->Config ->createCreateAgreementForm ($ communityId );
60
61
if ($ this ->_request ->isPost () && $ formAgreement ->isValid ($ this ->getRequest ()->getPost ()))
61
62
{
62
- $ this ->_helper ->layout ->disableLayout ();
63
- $ this ->_helper ->viewRenderer ->setNoRender ();
64
- $ agreementDao ->setAgreement ($ formAgreement ->getValue ('agreement ' ));
65
- if ($ agreementDao != false )
66
- {
67
- echo JsonComponent::encode (array (true , $ this ->t ('Changes saved ' )));
68
- }
69
- else
70
- {
71
- echo JsonComponent::encode (array (false , $ this ->t ('Error ' )));
72
- }
63
+ if ($ this ->_helper ->hasHelper ('layout ' ))
64
+ {
65
+ $ this ->_helper ->layout ->disableLayout ();
66
+ }
67
+ $ this ->_helper ->viewRenderer ->setNoRender ();
68
+ $ agreementDao ->setAgreement ($ formAgreement ->getValue ('agreement ' ));
69
+ if ($ agreementDao != false )
70
+ {
71
+ echo JsonComponent::encode (array (true , $ this ->t ('Changes saved ' )));
72
+ }
73
+ else
74
+ {
75
+ echo JsonComponent::encode (array (false , $ this ->t ('Error ' )));
76
+ }
73
77
}
74
78
75
79
// if agreement only contains white spaces, delete it from the database.
76
80
$ chopped_agreement = chop ($ agreementDao ->getAgreement ());
77
- if ($ chopped_agreement != '' ) {
78
- $ this ->Communityagreement_Agreement ->save ($ agreementDao );
79
- } else if ($ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId ) != false )
80
- {
81
- $ this ->Communityagreement_Agreement ->delete ($ agreementDao );
82
- }
81
+ if ($ chopped_agreement != '' )
82
+ {
83
+ $ this ->Communityagreement_Agreement ->save ($ agreementDao );
84
+ }
85
+ else if ($ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId ) != false )
86
+ {
87
+ $ this ->Communityagreement_Agreement ->delete ($ agreementDao );
88
+ }
83
89
84
90
//init form
85
91
$ agreement = $ formAgreement ->getElement ('agreement ' );
86
92
$ agreement ->setValue ($ agreementDao ->getAgreement ());
87
93
$ this ->view ->agreementForm = $ this ->getFormAsArray ($ formAgreement );
88
94
$ this ->view ->agreementDao = $ agreementDao ;
89
- }
95
+ }
90
96
91
- /**
97
+ /**
92
98
* @method agreementdialogAction()
93
99
* community agreement dialog, show the community agreements to peaple who want to join the community
94
- */
95
- function agreementdialogAction ()
96
- {
97
- $ this ->disableLayout ();
100
+ */
101
+ function agreementdialogAction ()
102
+ {
103
+ if ($ this ->_helper ->hasHelper ('layout ' ))
104
+ {
105
+ $ this ->_helper ->layout ->disableLayout ();
106
+ }
98
107
99
- $ communityId = $ this ->_getParam ("communityId " );
108
+ $ communityId = $ this ->_getParam ("communityId " );
100
109
if (!isset ($ communityId ) || (!is_numeric ($ communityId ) && strlen ($ communityId ) != 32 )) // This is tricky! and for Cassandra for now
101
110
{
102
111
throw new Zend_Exception ("Community ID should be a number " );
@@ -105,36 +114,36 @@ function agreementdialogAction()
105
114
$ agreementDao = $ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId );
106
115
if ($ agreementDao == false )
107
116
{
108
- $ agreement = '' ;
109
- $ agreementDao = $ this ->Communityagreement_Agreement ->createAgreement ($ communityId , $ agreement );
117
+ $ agreement = '' ;
118
+ $ agreementDao = $ this ->Communityagreement_Agreement ->createAgreement ($ communityId , $ agreement );
110
119
}
111
120
$ this ->view ->agreementDao = $ agreementDao ;
112
- }
121
+ }
113
122
114
123
115
124
/**
116
125
* @method checkIfAgreementEmptyAction()
117
- * ajax function which checks if the community agreement has been set
118
- */
119
- public function checkagreementAction ()
120
- {
121
- if (!$ this ->getRequest ()->isXmlHttpRequest ())
122
- {
123
- throw new Zend_Exception ("Why are you here ? Should be ajax. " );
124
- }
125
- $ this ->_helper ->layout ->disableLayout ();
126
- $ this ->_helper ->viewRenderer ->setNoRender ();
126
+ * ajax function which checks if the community agreement has been set
127
+ */
128
+ public function checkagreementAction ()
129
+ {
130
+ if (!$ this ->getRequest ()->isXmlHttpRequest ())
131
+ {
132
+ throw new Zend_Exception ("Why are you here ? Should be ajax. " );
133
+ }
134
+ $ this ->_helper ->layout ->disableLayout ();
135
+ $ this ->_helper ->viewRenderer ->setNoRender ();
127
136
128
- $ communityId = $ this ->_getParam ("communityId " );
129
- $ agreementDao = $ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId );
130
- if ($ agreementDao != false )
131
- {
132
- echo JsonComponent::encode (MIDAS_COMMUNITYAGREEMENT_AGREEMENT_NOT_EMPTY );
133
- }
134
- else
135
- {
136
- echo JsonComponent::encode (MIDAS_COMMUNITYAGREEMENT_AGREEMENT_IS_EMPTY );
137
- }
138
- }
137
+ $ communityId = $ this ->_getParam ("communityId " );
138
+ $ agreementDao = $ this ->Communityagreement_Agreement ->getByCommunityId ($ communityId );
139
+ if ($ agreementDao != false )
140
+ {
141
+ echo JsonComponent::encode (MIDAS_COMMUNITYAGREEMENT_AGREEMENT_NOT_EMPTY );
142
+ }
143
+ else
144
+ {
145
+ echo JsonComponent::encode (MIDAS_COMMUNITYAGREEMENT_AGREEMENT_IS_EMPTY );
146
+ }
147
+ }
139
148
140
149
}//end class
0 commit comments