- Get the email system to work for register.php
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 31 Aug 2008 15:02:53 +0000 (11:02 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 31 Aug 2008 15:02:53 +0000 (11:02 -0400)
- Fix includes/functions_datastore.php

global.php
includes/api_user.php
includes/emails.php
includes/functions_datastore.php
register.php

index eefd2ddcc33bb9d9ac55e3cdcc0a51eaa49c30ef..86677eb76557154dabdc682ecb4277d0570afce8 100755 (executable)
@@ -36,6 +36,9 @@ BSTemplate::$templatePath     = 'templates/%s.tpl';
 require_once ISSO . '/Mail.php';
 require_once 'includes/emails.php';
 
+define('MAIL_FROM_ADDRESS',    bugdar::$options['webmasteremail']);
+define('MAIL_FROM_NAME',       bugdar::$options['trackertitle']);
+
 // ###################################################################
 // global template variables
 
index a78c07e2d326ce03c58137af6d9a03892435eec7..acc45f7d1b1c441289b166d4e54b36f79dbc0259 100644 (file)
@@ -82,7 +82,7 @@ class UserAPI extends BSApi
        */
        function set_salt()
        {
-               $this->set('salt', BSFunctions::random(array(1, 15)));
+               $this->set('salt', BSFunctions::random(rand(3, 15)));
        }
        
        // ###################################################################
@@ -115,7 +115,7 @@ class UserAPI extends BSApi
        */
        function post_insert()
        {
-               $this->registry->db->query("
+               BSApp::$db->query("
                        INSERT INTO " . TABLE_PREFIX . "useremail
                                (userid, mask, relation)
                        VALUES
index e9b1fd15f1183662b97cb1ea0b7e5dcc060f7223..98743bede8fbce9563949421b6fd2b2bcaa16fd4 100644 (file)
@@ -49,7 +49,7 @@ If you have any questions, please don\'t hesitate to contact the webmaster.')
 
 You requested this lost password email at the %2$s bug tracker. To reset your password, simply click the link below (or paste it into your browser window exactly) and enter a new password.
 
-%3$s/login.php?do=recoverpw&amp;activator=%4$s
+%3$s/login.php?do=recoverpw&activator=%4$s
 
 If you did not request this, do not worry as this notice will expire in 24 hours.')
                ),
@@ -73,7 +73,7 @@ If you have any questions, please don\'t hesitate to contact the webmaster.')
 
 Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activate your account. To do this, please click this link:
 
-%3$s/register.php?do=activate&amp;userid=%4$d&amp;activator=%5$s')
+%3$s/register.php?do=activate&userid=%4$d&activator=%5$s')
                ),
                
                // bug notification
