Exemplo n.º 1
0
/**
 * Return if the email addresses are valid
 *
 * @param arr_email: list of email addresses
 * @param message (OUT): error message if an error is found
 * @param strict (IN): Parametrer for user_finder function
 *
 * @return boolean
 */
function util_validateCCList(&$arr_email, &$message, $strict = false)
{
    global $Language;
    $valid = true;
    $message = "";
    $purifier = Codendi_HTMLPurifier::instance();
    foreach ($arr_email as $key => $cc) {
        // Make sure that the address is valid
        $ref = util_user_finder($cc, $strict);
        if (empty($ref)) {
            $valid = false;
            $message .= "'" . $purifier->purify($cc) . "'<br>";
            continue;
        } else {
            $arr_email[$key] = $ref;
        }
    }
    if (!$valid) {
        $message = $Language->getText('include_utils', 'address_problem') . ":" . "<blockquote>{$message}</blockquote>" . $Language->getText('include_utils', 'email_explain');
    }
    return $valid;
}
Exemplo n.º 2
0
 function setWatchees($user_id, $watchees)
 {
     global $Language;
     //echo "setWatchees($user_id, $watchees)<br>";
     if ($watchees) {
         //echo "watchees";
         $res_watch = true;
         $arr_user_names = split('[,;]', $watchees);
         $arr_user_ids = array();
         while (list(, $user_name) = each($arr_user_names)) {
             $user_ident = util_user_finder($user_name, true);
             $res = user_get_result_set_from_unix($user_ident);
             if (!$res || db_numrows($res) <= 0) {
                 // user doesn;t exist  so abort this step and give feedback
                 $this->setError(" - " . $Language->getText('tracker_common_type', 'invalid_name', $user_name));
                 $res_watch = false;
                 continue;
             } else {
                 // store in a hash to eliminate duplicates. skip user itself
                 if (db_result($res, 0, 'user_id') != $user_id) {
                     $arr_user_ids[db_result($res, 0, 'user_id')] = 1;
                 }
             }
         }
         if ($res_watch) {
             $this->deleteWatchees($user_id);
             $arr_watchees = array_keys($arr_user_ids);
             $sql = 'INSERT INTO artifact_watcher (artifact_group_id, user_id,watchee_id) VALUES ';
             $num_watchees = count($arr_watchees);
             for ($i = 0; $i < $num_watchees; $i++) {
                 $sql .= "('" . db_ei($this->getID()) . "','" . db_ei($user_id) . "','" . db_ei($arr_watchees[$i]) . "'),";
             }
             $sql = substr($sql, 0, -1);
             // remove extra comma at the end
             //echo $sql."<br>";
             return db_query($sql);
         }
     } else {
         $this->deleteWatchees($user_id);
     }
 }