예제 #1
0
    if (empty($recipient_User)) {
        // Send mail to visitor
        // Get a message text from template file
        $message = mail_template('contact_message_new', 'text', $email_template_params);
        $success_message = send_mail($recipient_address, $recipient_name, $subject, $message, NULL, NULL, array('Reply-To' => $sender_address));
    } else {
        // Send mail to registered user
        $success_message = send_mail_to_User($recipient_User->ID, $subject, 'contact_message_new', $email_template_params, false, array('Reply-To' => $sender_address));
    }
    // restore the locale to the blog visitor language, before we would display an error message
    locale_restore_previous();
    if ($success_message) {
        // Email has been sent successfully
        if (!is_logged_in()) {
            // We should save a counter (only for anonymous users)
            antispam_increase_counter('contact_email');
        }
    } else {
        // Could not send email
        if ($demo_mode) {
            $Messages->add('Sorry, could not send email. Sending email in demo mode is disabled.', 'error');
        } else {
            $Messages->add(T_('Sorry, could not send email.') . '<br />' . T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error');
        }
    }
} else {
    // Restore the locale to the blog visitor language even in case of errors
    locale_restore_previous();
}
// Plugins should cleanup their temporary data here:
$Plugins->trigger_event('MessageFormSentCleanup', array('success_message' => $success_message));
예제 #2
0
    /**
     * Insert object into DB based on previously recorded changes
     *
     * Triggers the plugin event AfterUserInsert.
     *
     * @param boolean TRUE to automatically create new blog if group has permission
     * @return boolean true on success
     */
    function dbinsert($create_auto_blog = true)
    {
        global $Plugins, $DB;
        $DB->begin();
        if ($result = parent::dbinsert()) {
            // We could insert the user object..
            // Add new fields:
            if (!empty($this->new_fields)) {
                $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
								VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
                $DB->query($sql, 'Insert new fields');
                // Reset new fields in object:
                $this->new_fields = array();
            }
            // Notify plugins:
            // A user could be created also in another DB (to synchronize it with b2evo)
            $Plugins->trigger_event('AfterUserInsert', $params = array('User' => &$this));
            $Group =& $this->get_Group();
            if ($create_auto_blog && $Group->check_perm('perm_getblog', 'allowed')) {
                // automatically create new blog for this user
                // TODO: sam2kb> Create a blog only when this user is validated!
                $new_Blog = new Blog(NULL);
                $shortname = $this->get('login');
                $new_Blog->set('owner_user_ID', $this->ID);
                $new_Blog->set('shortname', $shortname);
                $new_Blog->set('name', $shortname . '\'s blog');
                $new_Blog->set('locale', $this->get('locale'));
                $new_Blog->set('urlname', urltitle_validate($shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get('locale')));
                // Defines blog settings by its kind.
                $Plugins->trigger_event('InitCollectionKinds', array('Blog' => &$new_Blog, 'kind' => 'std'));
                $new_Blog->create();
            }
            // Save IP Range and user counter
            antispam_increase_counter('user');
        }
        $DB->commit();
        return $result;
    }