forked from stefanocolarelli/hackunito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log
1885 lines (1883 loc) · 90.3 KB
/
log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[33mcommit c8206f7ac0dea9cc7a3cb057032de7d04fed8dab[m
Author: stefano_colarelli <[email protected]>
Date: Wed Nov 6 23:52:27 2013 +0100
In dev plugins
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/README b/wp-content/plugins/blog-categories-for-groups/README[m
[1mnew file mode 100644[m
[1mindex 0000000..702ffd3[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/README[m
[36m@@ -0,0 +1,3 @@[m
[32m+[m[32mBlog Categories for groups plugin allows BuddyPress group admins to associate categories to groups and act these as the mini blog of a group.[m
[32m+[m
[32m+[m[32mPlease move the folder "bcg" to your current theme to make this plugin work.[m
\ No newline at end of file[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg-admin.php b/wp-content/plugins/blog-categories-for-groups/bcg-admin.php[m
[1mnew file mode 100644[m
[1mindex 0000000..32fadec[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg-admin.php[m
[36m@@ -0,0 +1,85 @@[m
[32m+[m[32m<?php[m
[32m+[m[32m//handle everything except the front end display[m
[32m+[m
[32m+[m[32mclass BCG_Group_Extension extends BP_Group_Extension {[m
[32m+[m[32mvar $visibility = 'public'; // 'public' will show your extension to non-group members, 'private' means you have to be a member of the group to view your extension.[m
[32m+[m
[32m+[m[32mvar $enable_create_step = true; // enable create step[m
[32m+[m[32mvar $enable_nav_item = false; //do not show in front end[m
[32m+[m[32mvar $enable_edit_item = true; // If your extensi[m
[32m+[m [32mfunction __construct() {[m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m [32m$this->name = __('Blog Categories','bcg');[m
[32m+[m [32m$this->slug = 'blog-categories';[m
[32m+[m
[32m+[m [32m$this->create_step_position = 21;[m
[32m+[m [32m$this->nav_item_position = 31;[m
[32m+[m [32m}[m
[32m+[m[32m//on group crate step[m
[32m+[m [32mfunction create_screen() {[m
[32m+[m [32mif ( !bp_is_group_creation_step( $this->slug ) )[m
[32m+[m [32mreturn false;[m
[32m+[m [32mbcg_admin_form();[m
[32m+[m [32mwp_nonce_field( 'groups_create_save_' . $this->slug );[m
[32m+[m [32m}[m
[32m+[m[32m//on group create save[m
[32m+[m [32mfunction create_screen_save() {[m
[32m+[m [32mglobal $bp;[m
[32m+[m
[32m+[m [32mcheck_admin_referer( 'groups_create_save_' . $this->slug );[m
[32m+[m[32m $group_id=$bp->groups->new_group_id;[m
[32m+[m [32m $cats=$_POST["blog_cats"];[m
[32m+[m[32m //print_r($cats);[m
[32m+[m [32mif ( !bcg_update_categories($group_id, $cats) ) {[m
[32m+[m [32m//bp_core_add_message( __( 'There was an error updating group blog category settings, please try again.', 'buddypress' ), 'error' );[m
[32m+[m [32m} else {[m
[32m+[m [32mbp_core_add_message( __( 'Group Blog Categories settings were successfully updated.', 'bcg' ) );[m
[32m+[m [32m}[m
[32m+[m [32m}[m
[32m+[m
[32m+[m [32mfunction edit_screen() {[m
[32m+[m [32mif ( !bp_is_group_admin_screen( $this->slug ) )[m
[32m+[m [32mreturn false; ?>[m
[32m+[m
[32m+[m[32m <h2><?php echo esc_attr( $this->name ) ?></h2>[m
[32m+[m[32m<?php[m
[32m+[m[32m bcg_admin_form();[m
[32m+[m
[32m+[m
[32m+[m [32mwp_nonce_field( 'groups_edit_save_' . $this->slug );[m
[32m+[m[32m ?>[m
[32m+[m[32m <p><input type="submit" value="<?php _e( 'Save Changes', 'bcg' ) ?> →" id="save" name="save" /></p>[m
[32m+[m[32m <?php[m
[32m+[m [32m}[m
[32m+[m
[32m+[m [32mfunction edit_screen_save() {[m
[32m+[m [32mglobal $bp;[m
[32m+[m
[32m+[m [32mif ( !isset( $_POST['save'] ) )[m
[32m+[m [32mreturn false;[m
[32m+[m
[32m+[m [32mcheck_admin_referer( 'groups_edit_save_' . $this->slug );[m
[32m+[m
[32m+[m
[32m+[m[32m $group_id=$bp->groups->current_group->id;[m
[32m+[m [32m $cats=$_POST["blog_cats"];[m
[32m+[m[32m //print_r($cats);[m
[32m+[m [32mif ( !bcg_update_categories($group_id, $cats) ) {[m
[32m+[m [32mbp_core_add_message( __( 'There was an error updating Group Blog Categories settings, please try again.', 'bcg' ), 'error' );[m
[32m+[m [32m} else {[m
[32m+[m [32mbp_core_add_message( __( 'Group Blog Categories settings were successfully updated.', 'bcg' ) );[m
[32m+[m [32m}[m
[32m+[m
[32m+[m [32mbp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/' . $this->slug );[m
[32m+[m [32m}[m
[32m+[m
[32m+[m [32mfunction display() {[m
[32m+[m [32m/* Use this function to display the actual content of your group extension when the nav item is selected */[m
[32m+[m [32m}[m
[32m+[m
[32m+[m [32mfunction widget_display() {[m
[32m+[m [32m}[m
[32m+[m[32m}[m
[32m+[m[32mif(!bcg_is_disabled_for_group())[m
[32m+[m[32m bp_register_group_extension( 'BCG_Group_Extension' );[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg-functions.php b/wp-content/plugins/blog-categories-for-groups/bcg-functions.php[m
[1mnew file mode 100644[m
[1mindex 0000000..eaf85d8[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg-functions.php[m
[36m@@ -0,0 +1,91 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32mfunction bcg_load_template($template){[m
[32m+[m[41m [m
[32m+[m[32m if(is_readable(STYLESHEETPATH.'/'.$template))[m
[32m+[m[32m $load=STYLESHEETPATH.'/'.$template;[m
[32m+[m[32m elseif(is_readable(TEMPLATEPATH.'/'.$template))[m
[32m+[m[32m $load=TEMPLATEPATH.'/'.$template;[m
[32m+[m[32m else[m
[32m+[m[32m $load=BCG_PLUGIN_DIR.$template;[m
[32m+[m[41m [m
[32m+[m[32m include_once $load;[m
[32m+[m[32m}[m
[32m+[m[32m/**[m
[32m+[m[32m *[m
[32m+[m[32m * @global type $bp[m
[32m+[m[32m * @return type[m[41m [m
[32m+[m[32m */[m
[32m+[m[32mfunction bcg_is_disabled_for_group(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m $group_id=false;[m
[32m+[m[32m if (bp_is_group_create())[m
[32m+[m[32m $group_id=$_COOKIE['bp_new_group_id'];[m
[32m+[m[32m else if(bp_is_group ())[m
[32m+[m[32m $group_id=$bp->groups->current_group->id;[m
[32m+[m
[32m+[m[32m return apply_filters('bcg_is_disabled_for_group',bcg_is_disabled($group_id));[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m/**[m
[32m+[m[32m * Can the current user post to group blog[m
[32m+[m[32m * @global type $bp[m
[32m+[m[32m * @return type[m[41m [m
[32m+[m[32m */[m
[32m+[m[32mfunction bcg_current_user_can_post(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m $user_id= bp_loggedin_user_id();[m
[32m+[m[32m $group_id= bp_get_current_group_id();[m
[32m+[m[32m $can_post=is_user_logged_in()&&(groups_is_user_admin($user_id, $group_id)||groups_is_user_mod($user_id, $group_id));[m
[32m+[m[41m [m
[32m+[m[32m return apply_filters('bcg_current_user_can_post',$can_post,$group_id,$user_id);[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32mfunction bcg_get_home_url($group_id=null){[m
[32m+[m[32m global $bp;[m
[32m+[m
[32m+[m[32mif(!empty($group_id))[m
[32m+[m[32m $group=new BP_Groups_Group ($group_id);[m
[32m+[m[32melse[m
[32m+[m[32m $group= groups_get_current_group();[m
[32m+[m
[32m+[m[32mreturn apply_filters('bcg_home_url', bp_get_group_permalink($group).BCG_SLUG);[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32mfunction bcg_is_disabled($group_id){[m
[32m+[m[32m if(empty($group_id))[m
[32m+[m[32m return false; //if grou id is empty, it is active[m
[32m+[m[32m $is_disabled=groups_get_groupmeta($group_id,"bcg_is_active");[m
[32m+[m[32m return apply_filters("bcg_is_disabled",intval($is_disabled),$group_id);[m
[32m+[m[32m}[m
[32m+[m[32m//call me business function[m
[32m+[m[32mfunction bcg_get_categories($group_id){[m
[32m+[m[32m $cats=groups_get_groupmeta($group_id,'group_blog_cats');[m
[32m+[m[32m return maybe_unserialize($cats);[m
[32m+[m[32m}[m
[32m+[m[32m//update table[m
[32m+[m[32mfunction bcg_update_categories($group_id,$cats){[m
[32m+[m[32m $cats=maybe_serialize($cats);[m
[32m+[m[32m return groups_update_groupmeta($group_id, "group_blog_cats", $cats);[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m//get the appropriate query for various screens[m
[32m+[m[32mfunction bcg_get_query(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m $cats=bcg_get_categories($bp->groups->current_group->id);[m
[32m+[m
[32m+[m[32m if(!empty($cats))[m
[32m+[m[32m $cats_list=join(",",$cats);[m
[32m+[m[32m else return "name=-1";//we know it will not find anything[m
[32m+[m[32m if(bcg_is_single_post()){[m
[32m+[m[32m $slug=$bp->action_variables[0];[m
[32m+[m[32m return "name=".$slug."&cat=".$cats_list;[m
[32m+[m[32m }[m
[32m+[m[32m $paged=(get_query_var('paged')) ? get_query_var('paged') : 1;[m
[32m+[m[32mif(bcg_is_category ()){[m
[32m+[m[32m $query="cat=".$bp->action_variables[1];[m
[32m+[m[32m}//only posts from current category[m
[32m+[m[32melse[m
[32m+[m[32m $query= "cat=".$cats_list;[m
[32m+[m[32mreturn apply_filters("bcg_get_query",$query."&paged=".$paged);[m
[32m+[m[32m}[m
\ No newline at end of file[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg-hooks.php b/wp-content/plugins/blog-categories-for-groups/bcg-hooks.php[m
[1mnew file mode 100644[m
[1mindex 0000000..d443fd8[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg-hooks.php[m
[36m@@ -0,0 +1,66 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32m/**[m
[32m+[m[32m * Update and save group preference[m
[32m+[m[32m */[m
[32m+[m[32madd_action('groups_group_settings_edited','bcg_save_group_prefs');[m
[32m+[m[32madd_action('groups_create_group','bcg_save_group_prefs');[m
[32m+[m[32madd_action('groups_update_group','bcg_save_group_prefs');[m
[32m+[m
[32m+[m[32mfunction bcg_save_group_prefs($group_id){[m
[32m+[m[32m $disable=$_POST['group-disable-bcg'];[m
[32m+[m[32m groups_update_groupmeta($group_id, 'bcg_is_active', $disable);//save preference[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m/*put a settings for allowing disallowing the bcg*/[m
[32m+[m[32madd_action('bp_before_group_settings_admin','bcg_group_disable_form');[m
[32m+[m[32madd_action('bp_before_group_settings_creation_step','bcg_group_disable_form');[m
[32m+[m[32m//check if the group yt is enabled[m
[32m+[m[32mfunction bcg_group_disable_form(){?>[m
[32m+[m
[32m+[m[32m <div class="checkbox">[m
[32m+[m[32m <label><input type="checkbox" name="group-disable-bcg" id="group-disable-bcg" value="1" <?php if(bcg_is_disabled_for_group()):?> checked="checked"<?php endif;?>/> <?php _e( 'Disable Blog Categories', 'bcg' ) ?></label>[m
[32m+[m[32m </div>[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m//comment posting a lil bit better[m
[32m+[m[32madd_action('comment_form','bcg_fix_comment_form' );[m
[32m+[m
[32m+[m[32mfunction bcg_fix_comment_form($post_id){[m
[32m+[m[32m if(!bcg_is_single_post())[m
[32m+[m[32m return;[m
[32m+[m[32m $post=get_post($post_id);[m
[32m+[m[32m $permalink= bcg_get_post_permalink($post);[m
[32m+[m[32m ?>[m
[32m+[m[32m <input type='hidden' name='redirect_to' value="<?php echo esc_url($permalink);?>" />[m
[32m+[m[32m <?php[m
[32m+[m[32m}[m
[32m+[m
[32m+[m
[32m+[m[32m/* fixing permalinks for posts/categories inside the bcg loop*/[m
[32m+[m
[32m+[m
[32m+[m[32m//fix post permalink, should we ?[m
[32m+[m[32madd_filter('post_link','bcg_fix_permalink',10,3);[m
[32m+[m[32mfunction bcg_fix_permalink($post_link, $id, $leavename){[m
[32m+[m[32m if(!is_bcg_pages()||!in_bcg_loop())[m
[32m+[m[32m return $post_link;[m
[32m+[m
[32m+[m[32m $post_link=bcg_get_post_permalink(get_post($id));[m
[32m+[m[32m return $post_link;[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m//on Blog category pages fix the category link to point to internal, may cause troubles in some case[m
[32m+[m[32madd_filter( 'category_link', 'bcg_fix_category_permalink',10,2 );[m
[32m+[m[32mfunction bcg_fix_category_permalink($catlink, $category_id){[m
[32m+[m[32m if(!is_bcg_pages ()||!in_bcg_loop())[m
[32m+[m[32m return $catlink;[m
[32m+[m[41m [m
[32m+[m[32m $permalink=bcg_get_home_url();[m
[32m+[m[32m $cat=get_category($category_id);[m
[32m+[m[32m //think about the cat permalink, do we need it or not?[m
[32m+[m
[32m+[m[32m return $permalink.'/category/'.$category_id;//no need for category_name[m
[32m+[m[32m}[m
\ No newline at end of file[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg/blog.php b/wp-content/plugins/blog-categories-for-groups/bcg/blog.php[m
[1mnew file mode 100644[m
[1mindex 0000000..81303b2[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg/blog.php[m
[36m@@ -0,0 +1,55 @@[m
[32m+[m [32m<?php[m
[32m+[m [32m/*[m
[32m+[m [32mThis page is used for group blog home page/categories archives*/[m
[32m+[m [32m?>[m
[32m+[m [32m<?php $q=new WP_Query(bcg_get_query());?>[m
[32m+[m [32m<?php if ($q->have_posts() ) : ?>[m
[32m+[m [32m<?php do_action( 'bp_before_group_blog_content' ) ?>[m
[32m+[m [32m<div class="pagination no-ajax">[m
[32m+[m [32m<div id="posts-count" class="pag-count">[m
[32m+[m [32m<?php bcg_posts_pagination_count($q) ?>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<div id="posts-pagination" class="pagination-links">[m
[32m+[m [32m<?php bcg_pagination($q) ?>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<?php do_action( 'bp_before_group_blog_list' ) ?>[m
[32m+[m[32m<?php[m
[32m+[m [32mglobal $post;[m
[32m+[m [32mbcg_loop_start();//please do not remove it[m
[32m+[m [32mwhile($q->have_posts()):$q->the_post();?>[m
[32m+[m [32m<div class="post" id="post-<?php the_ID(); ?>">[m
[32m+[m
[32m+[m [32m<div class="author-box">[m
[32m+[m [32m<?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?>[m
[32m+[m [32m<p><?php printf( __( 'by %s', 'bcg' ), bp_core_get_userlink( $post->post_author ) ) ?></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<div class="post-content">[m
[32m+[m [32m<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'bcg' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>[m
[32m+[m
[32m+[m [32m<p class="date"><?php the_time() ?> <em><?php _e( 'in', 'bcg' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'bcg' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>[m
[32m+[m
[32m+[m [32m<div class="entry">[m
[32m+[m [32m<?php the_excerpt( ); ?>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<p class="postmetadata"><span class="tags"><?php the_tags( __( 'Tags: ', 'bcg' ), ', ', '<br />'); ?></span> <span class="comments"><?php comments_popup_link( __( 'No Comments »', 'bcg' ), __( '1 Comment »', 'bcg' ), __( '% Comments »', 'bcg' ) ); ?></span></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m</div>[m
[32m+[m [32m<?php endwhile;?>[m
[32m+[m [32m<?php do_action( 'bp_after_group_blog_content' ) ;[m
[32m+[m [32mbcg_loop_end();//please do not remove it[m
[32m+[m [32m?>[m
[32m+[m
[32m+[m[32m<?php else: ?>[m
[32m+[m
[32m+[m [32m<div id="message" class="info">[m
[32m+[m [32m<p><?php _e( 'This group has no Blog posts.', 'bcg' ); ?></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m[32m<?php endif; ?>[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg/create.php b/wp-content/plugins/blog-categories-for-groups/bcg/create.php[m
[1mnew file mode 100644[m
[1mindex 0000000..0305559[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg/create.php[m
[36m@@ -0,0 +1 @@[m
[32m+[m[32m<?php bcg_get_post_form(bp_get_group_id());?>[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg/home.php b/wp-content/plugins/blog-categories-for-groups/bcg/home.php[m
[1mnew file mode 100644[m
[1mindex 0000000..876f444[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg/home.php[m
[36m@@ -0,0 +1,47 @@[m
[32m+[m[32m<?php get_header() ?>[m
[32m+[m
[32m+[m [32m<div id="content">[m
[32m+[m [32m<div class="padder">[m
[32m+[m [32m<?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>[m
[32m+[m
[32m+[m [32m<?php do_action( 'bp_before_group_home_content' ) ?>[m
[32m+[m
[32m+[m [32m<div id="item-header">[m
[32m+[m [32m<?php locate_template( array( 'groups/single/group-header.php' ), true ) ?>[m
[32m+[m [32m</div><!-- #item-header -->[m
[32m+[m
[32m+[m [32m<div id="item-nav">[m
[32m+[m [32m<div class="item-list-tabs no-ajax" id="object-nav">[m
[32m+[m [32m<ul>[m
[32m+[m [32m<?php bp_get_options_nav() ?>[m
[32m+[m
[32m+[m [32m<?php do_action( 'bp_group_options_nav' ) ?>[m
[32m+[m [32m</ul>[m
[32m+[m [32m</div>[m
[32m+[m [32m</div><!-- #item-nav -->[m
[32m+[m [32m<div id="item-body">[m
[32m+[m [32m<div id="subnav" class="item-list-tabs no-ajax">[m
[32m+[m [32m<ul>[m
[32m+[m [32m<?php bcg_get_options_menu();?>[m
[32m+[m [32m</ul>[m
[32m+[m [32m</div>[m
[32m+[m [32m<?php[m
[32m+[m [32mif(bcg_is_single_post())[m
[32m+[m [32mbcg_load_template('bcg/single-post.php' );[m
[32m+[m [32melse if(bcg_is_post_create())[m
[32m+[m [32mbcg_load_template('bcg/create.php' );[m
[32m+[m [32melse[m
[32m+[m [32mbcg_load_template( 'bcg/blog.php');[m
[32m+[m [32m?>[m
[32m+[m [32m</div>[m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m [32m<?php do_action( 'bp_after_group_blog_home_content' ) ?>[m
[32m+[m
[32m+[m [32m<?php endwhile; endif; ?>[m
[32m+[m [32m</div><!-- .padder -->[m
[32m+[m [32m</div><!-- #content -->[m
[32m+[m
[32m+[m [32m<?php locate_template( array( 'sidebar.php' ), true ) ?>[m
[32m+[m
[32m+[m[32m<?php get_footer() ?>[m
\ No newline at end of file[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg/readme.txt b/wp-content/plugins/blog-categories-for-groups/bcg/readme.txt[m
[1mnew file mode 100644[m
[1mindex 0000000..0ef481e[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg/readme.txt[m
[36m@@ -0,0 +1,3 @@[m
[32m+[m[32mPlease move my parent folder "bcg" to your current active theme to make us work. Thanks![m
[32m+[m
[32m+[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/bcg/single-post.php b/wp-content/plugins/blog-categories-for-groups/bcg/single-post.php[m
[1mnew file mode 100644[m
[1mindex 0000000..f8980a2[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/bcg/single-post.php[m
[36m@@ -0,0 +1,48 @@[m
[32m+[m
[32m+[m[32m<?php[m[41m [m
[32m+[m [32m$q=new WP_Query(bcg_get_query());[m
[32m+[m [32mglobal $post;[m
[32m+[m [32mif ($q->have_posts() ) : ?>[m
[32m+[m
[32m+[m [32m<?php do_action( 'bp_before_group_blog_post_content' ) ?>[m
[32m+[m
[32m+[m[41m [m
[32m+[m
[32m+[m [32m<?php[m[41m [m
[32m+[m [32mbcg_loop_start();//please do not remove it[m
[32m+[m [32mwhile($q->have_posts()):$q->the_post();?>[m
[32m+[m [32m<div class="post" id="post-<?php the_ID(); ?>">[m
[32m+[m
[32m+[m [32m<div class="author-box">[m
[32m+[m [32m<?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?>[m
[32m+[m [32m<p><?php printf( __( 'by %s', 'bcg' ), bp_core_get_userlink( $post->post_author ) ) ?></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<div class="post-content">[m
[32m+[m [32m<h2 class="posttitle"><a href="<?php echo bcg_get_post_permalink($post);?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'bcg' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>[m
[32m+[m
[32m+[m [32m<p class="date"><?php the_time() ?> <em><?php _e( 'in', 'bcg' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'bcg' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>[m
[32m+[m
[32m+[m [32m<div class="entry">[m
[32m+[m [32m<?php the_content( __( 'Read the rest of this entry →', 'bcg' ) ); ?>[m
[32m+[m
[32m+[m [32m<?php wp_link_pages(array('before' => __( '<p><strong>Pages:</strong> ', 'bcg' ), 'after' => '</p>', 'next_or_number' => 'number')); ?>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m<p class="postmetadata"><span class="tags"><?php the_tags( __( 'Tags: ', 'bcg' ), ', ', '<br />'); ?></span> <span class="comments"><?php comments_popup_link( __( 'No Comments »', 'bcg' ), __( '1 Comment »', 'bcg' ), __( '% Comments »', 'bcg' ) ); ?></span></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m [32m</div>[m
[32m+[m [32m<?php comments_template(); ?>[m
[32m+[m[32m<?php endwhile;?>[m
[32m+[m[32m<?php do_action( 'bp_after_group_blog_content' ) ;[m
[32m+[m[32mbcg_loop_end();//please do not remove it[m
[32m+[m[32m?>[m
[32m+[m
[32m+[m[32m<?php else: ?>[m
[32m+[m
[32m+[m [32m<div id="message" class="info">[m
[32m+[m [32m<p><?php _e( 'This group has no Blog posts.', 'bcg' ); ?></p>[m
[32m+[m [32m</div>[m
[32m+[m
[32m+[m[32m<?php endif; ?>[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/blog-catetgories-for-groups.php b/wp-content/plugins/blog-categories-for-groups/blog-catetgories-for-groups.php[m
[1mnew file mode 100644[m
[1mindex 0000000..d7e40fa[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/blog-catetgories-for-groups.php[m
[36m@@ -0,0 +1,211 @@[m
[32m+[m[32m<?php[m
[32m+[m[32m/*[m
[32m+[m[32m * Plugin Name: Blog Categories for Groups[m
[32m+[m[32m * Author: Brajesh Singh[m
[32m+[m[32m * Plugin URI:http://buddydev.com/plugins/blog-categories-for-groups/[m
[32m+[m[32m * Author URI:http://buddydev.com/members/sbrajesh/[m
[32m+[m[32m * Description: Allow Group admins;/mods to associate blog categories with groups[m
[32m+[m[32m * Version: 1.1[m
[32m+[m[32m * Tested with WordPress 3.5.1+BuddyPress 1.7.2[m
[32m+[m[32m * License: GPL[m
[32m+[m[32m * Date: May 30, 2013[m
[32m+[m[32m */[m
[32m+[m
[32m+[m[32m #hackunito[m
[32m+[m[32mif(!defined('BCG_SLUG'))[m
[32m+[m[32m define('BCG_SLUG','category');[m
[32m+[m
[32m+[m[32mdefine('BCG_PLUGIN_DIR', plugin_dir_path(__FILE__));[m
[32m+[m[32m/**[m
[32m+[m[32m * The blog categories for Groups helper class[m
[32m+[m[32m * Loads the files and localizations[m
[32m+[m[32m */[m
[32m+[m[32mclass BCGroups_Helper{[m
[32m+[m[41m [m
[32m+[m[32m private static $instance;[m
[32m+[m[41m [m
[32m+[m[32m private function __construct(){[m
[32m+[m[41m [m
[32m+[m[32m add_action('bp_include',array($this,'load_extension'));[m
[32m+[m[32m //load javascript for comment reply[m
[32m+[m[32m add_action('bp_enqueue_scripts',array($this,'enqueue_script'));[m
[32m+[m[32m //load localization files[m
[32m+[m[32m add_action ( 'bp_init', array($this,'load_textdomain'), 2 );[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m public static function get_instance(){[m
[32m+[m[32m if( ! isset( self::$instance ) )[m
[32m+[m[32m self::$instance=new self();[m
[32m+[m[32m return self::$instance;[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m /**[m
[32m+[m[32m * Load required files[m
[32m+[m[32m */[m
[32m+[m[32m public function load_extension(){[m
[32m+[m[32m $files=array([m
[32m+[m[32m 'bcg-functions.php',[m
[32m+[m[32m 'template-tags.php',[m
[32m+[m[32m 'bcg-hooks.php',[m
[32m+[m[32m 'bcg-admin.php',[m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m[32m );[m
[32m+[m[41m [m
[32m+[m[32m foreach($files as $file)[m
[32m+[m[32m include_once (BCG_PLUGIN_DIR.$file);[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[32m /**[m
[32m+[m[32m * Load localization files[m
[32m+[m[32m * e.g /languages/en_US.mo[m
[32m+[m[32m */[m
[32m+[m[32m function load_textdomain() {[m
[32m+[m[32m $locale = apply_filters( 'bcg_load_textdomain_get_locale', get_locale() );[m
[32m+[m[32m // if load .mo file[m
[32m+[m[32m if ( !empty( $locale ) ) {[m
[32m+[m[32m $mofile_default = sprintf( '%s/languages/%s.mo',BCG_PLUGIN_DIR, $locale );[m
[32m+[m[32m $mofile = apply_filters( 'bcg_load_mofile', $mofile_default );[m
[32m+[m[32m // make sure file exists, and load it[m
[32m+[m[32m if ( file_exists( $mofile ) ) {[m
[32m+[m[32m load_textdomain( 'bcg', $mofile );[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m /**[m
[32m+[m[32m * Enqueue comment js on single post screen[m
[32m+[m[32m */[m
[32m+[m[32m function enqueue_script(){[m
[32m+[m[32m if(bcg_is_single_post ())[m
[32m+[m[32m wp_enqueue_script ('comment-reply');[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m//initialize[m
[32m+[m[32mBCGroups_Helper::get_instance();[m
[32m+[m
[32m+[m
[32m+[m
[32m+[m[32mclass BCG_View_Helper{[m
[32m+[m[41m [m
[32m+[m[32m private static $instance;[m
[32m+[m[41m [m
[32m+[m[32m private function __construct() {[m
[32m+[m[41m [m
[32m+[m[32m //setup nav[m
[32m+[m[32m add_action('groups_setup_nav', array($this,'setup_nav'));[m
[32m+[m[32m add_action('bp_ready', array($this,'screen_group_blog_single_post'),5);[m
[32m+[m[32m add_action('bp_init', array($this,'register_form'));[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m public static function get_instance(){[m
[32m+[m[41m [m
[32m+[m[32m if(!isset (self::$instance))[m
[32m+[m[32m self::$instance = new self();[m
[32m+[m[41m [m
[32m+[m[32m return self::$instance;[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m //setup nav[m
[32m+[m[32m function setup_nav($current_user_access){[m
[32m+[m[32m global $bp;[m
[32m+[m
[32m+[m[32m if(!bp_is_group())[m
[32m+[m[32m return;[m
[32m+[m[41m [m
[32m+[m[32m $group_id=bp_get_current_group_id();[m
[32m+[m
[32m+[m[32m if(bcg_is_disabled($group_id))[m
[32m+[m[32m return;[m
[32m+[m
[32m+[m[32m $current_group=groups_get_current_group();[m
[32m+[m[41m [m
[32m+[m[32m $group_link = bp_get_group_permalink($current_group);[m
[32m+[m[41m [m
[32m+[m [32m// #hackunito[m
[32m+[m[32m bp_core_new_subnav_item( array([m[41m [m
[32m+[m[32m 'name' => __( 'Category', 'bcg' ),[m
[32m+[m[32m 'slug' => BCG_SLUG,[m
[32m+[m[32m 'parent_url' => $group_link,[m
[32m+[m[32m 'parent_slug' => $current_group->slug,[m
[32m+[m[32m 'screen_function' => array($this,'screen_group_blog'),[m
[32m+[m[32m 'position' => 10,[m
[32m+[m[32m 'user_has_access' => $current_user_access,[m
[32m+[m[32m 'item_css_id' => 'category'[m
[32m+[m[32m ) );[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[32m /**[m
[32m+[m[32m * Register the simple front end post plugin[m
[32m+[m[32m */[m
[32m+[m[32m function register_form(){[m
[32m+[m[41m [m
[32m+[m[32m $group_id=bp_get_current_group_id();[m
[32m+[m[32m //register form if the BPDev PostEditor Exists[m
[32m+[m[32m if(function_exists('bp_new_simple_blog_post_form')){[m
[32m+[m[32m $form_params=array([m
[32m+[m[32m 'post_type'=>'post',[m
[32m+[m[32m 'post_author'=> bp_loggedin_user_id(),[m
[32m+[m[32m 'post_status'=>'draft',[m
[32m+[m[32m 'current_user_can_post'=> bcg_current_user_can_post(),[m
[32m+[m[32m 'tax'=>array([m
[32m+[m[32m 'category'=>array([m
[32m+[m[32m 'include'=>bcg_get_categories($group_id),//selected cats,[m
[32m+[m[32m )[m
[32m+[m[32m ),[m
[32m+[m
[32m+[m[32m 'show_tags'=>false,//current version does not support the tag[m
[32m+[m
[32m+[m[32m 'allowed_tags'=>array());[m
[32m+[m[41m [m
[32m+[m[32m $form=bp_new_simple_blog_post_form('bcg_form',apply_filters('bcg_form_args',$form_params));[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m }[m
[32m+[m[32m //load the blog home page for group[m
[32m+[m[32m function screen_group_blog(){[m
[32m+[m[32m //load template[m
[32m+[m[32m bp_core_load_template( apply_filters( 'groups_template_group_blog', 'bcg/home' ) );[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m //for single post screen[m
[32m+[m[32m function screen_group_blog_single_post(){[m
[32m+[m[32m global $bp;[m
[32m+[m[41m [m
[32m+[m[32m if(function_exists('bp_is_group')&&!bp_is_group())[m
[32m+[m[32m return;[m
[32m+[m[41m [m
[32m+[m[32m //do not catch the request for creating new post[m
[32m+[m[32m if(bp_is_action_variable('create',0))[m
[32m+[m[32m return;[m
[32m+[m[41m [m
[32m+[m[32m $current_group=groups_get_current_group();[m
[32m+[m[41m [m
[32m+[m[32m if(bcg_is_disabled($current_group->id))[m
[32m+[m[32m return;[m
[32m+[m[32m //if the group is private/hidden and user is not member, return[m
[32m+[m[32m if(($current_group->status=='private'||$current_group->status=='hidden')&&(!is_user_logged_in()||!groups_is_user_member(bp_loggedin_user_id(), $current_group->id)))[m
[32m+[m[32m return;//avoid prioivacy troubles[m
[32m+[m
[32m+[m[32m if (bp_is_groups_component() && bp_is_current_action(BCG_SLUG) &&!empty($bp->action_variables[0]) ){[m
[32m+[m
[32m+[m[32m $wpq=new WP_Query(bcg_get_query());[m
[32m+[m[32m if($wpq->have_posts()){[m
[32m+[m[32m //load template[m
[32m+[m[32m bp_core_load_template( apply_filters( 'groups_template_group_blog_single_post', 'bcg/home' ) );[m
[32m+[m[32m }[m
[32m+[m[32m else[m
[32m+[m[32m bp_core_add_message (__("Sorry, the post does not exists!","bcg"),"error");[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32mBCG_View_Helper::get_instance();[m
[32m+[m
[1mdiff --git a/wp-content/plugins/blog-categories-for-groups/template-tags.php b/wp-content/plugins/blog-categories-for-groups/template-tags.php[m
[1mnew file mode 100644[m
[1mindex 0000000..fa353c6[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/blog-categories-for-groups/template-tags.php[m
[36m@@ -0,0 +1,194 @@[m
[32m+[m[32m<?php[m
[32m+[m[32m/*[m
[32m+[m[32m * Template Tags for Blog categories[m
[32m+[m[32m *[m
[32m+[m[32m */[m
[32m+[m
[32m+[m[32m//if inside the post loop[m
[32m+[m[32mfunction in_bcg_loop(){[m
[32m+[m[32m global $bp;[m
[32m+[m
[32m+[m[32m return isset($bp->bcg)? $bp->bcg->in_the_loop:false;[m
[32m+[m[32m}[m
[32m+[m[32m//use it to mark t5he start of bcg post loop[m
[32m+[m[32mfunction bcg_loop_start(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m $bp->bcg=new stdClass();[m
[32m+[m[32m $bp->bcg->in_the_loop=true;[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m//use it to mark the end of bcg loop[m
[32m+[m[32mfunction bcg_loop_end(){[m
[32m+[m[32m global $bp;[m
[32m+[m[41m [m
[32m+[m[32m $bp->bcg->in_the_loop=false;[m
[32m+[m[32m}[m
[32m+[m
[32m+[m
[32m+[m[32m//get post permalink which leads to group blog single post page[m
[32m+[m[32mfunction bcg_get_post_permalink($post){[m
[32m+[m[41m [m
[32m+[m[32m return bp_get_group_permalink(groups_get_current_group()).BCG_SLUG."/".$post->post_name;[m
[32m+[m[32m}[m
[32m+[m[32m/**[m
[32m+[m[32m * Generate Pagination Link for posts[m
[32m+[m[32m * @param type $q[m[41m [m
[32m+[m[32m */[m
[32m+[m[32mfunction bcg_pagination($q) {[m
[32m+[m
[32m+[m [32m$posts_per_page = intval(get_query_var('posts_per_page'));[m
[32m+[m [32m$paged = intval(get_query_var('paged'));[m
[32m+[m [32m$numposts = $q->found_posts;[m
[32m+[m[32m $max_page = $q->max_num_pages;[m
[32m+[m [32mif(empty($paged) || $paged == 0) {[m
[32m+[m [32m$paged = 1;[m
[32m+[m [32m}[m
[32m+[m
[32m+[m[32m $pag_links = paginate_links( array([m
[32m+[m[32m 'base' => add_query_arg( array( 'paged' => '%#%', 'num' => $posts_per_page ) ),[m
[32m+[m[32m 'format' => '',[m
[32m+[m[32m 'total' => ceil($numposts / $posts_per_page),[m
[32m+[m[32m 'current' => $paged,[m
[32m+[m[32m 'prev_text' => '←',[m
[32m+[m[32m 'next_text' => '→',[m
[32m+[m[32m 'mid_size' => 1[m
[32m+[m[32m ));[m
[32m+[m[32m echo $pag_links;[m
[32m+[m[32m}[m
[32m+[m[32m//viewing x of z posts[m
[32m+[m[32mfunction bcg_posts_pagination_count($q){[m
[32m+[m
[32m+[m [32m$posts_per_page = intval(get_query_var('posts_per_page'));[m
[32m+[m [32m$paged = intval(get_query_var('paged'));[m
[32m+[m [32m$numposts = $q->found_posts;[m
[32m+[m[32m $max_page = $q->max_num_pages;[m
[32m+[m [32mif(empty($paged) || $paged == 0) {[m
[32m+[m [32m$paged = 1;[m
[32m+[m [32m}[m
[32m+[m
[32m+[m[32m $start_num = intval( $posts_per_page*($paged-1) ) + 1;[m
[32m+[m[32m $from_num = bp_core_number_format( $start_num );[m
[32m+[m[32m $to_num = bp_core_number_format( ( $start_num + ( $posts_per_page - 1 ) > $numposts ) ? $numposts : $start_num + ( $posts_per_page - 1 ) );[m
[32m+[m[32m $total = bp_core_number_format( $numposts );[m
[32m+[m
[32m+[m[32m printf( __( 'Viewing posts %1$s to %2$s (of %3$s posts)', 'bcg' ), $from_num, $to_num, $total )." ";[m
[32m+[m[41m [m
[32m+[m[32m if(bcg_is_category())[m
[32m+[m[32m printf(__("In the category %s ","bcg"), "<span class='bcg-cat-name'>". get_cat_name ($q->query_vars['cat'])."</span>");?>[m
[32m+[m [32m<span class="ajax-loader"></span><?php[m
[32m+[m[32m}[m
[32m+[m[32m/**[m
[32m+[m[32m * Are we dealing with blog categories pages?[m
[32m+[m[32m * @return type[m[41m [m
[32m+[m[32m */[m
[32m+[m[32mfunction bcg_is_component(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m if (bp_is_current_component($bp->groups->slug) && bp_is_current_action(BCG_SLUG ))[m
[32m+[m[32m return true;[m
[32m+[m[41m [m
[32m+[m[32m return false;[m
[32m+[m[32m}[m
[32m+[m[32mfunction bcg_is_single_post(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m if (bcg_is_component() &&!empty($bp->action_variables[0])&&(!in_array($bp->action_variables[0],array('create','category' ))))[m
[32m+[m[32m return true;[m
[32m+[m
[32m+[m[32m}[m
[32m+[m[32m//is bcg_home[m
[32m+[m[32mfunction bcg_is_home(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m if (bcg_is_component() &&empty($bp->action_variables[0]) )[m
[32m+[m[32m return true;[m
[32m+[m
[32m+[m[32m}[m
[32m+[m[32mfunction is_bcg_pages(){[m
[32m+[m[32m return bcg_is_component();[m
[32m+[m[32m}[m
[32m+[m[32mfunction bcg_is_post_create(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m if (bcg_is_component() &&!empty($bp->action_variables[0])&&$bp->action_variables[0]=='create' )[m
[32m+[m[32m return true;[m
[32m+[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32mfunction bcg_is_category(){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m if ( bcg_is_component() &&!empty($bp->action_variables[1])&&$bp->action_variables[0]=='category' )[m
[32m+[m[32m return true;[m
[32m+[m[32m}[m
[32m+[m[32m//sub menu[m
[32m+[m[32mfunction bcg_get_options_menu(){?>[m
[32m+[m[32m <li <?php if(bcg_is_home ()):?> class="current"<?php endif;?>><a href="<?php echo bcg_get_home_url();?>"><?php _e("Posts","bcg");?></a></li>[m
[32m+[m[32m <?php if(bcg_current_user_can_post()):?>[m
[32m+[m[32m <li <?php if(bcg_is_post_create()):?> class="current"<?php endif;?>><a href="<?php echo bcg_get_home_url();?>/create"><?php _e("Create New Post","bcg");?></a></li>[m
[32m+[m[32m <?php endif;?>[m
[32m+[m[32m <?php[m
[32m+[m[32m}[m
[32m+[m
[32m+[m
[32m+[m[32m//form for showing category lists[m
[32m+[m[32mfunction bcg_admin_form(){[m
[32m+[m[32m $group_id=bp_get_group_id();[m
[32m+[m
[32m+[m[32m $selected_cats=bcg_get_categories($group_id);[m
[32m+[m[32m echo "<p>".__("Check a category to assopciate the posts in this category with this group.","bcg")."</p>";[m
[32m+[m
[32m+[m[32m $cat_ids=get_all_category_ids();[m
[32m+[m[32m if(is_array($cat_ids)){////it is sure but do not take risk[m
[32m+[m[32m foreach($cat_ids as $cat_id){//show the form[m
[32m+[m[32m $checked=0;[m
[32m+[m [32mif(!empty($selected_cats)&&in_array($cat_id,$selected_cats))[m
[32m+[m [32m$checked=true;[m
[32m+[m [32m?>[m
[32m+[m [32m<label style="padding:5px;display:block;float:left;">[m
[32m+[m[32m <input type="checkbox" name="blog_cats[]" id="<?php $opt_id;?>" value="<?php echo $cat_id;?>" <?php if($checked) echo "checked='checked'" ;?>/>[m
[32m+[m[32m <?php echo get_cat_name($cat_id);?>[m
[32m+[m [32m</label>[m
[32m+[m
[32m+[m[32m<?php[m
[32m+[m[32m }[m
[32m+[m[32m}[m
[32m+[m[32m else{[m
[32m+[m[32m ?>[m
[32m+[m
[32m+[m[32m <div class="error">[m
[32m+[m[32m <p><?php _e("Please create the categories first to attach them to a group.","bcg");?></p>[m
[32m+[m[32m </div>[m
[32m+[m[32m<?php[m
[32m+[m[32m }[m
[32m+[m[32m?>[m
[32m+[m[32m <div class="clear"></div>[m
[32m+[m
[32m+[m[32m<?php[m
[32m+[m[32m}[m
[32m+[m
[32m+[m
[32m+[m
[32m+[m
[32m+[m[32m//post form if one quick pot is installed[m
[32m+[m[32mfunction bcg_get_post_form($group_id){[m
[32m+[m[32m global $bp;[m
[32m+[m[32m $cat_selected=bcg_get_categories($group_id);//selected cats[m
[32m+[m[32m if(empty($cat_selected)){[m
[32m+[m[32m _e('This group has no associated categories. To post to Group blog, you need to associate some categoris to it.','bcg');[m
[32m+[m[32m return;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m $all_cats=get_all_category_ids();[m
[32m+[m[32m $cats=array_diff($all_cats,$cat_selected);[m
[32m+[m[41m [m
[32m+[m
[32m+[m[32m //for form[m
[32m+[m[32m $url=bp_get_group_permalink(new BP_Groups_Group($group_id)).BCG_SLUG."/create/";[m
[32m+[m[32m if(function_exists('bp_get_simple_blog_post_form')){[m
[32m+[m[41m [m
[32m+[m[32m $form=bp_get_simple_blog_post_form('bcg_form');[m
[32m+[m[32m if($form)[m
[32m+[m[32m $form->show();[m
[32m+[m[41m [m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[32m do_action('bcg_post_form',$cats,$url);//pass the categories as array and the url of the current page[m
[32m+[m[41m [m
[32m+[m[32m}[m
[32m+[m
[1mdiff --git a/wp-content/plugins/bp-group-acivities-notifier/bp-group-activities-notifier.php b/wp-content/plugins/bp-group-acivities-notifier/bp-group-activities-notifier.php[m
[1mnew file mode 100644[m
[1mindex 0000000..1f054d1[m
[1m--- /dev/null[m
[1m+++ b/wp-content/plugins/bp-group-acivities-notifier/bp-group-activities-notifier.php[m
[36m@@ -0,0 +1,354 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32m/**[m
[32m+[m[32m * Plugin Name: BP Group Activities Notifier[m
[32m+[m[32m * Plugin URI: http://buddydev.com/plugins/bp-group-activities-notifier/[m
[32m+[m[32m * Author: Brajesh Singh(BuddyDev)[m
[32m+[m[32m * Author URI: http://buddydev.com/members/sbrajesh/[m
[32m+[m[32m * Version: 1.0[m
[32m+[m[32m * Description: Notifies on any action in the group to all group members. I have tested with group join, group post update, forum post/reply. Sould work with others too[m
[32m+[m[32m */[m
[32m+[m
[32m+[m[32m//load the component[m
[32m+[m[32madd_action('bp_include','bp_local_group_notifier_load');[m
[32m+[m
[32m+[m[32mfunction bp_local_group_notifier_load(){[m
[32m+[m[32m //we need a dummy component[m
[32m+[m[32m include_once (plugin_dir_path(__FILE__).'loader.php');[m
[32m+[m[41m [m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32mclass BPLocalGroupNotifierHelper{[m
[32m+[m[41m [m
[32m+[m[32m private static $instance;[m
[32m+[m
[32m+[m[32m private function __construct() {[m
[32m+[m[32m //notify members on new activity[m
[32m+[m[32m add_action('bp_activity_add',array($this,'notify_members'));[m
[32m+[m[32m //delete notification when viewing single activity[m
[32m+[m[32m add_action('bp_activity_screen_single_activity_permalink', array($this,'delete_on_single_activity'),10,2);[m
[32m+[m[32m //sniff and delete notification for forum topic/replies[m
[32m+[m[32m add_action('bp_init',array($this,'delete_for_group_forums'),20);[m
[32m+[m
[32m+[m[32m }[m
[32m+[m[41m [m
[32m+[m[41m [m
[32m+[m[32m public static function get_instance(){[m
[32m+[m[32m if(!isset(self::$instance))[m
[32m+[m[32m self::$instance= new self();[m
[32m+[m[41m [m
[32m+[m[32m return self::$instance;[m
[32m+[m[41m [m
[32m+[m[32m }[m
[32m+[m[32m /**[m
[32m+[m[32m * Notifies Users of new Group activity[m
[32m+[m[32m *[m[41m [m
[32m+[m[32m * should we put an options in the notifications page of user to allow them opt out ?[m
[32m+[m[32m *[m[41m [m
[32m+[m[32m * @global type $bp[m
[32m+[m[32m * @param type $params[m
[32m+[m[32m * @return type[m
[32m+[m[32m */[m
[32m+[m[32m function notify_members($params){[m
[32m+[m[32m global $bp;[m
[32m+[m[41m [m
[32m+[m[32m //first we need to check if this is a group activity[m
[32m+[m[32m if($params['component']!=$bp->groups->id)[m
[32m+[m[32m return ;[m
[32m+[m
[32m+[m[32m //now, find that activity[m
[32m+[m[32m $activity_id= bp_activity_get_activity_id($params);[m
[32m+[m
[32m+[m[32m if(empty($activity_id))[m
[32m+[m[32m return;[m
[32m+[m[41m [m
[32m+[m[32m //we found it, good![m[41m [m
[32m+[m[32m $activity= new BP_Activity_Activity($activity_id);[m
[32m+[m[32m //ok this is infact the group id[m
[32m+[m[32m //I am not sure about 3rd party plugins, but bbpress, buddypress adds group activities like this[m
[32m+[m[32m $group_id=$activity->item_id;[m
[32m+[m[41m [m
[32m+[m[32m //let us fetch all members data for the group except the banned users[m
[32m+[m[32m $members_data= BP_Groups_Member::get_all_for_group( $group_id, false,false,false );//include admin/mod[m
[32m+[m[41m [m
[32m+[m[32m //ok let us fetch the members list[m
[32m+[m[32m $members=$members_data['members'];[m
[32m+[m
[32m+[m[32m //and we will add a notification for each user[m
[32m+[m[32m foreach((array)$members as $member){[m
[32m+[m[32m if($member->user_id==$activity->user_id)[m
[32m+[m[32m continue;//but not for the current logged user who performed this action[m
[32m+[m
[32m+[m[32m //we need to make each notification unique, otherwise bp will group it[m
[32m+[m[32m self::add_notification($group_id, $member->user_id, 'localgroupnotifier', 'group_local_notification_'.$activity_id, $activity_id);[m
[32m+[m[32m }[m
[32m+[m
[32m+[m
[32m+[m[32m }[m
[32m+[m
[32m+[m
[32m+[m[32m /**[m
[32m+[m[32m * Delete notification for user when he views single activity[m
[32m+[m[32m */[m
[32m+[m[32m function delete_on_single_activity($activity, $has_access){[m
[32m+[m[32m if(!is_user_logged_in())[m
[32m+[m[32m return;[m
[32m+[m
[32m+[m[32m if(!$has_access)[m
[32m+[m[32m return ;[m
[32m+[m
[32m+[m[32m BP_Core_Notification::delete_for_user_by_item_id(get_current_user_id(), $activity->item_id, 'localgroupnotifier','group_local_notification_'.$activity->id, $activity->id);[m
[32m+[m[41m [m
[32m+[m[32m }[m
[32m+[m[32m /**[m
[32m+[m[32m * Delet the notifications for New topic/ Topic replies if viewing the topic/topic replies[m
[32m+[m[32m *[m[41m [m
[32m+[m[32m * I am supporting bbpress 2.3+ plugin and not standalone bbpress which comes with BP 1.6[m
[32m+[m[32m *[m[41m [m
[32m+[m[32m *[m[41m [m
[32m+[m[32m * @global type $wpdb[m
[32m+[m[32m * @return type[m
[32m+[m[32m */[m
[32m+[m[41m [m
[32m+[m[32m function delete_for_group_forums(){[m
[32m+[m[32m if(!is_user_logged_in()||!function_exists('bbpress'))//just make sure we are doing it for bbpress plugin[m