Ejemplo n.º 1
0
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->siteDomain = get_site_domain($CONFIG->site_guid);
     $this->site = elgg_get_site_entity();
     $this->approvedDomains = ['forces.gc.ca', 'test.gc.ca'];
 }
Ejemplo n.º 2
0
/**
 * Determine the best from email address
 *
 * @return string with email address
 */
function phpmailer_extract_from_email()
{
    global $CONFIG;
    $from_email = '';
    $site = get_entity($CONFIG->site_guid);
    // If there's an email address, use it - but only if its not from a user.
    if (isset($from->email) && !$from instanceof ElggUser) {
        $from_email = $from->email;
        // Has the current site got a from email address?
    } else {
        if ($site && isset($site->email)) {
            $from_email = $site->email;
            // If we have a url then try and use that.
        } else {
            if (isset($from->url)) {
                $breakdown = parse_url($from->url);
                $from_email = 'noreply@' . $breakdown['host'];
                // Handle anything with a url
                // If all else fails, use the domain of the site.
            } else {
                $from_email = 'noreply@' . get_site_domain($CONFIG->site_guid);
            }
        }
    }
    return $from_email;
}
Ejemplo n.º 3
0
function html_email_handler_notification_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
{
    if (!$from) {
        $msg = elgg_echo("NotificationException:MissingParameter", array("from"));
        throw new NotificationException($msg);
    }
    if (!$to) {
        $msg = elgg_echo("NotificationException:MissingParameter", array("to"));
        throw new NotificationException($msg);
    }
    if ($to->email == "") {
        $msg = elgg_echo("NotificationException:NoEmailAddress", array($to->guid));
        throw new NotificationException($msg);
    }
    // To
    $to = html_email_handler_make_rfc822_address($to);
    // From
    $site = elgg_get_site_entity();
    // If there's an email address, use it - but only if its not from a user.
    if (!$from instanceof ElggUser && !empty($from->email)) {
        $from = html_email_handler_make_rfc822_address($from);
    } elseif (!empty($site->email)) {
        // Use email address of current site if we cannot use sender's email
        $from = html_email_handler_make_rfc822_address($site);
    } else {
        // If all else fails, use the domain of the site.
        if (!empty($site->name)) {
            $name = $site->name;
            if (strstr($name, ',')) {
                $name = '"' . $name . '"';
                // Protect the name with quotations if it contains a comma
            }
            $name = '=?UTF-8?B?' . base64_encode($name) . '?=';
            // Encode the name. If may content nos ASCII chars.
            $from = $name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
        } else {
            $from = "noreply@" . get_site_domain($site->getGUID());
        }
    }
    // generate HTML mail body
    $html_message = html_email_handler_make_html_body($subject, $message);
    // set options for sending
    $options = array("to" => $to, "from" => $from, "subject" => '=?UTF-8?B?' . base64_encode($subject) . '?=', "html_message" => $html_message, "plaintext_message" => $message);
    if (!empty($params) && is_array($params)) {
        $options = array_merge($options, $params);
    }
    return html_email_handler_send_email($options);
}
Ejemplo n.º 4
0
function spam_login_filter_notify_admin($blockedEmail, $blockedIp, $reason)
{
    if (elgg_get_plugin_setting('notify_by_mail', 'spam_login_filter') == "yes") {
        //Notify spam tentative to administrator
        $site = elgg_get_site_entity();
        if ($site && isset($site->email)) {
            $from = $site->email;
        } else {
            $from = 'noreply@' . get_site_domain($site->guid);
        }
        $message = sprintf(elgg_echo('spam_login_filter:notify_message'), $blockedEmail, $blockedIp, $reason);
        $to = elgg_get_plugin_setting('notify_mail_address', 'spam_login_filter');
        if (!is_email_address($to)) {
            return;
        }
        elgg_send_email($from, $to, elgg_echo('spam_login_filter:notify_subject'), $message);
    }
}
Ejemplo n.º 5
0
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int  $user_guid       The user's GUID
 * @param bool $admin_requested Was it requested by admin
 * @return mixed
 */
function uservalidationbyadmin_request_validation($user_guid, $admin_requested = FALSE)
{
    $site = elgg_get_site_entity();
    if ($site && $site->email) {
        $from = $site->email;
    } else {
        $from = 'noreply@' . get_site_domain($site->guid);
    }
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    //notify admins
    if ($user && $user instanceof ElggUser) {
        // Work out validate link
        $code = uservalidationbyadmin_generate_code($user_guid, $user->email);
        $link = "{$site->url}uservalidationbyadmin/confirm?u={$user_guid}&c={$code}";
        // IP detection
        $ip_address = $_SERVER['REMOTE_ADDR'];
        /*$geoloc = "https://secure.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=".$ip_address;
        		$geotags = get_meta_tags($geoloc);
        		$geocountry = $geotags['country'];
        		$georegion = $geotags['region'];
        		$geocity = $geotags['city'];
        		$geocertainty = $geotags['certainty'];*/
        $geostring = $ip_address;
        //." ; ".$geocountry." ; ".$georegion." ; ".$geocity." ; ".$geocertainty;
        // Send validation email
        $subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
        $body = elgg_echo('email:validate:body', array($user->name, $user->email, $ip_address, $geostring, $link, $site->name, $site->url));
        $emails = elgg_get_plugin_setting('emails', 'uservalidationbyadmin');
        $admin_mails = explode(",", $emails);
        $sent_total = 0;
        foreach ($admin_mails as $mail) {
            if (elgg_send_email($from, $mail, $subject, $body)) {
                $sent_total++;
            }
        }
        // Atleast 1 mail sent
        if ($sent_total > 0 && !$admin_requested) {
            system_message(elgg_echo('uservalidationbyadmin:registerok'));
        }
        return $result;
    }
    return FALSE;
}
Ejemplo n.º 6
0
/**
 * Send password for new user who is registered using facebook connect
 *
 * @param $email
 * @param $name
 * @param $username
 * @param $password
 */
