mirror of
https://github.com/friendica/friendica
synced 2024-12-13 02:57:07 +01:00
Merge pull request #1123 from fabrixxm/mail_notification_cleanup
Mail notification cleanup
This commit is contained in:
commit
a7302daf96
265 changed files with 7372 additions and 12324 deletions
124
boot.php
124
boot.php
|
@ -796,7 +796,7 @@ if(! class_exists('App')) {
|
|||
}
|
||||
if ($name===""){
|
||||
echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
|
||||
killme();
|
||||
killme();
|
||||
}
|
||||
$this->template_engines[$name] = $class;
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ if(! class_exists('App')) {
|
|||
/**
|
||||
* return template engine instance. If $name is not defined,
|
||||
* return engine defined by theme, or default
|
||||
*
|
||||
*
|
||||
* @param strin $name Template engine name
|
||||
* @return object Template Engine instance
|
||||
*/
|
||||
|
@ -1037,26 +1037,14 @@ if(! function_exists('update_db')) {
|
|||
require_once("include/dbstructure.php");
|
||||
$retval = update_structure(false, true);
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$update' => DB_UPDATE_VERSION,
|
||||
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
|
||||
.'Content-type: text/plain; charset=UTF-8'."\n"
|
||||
.'Content-transfer-encoding: 8bit');
|
||||
//try the logger
|
||||
logger("CRITICAL: Database structure update failed: ".$retval);
|
||||
update_fail(
|
||||
DB_UPDATE_VERSION,
|
||||
sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
|
||||
);
|
||||
break;
|
||||
} else
|
||||
} else {
|
||||
set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success');
|
||||
}
|
||||
|
||||
for($x = $stored; $x < $current; $x ++) {
|
||||
if(function_exists('update_' . $x)) {
|
||||
|
@ -1080,22 +1068,10 @@ if(! function_exists('update_db')) {
|
|||
$retval = $func();
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$update' => $x,
|
||||
'$error' => sprintf( t('Update %s failed. See error logs.'), $x)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit' );
|
||||
//try the logger
|
||||
logger('CRITICAL: Update Failed: '. $x);
|
||||
update_fail(
|
||||
$x,
|
||||
sprintf(t('Update %s failed. See error logs.'), $x)
|
||||
);
|
||||
break;
|
||||
} else {
|
||||
set_config('database','update_' . $x, 'success');
|
||||
|
@ -1221,7 +1197,7 @@ if(! function_exists('login')) {
|
|||
}
|
||||
|
||||
$noid = get_config('system','no_openid');
|
||||
|
||||
|
||||
$dest_url = $a->get_baseurl(true) . '/' . $a->query_string;
|
||||
|
||||
if(local_user()) {
|
||||
|
@ -1242,18 +1218,18 @@ if(! function_exists('login')) {
|
|||
'$dest_url' => $dest_url,
|
||||
'$logout' => t('Logout'),
|
||||
'$login' => t('Login'),
|
||||
|
||||
|
||||
'$lname' => array('username', t('Nickname or Email address: ') , '', ''),
|
||||
'$lpassword' => array('password', t('Password: '), '', ''),
|
||||
'$lremember' => array('remember', t('Remember me'), 0, ''),
|
||||
|
||||
|
||||
'$openid' => !$noid,
|
||||
'$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
|
||||
|
||||
|
||||
'$hiddens' => $hiddens,
|
||||
|
||||
|
||||
'$register' => $reg,
|
||||
|
||||
|
||||
'$lostpass' => t('Forgot your password?'),
|
||||
'$lostlink' => t('Password Reset'),
|
||||
|
||||
|
@ -1316,9 +1292,9 @@ if(! function_exists('remote_user')) {
|
|||
if(! function_exists('notice')) {
|
||||
/**
|
||||
* Show an error message to user.
|
||||
*
|
||||
*
|
||||
* This function save text in session, to be shown to the user at next page load
|
||||
*
|
||||
*
|
||||
* @param string $s - Text of notice
|
||||
*/
|
||||
function notice($s) {
|
||||
|
@ -1331,9 +1307,9 @@ if(! function_exists('notice')) {
|
|||
if(! function_exists('info')) {
|
||||
/**
|
||||
* Show an info message to user.
|
||||
*
|
||||
*
|
||||
* This function save text in session, to be shown to the user at next page load
|
||||
*
|
||||
*
|
||||
* @param string $s - Text of notice
|
||||
*/
|
||||
function info($s) {
|
||||
|
@ -1757,7 +1733,7 @@ if(! function_exists('get_birthdays')) {
|
|||
$rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
|
||||
$rr['startime'] = Null;
|
||||
$rr['today'] = $today;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1832,7 +1808,7 @@ if(! function_exists('get_events')) {
|
|||
|
||||
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
|
||||
$today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);
|
||||
|
||||
|
||||
$rr['link'] = $md;
|
||||
$rr['title'] = $title;
|
||||
$rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
|
||||
|
@ -1892,7 +1868,7 @@ if(! function_exists('proc_run')) {
|
|||
}
|
||||
|
||||
$args = $newargs;
|
||||
|
||||
|
||||
$arr = array('args' => $args, 'run_cmd' => true);
|
||||
|
||||
call_hooks("proc_run", $arr);
|
||||
|
@ -1901,14 +1877,14 @@ if(! function_exists('proc_run')) {
|
|||
|
||||
if(count($args) && $args[0] === 'php')
|
||||
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
|
||||
// add baseurl to args. cli scripts can't construct it
|
||||
$args[] = $a->get_baseurl();
|
||||
|
||||
|
||||
for($x = 0; $x < count($args); $x ++)
|
||||
$args[$x] = escapeshellarg($args[$x]);
|
||||
|
||||
|
||||
|
||||
|
||||
$cmdline = implode($args," ");
|
||||
if(get_config('system','proc_windows'))
|
||||
|
@ -1921,9 +1897,9 @@ if(! function_exists('proc_run')) {
|
|||
if(! function_exists('current_theme')) {
|
||||
function current_theme(){
|
||||
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
|
||||
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
||||
// $mobile_detect = new Mobile_Detect();
|
||||
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
|
||||
$is_mobile = $a->is_mobile || $a->is_tablet;
|
||||
|
@ -1953,17 +1929,17 @@ if(! function_exists('current_theme')) {
|
|||
(file_exists('view/theme/' . $theme_name . '/style.css') ||
|
||||
file_exists('view/theme/' . $theme_name . '/style.php')))
|
||||
return($theme_name);
|
||||
|
||||
|
||||
foreach($app_base_themes as $t) {
|
||||
if(file_exists('view/theme/' . $t . '/style.css')||
|
||||
file_exists('view/theme/' . $t . '/style.php'))
|
||||
return($t);
|
||||
}
|
||||
|
||||
|
||||
$fallback = array_merge(glob('view/theme/*/style.css'),glob('view/theme/*/style.php'));
|
||||
if(count($fallback))
|
||||
return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2003,7 +1979,7 @@ if(! function_exists('feed_birthday')) {
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$birthday = '';
|
||||
|
||||
if(! strlen($tz))
|
||||
|
@ -2073,13 +2049,13 @@ if(! function_exists('load_contact_links')) {
|
|||
if(! function_exists('profile_tabs')){
|
||||
function profile_tabs($a, $is_owner=False, $nickname=Null){
|
||||
//echo "<pre>"; var_dump($a->user); killme();
|
||||
|
||||
|
||||
if (is_null($nickname))
|
||||
$nickname = $a->user['nickname'];
|
||||
|
||||
|
||||
if(x($_GET,'tab'))
|
||||
$tab = notags(trim($_GET['tab']));
|
||||
|
||||
|
||||
$url = $a->get_baseurl() . '/profile/' . $nickname;
|
||||
|
||||
$tabs = array(
|
||||
|
@ -2112,7 +2088,7 @@ if(! function_exists('profile_tabs')){
|
|||
'id' => 'video-tab',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if ($is_owner){
|
||||
$tabs[] = array(
|
||||
'label' => t('Events'),
|
||||
|
@ -2133,7 +2109,7 @@ if(! function_exists('profile_tabs')){
|
|||
|
||||
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
|
||||
call_hooks('profile_tabs', $arr);
|
||||
|
||||
|
||||
$tpl = get_markup_template('common_tabs.tpl');
|
||||
|
||||
return replace_macros($tpl,array('$tabs' => $arr['tabs']));
|
||||
|
@ -2172,28 +2148,28 @@ function zrl($s,$force = false) {
|
|||
/**
|
||||
* returns querystring as string from a mapped array
|
||||
*
|
||||
* @param params Array
|
||||
* @param params Array
|
||||
* @return string
|
||||
*/
|
||||
function build_querystring($params, $name=null) {
|
||||
$ret = "";
|
||||
function build_querystring($params, $name=null) {
|
||||
$ret = "";
|
||||
foreach($params as $key=>$val) {
|
||||
if(is_array($val)) {
|
||||
if(is_array($val)) {
|
||||
if($name==null) {
|
||||
$ret .= build_querystring($val, $key);
|
||||
$ret .= build_querystring($val, $key);
|
||||
} else {
|
||||
$ret .= build_querystring($val, $name."[$key]");
|
||||
$ret .= build_querystring($val, $name."[$key]");
|
||||
}
|
||||
} else {
|
||||
$val = urlencode($val);
|
||||
if($name!=null) {
|
||||
$ret.=$name."[$key]"."=$val&";
|
||||
$ret.=$name."[$key]"."=$val&";
|
||||
} else {
|
||||
$ret.= "$key=$val&";
|
||||
$ret.= "$key=$val&";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function explode_querystring($query) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_once('include/email.php');
|
||||
|
||||
class EmailNotification {
|
||||
class Emailer {
|
||||
/**
|
||||
* Send a multipart/alternative message with Text and HTML versions
|
||||
*
|
||||
|
@ -13,13 +13,13 @@ class EmailNotification {
|
|||
* @param messageSubject subject of the message
|
||||
* @param htmlVersion html version of the message
|
||||
* @param textVersion text only version of the message
|
||||
* @param additionalMailHeader additions to the smtp mail header
|
||||
*/
|
||||
static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
|
||||
static public function send($params) {
|
||||
|
||||
$fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
|
||||
$fromName = email_header_encode($fromName,'UTF-8');
|
||||
$messageSubject = email_header_encode($messageSubject,'UTF-8');
|
||||
|
||||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary =rand(0,9)."-"
|
||||
.rand(10000000000,9999999999)."-"
|
||||
|
@ -28,14 +28,15 @@ class EmailNotification {
|
|||
|
||||
// generate a multipart/alternative message header
|
||||
$messageHeader =
|
||||
"From: {$fromName} <{$fromEmail}>\n" .
|
||||
"Reply-To: {$replyTo}\n" .
|
||||
$params['additionalMailHeader'] .
|
||||
"From: $fromName <{$params['fromEmail']}>\n" .
|
||||
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
||||
"MIME-Version: 1.0\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
|
||||
// assemble the final multipart message body with the text and html types included
|
||||
$textBody = chunk_split(base64_encode($textVersion));
|
||||
$htmlBody = chunk_split(base64_encode($htmlVersion));
|
||||
$textBody = chunk_split(base64_encode($params['textVersion']));
|
||||
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
|
||||
$multipartMessageBody =
|
||||
"--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
|
@ -49,12 +50,13 @@ class EmailNotification {
|
|||
|
||||
// send the message
|
||||
$res = mail(
|
||||
$toEmail, // send to address
|
||||
$params['toEmail'], // send to address
|
||||
$messageSubject, // subject
|
||||
$multipartMessageBody, // message body
|
||||
$messageHeader // message headers
|
||||
);
|
||||
logger("sendTextHtmlEmail: END");
|
||||
logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
|
||||
logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
|
@ -1,5 +1,66 @@
|
|||
<?php
|
||||
require_once("boot.php");
|
||||
require_once("include/text.php");
|
||||
/*
|
||||
* send the email and do what is needed to do on update fails
|
||||
*
|
||||
* @param update_id (int) number of failed update
|
||||
* @param error_message (str) error message
|
||||
*/
|
||||
function update_fail($update_id, $error_message){
|
||||
//send the administrators an e-mail
|
||||
$admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
|
||||
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
|
||||
$admin_mail_list
|
||||
);
|
||||
|
||||
// every admin could had different language
|
||||
|
||||
foreach ($adminlist as $admin) {
|
||||
$lang = (($admin['language'])?$admin['language']:'en');
|
||||
push_lang($lang);
|
||||
|
||||
$preamble = deindent(t("
|
||||
The friendica developers released update %s recently,
|
||||
but when I tried to install it, something went terribly wrong.
|
||||
This needs to be fixed soon and I can't do it alone. Please contact a
|
||||
friendica developer if you can not help me on your own. My database might be invalid.");
|
||||
$body = t("The error message is\n[pre]%s[/pre]");
|
||||
$preamble = sprintf($preamble, $update_id);
|
||||
$body = sprintf($body, $error_message);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'to_email' => $admin['email'],
|
||||
'preamble' => $preamble,
|
||||
'body' => $body,
|
||||
'language' => $lang,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$update' => DB_UPDATE_VERSION,
|
||||
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
|
||||
.'Content-type: text/plain; charset=UTF-8'."\n"
|
||||
.'Content-transfer-encoding: 8bit');
|
||||
*/
|
||||
//try the logger
|
||||
logger("CRITICAL: Database structure update failed: ".$retval);
|
||||
break;
|
||||
}
|
||||
|
||||
function dbstructure_run(&$argv, &$argc) {
|
||||
global $a, $db;
|
||||
|
|
|
@ -249,6 +249,12 @@ function email_header_encode($in_str, $charset) {
|
|||
return $out_str;
|
||||
}
|
||||
|
||||
/**
|
||||
* email_send is used by NETWORK_EMAIL and NETWORK_EMAIL2 code
|
||||
* (not to notify the user, but to send items to email contacts
|
||||
*
|
||||
* TODO: this could be changed to use the Emailer class
|
||||
*/
|
||||
function email_send($addr, $subject, $headers, $item) {
|
||||
//$headers .= 'MIME-Version: 1.0' . "\n";
|
||||
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once('include/Emailer.php');
|
||||
require_once('include/email.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
function notification($params) {
|
||||
|
||||
logger('notification: entry', LOGGER_DEBUG);
|
||||
#logger('notification()', LOGGER_DEBUG);
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -26,8 +28,13 @@ function notification($params) {
|
|||
$hostname = substr($hostname,0,strpos($hostname,':'));
|
||||
|
||||
$sender_email = t('noreply') . '@' . $hostname;
|
||||
$additional_mail_header = "";
|
||||
|
||||
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
|
||||
// the database, and an email is sent if applicable.
|
||||
// default, if not specified: true
|
||||
$show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
|
||||
|
||||
$additional_mail_header = "";
|
||||
$additional_mail_header .= "Precedence: list\n";
|
||||
$additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
|
||||
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
|
||||
|
@ -35,6 +42,7 @@ function notification($params) {
|
|||
$additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
|
||||
$additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
|
||||
|
||||
|
||||
if(array_key_exists('item',$params)) {
|
||||
$title = $params['item']['title'];
|
||||
$body = $params['item']['body'];
|
||||
|
@ -223,6 +231,30 @@ function notification($params) {
|
|||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
|
||||
switch ($params['verb']) {
|
||||
case ACTIVITY_FRIEND:
|
||||
// someone started to share with user (mostly OStatus)
|
||||
$subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
|
||||
$preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename);
|
||||
break;
|
||||
case ACTIVITY_FOLLOW:
|
||||
// someone started to follow the user (mostly OStatus)
|
||||
$subject = sprintf( t('[Friendica:Notify] You have a new follower'));
|
||||
$preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename);
|
||||
break;
|
||||
default:
|
||||
// ACTIVITY_REQ_FRIEND is default activity for notifications
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($params['type'] == NOTIFY_SUGGEST) {
|
||||
|
@ -244,12 +276,81 @@ function notification($params) {
|
|||
}
|
||||
|
||||
if($params['type'] == NOTIFY_CONFIRM) {
|
||||
if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
|
||||
$subject = sprintf( t('[Friendica:Notify] Connection accepted'));
|
||||
$preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = t('You are now mutual friends and may exchange status updates, photos, and email
|
||||
without restriction.');
|
||||
|
||||
$sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
} else { // ACTIVITY_FOLLOW
|
||||
$subject = sprintf( t('[Friendica:Notify] Connection accepted'));
|
||||
$preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = sprintf(t('\'%1$s\' has chosen to accept you a "fan", which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.'), $params['source_name']);
|
||||
$body .= "\n\n";
|
||||
$body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
|
||||
|
||||
$sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($params['type'] == NOTIFY_SYSTEM) {
|
||||
switch($params['event']) {
|
||||
case "SYSTEM_REGISTER_REQUEST":
|
||||
$subject = sprintf( t('[Friendica System:Notify] registration request'));
|
||||
$preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
|
||||
$params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
|
||||
|
||||
$sitelink = t('Please visit %s to approve or reject the request.');
|
||||
$tsitelink = sprintf( $sitelink, $params['link'] );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
break;
|
||||
case "SYSTEM_DB_UPDATE_FAIL":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($params['type'] == "SYSTEM_EMAIL"){
|
||||
// not part of the notifications.
|
||||
// it just send a mail to the user.
|
||||
// It will be used by the system to send emails to users (like
|
||||
// password reset, invitations and so) using one look (but without
|
||||
// add a notification to the user, with could be inexistent)
|
||||
$subject = $params['subject'];
|
||||
$preamble = $params['preamble'];
|
||||
if (x($params,'epreamble')){
|
||||
$epreamble = $params['epreamble'];
|
||||
} else {
|
||||
$epreamble = str_replace("\n","<br>\n",$preamble);
|
||||
}
|
||||
$body = $params['body'];
|
||||
$sitelink = "";
|
||||
$tsitelink = "";
|
||||
$hsitelink = "";
|
||||
$itemlink = "";
|
||||
$show_in_notification_page = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$h = array(
|
||||
'params' => $params,
|
||||
'subject' => $subject,
|
||||
|
@ -274,114 +375,110 @@ function notification($params) {
|
|||
$itemlink = $h['itemlink'];
|
||||
|
||||
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
do {
|
||||
$dups = false;
|
||||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if(count($r))
|
||||
$dups = true;
|
||||
} while($dups == true);
|
||||
if ($show_in_notification_page) {
|
||||
logger("adding notification entry", LOGGER_DEBUG);
|
||||
do {
|
||||
$dups = false;
|
||||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if(count($r))
|
||||
$dups = true;
|
||||
} while($dups == true);
|
||||
|
||||
|
||||
$datarray = array();
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
$datarray['url'] = $params['source_link'];
|
||||
$datarray['photo'] = $params['source_photo'];
|
||||
$datarray['date'] = datetime_convert();
|
||||
$datarray['uid'] = $params['uid'];
|
||||
$datarray['link'] = $itemlink;
|
||||
$datarray['parent'] = $parent_id;
|
||||
$datarray['type'] = $params['type'];
|
||||
$datarray['verb'] = $params['verb'];
|
||||
$datarray['otype'] = $params['otype'];
|
||||
$datarray['abort'] = false;
|
||||
$datarray = array();
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
$datarray['url'] = $params['source_link'];
|
||||
$datarray['photo'] = $params['source_photo'];
|
||||
$datarray['date'] = datetime_convert();
|
||||
$datarray['uid'] = $params['uid'];
|
||||
$datarray['link'] = $itemlink;
|
||||
$datarray['parent'] = $parent_id;
|
||||
$datarray['type'] = $params['type'];
|
||||
$datarray['verb'] = $params['verb'];
|
||||
$datarray['otype'] = $params['otype'];
|
||||
$datarray['abort'] = false;
|
||||
|
||||
call_hooks('enotify_store', $datarray);
|
||||
call_hooks('enotify_store', $datarray);
|
||||
|
||||
if($datarray['abort']) {
|
||||
pop_lang();
|
||||
return;
|
||||
}
|
||||
|
||||
// create notification entry in DB
|
||||
|
||||
$r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
|
||||
values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
|
||||
dbesc($datarray['hash']),
|
||||
dbesc($datarray['name']),
|
||||
dbesc($datarray['url']),
|
||||
dbesc($datarray['photo']),
|
||||
dbesc($datarray['date']),
|
||||
intval($datarray['uid']),
|
||||
dbesc($datarray['link']),
|
||||
intval($datarray['parent']),
|
||||
intval($datarray['type']),
|
||||
dbesc($datarray['verb']),
|
||||
dbesc($datarray['otype'])
|
||||
);
|
||||
|
||||
$r = q("select id from notify where hash = '%s' and uid = %d limit 1",
|
||||
dbesc($hash),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($r)
|
||||
$notify_id = $r[0]['id'];
|
||||
else {
|
||||
pop_lang();
|
||||
return;
|
||||
}
|
||||
|
||||
// we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
|
||||
// After we've stored everything, look again to see if there are any duplicates and if so remove them
|
||||
|
||||
$p = null;
|
||||
$p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
|
||||
intval(NOTIFY_TAGSELF),
|
||||
intval(NOTIFY_COMMENT),
|
||||
dbesc($params['link']),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($p && (count($p) > 1)) {
|
||||
for ($d = 1; $d < count($p); $d ++) {
|
||||
q("delete from notify where id = %d",
|
||||
intval($p[$d]['id'])
|
||||
);
|
||||
}
|
||||
|
||||
// only continue on if we stored the first one
|
||||
|
||||
if($notify_id != $p[0]['id']) {
|
||||
if($datarray['abort']) {
|
||||
pop_lang();
|
||||
return;
|
||||
return False;
|
||||
}
|
||||
|
||||
// create notification entry in DB
|
||||
|
||||
$r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
|
||||
values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
|
||||
dbesc($datarray['hash']),
|
||||
dbesc($datarray['name']),
|
||||
dbesc($datarray['url']),
|
||||
dbesc($datarray['photo']),
|
||||
dbesc($datarray['date']),
|
||||
intval($datarray['uid']),
|
||||
dbesc($datarray['link']),
|
||||
intval($datarray['parent']),
|
||||
intval($datarray['type']),
|
||||
dbesc($datarray['verb']),
|
||||
dbesc($datarray['otype'])
|
||||
);
|
||||
|
||||
$r = q("select id from notify where hash = '%s' and uid = %d limit 1",
|
||||
dbesc($hash),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($r)
|
||||
$notify_id = $r[0]['id'];
|
||||
else {
|
||||
pop_lang();
|
||||
return False;
|
||||
}
|
||||
|
||||
// we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
|
||||
// After we've stored everything, look again to see if there are any duplicates and if so remove them
|
||||
|
||||
$p = null;
|
||||
$p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
|
||||
intval(NOTIFY_TAGSELF),
|
||||
intval(NOTIFY_COMMENT),
|
||||
dbesc($params['link']),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($p && (count($p) > 1)) {
|
||||
for ($d = 1; $d < count($p); $d ++) {
|
||||
q("delete from notify where id = %d",
|
||||
intval($p[$d]['id'])
|
||||
);
|
||||
}
|
||||
|
||||
// only continue on if we stored the first one
|
||||
|
||||
if($notify_id != $p[0]['id']) {
|
||||
pop_lang();
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
|
||||
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
|
||||
$r = q("update notify set msg = '%s' where id = %d and uid = %d",
|
||||
dbesc($msg),
|
||||
intval($notify_id),
|
||||
intval($params['uid'])
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
|
||||
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
|
||||
$r = q("update notify set msg = '%s' where id = %d and uid = %d",
|
||||
dbesc($msg),
|
||||
intval($notify_id),
|
||||
intval($params['uid'])
|
||||
);
|
||||
|
||||
|
||||
// send email notification if notification preferences permit
|
||||
if((intval($params['notify_flags']) & intval($params['type']))
|
||||
|| $params['type'] == NOTIFY_SYSTEM
|
||||
|| $params['type'] == "SYSTEM_EMAIL") {
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
|
||||
|
||||
logger('notification: sending notification email');
|
||||
logger('sending notification email');
|
||||
|
||||
if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
|
||||
$id_for_parent = $params['parent']."@".$hostname;
|
||||
|
@ -410,16 +507,18 @@ function notification($params) {
|
|||
} else {
|
||||
// If not, just "follow" the thread.
|
||||
$additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
|
||||
logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
|
||||
logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
|
||||
$body))),ENT_QUOTES,'UTF-8'));
|
||||
// textversion keeps linebreaks
|
||||
$textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
|
||||
$body))),ENT_QUOTES,'UTF-8')));
|
||||
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
|
||||
"<br />\n",$body))),ENT_QUOTES,'UTF-8');
|
||||
|
||||
|
||||
$datarray = array();
|
||||
$datarray['banner'] = $banner;
|
||||
$datarray['product'] = $product;
|
||||
|
@ -494,9 +593,9 @@ function notification($params) {
|
|||
|
||||
// logger('text: ' . $email_text_body);
|
||||
|
||||
// use the EmailNotification library to send the message
|
||||
// use the Emailer class to send the message
|
||||
|
||||
enotify::send(array(
|
||||
Emailer::send(array(
|
||||
'fromName' => $sender_name,
|
||||
'fromEmail' => $sender_email,
|
||||
'replyTo' => $sender_email,
|
||||
|
@ -506,69 +605,11 @@ function notification($params) {
|
|||
'textVersion' => $email_text_body,
|
||||
'additionalMailHeader' => $datarray['headers'],
|
||||
));
|
||||
return True;
|
||||
}
|
||||
|
||||
pop_lang();
|
||||
return False;
|
||||
|
||||
}
|
||||
|
||||
require_once('include/email.php');
|
||||
|
||||
class enotify {
|
||||
/**
|
||||
* Send a multipart/alternative message with Text and HTML versions
|
||||
*
|
||||
* @param fromName name of the sender
|
||||
* @param fromEmail email fo the sender
|
||||
* @param replyTo replyTo address to direct responses
|
||||
* @param toEmail destination email address
|
||||
* @param messageSubject subject of the message
|
||||
* @param htmlVersion html version of the message
|
||||
* @param textVersion text only version of the message
|
||||
* @param additionalMailHeader additions to the smtp mail header
|
||||
*/
|
||||
static public function send($params) {
|
||||
|
||||
$fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary =rand(0,9)."-"
|
||||
.rand(10000000000,9999999999)."-"
|
||||
.rand(10000000000,9999999999)."=:"
|
||||
.rand(10000,99999);
|
||||
|
||||
// generate a multipart/alternative message header
|
||||
$messageHeader =
|
||||
$params['additionalMailHeader'] .
|
||||
"From: $fromName <{$params['fromEmail']}>\n" .
|
||||
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
||||
"MIME-Version: 1.0\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
|
||||
// assemble the final multipart message body with the text and html types included
|
||||
$textBody = chunk_split(base64_encode($params['textVersion']));
|
||||
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
|
||||
$multipartMessageBody =
|
||||
"--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$textBody . "\n" .
|
||||
"--" . $mimeBoundary . "\n" . // text/html section
|
||||
"Content-Type: text/html; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$htmlBody . "\n" .
|
||||
"--" . $mimeBoundary . "--\n"; // message ending
|
||||
|
||||
// send the message
|
||||
$res = mail(
|
||||
$params['toEmail'], // send to address
|
||||
$messageSubject, // subject
|
||||
$multipartMessageBody, // message body
|
||||
$messageHeader // message headers
|
||||
);
|
||||
logger("notification: enotify::send header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
|
||||
logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -3828,6 +3828,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
dbesc(datetime_convert())
|
||||
);
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($importer['uid'])
|
||||
);
|
||||
|
@ -3841,20 +3842,24 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
|
||||
if(($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
(($r[0]['page-flags'] == PAGE_NORMAL) OR ($r[0]['page-flags'] == PAGE_SOAPBOX))) {
|
||||
$email_tpl = get_intltext_template('follow_notify_eml.tpl');
|
||||
$email = replace_macros($email_tpl, array(
|
||||
'$requestor' => ((strlen($name)) ? $name : t('[Name Withheld]')),
|
||||
'$url' => $url,
|
||||
'$myname' => $r[0]['username'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$sitename' => $a->config['sitename']
|
||||
|
||||
|
||||
|
||||
notification(array(
|
||||
'type' => NOTIFY_INTRO,
|
||||
'notify_flags' => $r[0]['notify-flags'],
|
||||
'language' => $r[0]['language'],
|
||||
'to_name' => $r[0]['username'],
|
||||
'to_email' => $r[0]['email'],
|
||||
'uid' => $r[0]['uid'],
|
||||
'link' => $a->get_baseurl() . '/notifications/intro',
|
||||
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
|
||||
'source_link' => $contact_record['url'],
|
||||
'source_photo' => $contact_record['photo'],
|
||||
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
|
||||
'otype' => 'intro'
|
||||
));
|
||||
$res = mail($r[0]['email'],
|
||||
email_header_encode((($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'],'UTF-8'),
|
||||
$email,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit' );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2229,3 +2229,22 @@ function is_a_date_arg($s) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove intentation from a text
|
||||
*/
|
||||
function deindent($text, $chr="[\t ]", $count=NULL) {
|
||||
$text = fix_mce_lf($text);
|
||||
$lines = explode("\n", $text);
|
||||
if (is_null($count)) {
|
||||
$m = array();
|
||||
$k=0; while($k<count($lines) && strlen($lines[$k])==0) $k++;
|
||||
preg_match("|^".$chr."*|", $lines[$k], $m);
|
||||
$count = strlen($m[0]);
|
||||
}
|
||||
for ($k=0; $k<count($lines); $k++){
|
||||
$lines[$k] = preg_replace("|^".$chr."{".$count."}|", "", $lines[$k]);
|
||||
}
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ require_once('include/plugin.php');
|
|||
require_once('include/text.php');
|
||||
require_once('include/pgettext.php');
|
||||
require_once('include/datetime.php');
|
||||
require_once('include/enotify.php');
|
||||
|
||||
|
||||
function create_user($arr) {
|
||||
|
@ -44,7 +45,7 @@ function create_user($arr) {
|
|||
$result['message'] .= t('Invitation could not be verified.') . EOL;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((! x($username)) || (! x($email)) || (! x($nickname))) {
|
||||
if($openid_url) {
|
||||
|
@ -57,17 +58,17 @@ function create_user($arr) {
|
|||
require_once('library/openid.php');
|
||||
$openid = new LightOpenID;
|
||||
$openid->identity = $openid_url;
|
||||
$openid->returnUrl = $a->get_baseurl() . '/openid';
|
||||
$openid->returnUrl = $a->get_baseurl() . '/openid';
|
||||
$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
|
||||
$openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
|
||||
try {
|
||||
try {
|
||||
$authurl = $openid->authUrl();
|
||||
} catch (Exception $e){
|
||||
$result['message'] .= t("We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID."). EOL . EOL . t("The error message was:") . $e->getMessage() . EOL;
|
||||
$result['message'] .= t("We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID."). EOL . EOL . t("The error message was:") . $e->getMessage() . EOL;
|
||||
return $result;
|
||||
}
|
||||
goaway($authurl);
|
||||
// NOTREACHED
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
notice( t('Please enter the required information.') . EOL );
|
||||
|
@ -90,12 +91,12 @@ function create_user($arr) {
|
|||
|
||||
// I don't really like having this rule, but it cuts down
|
||||
// on the number of auto-registrations by Russian spammers
|
||||
|
||||
|
||||
// Using preg_match was completely unreliable, due to mixed UTF-8 regex support
|
||||
// $no_utf = get_config('system','no_utf');
|
||||
// $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
|
||||
// $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
|
||||
|
||||
// So now we are just looking for a space in the full name.
|
||||
// So now we are just looking for a space in the full name.
|
||||
|
||||
$loose_reg = get_config('system','no_regfullname');
|
||||
if(! $loose_reg) {
|
||||
|
@ -182,7 +183,7 @@ function create_user($arr) {
|
|||
* will take several minutes each to process.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$sres = new_keypair(512);
|
||||
$sprvkey = $sres['prvkey'];
|
||||
$spubkey = $sres['pubkey'];
|
||||
|
@ -207,7 +208,7 @@ function create_user($arr) {
|
|||
);
|
||||
|
||||
if($r) {
|
||||
$r = q("SELECT * FROM `user`
|
||||
$r = q("SELECT * FROM `user`
|
||||
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
|
||||
dbesc($username),
|
||||
dbesc($new_password_encoded)
|
||||
|
@ -220,10 +221,10 @@ function create_user($arr) {
|
|||
else {
|
||||
$result['message'] .= t('An error occurred during registration. Please try again.') . EOL ;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if somebody clicked submit twice very quickly, they could end up with two accounts
|
||||
* if somebody clicked submit twice very quickly, they could end up with two accounts
|
||||
* due to race condition. Remove this one.
|
||||
*/
|
||||
|
||||
|
@ -281,8 +282,8 @@ function create_user($arr) {
|
|||
dbesc(datetime_convert())
|
||||
);
|
||||
|
||||
// Create a group with no members. This allows somebody to use it
|
||||
// right away as a default group for new contacts.
|
||||
// Create a group with no members. This allows somebody to use it
|
||||
// right away as a default group for new contacts.
|
||||
|
||||
require_once('include/group.php');
|
||||
group_add($newuid, t('Friends'));
|
||||
|
@ -323,7 +324,7 @@ function create_user($arr) {
|
|||
// guess mimetype from headers or filename
|
||||
$type = guess_image_type($photo,true);
|
||||
|
||||
|
||||
|
||||
$img = new Photo($img_str, $type);
|
||||
if($img->is_valid()) {
|
||||
|
||||
|
@ -365,3 +366,51 @@ function create_user($arr) {
|
|||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* send registration confirmation.
|
||||
* It's here as a function because the mail is sent
|
||||
* from different parts
|
||||
*/
|
||||
function send_register_open_eml($email, $sitename, $siteurl, $username, $password){
|
||||
$preamble = deindent(t('
|
||||
Dear %1$s,
|
||||
Thank you for registering at %2$s. Your account has been created.
|
||||
'));
|
||||
$body = deindent(t('
|
||||
The login details are as follows:
|
||||
Site Location: %3$s
|
||||
Login Name: %1$s
|
||||
Password: %5$
|
||||
|
||||
You may change your password from your account "Settings" page after logging
|
||||
in.
|
||||
|
||||
Please take a few moments to review the other account settings on that page.
|
||||
|
||||
You may also wish to add some basic information to your default profile
|
||||
(on the "Profiles" page) so that other people can easily find you.
|
||||
|
||||
We recommend setting your full name, adding a profile photo,
|
||||
adding some profile "keywords" (very useful in making new friends) - and
|
||||
perhaps what country you live in; if you do not wish to be more specific
|
||||
than that.
|
||||
|
||||
We fully respect your right to privacy, and none of these items are necessary.
|
||||
If you are new and do not know anybody here, they may help
|
||||
you to make some new and interesting friends.
|
||||
|
||||
|
||||
Thank you and welcome to %2$s.'));
|
||||
|
||||
$preamble = sprintf($preamble, $username, $sitename);
|
||||
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Registration details for %s'), $sitename),
|
||||
'preamble'=> $preamble,
|
||||
'body' => $body));
|
||||
}
|
||||
|
|
156
mod/admin.php
156
mod/admin.php
|
@ -4,6 +4,8 @@
|
|||
* Friendica admin
|
||||
*/
|
||||
require_once("include/remoteupdate.php");
|
||||
require_once("include/enotify.php");
|
||||
require_once("include/text.php");
|
||||
|
||||
|
||||
/**
|
||||
|
@ -419,9 +421,9 @@ function admin_page_site_post(&$a){
|
|||
set_config('system','banner', $banner);
|
||||
}
|
||||
if ($info=="") {
|
||||
del_config('config','info');
|
||||
del_config('config','info');
|
||||
} else {
|
||||
set_config('config','info',$info);
|
||||
set_config('config','info',$info);
|
||||
}
|
||||
set_config('system','language', $language);
|
||||
set_config('system','theme', $theme);
|
||||
|
@ -429,12 +431,12 @@ function admin_page_site_post(&$a){
|
|||
del_config('system','mobile-theme');
|
||||
} else {
|
||||
set_config('system','mobile-theme', $theme_mobile);
|
||||
}
|
||||
if ( $singleuser === '---' ) {
|
||||
del_config('system','singleuser');
|
||||
} else {
|
||||
set_config('system','singleuser', $singleuser);
|
||||
}
|
||||
}
|
||||
if ( $singleuser === '---' ) {
|
||||
del_config('system','singleuser');
|
||||
} else {
|
||||
set_config('system','singleuser', $singleuser);
|
||||
}
|
||||
set_config('system','maximagesize', $maximagesize);
|
||||
set_config('system','max_image_length', $maximagelength);
|
||||
set_config('system','jpeg_quality', $jpegimagequality);
|
||||
|
@ -473,7 +475,7 @@ function admin_page_site_post(&$a){
|
|||
set_config('system','curl_timeout', $timeout);
|
||||
set_config('system','dfrn_only', $dfrn_only);
|
||||
set_config('system','ostatus_disabled', $ostatus_disabled);
|
||||
set_config('system','ostatus_poll_interval', $ostatus_poll_interval);
|
||||
set_config('system','ostatus_poll_interval', $ostatus_poll_interval);
|
||||
set_config('system','diaspora_enabled', $diaspora_enabled);
|
||||
set_config('config','private_addons', $private_addons);
|
||||
|
||||
|
@ -524,32 +526,32 @@ function admin_page_site(&$a) {
|
|||
foreach($files as $file) {
|
||||
$f = basename($file);
|
||||
$theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
|
||||
if (file_exists($file . '/mobile')) {
|
||||
$theme_choices_mobile[$f] = $theme_name;
|
||||
}
|
||||
if (file_exists($file . '/mobile')) {
|
||||
$theme_choices_mobile[$f] = $theme_name;
|
||||
}
|
||||
else {
|
||||
$theme_choices[$f] = $theme_name;
|
||||
$theme_choices[$f] = $theme_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* OStatus conversation poll choices */
|
||||
$ostatus_poll_choices = array(
|
||||
/* OStatus conversation poll choices */
|
||||
$ostatus_poll_choices = array(
|
||||
"-2" => t("Never"),
|
||||
"-1" => t("At post arrival"),
|
||||
"0" => t("Frequently"),
|
||||
"60" => t("Hourly"),
|
||||
"720" => t("Twice daily"),
|
||||
"1440" => t("Daily")
|
||||
);
|
||||
);
|
||||
|
||||
/* get user names to make the install a personal install of X */
|
||||
$user_names = array();
|
||||
$user_names['---'] = t('Multi user instance');
|
||||
$users = q("SELECT username, nickname FROM `user`");
|
||||
foreach ($users as $user) {
|
||||
$user_names[$user['nickname']] = $user['username'];
|
||||
}
|
||||
/* get user names to make the install a personal install of X */
|
||||
$user_names = array();
|
||||
$user_names['---'] = t('Multi user instance');
|
||||
$users = q("SELECT username, nickname FROM `user`");
|
||||
foreach ($users as $user) {
|
||||
$user_names[$user['nickname']] = $user['username'];
|
||||
}
|
||||
|
||||
/* Banner */
|
||||
$banner = get_config('system','banner');
|
||||
|
@ -626,9 +628,9 @@ function admin_page_site(&$a) {
|
|||
'$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")),
|
||||
'$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
|
||||
'$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")),
|
||||
'$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
|
||||
'$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
|
||||
'$ostatus_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system','ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices),
|
||||
'$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
|
||||
'$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
|
||||
'$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), get_config('system','dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")),
|
||||
'$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")),
|
||||
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
|
||||
|
@ -651,7 +653,7 @@ function admin_page_site(&$a) {
|
|||
'$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."),
|
||||
|
||||
'$enable_noscrape'=> array('enable_noscrape', t("Enable noscrape"), get_config('system','enable_noscrape'), t("The noscrape feature speeds up directory submissions by using JSON data instead of HTML scraping.")),
|
||||
'$form_security_token' => get_form_security_token("admin_site")
|
||||
'$form_security_token' => get_form_security_token("admin_site")
|
||||
|
||||
));
|
||||
|
||||
|
@ -744,39 +746,61 @@ function admin_page_dbsync(&$a) {
|
|||
function admin_page_users_post(&$a){
|
||||
$pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
|
||||
$users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
|
||||
$nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
|
||||
$nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
|
||||
$nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
|
||||
$nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
|
||||
$nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
|
||||
$nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
|
||||
|
||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
|
||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
|
||||
|
||||
if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
|
||||
require_once('include/user.php');
|
||||
require_once('include/email.php');
|
||||
$result = create_user( array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1) );
|
||||
if(! $result['success']) {
|
||||
notice($result['message']);
|
||||
return;
|
||||
}
|
||||
$nu = $result['user'];
|
||||
$email_tpl = get_intltext_template("register_adminadd_eml.tpl");
|
||||
$email_tpl = replace_macros($email_tpl, array(
|
||||