provide auto admin registration as before, but allow the current admin to create other admins
This commit is contained in:
parent
4302134fdd
commit
7bee460df2
24
boot.php
24
boot.php
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
2012-10-03.96
|
||||
2012-10-04.97
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user