function send_user_password_mail($email, $name, $username, $password)
{
    $site = elgg_get_site_entity();
    $email = trim($email);
    // send out other email addresses
    if (!is_email_address($email)) {
        return false;
    }
    $message = elgg_echo('facebook_connect:email:body', array($name, $site->name, $site->url, $username, $email, $password, $site->name, $site->url));
    $subject = elgg_echo('facebook_connect:email:subject', array($name));
    // create the from address
    $site = get_entity($site->guid);
    if ($site && isset($site->email)) {
        $from = $site->email;
    } else {
        $from = 'noreply@' . get_site_domain($site->guid);
    }
    elgg_send_email($from, $email, $subject, $message);
}
Ejemplo n.º 7
0
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
    $result = false;
    if (!empty($group) && $group instanceof ElggGroup && !empty($email) && is_email_address($email) && ($loggedin_user = elgg_get_logged_in_user_entity())) {
        // get site secret
        $site_secret = get_site_secret();
        // generate invite code
        $invite_code = md5($site_secret . $email . $group->getGUID());
        if (!group_tools_check_group_email_invitation($invite_code, $group->getGUID()) || $resend) {
            // make site email
            $site = elgg_get_site_entity();
            if (!empty($site->email)) {
                if (!empty($site->name)) {
                    $site_from = $site->name . " <" . $site->email . ">";
                } else {
                    $site_from = $site->email;
                }
            } else {
                // no site email, so make one up
                if (!empty($site->name)) {
                    $site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
                } else {
                    $site_from = "noreply@" . get_site_domain($site->getGUID());
                }
            }
            if (!$resend) {
                // register invite with group
                $group->annotate("email_invitation", $invite_code, ACCESS_LOGGED_IN, $group->getGUID());
            }
            // make subject
            $subject = elgg_echo("group_tools:groups:invite:email:subject", array($group->name));
            // make body
            $body = elgg_echo("group_tools:groups:invite:email:body", array($loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_get_site_url() . "register", elgg_get_site_url() . "groups/invitations/?invitecode=" . $invite_code, $invite_code));
            $result = elgg_send_email($site_from, $email, $subject, $body);
        } else {
            $result = null;
        }
    }
    return $result;
}
Ejemplo n.º 8
0
function event_manager_send_registration_validation_email($event, $object)
{
    $subject = elgg_echo("event_manager:registration:confirm:subject", array($event->title));
    $message = elgg_echo("event_manager:registration:confirm:message", array($object->name, $event->title, event_manager_get_registration_validation_url($event->getGUID(), $object->getGUID())));
    $site = elgg_get_site_entity();
    // send confirmation mail
    if (elgg_instanceof($object, "user")) {
        notify_user($object->getGUID(), $site->getGUID(), $subject, $message, null, "email");
    } else {
        $from = $site->email;
        if (empty($from)) {
            $from = "noreply@" . get_site_domain($site->getGUID());
        }
        if (!empty($site->name)) {
            $site_name = $site->name;
            if (strstr($site_name, ',')) {
                $site_name = '"' . $site_name . '"';
                // Protect the name with quotations if it contains a comma
            }
            $site_name = '=?UTF-8?B?' . base64_encode($site_name) . '?=';
            // Encode the name. If may content nos ASCII chars.
            $from = $site_name . " <" . $from . ">";
        }
        elgg_send_email($from, $object->email, $subject, $message);
    }
}
Ejemplo n.º 9
0
function izap_get_video_name_prefix()
{
    global $CONFIG;
    $domain = get_site_domain($CONFIG->site_guid);
    $domain = preg_replace('/[^A-Za-z0-9]+/', '_', $domain);
    return $domain . '_izap_videos_';
}
Ejemplo n.º 10
0
     // try to find a registration
     $options = array("type" => "object", "subtype" => EventRegistration::SUBTYPE, "owner_guid" => $entity->getGUID(), "limit" => 1, "metadata_name_value_pairs" => array("name" => "email", "value" => $email, "case_sensitive" => false));
     if ($registrations = elgg_get_entities_from_metadata($options)) {
         $registration = $registrations[0];
         // generate unsubscribe code
         $unsubscribe_code = event_manager_create_unsubscribe_code($registration, $entity);
         $unsubscribe_link = elgg_normalize_url("events/unsubscribe/confirm/" . $registration->getGUID() . "/" . $unsubscribe_code);
         // make a message with further instructions
         $subject = elgg_echo("event_manager:unsubscribe:confirm:subject", array($entity->title));
         $message = elgg_echo("event_manager:unsubscribe:confirm:message", array($registration->name, $entity->title, $entity->getURL(), $unsubscribe_link));
         // nice e-mail addresses
         $site = elgg_get_site_entity();
         if ($site->email) {
             $from = $site->name . " <" . $site->email . ">";
         } else {
             $from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
         }
         $to = $registration->name . " <" . $registration->email . ">";
         if (elgg_send_email($from, $to, $subject, $message)) {
             elgg_clear_sticky_form("event_unsubscribe");
             $forward_url = $entity->getURL();
             system_message(elgg_echo("event_manager:action:unsubscribe:success"));
         } else {
             register_error(elgg_echo("event_manager:action:unsubscribe:error:mail"));
         }
     } else {
         register_error(elgg_echo("event_manager:action:unsubscribe:error:no_registration"));
     }
 } else {
     register_error(elgg_echo("ClassException:ClassnameNotClass", array($guid, elgg_echo("item:object:" . Event::SUBTYPE))));
 }