index 113c21abe835df561a1ad3ac2f0f4d1b1066a8e1..4d6a7f38808030037bb4568bf496dd14de7bd30a 100755 (executable)
@@ -24,16 +24,16 @@ function build_languages()
 {
        global $bugsys;
        
-       $languages = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "language");
+       $languages = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "language");
        foreach ($languages as $language)
        {
                $tempstore["$language[languageid]"] = $language;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing the language cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('language', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('language', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
 
        bugdar::$datastore['language'] = $tempstore;
@@ -44,16 +44,16 @@ function build_settings()
 {
        global $bugsys;
        
-       $settings = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "setting");
+       $settings = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "setting");
        foreach ($settings as $setting)
        {
                $options["$setting[varname]"] = $setting['value'];
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing the setting cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('setting', '" . $bugsys->escape(serialize($options)) . "')"
+               VALUES ('setting', '" . BSApp::$input->escape(serialize($options)) . "')"
        );
        
        bugdar::$datastore['setting'] = $options;
@@ -64,16 +64,16 @@ function build_usergroups()
 {
        global $bugsys;
        
-       $usergroups = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup");
+       $usergroups = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup");
        foreach ($usergroups as $usergroup)
        {
                $groups["$usergroup[usergroupid]"] = $usergroup;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing usergroup cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('usergroup', '" . $bugsys->escape(serialize($groups)) . "')"
+               VALUES ('usergroup', '" . BSApp::$input->escape(serialize($groups)) . "')"
        );
        
        bugdar::$datastore['usergroup'] = $groups;
@@ -84,16 +84,16 @@ function build_statuses()
 {
        global $bugsys;
        
-       $statuses = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "status ORDER BY displayorder ASC");
+       $statuses = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "status ORDER BY displayorder ASC");
        foreach ($statuses as $status)
        {
                $tempstore["$status[statusid]"] = $status;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing status cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('status', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('status', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['status'] = $tempstore;
@@ -104,16 +104,16 @@ function build_severities()
 {
        global $bugsys;
        
-       $severities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder ASC");
+       $severities = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder ASC");
        foreach ($severities as $severity)
        {
                $tempstore["$severity[severityid]"] = $severity;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing severity cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('severity', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('severity', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['severity'] = $tempstore;
@@ -124,16 +124,16 @@ function build_priorities()
 {
        global $bugsys;
        
-       $priorities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder ASC");
+       $priorities = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder ASC");
        foreach ($priorities as $priority)
        {
                $tempstore["$priority[priorityid]"] = $priority;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing priority cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('priority', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('priority', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['priority'] = $tempstore;
@@ -157,7 +157,7 @@ function build_assignedto()
        
        $ids = implode(',', $ids);
        $exprs = implode(' OR ', $exprs);
-       $users = $bugsys->db->query("
+       $users = BSApp::$db->query("
                SELECT email, displayname, userid, showemail
                FROM " . TABLE_PREFIX . "user AS user
                WHERE usergroupid IN ($ids) OR $exprs"
@@ -167,10 +167,10 @@ function build_assignedto()
                $devs["$user[userid]"] = $user;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing developer / assign to cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('assignto', '" . $bugsys->escape(serialize($devs)) . "')"
+               VALUES ('assignto', '" . BSApp::$input->escape(serialize($devs)) . "')"
        );
        
        bugdar::$datastore['assignto'] = $devs;
@@ -181,16 +181,16 @@ function build_resolutions()
 {
        global $bugsys;
        
-       $resolutions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC");
+       $resolutions = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC");
        foreach ($resolutions as $resolution)
        {
                $tempstore["$resolution[resolutionid]"] = $resolution;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing resolution cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('resolution', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('resolution', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['resolution'] = $tempstore;
@@ -201,16 +201,16 @@ function build_versions()
 {
        global $bugsys;
        
-       $versions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
+       $versions = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
        foreach ($versions as $version)
        {
                $tempstore["$version[versionid]"] = $version;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing version cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('version', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('version', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['version'] = $tempstore;
@@ -221,7 +221,7 @@ function build_products()
 {
        global $bugsys;
        
-       $products = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
+       $products = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
        foreach ($products as $product)
        {
                if ($product['parentid'])
@@ -234,12 +234,12 @@ function build_products()
                }
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing product / component cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
                VALUES
-                       ('product', '" . $bugsys->escape(serialize($tempstore['product'])) . "'),
-                       ('component', '" . $bugsys->escape(serialize($tempstore['component'])) . "')"
+                       ('product', '" . BSApp::$input->escape(serialize($tempstore['product'])) . "'),
+                       ('component', '" . BSApp::$input->escape(serialize($tempstore['component'])) . "')"
        );
        
        bugdar::$datastore['product'] = $tempstore['product'];
@@ -251,16 +251,16 @@ function build_permissions()
 {
        global $bugsys;
        
-       $permissions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "permission ORDER BY usergroupid, productid");
+       $permissions = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "permission ORDER BY usergroupid, productid");
        foreach ($permissions as $permission)
        {
                $tempstore["$permission[usergroupid]"]["$permission[productid]"] = $permission['mask'];
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing permissions cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('permission', '" . $bugsys->escape(serialize($tempstore)) . "')"
+               VALUES ('permission', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
        );
        
        bugdar::$datastore['permission'] = $tempstore;
@@ -271,16 +271,16 @@ function build_automations()
 {
        global $bugsys;
        
-       $automations = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "automation ORDER BY name ASC");
+       $automations = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "automation ORDER BY name ASC");
        foreach ($automations as $automation)
        {
                $actions["$automation[actionid]"] = $automation;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing automation cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('automation', '" . $bugsys->escape(serialize($actions)) . "')"
+               VALUES ('automation', '" . BSApp::$input->escape(serialize($actions)) . "')"
        );
        
        bugdar::$datastore['automation'] = $actions;
@@ -292,23 +292,23 @@ function build_user_help()
        global $bugsys;
        
        // custom field descriptions
-       $descriptions = $bugsys->db->query("SELECT fieldid, name, description FROM " . TABLE_PREFIX . "bugfield");
+       $descriptions = BSApp::$db->query("SELECT fieldid, name, description FROM " . TABLE_PREFIX . "bugfield");
        foreach ($descriptions as $field)
        {
                $help["field$field[fieldid]"] = array('title' => $field['name'], 'body' => $field['description']);
        }
        
        // standard help texts
-       $texts = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp");
+       $texts = BSApp::$db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp");
        foreach ($texts as $field)
        {
                $help["$field[keystring]"] = $field;
        }
        
-       $bugsys->db->query("
+       BSApp::$db->query("
                ### replacing user help cache ###
                REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
-               VALUES ('help', '" . $bugsys->escape(serialize($help)) . "')"
+               VALUES ('help', '" . BSApp::$input->escape(serialize($help)) . "')"
        );
        
        bugdar::$datastore['help'] = $help;
index ffb47909f2a33d95df9a5ab6f74ed2c6dac70dd6..4ff905dbf8fc12d1f246af1718a35dc3201bd9f1 100755 (executable)
@@ -93,11 +93,12 @@ if ($_POST['do'] == 'insert')
                        
                        $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
                        
-                       eval('$email = "' . $template->fetch(FetchEmailPath('activateaccount.xml', bugdar::$datastore['language'][$input->in['languageid']]['langcode'])) . '";');
-                       $email = $bugsys->xml->parse($email);
-                       $mail->setSubject($email['email']['subject']['value']);
-                       $mail->setBodyText($email['email']['bodyText']['value']);
-                       
+                       $email = get_email_text('activate_account');
+                       $mail = new BSMail();
+                       $mail->setSubject($email['subject']);
+                       $mail->setBodyText(sprintf($email['bodyText'], $input->in['displayname'], bugdar::$options['trackertitle'], bugdar::$options['trackerurl'], $userid, $activationid));
+                       $mail->setFromAddress(MAIL_FROM_ADDRESS);
+                       $mail->setFromName(MAIL_FROM_NAME);
                        $mail->send($input->in['email'], $input->in['displayname']);
                
                        $message->message(T('You now need to activate your account via email.'));
@@ -107,10 +108,13 @@ if ($_POST['do'] == 'insert')
                        if (bugdar::$options['sendwelcomemail'])
                        {
                                $displayName = $input->in['displayname'];
-                               eval('$email = "' . $template->fetch(FetchEmailPath('welcome.xml', bugdar::$datastore['language'][$input->in['languageid']]['langcode'])) . '";');
-                               $email = $bugsys->xml->parse($email);
-                               $mail->setSubject($email['email']['subject']['value']);
-                               $mail->setBodyText($email['email']['bodyText']['value']);
+                               
+                               $email = get_email_text('welcome');
+                               $mail = new BSMail();
+                               $mail->setSubject($email['subject']);
+                               $mail->setBodyText(sprintf($email['bodyText'], $input->in['displayname'], bugdar::$options['trackertitle']));
+                               $mail->setFromAddress(MAIL_FROM_ADDRESS);
+                               $mail->setFromName(MAIL_FROM_NAME);
                                $mail->send($input->in['email'], $input->in['displayname']);
                        }
                        
@@ -177,10 +181,13 @@ if ($_REQUEST['do'] == 'activate')
                if (bugdar::$options['sendwelcomemail'])
                {
                        $displayName = $user['displayname'];
-                       eval('$email = "' . $template->fetch(FetchEmailPath('welcome.xml', bugdar::$datastore['language'][$user['languageid']]['langcode'])) . '";');
-                       $email = $bugsys->xml->parse($email);
-                       $mail->setSubject($email['email']['subject']['value']);
-                       $mail->setBodyText($email['email']['bodyText']['value']);
+                       
+                       $email = get_email_text('welcome');
+                       $mail = new BSMail();
+                       $mail->setSubject($email['subject']);
+                       $mail->setBodyText(sprintf($email['bodyText'], $user['displayname'], bugdar::$options['trackertitle']));
+                       $mail->setFromAddress(MAIL_FROM_ADDRESS);
+                       $mail->setFromName(MAIL_FROM_NAME);
                        $mail->send($user['email'], $user['displayname']);
                }