/**
 * Get alert metrics results for the named alert types(s) for the data from the given url
 * @param $url the url for the data to process
 * @param $alerttypes one or more alert types to get the metrics for (comma sparated list).
 * @param $timeout (optional) the length of time the metrics server should cache the data for in seconds. Default to 60
 * @param $userids (optional) one or more userid of the users to get alerts for (comma sparated list)
 * @param $root (optional) the post id of the map tree to process within the given data
 * @return false, if the call failed, else the response data from the call (will be a json string).
 */
function getAlertMetrics($url, $cipher, $alerttypes, $timeout = 60, $userids = "", $root = "")
{
    global $CFG;
    $requests = createAlertMetricRequestPostField($alerttypes, $cipher, $userids, $root);
    $results = callAnalyticsAPIWithURL('POST', $requests, $url, $timeout);
    if (!$results) {
        $message = "Metrics server unreachable for: " . $url;
        sendMailMessage("Alert Metrics down on " . $CFG->SITE_TITLE, $CFG->ERROR_ALERT_RECIPIENT, $message);
    }
    return $results;
}
     if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
         if (strlen($specifiedpassword) < 6) {
             webAlertAndQuit("Password is too short!");
         } else {
             $newpassword = $specifiedpassword;
         }
     } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
         webAlertAndQuit("You didn't specify a password for this user!");
     } elseif ($passwordgenmethod == 'g') {
         $newpassword = generate_password(8);
     } else {
         webAlertAndQuit("No password generation method specified!");
     }
 }
 if ($passwordnotifymethod == 'e') {
     sendMailMessage($email, $newusername, $newpassword, $fullname);
 }
 // check if the username already exist
 $rs = $modx->db->select('count(id)', $tbl_manager_users, "username='******' AND id!='{$id}'");
 $limit = $modx->db->getValue($rs);
 if ($limit > 0) {
     webAlertAndQuit("User name is already in use!");
 }
 // check if the email address already exists
 $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
 $limit = $modx->db->getValue($rs);
 if ($limit > 0) {
     webAlertAndQuit("Email is already in use!");
 }
 // invoke OnBeforeUserFormSave event
 $modx->invokeEvent("OnBeforeUserFormSave", array("mode" => "upd", "id" => $id));