Ejemplo n.º 11
0
/**
 * 
 * This function sends out a full HTML mail. It can handle several options
 * 
 * This function requires the options 'to' and ('html_message' or 'plaintext_message')
 * 
 * @param $options Array in the format:
 * 		to => STR|ARR of recipients in RFC-2822 format (http://www.faqs.org/rfcs/rfc2822.html)
 * 		from => STR of senden in RFC-2822 format (http://www.faqs.org/rfcs/rfc2822.html)
 * 		subject => STR with the subject of the message
 * 		html_message => STR with the HTML version of the message
 * 		plaintext_message STR with the plaintext version of the message
 * 		cc => NULL|STR|ARR of CC recipients in RFC-2822 format (http://www.faqs.org/rfcs/rfc2822.html)
 * 		bcc => NULL|STR|ARR of BCC recipients in RFC-2822 format (http://www.faqs.org/rfcs/rfc2822.html)
 * 		date => NULL|UNIX timestamp with the date the message was created
 * 
 * @return BOOL true|false
 */
function html_email_handler_send_email(array $options = null)
{
    $result = false;
    $site = elgg_get_site_entity();
    // make site email
    if (!empty($site->email)) {
        $sendmail_from = $site->email;
        $site_from = html_email_handler_make_rfc822_address($site);
    } else {
        // no site email, so make one up
        $sendmail_from = "noreply@" . get_site_domain($site->getGUID());
        $site_from = $sendmail_from;
        if (!empty($site->name)) {
            $site_name = $site->name;
            if (strstr($site_name, ',')) {
                $site_name = '"' . $site_name . '"';
                // Protect the name with quotations if it contains a comma
            }
            $site_name = '=?UTF-8?B?' . base64_encode($site_name) . '?=';
            // Encode the name. If may content nos ASCII chars.
            $site_from = $site_name . " <" . $sendmail_from . ">";
        }
    }
    $sendmail_options = html_email_handler_get_sendmail_options();
    // set default options
    $default_options = array("to" => array(), "from" => $site_from, "subject" => "", "html_message" => "", "plaintext_message" => "", "cc" => array(), "bcc" => array(), "date" => null);
    // merge options
    $options = array_merge($default_options, $options);
    // check options
    if (!empty($options["to"]) && !is_array($options["to"])) {
        $options["to"] = array($options["to"]);
    }
    if (!empty($options["cc"]) && !is_array($options["cc"])) {
        $options["cc"] = array($options["cc"]);
    }
    if (!empty($options["bcc"]) && !is_array($options["bcc"])) {
        $options["bcc"] = array($options["bcc"]);
    }
    // can we send a message
    if (!empty($options["to"]) && (!empty($options["html_message"]) || !empty($options["plaintext_message"]))) {
        // start preparing
        $boundary = uniqid($site->name);
        // start building headers
        $headers = "";
        if (!empty($options["from"])) {
            $headers .= "From: " . $options["from"] . PHP_EOL;
        } else {
            $headers .= "From: " . $site_from . PHP_EOL;
        }
        // check CC mail
        if (!empty($options["cc"])) {
            $headers .= "Cc: " . implode(", ", $options["cc"]) . PHP_EOL;
        }
        // check BCC mail
        if (!empty($options["bcc"])) {
            $headers .= "Bcc: " . implode(", ", $options["bcc"]) . PHP_EOL;
        }
        // add a date header
        if (!empty($options["date"])) {
            $headers .= "Date: " . date("r", $options["date"]) . PHP_EOL;
        }
        $headers .= "X-Mailer: PHP/" . phpversion() . PHP_EOL;
        $headers .= "MIME-Version: 1.0" . PHP_EOL;
        $headers .= "Content-Type: multipart/alternative; boundary=\"" . $boundary . "\"" . PHP_EOL . PHP_EOL;
        // start building the message
        $message = "";
        // TEXT part of message
        if (!empty($options["plaintext_message"])) {
            $message .= "--" . $boundary . PHP_EOL;
            $message .= "Content-Type: text/plain; charset=\"utf-8\"" . PHP_EOL;
            $message .= "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL;
            $message .= chunk_split(base64_encode($options["plaintext_message"])) . PHP_EOL . PHP_EOL;
        }
        // HTML part of message
        if (!empty($options["html_message"])) {
            $message .= "--" . $boundary . PHP_EOL;
            $message .= "Content-Type: text/html; charset=\"utf-8\"" . PHP_EOL;
            $message .= "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL;
            $message .= chunk_split(base64_encode($options["html_message"])) . PHP_EOL;
        }
        // Final boundry
        $message .= "--" . $boundary . "--" . PHP_EOL;
        // convert to to correct format
        $to = implode(", ", $options["to"]);
        $result = mail($to, $options["subject"], $message, $headers, $sendmail_options);
    }
    return $result;
}
Ejemplo n.º 12
0
/**
 * Get the user attributes for the provided IDendtity Provider (IDP) configuration.
 *
 * These attributes will be send to an external Service Provider.
 *
 * @param string $idp_auth_id the name of the IDP configuration
 *
 * @return array an array with all the configured attributes
 */
