-
Notifications
You must be signed in to change notification settings - Fork 24
/
default_config.php
1473 lines (1247 loc) · 41.6 KB
/
default_config.php
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
<?php
/**
* @package StartupAPI
*/
require_once(__DIR__ . '/php-bootstrap/bootstrap.php');
require_once(__DIR__ . '/classes/Plan.php');
require_once(__DIR__ . '/classes/TransactionLogger.php');
require_once(__DIR__ . '/classes/Cohort.php');
require_once(__DIR__ . '/classes/Feature.php');
require_once(__DIR__ . '/classes/Badge.php');
require_once(__DIR__ . '/classes/StartupAPIModule.php');
require_once(__DIR__ . '/tools.php');
require_once(__DIR__ . '/swiftmailer/lib/swift_required.php');
/**
* This class contains a bunch of static variables defining how Startup API instance
* would behave with reasonable defaults that can be overriden in users_config.php
*
* @package StartupAPI
*
* @todo Move read-only arrays into appropriate classes and make them private
*/
class UserConfig {
/* ========================================================================
*
* Modules and extensions
*
* ===================================================================== */
/**
* @var StartupAPIModule[] List of all available modules (StartupAPIModule objects). Do not modify!
*/
public static $all_modules = array();
/**
* List of authentication modules (AuthenticationModule objects). Do not modify!
* Multiple authentication modules can be assigned for the same instance
*
* @var AuthenticationModule[]
*/
public static $authentication_modules = array();
// payment modules
/**
* List of payment methods to be used for subscription. Do not modify!
* Multiple payment modules can be enabled in the system, but only one can
* be used by account at a time.
*
* Imitialize your like the following:
* <code>
* UserConfig::loadModule('manual');
* new ManualPaymentEngine();
* </code>
*
* Only used when $useSubscriptions is set
*
* @var PaymentEngine[]
*/
public static $payment_modules = array();
/**
* Email module responsible for syncronization with newsletter service. Only one can be assigned. Do not modify!
*
* @var EmailModule
*/
public static $email_module;
/* ========================================================================
*
* Debugging
*
* ===================================================================== */
/**
* @var boolean Enable / disable debug messages
*/
public static $DEBUG = false;
/**
* @var boolean Show function arguments in debug messages
*/
public static $DEBUG_SHOW_ARGS = false;
/**
* @var boolean Enable / disable developer tools in the UI
*/
public static $DEVMODE = false;
/* ========================================================================
*
* Paths and URLs
*
* ===================================================================== */
/**
* @var string Root path of the project on the file system
*/
public static $ROOTPATH;
/**
* @var string Root URL of Startup API code (relative, e.g. /myapp/users/)
*/
public static $USERSROOTURL;
/**
* @var string Root URL of Startup API code (full, e.g. http://example.com/myapp/users/)
*/
public static $USERSROOTFULLURL;
/**
* @var string Root URL of the application using Startup API (relative, e.g. /myapp/)
*/
public static $SITEROOTURL;
/**
* @var string Root URL of the application using Startup API (full, e.g. http://example.com/myapp/)
*/
public static $SITEROOTFULLURL;
/**
* @var string Default location URL to return to upon login
*/
public static $DEFAULTLOGINRETURN;
/**
* @var string Default location URL to return to upon logout
*/
public static $DEFAULTLOGOUTRETURN;
/**
* @var string Default location URL to return to upon registration
*/
public static $DEFAULTREGISTERRETURN;
/**
* @var string Default location URL to return to upon password reset (for username/password auth)
*/
public static $DEFAULTUPDATEPASSWORDRETURN;
/**
* @var string Default location URL to return to upon successful email verification
*/
public static $DEFAULT_EMAIL_VERIFIED_RETURN;
/* ========================================================================
*
* Sessions and cookies
*
* All cookies are stored encrypted using a session secret
*
* ===================================================================== */
/**
* @var string Session secret - must be unique for each installation
*
* @todo Add some validation to ensure that this instance actually specified a unique secret
*/
public static $SESSION_SECRET;
/**
* @var string Cookie name for csrf nonce storage
*/
public static $csrf_nonce_key = 'users-csrf-nonce';
/**
* @var string Cookie name for User ID, indicates that user is logged in.
*/
public static $session_userid_key = 'users-userid';
/**
* Cookie name for the URL to return to for redirect-based actions
* like login, registration and etc.
*
* @var string
*/
public static $session_return_key = 'users-return-to';
/**
* @var string Cookie name for User ID of the user being impersonated
*/
public static $impersonation_userid_key = 'users-userid-impr';
/**
* @var string Facebook session storage cookie name prefix
*/
public static $facebook_storage_key_prefix = 'users-fb';
/**
* @var string Cookie name for OAuth User ID during the OAuth workflow
*/
public static $oauth_user_id_key = 'users-oauth-user-id';
/**
* @var string cookie name for Facebook access token storage
*/
public static $fb_access_token_key = 'users-fbatkn';
/**
* @var string Cookie name for storing referrer between anonymous user's arrival and their registration
*/
public static $entry_referer_key = 'users-ref';
/**
* @var string Cookie name for storing campaign object between anonymous user's arrival and their registration
*/
public static $entry_cmp_key = 'users-cmp';
/**
* @var string Cookie name for last login cookie
*/
public static $last_login_key = 'users-last-login';
/**
* @var string Cookie name for storing invitation ID between registration start and user creation
*/
public static $invitation_code_key = 'users-invite-code';
/**
* @var boolean Allow remembering a user beyond their browser session, true by default
*/
public static $allowRememberMe = true;
/**
* @var boolean Automatically remember user beyond their browser session when they register, true by default
*/
public static $rememberUserOnRegistration = true;
/**
* Time in seconds for long sessions - defaults to 10 years, can be set to relatively short, e.g. 2 weeks if needed
*
* @var int
*/
public static $rememberMeTime = 315360000;
/**
* @var boolean Checks "remember me" box on registration and login forms (false by default)
*/
public static $rememberMeDefault = false;
/* ========================================================================
*
* Admin UI and access
*
* ===================================================================== */
/**
* Array of integer IDs for site administrators (who have access to adin UI).
*
* Usually first user with ID of 1 is administrator, but defining it without
* having this user in the system might be dangerous if IDs didnt generate
* as you expected upon data re-import or something.
*
* @var array
*/
public static $admins = array();
/**
* By default, do not allow usage of non-secure connections and enforce HTTPS
*
* WARNING, be absolutely sure when you change this and disable HTTPS:
* https://www.owasp.org/index.php/REST_Security_Cheat_Sheet#HTTPS
*
* @var boolean
*/
public static $disableSecureConnection = FALSE;
/* ========================================================================
*
* DB cpnnectivity
*
* ===================================================================== */
/**
* @var string MySQL host
*/
public static $mysql_host = 'localhost';
/**
* @var int MySQL port
*/
public static $mysql_port = 3306;
/**
* MySQL socket path on file system. If specified, StartupAPI will not use TCP/IP,
* but a socket connection instead.
*
* @var string
*/
public static $mysql_socket;
/**
* @var string MySQL database name
*/
public static $mysql_db;
/**
* @var string MySQL database user. See access permissions requirements at http://StartupAPI.org/StartupAPI/DB_privileges
*/
public static $mysql_user;
/**
* @var string MySQL password
*/
public static $mysql_password;
/**
* @var string MySQL table prefix for all StartupAPI tables ('u_' by default)
*
* @deprecated prefix is now hard-coded so there is no need to change it
*/
public static $mysql_prefix = 'u_';
/**
* @var mysqli Database connection singleton
*/
private static $db = null;
/* ========================================================================
*
* Headers, footers and look and feel
*
* ===================================================================== */
/**
* @var string Application name
*/
public static $appName;
/**
* @var string Application icon URL (20x20)
*/
public static $appIconURL;
/**
* @var string File system path to header HTML file.
* @deprecated since version 0.7
*/
public static $header;
/**
* @var string File system path to footer HTML file.
* @deprecated since version 0.7
*/
public static $footer;
/**
* File system path to maillist management widget file to be included on profile management page.
*
* @var string
*/
public static $maillist;
/**
* @var string File system path to admin UI header HTML file.
* @deprecated since version 0.7
*/
public static $admin_header;
/**
* @var string File system path to admin UI footer HTML file.
* @deprecated since version 0.7
*/
public static $admin_footer;
/**
* @var array[] Array of available theme slugs
*/
public static $available_themes = array('classic', 'awesome');
/**
* @var string Theme slug for current theme
*/
public static $theme = 'awesome';
/**
* @var string Folder with local theme overrides
*/
public static $theme_override = null;
/**
* @var string[]|int[]|boolean[]|array[] Description
*/
public static $app_global_template_variables = array();
/**
* @var string If specified, StartupAPI::head() will include this Twitter Bootstrap CSS instead of default one
* @deprecated since 0.7 Now using Bootstrap 3 which has separate theme file, main bootstrap file is no longer modifiable
*/
public static $bootstrapCSS = null;
/**
* @var string[] Bootstrap themes available
*/
public static $availableBootstrapThemes = array(
'cerulean',
'cosmo',
'cyborg',
'darkly',
'flatly',
'journal',
'lumen',
'paper',
'readable',
'sandstone',
'simplex',
'slate',
'spacelab',
'superhero',
'united',
'yeti'
);
/**
* @var string If specified, StartupAPI::head() will include this Twitter Bootstrap Theme instead of default one
*/
public static $bootstrapTheme = null;
/**
* @var string If specified, Admin UI will include this Twitter Bootstrap CSS instead of default one
*/
public static $bootstrapAdminCSS = null;
/**
* @var array Associative array of Twig environment options
*/
public static $twig_options = array();
/**
* @var boolean Put power strip in a navbar (disable if you have your own navbar going)
*/
public static $powerStripShowNavbar = true;
/**
* @var boolean Invert power strip styles
*/
public static $powerStripInvertedNavbar = false;
/**
* @var boolean Show power strip as Bootstrap nav pills instead of navbar
*/
public static $powerStripNavPills = false;
/**
* @var boolean Align power strip to the right
*/
public static $powerStripPullRight = true;
/* ========================================================================
*
* REST API configuration
*
* ===================================================================== */
/**
* StartupAPI namespace definition.
*
* Make it null to disable StartupAPI's default APIs or update API description
* or namespace slug to match your app.
*
* @var EndpointNameSpace
*/
public static $apiNamespace = null;
/* ========================================================================
*
* Activity tracking and analytics
*
* ===================================================================== */
/**
* @var array An array of activity entries
*
* @todo Create Activity class and rewrite everything to use the class instead of params array
*/
public static $activities = array();
/**
* @var boolean Only consider users active if they had activities with non-zero value points assigned
*/
public static $adminActiveOnlyWithPoints = false;
/**
* @var CohortProvider[] An array of cohort providers (CohortProvider objects) for cohort analysis
*/
public static $cohort_providers = array();
// returning user activity configs
/**
* @var int Number of minutes for considering a user as returning user, 30 minutes by default
*/
public static $last_login_session_length = 30;
/**
* Array of arrays of URL parameters to be used for campaign tracking.
* Google Analytics (Urchin) defaults are pre-configured, you can append your keys.
*
* The following keys are used:
* - cmp_source - campaign source ('utm_source' is tracked by default)
* - cmp_medium - campaign medium ('utm_medium' is tracked by default)
* - cmp_keywords - campaign keyworkds ('utm_term' is tracked by default)
* - cmp_content - campaign content ('utm_content' is tracked by default)
* - cmp_name - campaign name ('utm_campaign' is tracked by default)
*
* @var array
*/
public static $campaign_variables = array(
'cmp_source' => array('utm_source'),
'cmp_medium' => array('utm_medium'),
'cmp_keywords' => array('utm_term'),
'cmp_content' => array('utm_content'),
'cmp_name' => array('utm_campaign')
);
/**
* Array of match => replacement pairs for rewriting referrers in referrer report in admin UI
*
* @var array
*/
public static $refererRegexes = array();
/**
* An array of user IDs to exclude from activity listing in admin UI.
* Try not to use it unless absolutely necessary - transparency is very important for operations.
*
* @var int[]
*/
public static $dont_display_activity_for = array();
/* ========================================================================
*
* Gamification
*
* ===================================================================== */
/**
* @var boolean If set to true, enables gamification features
*/
public static $enableGamification = false;
/**
* @var int Size of badge images on the badge listing pages
*/
public static $badgeListingSize = 100;
/**
* @var int Size of the badge image on badge page
*/
public static $badgeLargeSize = 300;
/* ========================================================================
*
* Systems features
*
* ===================================================================== */
/**
*
* [DEPRECATED] A list of features in the system.
*
* This way of defining features is deprecated, use Feature class instead.
*
* Key must be a unique integer, usually defined as a constant
*
* Values of the array are arrays with following elements:
* [0] name of the feature (string)
* [1] if feature is enabled or disabled globally (boolean)
* [2] if featurei s enabled for everybody, overriding account settings (boolean)
*
* @var array
*
* @deprecated
*/
public static $features = array();
/* ========================================================================
*
* Startup API functionality switches
*
* ===================================================================== */
/**
* @var boolean Set to false to disable registration of new users
*/
public static $enableRegistration = true;
/**
* @var string Disabled registration message, e.g. "Registration is disabled." (default) or "Coming soon"
*/
public static $registrationDisabledMessage = 'Registration is disabled.';
/**
* @var boolean Invitation from administrator required for registration
*/
public static $adminInvitationOnly = false;
/**
* @var boolean Deprecated config option, replaced with UserConfig::$adminInvitationOnly
* @deprecated since version 0.5.1
*/
public static $enableInvitations = null;
/**
* @var string Message to be displayed on registration page if person came without an invitation
*/
public static $invitationRequiredMessage = 'Please enter your invitation code';
/**
* @var boolean Enables user invitations
*/
public static $enableUserInvitations = true;
/**
* @var string Invitation menu/section title
*/
public static $userInvitationSectionTitle = 'Invite Friends';
/**
* @var string URL of Terms of Service Document
*/
public static $termsOfServiceURL;
/**
* @var string Absolute URL of Terms of Service Document (used in emails and such)
*/
public static $termsOfServiceFullURL;
/**
* @var string URL of Privacy Policy Document
*/
public static $privacyPolicyURL;
/**
* @var string Absolute URL of Privacy Policy Document (used in emails and such)
*/
public static $privacyPolicyFullURL;
/**
* Version of the Terms Of Service Document users consent to when signing up,
* increment it when you change TOS document contents
*
* @var int
*/
public static $currentTOSVersion;
/* ========================================================================
*
* System emails settings
*
* ===================================================================== */
/**
* @var string SMTP host
*/
public static $SMTPHost = 'localhost';
/**
* @var int SMTP port
*/
public static $SMTPPort = 25;
/**
* @var string User name for SMTP authentication
*/
public static $SMTPUserName;
/**
* @var string Password for SMTP authentication
*/
public static $SMTPPassword;
/**
* Encryption method for Swiftmailer SMTP encryption
* - 'ssl' for SMTPS - mandatory encryption with TLS)
* - 'tls' best-effort encryption for SMTP using TLS
* encryption will not be used if parameter is not set
* (see https://swiftmailer.symfony.com/docs/sending.html#encrypted-smtp for mode details)
* @var string
*/
public static $SMTPEncryption;
/**
* @var Swift_Mailer Transactional mailer object
* @deprecated do not access directly, use UserConfig::getMailer() function to get mailer object
*/
public static $mailer;
/**
* @var Swift_Mailer Mailer singleton used in UserConfig::getMailer()
*/
private static $_mailer;
/**
* @var string Name and email to send invitations from (e.g. 'User Support <[email protected]>')
* @deprecated
*/
public static $supportEmailFrom = 'User Support <[email protected]>';
/**
* Name to send invitations from (e.g. 'User Support')
* @var string
*/
public static $supportEmailFromName = 'User Support';
/**
* Email to send invitations from (e.g. '[email protected]')
* @var string
*/
public static $supportEmailFromEmail = '[email protected]';
/**
* @var string Reply-To email address for return emails
*/
public static $supportEmailReplyTo = '[email protected]';
/**
* @var string Email agent header (X-Mailer), 'Startup API (PHP/'.phpversion().')' by default.
* '
* @todo Figure out if there are best practices to be applied here,
* e.g. administrator's email address or backlink to the site, etc.
*/
public static $supportEmailXMailer;
/**
* @var string Password recovery email subject line
*/
public static $passwordRecoveryEmailSubject = 'Your Password';
/**
* @var string Email verification message subject line
*/
public static $emailVerificationSubject = 'Please verify your email';
/**
* Set to true if you want to require users to verify their email addresses
* before they can log in.
*
* @var boolean
*/
public static $requireVerifiedEmail = false;
/**
* @var int Amount of days email verification code is valid for
*/
public static $emailVerificationCodeExpiresInDays = 5;
/**
* Bypasses required email verificatiob flag if set to true
*
* THIS SHOULD ONLY BE SET ON EMAIL VERIFICATION PAGE
* SETTING THIS ON OTHER PAGES CAN RESULT IN SECURITY BREACH
*
* @var boolean
*
* @internal
*/
public static $IGNORE_REQUIRED_EMAIL_VERIFICATION = false;
/* ========================================================================
*
* Accounts
*
* ===================================================================== */
/**
* Use accounts in addition to users, disable this only if youare not going to
* charge subscription fees and 100% sure that you will never have multiple
* users using same data in your system.
*
* @var boolean
*
* @deprecated
*/
public static $useAccounts = true;
/**
* @var string Destination URL used when account is switched (current page by default, if null)
*/
public static $accountSwitchDestination = null;
/**
* Creates personal accounts even if user was invited to a group account when registered
*
* @var boolean
*/
public static $createPersonalAccountsIfInvitedToGroupAccount = false;
/**
* Bypasses required account plan verification flag if set to true
*
* THIS SHOULD ONLY BE SET ON PLAN SELECTION PAGESS
* SETTING THIS ON OTHER PAGES CAN RESULT IN PRIVILEGE ESCALATION
*
* @var boolean
*
* @internal
*/
public static $IGNORE_CURRENT_ACCOUNT_PLAN_VERIFICATION = false;
/* ========================================================================
*
* OAuth client configuration
*
* ===================================================================== */
/**
* @var string OAuth application name, not sent if null (default) - apps use registered name most of the time anyway
*/
public static $OAuthAppName = null;
/* ========================================================================
*
* Hooks
*
* ===================================================================== */
/**
* @var callable Hook for rendering invitation action UI in admin interface
*/
public static $onRenderUserInvitationAction = 'UserConfig::renderUserInvitationAction';
/**
* @var callable Hook for rendering invitation followup action UI in admin interface
*/
public static $onRenderUserInvitationFollowUpAction = 'UserConfig::renderUserInvitationFollowUpAction';
/**
* @var callable Formatter for password recovery email
*/
public static $onRenderTemporaryPasswordEmail = 'UserConfig::renderTemporaryPasswordEmail';
/**
* @var callable Formatter for user invitation message placeholder
*/
public static $onRenderUserInvitationMessagePlaceholder = 'UserConfig::renderUserInvitationMessagePlaceholder';
/**
* @var callable Formatter for email verification message
*/
public static $onRenderVerificationCodeEmail = 'UserConfig::renderVerificationCodeEmail';
/**
* @var callable Formatter for user-to-user invitation email message
*/
public static $onRenderInvitationEmailMessage = 'UserConfig::renderInvitationEmailMessage';
/**
* @var callable Formatter for user-to-user invitation email subject
*/
public static $onRenderInvitationEmailSubject = 'UserConfig::renderInvitationEmailSubject';
/**
* @var callable Handler to be called when new user is created, newly created user object is passed in
*/
public static $onCreate = null;
/**
* @var callable Hook for rendering extra links on power strip
*/
public static $onLoginStripLinks = null;
/**
* @var callable Hook for rendering Terms of Service and Privacy Policy verbiage on signup forms
*/
public static $onRenderTOSLinks = 'UserConfig::renderTOSLinks';
/**
* @var callable Hook to execute after StartupAPI finished initializing
*/
public static $onStartupAPIInit = null;
/* ========================================================================
*
* Subscription data
*
* ===================================================================== */
/**
* Enables subscription plans and payments management
*
* Only works when $useAccounts is set (default)
*
* @var boolean
*/
public static $useSubscriptions = false;
/**
* Free plan slug which is set to the user when they register without payment
*
* @var string Free plan slug
*/
public static $plan_free = 'PLAN_FREE';
/**
* Plan configuration array with plan slugs as keys and config parameters as details
*
* This array must contain plan configuration for the plan defined in UserConfig::$plan_free
*
* <code>
* UserConfig::$PLANS = array(
* 'PLAN_FREE' => array(
* 'id' => 0,
* 'name' => 'Free account',
* 'description' => 'Free access with basic functionality',
* 'capabilities' => array(
* 'individual' => true
* )
* )
* );
* </code>
*
* @var array
*/
public static $PLANS = array(
'PLAN_FREE' => array(
'id' => 0,
'name' => 'Free account',
'description' => 'Free access with basic functionality',
'capabilities' => array(
'individual' => true
)
)
);
/**
* The slug of the plan that gets assigned to the user by default
*
* @var string
*/
public static $default_plan_slug = 'PLAN_FREE';
/**
* The slug of the payment schedule that gets assigned to the user by default
*
* @var string
*/
public static $default_schedule_slug = 'default';
/* ========================================================================
*
* API - related configurations
*
* ===================================================================== */
/**
* @var boolean Exposed core StartupAPI methods in API (true by default)
*/
public static $enable_startupapi_apis = true;
public static $apiSpecVersion = '1.0.0';
/* ========================================================================
*
* Some global functions and default hooks, as well as static initializer
*
* ===================================================================== */
/**
* Singleton call for getting database connection object
*
* Creates new connection if none made yet or uses existing connection aleady opened previously.
*
* Example:
* <code>
* $db = UserConfig::getDB();
* </code>
*
* @return mysqli
*
* @throws DBException
*/
public static function getDB() {
if (is_null(self::$db)) {
self::$db = new mysqli(self::$mysql_host, self::$mysql_user, self::$mysql_password, self::$mysql_db, self::$mysql_port, self::$mysql_socket);
if (is_null(self::$db) || self::$db->connect_error) {
throw new DBException(self::$db, null, "Couldn't connect to database");
}
if (!self::$db->set_charset('utf8')) {
error_log("[Startup API] Warning: Can't set utf8 charset for DB connection");
}
}
return self::$db;
}
/**
* Sets database connection object (mysqli)
*
* Can be used in users_config.php instead of defining connection parameters,
* useful when your app is using same connection which is configured elsewhere