From 5f583fb8d6b71f63bf240729c00f9fd2009afd93 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 16 Jun 2011 12:05:35 +0200 Subject: [PATCH] Admin: register policy in site page, initial users page. Aside 'Users' link show pending registrations. --- mod/admin.php | 71 ++++++++++++++++++++++++------- view/admin_aside.tpl | 15 ++++++- view/admin_site.tpl | 21 +++++---- view/theme/duepuntozero/style.css | 15 ++++++- 4 files changed, 95 insertions(+), 27 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index 6386e6ebce..d5f27a44a0 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -63,6 +63,7 @@ function admin_content(&$a) { $t = get_markup_template("admin_aside.tpl"); $a->page['aside'] = replace_macros( $t, array( '$admin' => $aside, + '$h_pending' => t('User registrations waiting for confirm'), '$admurl'=> $a->get_baseurl()."/admin/" )); @@ -148,6 +149,11 @@ function admin_page_site_post(&$a){ $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : ''); $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0); + + + $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0); + $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); + $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : ''); $block_public = ((x($_POST,'block_public')) ? True : False); @@ -166,7 +172,7 @@ function admin_page_site_post(&$a){ $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); - $a->config['sitename'] = $sitename; + set_config('config','sitename',$sitename); if ($banner==""){ // don't know why, but del_config doesn't work... q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", @@ -179,6 +185,9 @@ function admin_page_site_post(&$a){ set_config('system','language', $language); set_config('system','theme', $theme); set_config('system','maximagesize', $maximagesize); + + set_config('config','register_policy', $register_policy); + set_config('config','register_text', $register_text); set_config('system','allowed_sites', $allowed_sites); set_config('system','allowed_email', $allowed_email); set_config('system','block_public', $block_public); @@ -204,18 +213,6 @@ function admin_page_site_post(&$a){ set_config('system','proxy', $proxy); set_config('system','curl_timeout', $timeout); - $r = q("SELECT * FROM `config` WHERE `cat`='config' AND `k`='sitename'"); - if (count($r)>0){ - q("UPDATE `config` SET `v`='%s' WHERE `cat`='config' AND `k`='sitename'", - dbesc($a->config['sitename']) - ); - } else { - q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( 'config', 'sitename', '%s' )", - dbesc($a->config['sitename']) - ); - } - - goaway($a->get_baseurl() . '/admin/site' ); return; // NOTREACHED @@ -257,7 +254,12 @@ function admin_page_site(&$a) { //echo "
"; var_dump($lang_choices); die("
"); - + /* Register policy */ + $register_choices = Array( + REGISTER_CLOSED => t("Closed"), + REGISTER_APPROVE => t("Need approvation"), + REGISTER_OPEN => t("Open") + ); $t = get_markup_template("admin_site.tpl"); return replace_macros($t, array( @@ -274,6 +276,8 @@ function admin_page_site(&$a) { '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), "Maximum size in bytes of uploaded images. Default is 0, which means no limits."), + '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices), + '$register_text' => array('register_text', t("Register text"), $a->config['register_text'], "Will be displayed prominently on the registration page."), '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), "Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains"), '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), "Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains"), '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), "Check to block public access to all otherwise public personal pages on this site unless you are currently logged in."), @@ -305,7 +309,44 @@ function admin_page_site(&$a) { */ function admin_page_users(&$a){ - return ":)"; + /* get pending */ + $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email` + FROM `register` + LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid` + LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;"); + + /* get users */ + $users = q("SELECT `user`.*, `contact`.`name` FROM `user` + LEFT JOIN `contact` ON `user`.`uid` = `contact`.`uid` + WHERE `user`.`verified`=1 AND `contact`.`self`=1 + ORDER BY `contact`.`name`"); + + + $t = get_markup_template("admin_users.tpl"); + return replace_macros($t, array( + // strings // + '$title' => t('Administration'), + '$page' => t('Users'), + '$submit' => t('Submit'), + '$select_all' => t('select all'), + '$h_pending' => t('User registrations waiting for confirm'), + '$th_pending' => array( t('Request date'), t('Name'), t('Email') ), + '$no_pending' => t('No registrations.'), + '$approve' => t('Approve'), + '$deny' => t('Deny'), + '$delete' => t('Delete'), + '$block' => t('Block'), + + '$h_users' => t('Users'), + '$th_users' => array( t('Name'), t('Nickname'), t('Email'), t('Register date'), t('Last login') ), + + // values // + '$baseurl' => $a->get_baseurl(), + + '$pending' => $pending, + '$users' => $users, + )); + } diff --git a/view/admin_aside.tpl b/view/admin_aside.tpl index dd81a6fee3..ade0c473bc 100644 --- a/view/admin_aside.tpl +++ b/view/admin_aside.tpl @@ -1,7 +1,20 @@ +

Admin

diff --git a/view/admin_site.tpl b/view/admin_site.tpl index f120461aa5..dba29f11cb 100644 --- a/view/admin_site.tpl +++ b/view/admin_site.tpl @@ -10,6 +10,18 @@
+

Registration

+ {{ inc field_input.tpl with $field=$register_text }}{{ endinc }} + {{ inc field_select.tpl with $field=$register_policy }}{{ endinc }} + + {{ inc field_checkbox.tpl with $field=$no_multi_reg }}{{ endinc }} + {{ inc field_checkbox.tpl with $field=$no_openid }}{{ endinc }} + {{ inc field_checkbox.tpl with $field=$no_gravatar }}{{ endinc }} + {{ inc field_checkbox.tpl with $field=$no_regfullname }}{{ endinc }} + {{ inc field_checkbox.tpl with $field=$no_utf }}{{ endinc }} + +
+

Upload

{{ inc field_input.tpl with $field=$maximagesize }}{{ endinc }} @@ -23,15 +35,6 @@
-

Registration

- {{ inc field_checkbox.tpl with $field=$no_multi_reg }}{{ endinc }} - {{ inc field_checkbox.tpl with $field=$no_openid }}{{ endinc }} - {{ inc field_checkbox.tpl with $field=$no_gravatar }}{{ endinc }} - {{ inc field_checkbox.tpl with $field=$no_regfullname }}{{ endinc }} - {{ inc field_checkbox.tpl with $field=$no_utf }}{{ endinc }} - -
-

Advanced

{{ inc field_checkbox.tpl with $field=$rino_enc }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$verifyssl }}{{ endinc }} diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 78e02681a5..206074c926 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2485,7 +2485,14 @@ a.mail-list-link { /** * ADMIN */ - +#pending-update { + float:right; + color: #ffffff; + font-weight: bold; + background-color: #FF0000; + padding: 0em 0.3em; + +} #adminpage dl { clear: left; margin-bottom: 2px; @@ -2551,7 +2558,9 @@ a.mail-list-link { margin-right: 1em; } #adminpage .author .icon { float: left;} - +#adminpage table {width:100%; border-bottom: 1p solid #000000; margin: 5px 0px;} +#adminpage table th { text-align: left;} +#adminpage td .icon { float: left;} /** * ICONS */ @@ -2594,6 +2603,8 @@ a.mail-list-link { .off { background-position: 0px -48px; } +.icon.dim { opacity: 0.3;filter:alpha(opacity=30); } + .attachtype { display: block; width: 20px; height: 23px; float: left;