function simplesaml_get_user_attributes($idp_auth_id)
{
    $result = null;
    $user = elgg_get_logged_in_user_entity();
    if (!empty($idp_auth_id) && !empty($user)) {
        $field_configuration = elgg_get_plugin_setting("idp_" . $idp_auth_id . "_attributes", "simplesaml");
        $site = elgg_get_site_entity();
        $result = array("uid" => array($user->username . "@" . get_site_domain($site->getGUID())));
        if (!empty($field_configuration)) {
            $field_configuration = json_decode($field_configuration, true);
            foreach ($field_configuration as $profile_field => $attribute_name) {
                if (!empty($attribute_name)) {
                    $value = $user->{$profile_field};
                    if (!empty($value)) {
                        if (!is_array($value)) {
                            $value = array($value);
                        }
                        $result[$attribute_name] = $value;
                    }
                }
            }
        }
        $params = array("user" => $user, "idp_auth_id" => $idp_auth_id, "attributes" => $result);
        $result = elgg_trigger_plugin_hook("idp_attributes", "simplesaml", $params, $result);
    }
    return $result;
}
 $message = sprintf(elgg_echo('invitefriends:email'), $CONFIG->site->name, $_SESSION['user']->name, $emailmessage, $link);
 // **** this should be replaced by a core function for sending emails to people who are not members
 $site = get_entity($CONFIG->site_guid);
 // If there's an email address, use it - but only if its not from a user.
 if ($site && isset($site->email)) {
     // Has the current site got a from email address?
     $from = $site->email;
 } else {
     if (isset($from->url)) {
         // If we have a url then try and use that.
         $breakdown = parse_url($from->url);
         $from = 'noreply@' . $breakdown['host'];
         // Handle anything with a url
     } else {
         // If all else fails, use the domain of the site.
         $from = 'noreply@' . get_site_domain($CONFIG->site_guid);
     }
 }
 if (is_callable('mb_internal_encoding')) {
     mb_internal_encoding('UTF-8');
 }
 $site = get_entity($CONFIG->site_guid);
 $sitename = $site->name;
 if (is_callable('mb_encode_mimeheader')) {
     $sitename = mb_encode_mimeheader($site->name, "UTF-8", "B");
 }
 $header_eol = "\r\n";
 if (isset($CONFIG->broken_mta) && $CONFIG->broken_mta) {
     // Allow non-RFC 2822 mail headers to support some broken MTAs
     $header_eol = "\n";
 }
