diff options
author | friendica <info@friendica.com> | 2012-10-04 23:05:45 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-10-04 23:05:45 -0700 |
commit | 7bee460df28bcd956206c3719e091fb500e3045d (patch) | |
tree | 4d06c81c9cfd39d2f88cab1c52aa5b6d11ef20ab | |
parent | 4302134fdd2640843aa1349e95285b966d1282ab (diff) | |
download | volse-hubzilla-7bee460df28bcd956206c3719e091fb500e3045d.tar.gz volse-hubzilla-7bee460df28bcd956206c3719e091fb500e3045d.tar.bz2 volse-hubzilla-7bee460df28bcd956206c3719e091fb500e3045d.zip |
provide auto admin registration as before, but allow the current admin to create other admins
-rw-r--r-- | boot.php | 24 | ||||
-rw-r--r-- | htconfig.php | 2 | ||||
-rw-r--r-- | include/account.php | 19 | ||||
-rw-r--r-- | include/security.php | 4 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rwxr-xr-x | mod/install.php | 2 | ||||
-rw-r--r-- | mod/item.php | 4 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/en/htconfig.tpl | 2 |
9 files changed, 46 insertions, 15 deletions
@@ -9,6 +9,7 @@ require_once('include/language.php'); require_once('include/nav.php'); require_once('include/cache.php'); require_once('library/Mobile_Detect/Mobile_Detect.php'); +require_once('object/BaseObject.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); @@ -327,7 +328,8 @@ define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 ); function startup() { error_reporting(E_ERROR | E_WARNING | E_PARSE); - set_time_limit(0); + + @set_time_limit(0); // This has to be quite large to deal with embedded private photos ini_set('pcre.backtrack_limit', 500000); @@ -367,16 +369,16 @@ function startup() { if(! class_exists('App')) { class App { - public $account = null; + public $account = null; // account record - private $channel = null; - private $observer = null; - private $widgets = array(); + private $channel = null; // channel record + private $observer = null; // xchan record + private $widgets = array(); // widgets for this page public $language; public $module_loaded = false; public $query_string; - public $config; + public $config; // config cache public $page; public $profile; public $user; @@ -548,6 +550,8 @@ if(! class_exists('App')) { $mobile_detect = new Mobile_Detect(); $this->is_mobile = $mobile_detect->isMobile(); $this->is_tablet = $mobile_detect->isTablet(); + + BaseObject::set_app($this); } function get_baseurl($ssl = false) { @@ -606,6 +610,14 @@ if(! class_exists('App')) { return $this->path; } + function set_account($aid) { + $this->account = $aid; + } + + function get_account() { + return $this->account; + } + function set_channel($channel) { $this->channel = $channel; } diff --git a/htconfig.php b/htconfig.php index 8b265131f..dc46d646c 100644 --- a/htconfig.php +++ b/htconfig.php @@ -37,7 +37,7 @@ $a->config['sitename'] = "Friendica Social Network"; $a->config['system']['register_policy'] = REGISTER_OPEN; $a->config['register_text'] = ''; -$a->config['admin_email'] = ''; +$a->config[system']['admin_email'] = ''; // Maximum size of an imported message, 0 is unlimited diff --git a/include/account.php b/include/account.php index fa56afe7d..b850fcffd 100644 --- a/include/account.php +++ b/include/account.php @@ -77,6 +77,15 @@ function check_account_invite($invite_code) { } +function check_account_admin($arr) { + if(is_site_admin()) + return true; + $admin_mail = trim(get_config('system','admin_email')); + if(strlen($admin_email) && $admin_email === trim($arr['email'])) + return true; + return false; +} + function create_account($arr) { @@ -90,6 +99,7 @@ function create_account($arr) { $password2 = ((x($arr,'password2')) ? trim($arr['password2']) : ''); $parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 ); $flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK); + $roles = ((x($arr,'account_roles')) ? intval($arr['account_roles']) : 0 ); $default_service_class = get_config('system','default_service_class'); if($default_service_class === false) @@ -100,6 +110,13 @@ function create_account($arr) { return $result; } + if($roles & ACCOUNT_ROLE_ADMIN) { + $admin_result = check_account_admin($arr); + if(! $admin_result) { + $roles = 0; + } + } + $invite_result = check_account_invite($invite_code); if($invite_result['error']) { $result['message'] = $invite_result['message']; @@ -134,7 +151,7 @@ function create_account($arr) { dbesc(get_best_language()), dbesc(datetime_convert()), dbesc($flags), - dbesc(0), + dbesc($roles), dbesc($expires), dbesc($default_service_class) diff --git a/include/security.php b/include/security.php index da58a65c3..926b2a8fe 100644 --- a/include/security.php +++ b/include/security.php @@ -10,9 +10,9 @@ function authenticate_success($user_record, $login_initial = false, $interactive // logger('authenticate_success: ' . print_r($_SESSION,true)); if(x($user_record,'account_id')) { - logger('authenticate_success: Red-style'); +// logger('authenticate_success: Red-style'); $a->account = $user_record; - $_SESSION['account_id'] = $a->account['account_id']; + $_SESSION['account_id'] = $user_record['account_id']; $_SESSION['authenticated'] = 1; if($login_initial) { @@ -13,10 +13,8 @@ */ require_once('boot.php'); -require_once('object/BaseObject.php'); $a = new App; -BaseObject::set_app($a); /** * diff --git a/mod/install.php b/mod/install.php index 722b1f342..a6ca48b61 100755 --- a/mod/install.php +++ b/mod/install.php @@ -6,7 +6,7 @@ $install_wizard_pass=1; function install_init(&$a){ // $baseurl/install/testrwrite to test if rewite in .htaccess is working - if ($a->argc==2 && $a->argv[1]=="testrewrite") { + if (argc() ==2 && argv(1)=="testrewrite") { echo "ok"; killme(); } diff --git a/mod/item.php b/mod/item.php index 4c30736c9..83c0fa1d3 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,6 +22,10 @@ require_once('include/items.php'); function item_post(&$a) { + + // This will change. Figure out who the observer is and whether or not + // they have permission to post here. Else ignore the post. + if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) return; diff --git a/version.inc b/version.inc index 612022b77..7e38c710f 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2012-10-03.96 +2012-10-04.97 diff --git a/view/en/htconfig.tpl b/view/en/htconfig.tpl index 9e39eeb59..de699a5f1 100644 --- a/view/en/htconfig.tpl +++ b/view/en/htconfig.tpl @@ -33,7 +33,7 @@ $a->config['sitename'] = "My Friend Network"; $a->config['register_policy'] = REGISTER_OPEN; $a->config['register_text'] = ''; -$a->config['admin_email'] = '$adminmail'; +$a->config['system']['admin_email'] = '$adminmail'; // Maximum size of an imported message, 0 is unlimited |