Skip to content

Commit fb7a5b1

Browse files
committed
Ajax issue resolved
1 parent 59354ac commit fb7a5b1

File tree

7 files changed

+44
-25
lines changed

7 files changed

+44
-25
lines changed

app/Http/Controllers/UserController.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ function members(Request $request){
7777
}
7878

7979
function delete_users(Request $request){
80-
80+
81+
$request->ids = array_filter($request->ids);
82+
8183
if($request->role != 'admin'){
8284
return false;
8385
}
8486

85-
if(count($request->ids)){
87+
if(count($request->ids) == 0){
8688
return json_encode(['error' => 'Please select user first']);
8789
}
8890

@@ -98,11 +100,13 @@ function delete_users(Request $request){
98100

99101
function set_inactive_users(Request $request){
100102

103+
$request->ids = array_filter($request->ids);
104+
101105
if($request->role != 'admin'){
102106
return false;
103107
}
104108

105-
if(count($request->ids)){
109+
if(count($request->ids) == 0){
106110
return json_encode(['error' => 'Please select user first']);
107111
}
108112

@@ -119,12 +123,14 @@ function set_inactive_users(Request $request){
119123
}
120124

121125
function set_active_users(Request $request){
126+
127+
$request->ids = array_filter($request->ids);
122128

123129
if($request->role != 'admin'){
124130
return false;
125131
}
126132

127-
if(count($request->ids)){
133+
if(count($request->ids) == 0){
128134
return json_encode(['error' => 'Please select user first']);
129135
}
130136

@@ -142,7 +148,9 @@ function set_active_users(Request $request){
142148

143149
function block_users(Request $request){
144150

145-
if(count($request->ids)){
151+
$request->ids = array_filter($request->ids);
152+
153+
if(count($request->ids) == 0){
146154
return json_encode(['error' => 'Please select user first']);
147155
}
148156

@@ -160,7 +168,7 @@ function block_users(Request $request){
160168

161169
function unblock_users(Request $request){
162170

163-
if(count($request->ids)){
171+
if(count($request->ids) == 0){
164172
return json_encode(['error' => 'Please select user first']);
165173
}
166174

@@ -178,11 +186,13 @@ function unblock_users(Request $request){
178186

179187
function MakeAdmin(Request $request){
180188

189+
$request->ids = array_filter($request->ids);
190+
181191
if($request->role != 'admin'){
182192
return false;
183193
}
184194

185-
if(count($request->ids)){
195+
if(count($request->ids) == 0){
186196
return json_encode(['error' => 'Please select user first']);
187197
}
188198

@@ -200,11 +210,13 @@ function MakeAdmin(Request $request){
200210

201211
function RevokeAdmin(Request $request){
202212

213+
$request->ids = array_filter($request->ids);
214+
203215
if($request->role != 'admin'){
204216
return false;
205217
}
206218

207-
if(count($request->ids)){
219+
if(count($request->ids) == 0){
208220
return json_encode(['error' => 'Please select user first']);
209221
}
210222

@@ -237,8 +249,10 @@ function Profile(Request $request){
237249
}
238250

239251
function NewConversation(Request $request){
252+
253+
$request->ids = array_filter($request->ids);
240254

241-
if(count($request->ids)){
255+
if(count($request->ids) == 0){
242256
return json_encode(['error' => 'Please select user first']);
243257
}
244258

@@ -261,7 +275,7 @@ function NewConversation(Request $request){
261275
$ids = array_unique($ids);
262276

263277
if(count($ids) == 1){
264-
return false;
278+
return json_encode(['error' => 'You are only member of conversations, <strong>Please add two or more member</strong>']);
265279
}
266280

267281
$data = [];
@@ -324,6 +338,8 @@ function SaveProfile(Request $request){
324338
->update($data);
325339

326340
ActivityLog::log()->save('Profile','You have successfully updated your profile.');
341+
342+
return json_encode([]);
327343

328344
}
329345

public/js/kchat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Get id of selected options
301301

302302
function __post(url,posts){
303303
Data = {};
304-
Data['ids'] = posts;
304+
Data = posts;
305305
Data['_token'] = $('meta[name="csrf_token"]').attr('content');
306306
$.ajax({
307307
type: "POST",

public/js/members.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11

22
function delete_users(){
3-
kchat_alert("Are you sure you want to <strong>delete</strong> users?",(function(){__post('/members/delete_users',getSelectedID());}));
3+
kchat_alert("Are you sure you want to <strong>delete</strong> users?",(function(){__post('/members/delete_users',{'ids':{'ids':getSelectedID()}});}));
44
}
55

66
function set_inactive_users(){
7-
kchat_alert("Are you sure you want to set <strong>inactive</strong>?",(function(){__post('/members/set_inactive_users',getSelectedID());}));
7+
kchat_alert("Are you sure you want to set <strong>inactive</strong>?",(function(){__post('/members/set_inactive_users',{'ids':getSelectedID()});}));
88
}
99

1010
function set_active_users(){
11-
kchat_alert("Are you sure you want to set <strong>active</strong>?",(function(){__post('/members/set_active_users',getSelectedID());}));
11+
kchat_alert("Are you sure you want to set <strong>active</strong>?",(function(){__post('/members/set_active_users',{'ids':getSelectedID()});}));
1212
}
1313

1414
function block_users(){
15-
kchat_alert("Are you sure you want to <strong>block</strong> users?",(function(){__post('/members/block_users',getSelectedID());}));
15+
kchat_alert("Are you sure you want to <strong>block</strong> users?",(function(){__post('/members/block_users',{'ids':getSelectedID()});}));
1616
}
1717

1818
function unblock_users(){
19-
kchat_alert("Are you sure you want to <strong>unblock</strong> users?",(function(){__post('/members/unblock_users',getSelectedID());}));
19+
kchat_alert("Are you sure you want to <strong>unblock</strong> users?",(function(){__post('/members/unblock_users',{'ids':getSelectedID()});}));
2020
}
2121

2222
function NewConversation(){
23-
kchat_alert("Are you sure you want to start new <strong>Conversation</strong>?",(function(){__post('/members/newconversation',getSelectedID(),{
24-
'grpname' : $('#grpname').val()
25-
});}));
23+
kchat_alert("Are you sure you want to start new <strong>Conversation</strong>?",(function(){
24+
Data = {};
25+
Data['ids'] = getSelectedID();
26+
Data['grpname'] = $('#grpname').val();
27+
__post('/members/newconversation',Data);
28+
}));
2629
}
2730

2831
function revoke_admins(){
29-
kchat_alert("Are you sure you want to revoke <strong>admin privileges</strong>?",(function(){__post('/members/revokeadmin',getSelectedID());}));
32+
kchat_alert("Are you sure you want to revoke <strong>admin privileges</strong>?",(function(){__post('/members/revokeadmin',{'ids':getSelectedID()});}));
3033
}
3134

3235
function make_admins(){
33-
kchat_alert("Are you sure you want to grant <strong>admin privileges</strong>?",(function(){__post('/members/makeadmin',getSelectedID());}));
36+
kchat_alert("Are you sure you want to grant <strong>admin privileges</strong>?",(function(){__post('/members/makeadmin',{'ids':getSelectedID()});}));
3437
}
3538

3639
function delete_user(){

resources/views/admin/activities.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
@section('script')
6868
<script>
6969
function delete_activity(){
70-
kchat_alert("Are you sure you want to delete <strong>Activities</strong>?",(function(){__post('/activity/delete',getSelectedID());}));
70+
kchat_alert("Are you sure you want to delete <strong>Activities</strong>?",(function(){__post('/activity/delete',{'ids':getSelectedID()});}));
7171
}
7272
</script>
7373
@endsection

resources/views/admin/notifications.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
@section('script')
6868
<script>
6969
function delete_notificatios(){
70-
kchat_alert("Are you sure you want to delete <strong>Notifications</strong>?",(function(){__post('/notification/delete',getSelectedID());}));
70+
kchat_alert("Are you sure you want to delete <strong>Notifications</strong>?",(function(){__post('/notification/delete',{'ids':getSelectedID()});}));
7171
}
7272
</script>
7373
@endsection

resources/views/user/activities.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
@section('script')
6868
<script>
6969
function delete_activity(){
70-
kchat_alert("Are you sure you want to delete <strong>Activities</strong>?",(function(){__post('/activity/delete',getSelectedID());}));
70+
kchat_alert("Are you sure you want to delete <strong>Activities</strong>?",(function(){__post('/activity/delete',{'ids':getSelectedID()});}));
7171
}
7272
</script>
7373
@endsection

resources/views/user/notifications.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
@section('script')
6868
<script>
6969
function delete_notificatios(){
70-
kchat_alert("Are you sure you want to delete <strong>Notifications</strong>?",(function(){__post('/notification/delete',getSelectedID());}));
70+
kchat_alert("Are you sure you want to delete <strong>Notifications</strong>?",(function(){__post('/notification/delete',{'ids':getSelectedID()});}));
7171
}
7272
</script>
7373
@endsection

0 commit comments

Comments
 (0)