Ejemplo n.º 14
0
/**
 * Invite a new user by email to a group
 *
 * @param ElggGroup $group  the group to be invited for
 * @param string    $email  the email address to be invited
 * @param string    $text   (optional) extra text in the invitation
 * @param boolean   $resend should existing invitations be resend
 *
 * @return boolean|NULL true is invited, false on failure, null when already send
 */
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
    $result = false;
    $loggedin_user = elgg_get_logged_in_user_entity();
    if (!empty($group) && $group instanceof ElggGroup && !empty($email) && is_email_address($email) && !empty($loggedin_user)) {
        // generate invite code
        $invite_code = group_tools_generate_email_invite_code($group->getGUID(), $email);
        if (!empty($invite_code)) {
            $found_group = group_tools_check_group_email_invitation($invite_code, $group->getGUID());
            if (empty($found_group) || $resend) {
                // make site email
                $site = elgg_get_site_entity();
                if (!empty($site->email)) {
                    if (!empty($site->name)) {
                        $site_from = $site->name . " <" . $site->email . ">";
                    } else {
                        $site_from = $site->email;
                    }
                } else {
                    // no site email, so make one up
                    if (!empty($site->name)) {
                        $site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
                    } else {
                        $site_from = "noreply@" . get_site_domain($site->getGUID());
                    }
                }
                if (empty($found_group)) {
                    // register invite with group
                    $group->annotate("email_invitation", $invite_code . "|" . $email, ACCESS_LOGGED_IN, $group->getGUID());
                }
                // make subject
                $subject = elgg_echo("group_tools:groups:invite:email:subject", array($group->name));
                // make body
                $body = elgg_echo("group_tools:groups:invite:email:body", array($loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_get_site_url() . "register?group_invitecode=" . $invite_code, elgg_get_site_url() . "groups/invitations/?invitecode=" . $invite_code, $invite_code));
                $params = array("group" => $group, "inviter" => $loggedin_user, "invitee" => $email);
                $body = elgg_trigger_plugin_hook("invite_notification", "group_tools", $params, $body);
                $result = elgg_send_email($site_from, $email, $subject, $body);
            } else {
                $result = null;
            }
        }
    }
    return $result;
}
Ejemplo n.º 15
0
function form_send_invitations($invite_box_name, $form_data_id)
{
    global $CONFIG;
    $contacts = trim(get_input($invite_box_name . '_contacts', ''));
    if ($contacts) {
        $user_message = trim(get_input($invite_box_name . '_message', ''));
        $url = $CONFIG->wwwroot . 'mod/form/display_object.php?d=' . $form_data_id;
        $message = sprintf(elgg_echo('form:invite_message'), $_SESSION['user']->name, $url);
        if ($user_message) {
            $message .= sprintf(elgg_echo('form:user_message'), $user_message);
        }
        $user_list = array();
        $email_address_list = array();
        // handle comma separators
        $contacts2 = explode(",", $contacts);
        // handle new line separators as well
        $contact_list = array();
        foreach ($contacts2 as $contact) {
            $contact_list = array_merge($contact_list, explode("\n", $contact));
        }
        foreach ($contact_list as $contact) {
            $contact = trim($contact);
            if (strpos($contact, '@') === false) {
                $user = get_user_by_username($contact);
                if ($user && ($user_id = $user->getGUID())) {
                    $user_list[] = $user_id;
                }
            } else {
                $email_address_list[] = $contact;
            }
        }
        $subject = sprintf(elgg_echo('form:invite_subject'), $_SESSION['user']->name);
        if ($user_list) {
            $from = $_SESSION['user']->getGUID();
            //print_r($user_list);
            //print $subject;
            //print $message;
            // need to force email for now as Elgg 1 notification does not seem to work without it
            notify_user($user_list, $from, $subject, $message, null, array('email'));
        }
        if ($email_address_list) {
            $site = get_entity($CONFIG->site_guid);
            if ($site->email) {
                // this should be defined as of Elgg 1.1
                $from = $site->email;
            } else {
                $from = 'noreply@' . get_site_domain($CONFIG->site_guid);
            }
            form_send_email($email_address_list, $from, $subject, $message);
        }
    }
}
Ejemplo n.º 16
0
        continue;
    }
    if (get_user_by_email($email)) {
        $error = TRUE;
        $already_members[] = $email;
        continue;
    }
    $link = elgg_get_site_url() . 'register?friend_guid=' . $current_user->guid . '&invitecode=' . generate_invite_code($current_user->username);
    $message = elgg_echo('invitefriends:email', array($site->name, $current_user->name, $emailmessage, $link));
    $subject = elgg_echo('invitefriends:subject', array($site->name));
    // create the from address
    $site = get_entity($site->guid);
    if ($site && isset($site->email)) {
        $from = $site->email;
    } else {
        $from = 'noreply@' . get_site_domain($site->guid);
    }
    elgg_send_email($from, $email, $subject, $message);
    $sent_total++;
}
if ($error) {
    register_error(elgg_echo('invitefriends:invitations_sent', array($sent_total)));
    if (count($bad_emails) > 0) {
        register_error(elgg_echo('invitefriends:email_error', array(implode(', ', $bad_emails))));
    }
    if (count($already_members) > 0) {
        register_error(elgg_echo('invitefriends:already_members', array(implode(', ', $already_members))));
    }
} else {
    system_message(elgg_echo('invitefriends:success'));
}
/**
 * Send a notification via email.
 *
 * @param ElggEntity $from The from user/site/object
 * @param ElggUser $to To which user?
 * @param string $subject The subject of the message.
 * @param string $message The message body
 * @param array $params Optional parameters (none taken in this instance)
 * @return bool
 */
