Ejemplo n.º 1
0
 public static function init()
 {
     UserConfig::$ROOTPATH = dirname(__FILE__);
     // Chopping of trailing slash which is not supposed to be there in Apache config
     // See: http://httpd.apache.org/docs/2.0/mod/core.html#documentroot
     $docroot = $_SERVER['DOCUMENT_ROOT'];
     if (substr($docroot, -1) == '/') {
         $docroot = substr($docroot, 0, -1);
     }
     $docrootlength = strlen($docroot);
     UserConfig::$USERSROOTURL = substr(UserConfig::$ROOTPATH, $docrootlength);
     // we assume that package is extracted into the root of the site
     UserConfig::$SITEROOTURL = substr(dirname(UserConfig::$ROOTPATH), $docrootlength) . '/';
     UserConfig::$DEFAULTLOGINRETURN = UserConfig::$SITEROOTURL;
     UserConfig::$DEFAULTLOGOUTRETURN = UserConfig::$SITEROOTURL;
     UserConfig::$DEFAULTREGISTERRETURN = UserConfig::$SITEROOTURL;
     UserConfig::$DEFAULTUPDATEPASSWORDRETURN = UserConfig::$SITEROOTURL;
     if (array_key_exists('HTTP_HOST', $_SERVER)) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         error_log("[UserBase config] Warning: Can't determine site's host name, using www.example.com");
         $host = 'www.example.com';
     }
     UserConfig::$SITEROOTFULLURL = 'http://' . $host . UserConfig::$SITEROOTURL;
     UserConfig::$USERSROOTFULLURL = 'http://' . $host . substr(UserConfig::$ROOTPATH, $docrootlength);
     UserConfig::$supportEmailXMailer = 'UserBase (PHP/' . phpversion();
     UserConfig::$header = dirname(__FILE__) . '/header.php';
     UserConfig::$footer = dirname(__FILE__) . '/footer.php';
     // Built in activities
     define('USERBASE_ACTIVITY_LOGIN_UPASS', 1000);
     define('USERBASE_ACTIVITY_LOGIN_FB', 1001);
     define('USERBASE_ACTIVITY_LOGIN_GFC', 1002);
     define('USERBASE_ACTIVITY_ADDED_UPASS', 1003);
     define('USERBASE_ACTIVITY_ADDED_FB', 1004);
     define('USERBASE_ACTIVITY_ADDED_GFC', 1005);
     define('USERBASE_ACTIVITY_REMOVED_FB', 1006);
     define('USERBASE_ACTIVITY_REMOVED_GFC', 1007);
     define('USERBASE_ACTIVITY_LOGOUT', 1008);
     define('USERBASE_ACTIVITY_REGISTER_UPASS', 1009);
     define('USERBASE_ACTIVITY_REGISTER_FB', 1010);
     define('USERBASE_ACTIVITY_REGISTER_GFC', 1011);
     define('USERBASE_ACTIVITY_UPDATEUSERINFO', 1012);
     define('USERBASE_ACTIVITY_UPDATEPASS', 1013);
     define('USERBASE_ACTIVITY_RESETPASS', 1014);
     define('USERBASE_ACTIVITY_RETURN_DAILY', 1015);
     define('USERBASE_ACTIVITY_RETURN_WEEKLY', 1016);
     define('USERBASE_ACTIVITY_RETURN_MONTHLY', 1017);
     // Array of activities in the system.
     // Key must be integer (best if specified using a constant).
     // The values are an array with label and "points" value of activity.
     UserConfig::$activities = array(USERBASE_ACTIVITY_LOGIN_UPASS => array('Logged in using username and password', 1), USERBASE_ACTIVITY_LOGIN_FB => array('Logged in using Facebook', 1), USERBASE_ACTIVITY_LOGIN_GFC => array('Logged in using Google Friend Connect', 1), USERBASE_ACTIVITY_ADDED_UPASS => array('Added username and password', 1), USERBASE_ACTIVITY_ADDED_FB => array('Added Facebook credential', 1), USERBASE_ACTIVITY_ADDED_GFC => array('Added Google Friend Connect credential', 1), USERBASE_ACTIVITY_REMOVED_FB => array('Removed Facebook Connect', 0), USERBASE_ACTIVITY_REMOVED_GFC => array('Removed Google Friend Connect credential', 0), USERBASE_ACTIVITY_LOGOUT => array('Logged out', 0), USERBASE_ACTIVITY_REGISTER_UPASS => array('Registered using a form', 1), USERBASE_ACTIVITY_REGISTER_FB => array('Registered using Facebook', 1), USERBASE_ACTIVITY_REGISTER_GFC => array('Registered using Google Friend Connect', 1), USERBASE_ACTIVITY_UPDATEUSERINFO => array('Updated user info', 0), USERBASE_ACTIVITY_UPDATEPASS => array('Updated their password', 0), USERBASE_ACTIVITY_RESETPASS => array('Reset forgotten password', 0), USERBASE_ACTIVITY_RETURN_DAILY => array('Returned to the site within a day', 3), USERBASE_ACTIVITY_RETURN_WEEKLY => array('Returned to the site within a week', 2), USERBASE_ACTIVITY_RETURN_MONTHLY => array('Returned to the site within a month', 1));
     UserConfig::$cohort_providers[] = new GenerationCohorts(GenerationCohorts::MONTH);
     UserConfig::$cohort_providers[] = new GenerationCohorts(GenerationCohorts::WEEK);
     UserConfig::$cohort_providers[] = new GenerationCohorts(GenerationCohorts::YEAR);
     UserConfig::$cohort_providers[] = new RegMethodCohorts();
 }