Skip to content

Commit cc484a0

Browse files
author
helpfulrobot
committed
Converted to PSR-2
1 parent f7ff2f8 commit cc484a0

42 files changed

Lines changed: 2839 additions & 2473 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code/CodeBankRedirecter.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<?php
2-
class CodeBankRedirecter extends Controller {
3-
public function init() {
4-
parent::init();
5-
6-
$this->redirect('admin');
7-
}
8-
}
9-
?>
1+
<?php
2+
class CodeBankRedirecter extends Controller
3+
{
4+
public function init()
5+
{
6+
parent::init();
7+
8+
$this->redirect('admin');
9+
}
10+
}

code/amf/CodeBankAdministration.php

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
2-
class CodeBankAdministration implements CodeBank_APIClass {
2+
class CodeBankAdministration implements CodeBank_APIClass
3+
{
34
/**
45
* Gets a list of users in the database
56
* @return {array} Returns a standard response array
67
*/
7-
public function getUsersList() {
8+
public function getUsersList()
9+
{
810
$response=CodeBank_ClientAPI::responseBase();
911

1012
$members=Permission::get_members_by_permission(array('ADMIN', 'CODE_BANK_ACCESS'));
11-
foreach($members as $member) {
13+
foreach ($members as $member) {
1214
$response['data'][]=array(
1315
'id'=>$member->ID,
1416
'username'=>$member->Email,
@@ -25,18 +27,19 @@ public function getUsersList() {
2527
* @param {stdClass} $data Data passed from ActionScript
2628
* @return {array} Returns a standard response array
2729
*/
28-
public function deleteUser($data) {
30+
public function deleteUser($data)
31+
{
2932
$response=CodeBank_ClientAPI::responseBase();
3033

3134
try {
3235
$member=Member::get()->filter('ID', intval($data->id))->filter('ID:not', Member::currentUserID())->First();
33-
if(!empty($member) && $member!==false && $member->ID!=0) {
36+
if (!empty($member) && $member!==false && $member->ID!=0) {
3437
$member->delete();
3538
}
3639

3740
$response['status']='HELO';
3841
$response['message']=_t('CodeBankAPI.USER_DELETED', '_User deleted successfully');
39-
}catch (Exception $e) {
42+
} catch (Exception $e) {
4043
$response['status']='EROR';
4144
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
4245
}
@@ -49,19 +52,20 @@ public function deleteUser($data) {
4952
* @param {stdClass} $data Data passed from ActionScript
5053
* @return {array} Returns a standard response array
5154
*/
52-
public function changeUserPassword($data) {
55+
public function changeUserPassword($data)
56+
{
5357
$response=CodeBank_ClientAPI::responseBase();
5458

5559
try {
5660
$member=Member::get()->byID(intval($data->id));
57-
if(empty($member) || $member===false || $member->ID==0) {
61+
if (empty($member) || $member===false || $member->ID==0) {
5862
$response['status']='EROR';
5963
$response['message']=_t('CodeBankAPI.MEMBER_NOT_FOUND', '_Member not found');
6064

6165
return $response;
6266
}
6367

64-
if(!$member->changePassword($data->password)) {
68+
if (!$member->changePassword($data->password)) {
6569
$response['status']='EROR';
6670
$response['message']=_t('CodeBankAPI.NEW_PASSWORD_NOT_VALID', '_New password is not valid');
6771

@@ -71,7 +75,7 @@ public function changeUserPassword($data) {
7175

7276
$response['status']='HELO';
7377
$response['message']=_t('CodeBankAPI.PASSWORD_CHANGED', '_User\'s password changed successfully');
74-
}catch (Exception $e) {
78+
} catch (Exception $e) {
7579
$response['status']='EROR';
7680
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
7781
}
@@ -84,11 +88,12 @@ public function changeUserPassword($data) {
8488
* @param {stdClass} $data Data passed from ActionScript
8589
* @return {array} Returns a standard response array
8690
*/
87-
public function createUser($data) {
91+
public function createUser($data)
92+
{
8893
$response=CodeBank_ClientAPI::responseBase();
8994

9095
try {
91-
if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
96+
if (Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
9297
$response['status']='EROR';
9398
$response['message']=_t('CodeBankAPI.EMAIL_EXISTS', '_An account with that email already exists');
9499

@@ -104,7 +109,7 @@ public function createUser($data) {
104109
$member->Password=$data->Password;
105110
$member->UseHeartbeat=0;
106111

107-
if(!$member->validate()) {
112+
if (!$member->validate()) {
108113
$response['status']='EROR';
109114
$response['message']=_t('CodeBankAPI.PASSWORD_NOT_VALID', '_Password is not valid');
110115

@@ -116,7 +121,7 @@ public function createUser($data) {
116121

117122
$response['status']='HELO';
118123
$response['message']="User added successfully";
119-
}catch (Exception $e) {
124+
} catch (Exception $e) {
120125
$response['status']='EROR';
121126
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
122127
}
@@ -128,11 +133,12 @@ public function createUser($data) {
128133
* Gets the list of languages with snippet counts
129134
* @return {array} Standard response base
130135
*/
131-
public function getAdminLanguages() {
136+
public function getAdminLanguages()
137+
{
132138
$response=CodeBank_ClientAPI::responseBase();
133139

134140
$languages=SnippetLanguage::get();
135-
foreach($languages as $lang) {
141+
foreach ($languages as $lang) {
136142
$response['data'][]=array(
137143
'id'=>$lang->ID,
138144
'language'=>$lang->Name,
@@ -153,11 +159,12 @@ public function getAdminLanguages() {
153159
* @param {stdClass} $data Data passed from ActionScript
154160
* @return {array} Returns a standard response array
155161
*/
156-
public function createLanguage($data) {
162+
public function createLanguage($data)
163+
{
157164
$response=CodeBank_ClientAPI::responseBase();
158165

159166
try {
160-
if(SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) {
167+
if (SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) {
161168
$response['status']='EROR';
162169
$response['message']=_t('CodeBankAPI.LANGUAGE_EXISTS', '_Language already exists');
163170

@@ -175,7 +182,7 @@ public function createLanguage($data) {
175182

176183
$response['status']='HELO';
177184
$response['message']="Language added successfully";
178-
}catch (Exception $e) {
185+
} catch (Exception $e) {
179186
$response['status']='EROR';
180187
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
181188
}
@@ -188,19 +195,20 @@ public function createLanguage($data) {
188195
* @param {stdClass} $data Data passed from ActionScript
189196
* @return {array} Returns a standard response array
190197
*/
191-
public function deleteLanguage($data) {
198+
public function deleteLanguage($data)
199+
{
192200
$response=CodeBank_ClientAPI::responseBase();
193201

194202
try {
195203
$lang=SnippetLanguage::get()->byID(intval($data->id));
196-
if(!empty($lang) && $lang!==false && $lang->ID!=0) {
197-
if($lang->canDelete()==false) {
204+
if (!empty($lang) && $lang!==false && $lang->ID!=0) {
205+
if ($lang->canDelete()==false) {
198206
$response['status']='EROR';
199207
$response['message']=_t('CodeBankAPI.LANGUAGE_DELETE_ERROR', '_Language cannot be deleted, it is either not a user language or has snippets attached to it');
200208

201209
return $response;
202210
}
203-
}else {
211+
} else {
204212
$response['status']='EROR';
205213
$response['message']=_t('CodeBankAPI.LANGUAGE_NOT_FOUND', '_Language not found');
206214

@@ -213,7 +221,7 @@ public function deleteLanguage($data) {
213221

214222
$response['status']='HELO';
215223
$response['message']="Language deleted successfully";
216-
}catch (Exception $e) {
224+
} catch (Exception $e) {
217225
$response['status']='EROR';
218226
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
219227
}
@@ -226,11 +234,12 @@ public function deleteLanguage($data) {
226234
* @param {stdClass} $data Data passed from ActionScript
227235
* @return {array} Returns a standard response array
228236
*/
229-
public function editLanguage($data) {
237+
public function editLanguage($data)
238+
{
230239
$response=CodeBank_ClientAPI::responseBase();
231240

232241
try {
233-
if(SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) {
242+
if (SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) {
234243
$response['status']='EROR';
235244
$response['message']=_t('CodeBankAPI.LANGUAGE_EXISTS', '_Language already exists');
236245

@@ -239,7 +248,7 @@ public function editLanguage($data) {
239248

240249

241250
$lang=SnippetLanguage::get()->byID(intval($data->id));
242-
if(empty($lang) || $lang===false || $lang->ID==0) {
251+
if (empty($lang) || $lang===false || $lang->ID==0) {
243252
$response['status']='EROR';
244253
$response['message']=_t('CodeBankAPI.LANGUAGE_NOT_FOUND', '_Language not found');
245254

@@ -248,7 +257,7 @@ public function editLanguage($data) {
248257

249258

250259
//Update language and write
251-
if($lang->UserLanguage==true) {
260+
if ($lang->UserLanguage==true) {
252261
$lang->Name=$data->language;
253262
$lang->FileExtension=$data->fileExtension;
254263
}
@@ -259,7 +268,7 @@ public function editLanguage($data) {
259268

260269
$response['status']='HELO';
261270
$response['message']="Language edited successfully";
262-
}catch (Exception $e) {
271+
} catch (Exception $e) {
263272
$response['status']='EROR';
264273
$response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
265274
}
@@ -271,11 +280,11 @@ public function editLanguage($data) {
271280
* Gets the permissions required to access the class
272281
* @return {array} Array of permission names to check
273282
*/
274-
public function getRequiredPermissions() {
283+
public function getRequiredPermissions()
284+
{
275285
return array(
276286
'CODE_BANK_ACCESS',
277287
'ADMIN'
278288
);
279289
}
280290
}
281-
?>

0 commit comments

Comments
 (0)