function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
{
    global $CONFIG;
    if (!$from) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));
    }
    if (!$to) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));
    }
    if ($to->email == "") {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid));
    }
    // Sanitise subject
    $subject = preg_replace("/(\r\n|\r|\n)/", " ", $subject);
    // Strip line endings
    // To
    $to = $to->email;
    // From
    $site = get_entity($CONFIG->site_guid);
    // If there's an email address, use it - but only if its not from a user.
    if (isset($from->email) && !$from instanceof ElggUser) {
        $from = $from->email;
    } else {
        if ($site && isset($site->email)) {
            // Has the current site got a from email address?
            $from = $site->email;
        } else {
            if (isset($from->url)) {
                // If we have a url then try and use that.
                $breakdown = parse_url($from->url);
                $from = 'noreply@' . $breakdown['host'];
                // Handle anything with a url
            } else {
                // If all else fails, use the domain of the site.
                $from = 'noreply@' . get_site_domain($CONFIG->site_guid);
            }
        }
    }
    if (is_callable('mb_internal_encoding')) {
        mb_internal_encoding('UTF-8');
    }
    $site = get_entity($CONFIG->site_guid);
    $sitename = $site->name;
    if (is_callable('mb_encode_mimeheader')) {
        $sitename = mb_encode_mimeheader($site->name, "UTF-8", "B");
    }
    $header_eol = "\r\n";
    if (isset($CONFIG->broken_mta) && $CONFIG->broken_mta) {
        // Allow non-RFC 2822 mail headers to support some broken MTAs
        $header_eol = "\n";
    }
    $from_email = "\"{$sitename}\" <{$from}>";
    if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
        // Windows is somewhat broken, so we use a different format from header
        $from_email = "{$from}";
    }
    $headers = "From: {$from_email}{$header_eol}" . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}" . "MIME-Version: 1.0{$header_eol}" . "Content-Transfer-Encoding: 8bit{$header_eol}";
    if (is_callable('mb_encode_mimeheader')) {
        $subject = mb_encode_mimeheader($subject, "UTF-8", "B");
    }
    // Format message
    $message = html_entity_decode($message, ENT_COMPAT, 'UTF-8');
    // Decode any html entities
    $message = strip_tags($message);
    // Strip tags from message
    $message = preg_replace("/(\r\n|\r)/", "\n", $message);
    // Convert to unix line endings in body
    $message = preg_replace("/^From/", ">From", $message);
    // Change lines starting with From to >From
    return mail($to, $subject, wordwrap($message), $headers);
}
function facebookservice_api()
{
    global $CONFIG;
    // Get site domain name as it is required for Facebook class
    $site_domain = get_site_domain($CONFIG->site_guid);
    elgg_load_library('facebook');
    return new Facebook(array('appId' => elgg_get_plugin_setting('consumer_key', 'facebook_connect'), 'secret' => elgg_get_plugin_setting('consumer_secret', 'facebook_connect'), 'cookie' => true, 'domain' => $site_domain));
}
Ejemplo n.º 19
0
/**
 *
 * This function build an RFC822 compliant address
 *
 * This function requires the option 'entity'
 *
 * @param ElggEntity $entity entity to use as the basis for the address
 *
 * @return string with the correctly formatted address
 */
function html_email_handler_make_rfc822_address(ElggEntity $entity)
{
    // get the email address of the entity
    $email = $entity->email;
    if (empty($email)) {
        // no email found, fallback to site email
        $site = elgg_get_site_entity();
        $email = $site->email;
        if (empty($email)) {
            // no site email, default to noreply
            $email = "noreply@" . get_site_domain($site->getGUID());
        }
    }
    // build the RFC822 format
    if (!empty($entity->name)) {
        $name = $entity->name;
        if (strstr($name, ',')) {
            $name = '"' . $name . '"';
            // Protect the name with quotations if it contains a comma
        }
        $name = '=?UTF-8?B?' . base64_encode($name) . '?=';
        // Encode the name. If may content nos ASCII chars.
        $email = $name . " <" . $email . ">";
    }
    return $email;
}
Ejemplo n.º 20
0
/**
 * Get the user attributes for the provided IDendtity Provider (IDP) configuration.
 *
 * These attributes will be send to an external Service Provider.
 *
 * @param string $idp_auth_id the name of the IDP configuration
 *
 * @return void|array
 */
function simplesaml_get_user_attributes($idp_auth_id)
{
    $user = elgg_get_logged_in_user_entity();
    if (empty($idp_auth_id) || empty($user)) {
        return;
    }
    $site = elgg_get_site_entity();
    $result = ['uid' => [$user->username . '@' . get_site_domain($site->getGUID())]];
    $field_configuration = elgg_get_plugin_setting("idp_{$idp_auth_id}_attributes", 'simplesaml');
    if (!empty($field_configuration)) {
        $field_configuration = json_decode($field_configuration, true);
        foreach ($field_configuration as $profile_field => $attribute_name) {
            if (empty($attribute_name)) {
                continue;
            }
            $value = $user->{$profile_field};
            if (empty($value)) {
                continue;
            }
            if (!is_array($value)) {
                $value = [$value];
            }
            $result[$attribute_name] = $value;
        }
    }
    $params = ['user' => $user, 'idp_auth_id' => $idp_auth_id, 'attributes' => $result];
    return elgg_trigger_plugin_hook('idp_attributes', 'simplesaml', $params, $result);
}
Ejemplo n.º 21
0
            foreach ($collections as $collection) {
                delete_access_collection($collection->id);
            }
        }
        // remove from access collections
        $access = get_access_array();
        foreach ($access as $id) {
            if (!in_array($id, array(ACCESS_PUBLIC, ACCESS_LOGGED_IN, ACCESS_FRIENDS, ACCESS_PRIVATE))) {
                remove_user_from_access_collection($user->guid, $id);
            }
        }
        // reset password to unusable password
        $user->password = '';
        $user->salt = '';
        $user->password_hash = '';
        $user->email = "anon{$user->guid}@" . get_site_domain();
        // set our single piece of metadata that tells us this user has been deleted
        $user->member_selfdelete = "anonymized";
        $user->save();
        logout();
        session_regenerate_id(true);
        system_message(elgg_echo('member_selfdelete:action:anonymized'));
        break;
    default:
        // default is to delete the user
        $user->delete();
        session_regenerate_id(true);
        system_message(elgg_echo('member_selfdelete:deleted'));
        break;
}
elgg_clear_sticky_form('member_selfdelete');
Ejemplo n.º 22
0
function the_site_domain()
{
    echo get_site_domain();
}
Ejemplo n.º 23
0
function get_uinvite_url($user_id)
{
    global $indexFile;
    return get_site_domain() . $indexFile . '?tg=invite&uid=' . $user_id;
}
Ejemplo n.º 24
0
/**
 * Retrieve the workflow access collection controlling access
 * of the workflow entities.
 * 
 * @param int $group_id the group id of the workflow
 *
 * @return int $ac_id the access id
 */
