Ejemplo n.º 1
0
function send_error_email($userid, $emailaddress, $sendEmail, $errors, $Build, $Project, $prefix = 'none')
{
    include 'config/config.php';
    $emailtext = array();
    $emailtext['nerror'] = 0;
    if ($userid != 0) {
        // For registered users, tune the error array based on user preferences
        // to make sure he doesn't get emails that are unwanted/unnecessary
        $UserProject = new UserProject();
        $UserProject->UserId = $userid;
        $UserProject->ProjectId = $Project->Id;
        $useremailcategory = $UserProject->GetEmailCategory();
    }
    // Check if an email has been sent already for this user
    foreach ($errors as $errorkey => $nerrors) {
        if ($nerrors == 0 || $errorkey == 'errors') {
            continue;
        }
        $stop = false;
        if ($userid != 0) {
            // If the user doesn't want to get the email
            switch ($errorkey) {
                case 'update_errors':
                    if (!check_email_category('update', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
                case 'configure_errors':
                    if (!check_email_category('configure', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
                case 'build_errors':
                    if (!check_email_category('error', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
                case 'build_warnings':
                    if (!check_email_category('warning', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
                case 'test_errors':
                    if (!check_email_category('test', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
                case 'dynamicanalysis_errors':
                    if (!check_email_category('dynamicanalysis', $useremailcategory)) {
                        $stop = true;
                    }
                    break;
            }
        } else {
            // For committers, only send emails when the errorkey starts with the
            // prefix associated with the current handler calling us.
            // (So stop if the errorkey does not begin with the prefix...)
            // This minimizes sending out possibly near-duplicate emails to the
            // same committers...
            //
            if (0 !== strpos($errorkey, $prefix)) {
                $stop = true;
            }
        }
        if ($stop) {
            continue;
        }
        if (0 == $userid || !check_email_sent($userid, $Build->Id, $errorkey)) {
            $emailtext['summary'][$errorkey] = get_email_summary($Build->Id, $errors, $errorkey, $Project->EmailMaxItems, $Project->EmailMaxChars, $Project->TestTimeMaxStatus, $Project->EmailTestTimingChanged);
            $emailtext['category'][$errorkey] = $nerrors;
            $emailtext['nerror'] = 1;
        }
    }
    // Send the email
    if ($emailtext['nerror'] == 1) {
        if ($userid != 0) {
            send_email_to_user($userid, $emailtext, $Build, $Project);
            if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
                $sendEmail->UserId = $userid;
                $sendEmail->Text = $emailtext;
                $sendEmail->SendToUser();
            }
        } else {
            send_email_to_address($emailaddress, $emailtext, $Build, $Project);
            //
            // Do we still need a "$sendEmail->" call here even if
            // there is no UserId...?
            //
        }
    }
}
Ejemplo n.º 2
0
 }
 // Check if the user is not already in the database
 $user2project = pdo_query("SELECT role,emailtype,emailcategory,emailmissingsites,emailsuccess\n                             FROM user2project WHERE userid='{$userid}' AND projectid='{$projectid}'");
 if (pdo_num_rows($user2project) > 0) {
     $user2project_array = pdo_fetch_array($user2project);
     $xml .= add_XML_value("role", $user2project_array["role"]);
     $xml .= add_XML_value("emailtype", $user2project_array["emailtype"]);
     $xml .= add_XML_value("emailmissingsites", $user2project_array["emailmissingsites"]);
     $xml .= add_XML_value("emailsuccess", $user2project_array["emailsuccess"]);
     $emailcategory = $user2project_array["emailcategory"];
     $xml .= add_XML_value("emailcategory_update", check_email_category("update", $emailcategory));
     $xml .= add_XML_value("emailcategory_configure", check_email_category("configure", $emailcategory));
     $xml .= add_XML_value("emailcategory_warning", check_email_category("warning", $emailcategory));
     $xml .= add_XML_value("emailcategory_error", check_email_category("error", $emailcategory));
     $xml .= add_XML_value("emailcategory_test", check_email_category("test", $emailcategory));
     $xml .= add_XML_value("emailcategory_dynamicanalysis", check_email_category("dynamicanalysis", $emailcategory));
 } else {
     $xml .= add_XML_value("emailcategory_update", 1);
     $xml .= add_XML_value("emailcategory_configure", 1);
     $xml .= add_XML_value("emailcategory_warning", 1);
     $xml .= add_XML_value("emailcategory_error", 1);
     $xml .= add_XML_value("emailcategory_test", 1);
     $xml .= add_XML_value("emailcategory_dynamicanalysis", 1);
 }
 // If we ask to subscribe
 @($Subscribe = $_POST["subscribe"]);
 @($UpdateSubscription = $_POST["updatesubscription"]);
 @($Unsubscribe = $_POST["unsubscribe"]);
 @($Role = $_POST["role"]);
 @($Credentials = $_POST["credentials"]);
 @($EmailType = $_POST["emailtype"]);
Ejemplo n.º 3
0
 }
 // Check if the user is not already in the database
 $user2project = pdo_query("SELECT role,emailtype,emailcategory,emailmissingsites,emailsuccess\n                             FROM user2project WHERE userid='{$userid}' AND projectid='{$projectid}'");
 if (pdo_num_rows($user2project) > 0) {
     $user2project_array = pdo_fetch_array($user2project);
     $xml .= add_XML_value('role', $user2project_array['role']);
     $xml .= add_XML_value('emailtype', $user2project_array['emailtype']);
     $xml .= add_XML_value('emailmissingsites', $user2project_array['emailmissingsites']);
     $xml .= add_XML_value('emailsuccess', $user2project_array['emailsuccess']);
     $emailcategory = $user2project_array['emailcategory'];
     $xml .= add_XML_value('emailcategory_update', check_email_category('update', $emailcategory));
     $xml .= add_XML_value('emailcategory_configure', check_email_category('configure', $emailcategory));
     $xml .= add_XML_value('emailcategory_warning', check_email_category('warning', $emailcategory));
     $xml .= add_XML_value('emailcategory_error', check_email_category('error', $emailcategory));
     $xml .= add_XML_value('emailcategory_test', check_email_category('test', $emailcategory));
     $xml .= add_XML_value('emailcategory_dynamicanalysis', check_email_category('dynamicanalysis', $emailcategory));
 } else {
     // we set the default categories
     $xml .= add_XML_value('emailcategory_update', 1);
     $xml .= add_XML_value('emailcategory_configure', 1);
     $xml .= add_XML_value('emailcategory_warning', 1);
     $xml .= add_XML_value('emailcategory_error', 1);
     $xml .= add_XML_value('emailcategory_test', 1);
     $xml .= add_XML_value('emailcategory_dynamicanalysis', 1);
 }
 // If we ask to subscribe
 @($Subscribe = $_POST['subscribe']);
 @($UpdateSubscription = $_POST['updatesubscription']);
 @($Unsubscribe = $_POST['unsubscribe']);
 @($Role = $_POST['role']);
 @($Credentials = $_POST['credentials']);