function questions_get_site_email()
{
    $site = elgg_get_site_entity();
    if (!empty($site->email)) {
        if (!empty($site->name)) {
            $site_from = $site->name . " <" . $site->email . ">";
        } else {
            $site_from = $site->email;
        }
    } else {
        // no site email, so make one up
        if (!empty($site->name)) {
            $site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
        } else {
            $site_from = "noreply@" . get_site_domain($site->getGUID());
        }
    }
    return $site_from;
}
Ejemplo n.º 25
0
function subsite_manager_subsite_invite_email($email, $message = "")
{
    $result = false;
    if (subsite_manager_on_subsite() && !empty($email) && ($user = elgg_get_logged_in_user_entity()) && $user->isAdmin()) {
        $site = elgg_get_site_entity();
        $parent_site = $site->getOwnerEntity();
        $registration_link = $site->url . "register";
        if (get_config("disable_registration") === true) {
            $registration_link = $parent_site->url . "register";
        }
        // make mail
        $subject = elgg_echo("subsite_manager:subsite_admin:invite:new_user:subject", array($site->name));
        $body = elgg_echo("subsite_manager:subsite_admin:invite:new_user:message", array($user->name, $site->name, $parent_site->name, $message, $registration_link));
        // make site email
        if (!empty($site->email)) {
            if (!empty($site->name)) {
                $site_from = $site->name . " <" . $site->email . ">";
            } else {
                $site_from = $site->email;
            }
        } else {
            // no site email, so make one up
            if (!empty($site->name)) {
                $site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
            } else {
                $site_from = "noreply@" . get_site_domain($site->getGUID());
            }
        }
        $result = elgg_send_email($site_from, $email, $subject, $body);
    }
    return $result;
}
Ejemplo n.º 26
0
 public function notifyOnRsvp($type, $to = null)
 {
     $ia = elgg_set_ignore_access(true);
     if ($to == null) {
         $to = elgg_get_logged_in_user_guid();
     }
     if ($to_entity = get_entity($to)) {
         // can we make nice links in the emails
         $html_email_handler_enabled = elgg_is_active_plugin("html_email_handler");
         // do we have a registration link
         if ($type == EVENT_MANAGER_RELATION_ATTENDING) {
             if ($this->registration_needed) {
                 $link = elgg_get_site_url() . 'events/registration/view/?guid=' . $this->getGUID() . '&u_g=' . $to . '&k=' . md5($this->time_created . get_site_secret() . $to);
                 $registrationLink = PHP_EOL . PHP_EOL;
                 $registrationLink .= elgg_echo('event_manager:event:registration:notification:program:linktext');
                 $registrationLink .= PHP_EOL . PHP_EOL;
                 if ($html_email_handler_enabled) {
                     $registrationLink .= elgg_view("output/url", array("text" => $link, "href" => $link));
                 } else {
                     $registrationLink .= $link;
                 }
             }
         }
         // make the event title for in the e-mail
         if ($html_email_handler_enabled) {
             $event_title_link = elgg_view("output/url", array("text" => $this->title, "href" => $this->getURL()));
         } else {
             $event_title_link = $this->title;
         }
         // notify the onwer of the event
         $owner_subject = elgg_echo('event_manager:event:registration:notification:owner:subject');
         $owner_message = elgg_echo('event_manager:event:registration:notification:owner:text:' . $type, array($this->getOwnerEntity()->name, $to_entity->name, $event_title_link));
         $owner_message .= $registrationLink;
         notify_user($this->getOwnerGUID(), $this->getGUID(), $owner_subject, $owner_message);
         // notify the attending user
         $user_subject = elgg_echo('event_manager:event:registration:notification:user:subject');
         $user_message = elgg_echo('event_manager:event:registration:notification:user:text:' . $type, array($to_entity->name, $event_title_link));
         $user_message .= $registrationLink;
         if ($to_entity instanceof ElggUser) {
             // use notification system for real users
             notify_user($to, $this->getGUID(), $user_subject, $user_message);
         } else {
             // send e-mail for non users
             $to_email = $to_entity->name . "<" . $to_entity->email . ">";
             $site = elgg_get_site_entity($this->site_guid);
             if ($site->email) {
                 if ($site->name) {
                     $site_from = $site->name . " <" . $site->email . ">";
                 } else {
                     $site_from = $site->email;
                 }
             } else {
                 // no site email, so make one up
                 if ($site->name) {
                     $site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
                 } else {
                     $site_from = "noreply@" . get_site_domain($site->getGUID());
                 }
             }
             elgg_send_email($site_from, $to_email, $user_subject, $user_message);
         }
     }
     elgg_set_ignore_access($ia);
 }
/**
 * Send a notification via email.
 *
 * @param ElggEntity $from    The from user/site/object
 * @param ElggUser   $to      To which user?
 * @param string     $subject The subject of the message.
 * @param string     $message The message body
 * @param array      $params  Optional parameters (none taken in this instance)
 *
 * @return bool
 * @access private
 */
function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
{
    global $CONFIG;
    if (!$from) {
        $msg = elgg_echo('NotificationException:MissingParameter', array('from'));
        throw new NotificationException($msg);
    }
    if (!$to) {
        $msg = elgg_echo('NotificationException:MissingParameter', array('to'));
        throw new NotificationException($msg);
    }
    if ($to->email == "") {
        $msg = elgg_echo('NotificationException:NoEmailAddress', array($to->guid));
        throw new NotificationException($msg);
    }
    // To
    $to = $to->email;
    // From
    $site = get_entity($CONFIG->site_guid);
    // If there's an email address, use it - but only if its not from a user.
    if (!$from instanceof ElggUser && $from->email) {
        $from = $from->email;
    } else {
        if ($site && $site->email) {
            // Use email address of current site if we cannot use sender's email
            $from = $site->email;
        } else {
            // If all else fails, use the domain of the site.
            $from = 'noreply@' . get_site_domain($CONFIG->site_guid);
        }
    }
    return elgg_send_email($from, $to, $subject, $message);
}
Ejemplo n.º 28
0
     $lan = get_config("language", $CONFIG->site_guid);
     set_config("language", $lan, $site->getGUID());
     // set default access
     set_config("default_access", $site->getACL(), $site->getGUID());
     // default allow registration
     set_config("allow_registration", true, $site->getGUID());
     // enable simple cache
     datalist_set("simplecache_enabled_" . $site->getGUID(), 1);
     // enable file path cache
     datalist_set("viewpath_cache_enabled_" . $site->getGUID(), 1);
 }
 if (!empty($site)) {
     // Default site attributes
     $site->name = $name;
     $site->description = $description;
     $site->email = "noreply@" . get_site_domain($site->getGUID());
     $site->url = $url;
     // site category
     $site->category = $category;
     // Site icon
     if (get_resized_image_from_uploaded_file("icon", 16, 16)) {
         // prepare image sizes
         $topbar = get_resized_image_from_uploaded_file("icon", 16, 16, true);
         $tiny = get_resized_image_from_uploaded_file("icon", 25, 25, true);
         $small = get_resized_image_from_uploaded_file("icon", 40, 40, true);
         $medium = get_resized_image_from_uploaded_file("icon", 100, 100, true);
         $large = get_resized_image_from_uploaded_file("icon", 200, 200);
         $master = get_resized_image_from_uploaded_file("icon", 500, 500);
         // Add images to Subsite
         $site->uploadIcon("topbar", $topbar);
         $site->uploadIcon("favicon", $topbar);
Ejemplo n.º 29
0
echo $ah_langpackage->ah_homepage;
?>
</a>
	    <a href="index.php?tg=search_pals_list&online=1"><?php 
echo $ah_langpackage->ah_see_who_online;
?>
</a>
	    <a href="help/help.html">帮助</a>
		</span>
	  <span class="right">
		  <a href="javascript:addBookMark();"><?php 
echo $pu_langpackage->pu_collection;
?>
</a>
		  <a href="javascript:setMyHomepage('<?php 
echo get_site_domain();
?>
');"><?php 
echo $pu_langpackage->pu_index_set;
?>
</a>
		  <a href="modules.php?app=user_reg"><?php 
echo $pu_langpackage->pu_register;
?>
</a>
		  <a href="index.php"><?php 
echo $pu_langpackage->pu_logon;
?>
</a>
	  </span>
	</div>
Ejemplo n.º 30
0
function zhgroups_send_email($from_name, $to_email, $subject, $message, $end = '')
{
    $site = elgg_get_site_entity();
    if ($site->email) {
        $site_from = $from_name . " <" . $site->email . ">";
    } else {
        // no site email, so make one up
        $site_from = $from_name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
    }
    if (empty($end)) {
        $body = zhaohuEmailHead() . $message . zhaohuEmailEnd();
    } else {
        $body = zhaohuEmailHead() . $message . $end;
    }
    return elgg_send_email($site_from, $to_email, $subject, $body);
}