Beispiel #1
0
 function getDotnameArray($table = "", $where = "")
 {
     $sql = "SELECT " . "  AV.av_identity, " . "  AV.av_firstname, " . "  AV.av_lastname, " . "  AV.av_von " . "FROM " . "  zzz_avatars AS AV " . "  LEFT JOIN zzz_unit_members AS UM ON AV.av_id=UM.um_avid " . "  LEFT JOIN zzz_lists AS L ON AV.av_id=L.l_parent " . "  LEFT JOIN zzz_list_members AS LM ON L.l_id=LM.lm_lid " . "WHERE " . "  (UM.um_uid='" . MYPEAR_NORDITA_EMPLOYEES . "') " . "  AND (UM.um_status REGEXP '" . MYPEAR_REGEXP_IS_EMPLOYEE_OR_VISITOR . "') " . "  AND (LM.lm_option REGEXP '" . MYPEAR_REGEXP_NORDITA_IS_HOME_INSTITUTE . "') " . "  AND ('2007-01-01'<=LM.lm_status)";
     // We are only interested in Nordita Stockholm era
     $result = $this->query($sql);
     if ($this->num_rows($result) == 0) {
         return "";
     }
     $dotname = array();
     while ($rec = $this->next_record_assoc($result)) {
         $all = array();
         $dn = functions::dotname(preg_replace("/\\s+/", " ", $rec["av_firstname"] . " " . $rec["av_von"] . " " . $rec["av_lastname"]));
         // Add basic dotname to $all:
         $all = array($dn => 1);
         // Add any username-like field to $all:
         foreach ($this->usernameFields as $field) {
             if ($field == "av_identity") {
                 // NB: not many users have the "av_identity" field set
                 $users = explode(",", $rec["av_identity"]);
                 foreach ($users as $usr) {
                     if (!empty($usr)) {
                         $all[$usr] = 1;
                     }
                 }
             } elseif (!empty($rec[$field]) && !is_numeric($rec[$field])) {
                 $all[$rec[$field]] = 1;
             }
         }
         // Add usernames with "-" replaced by ".":
         $more = array();
         foreach ($all as $d => $value) {
             if (strpos($d, "-") !== FALSE) {
                 $more[str_replace("-", ".", $d)] = 1;
             }
         }
         $all = array_merge($all, $more);
         // Add any ad-hoc modifications of dotnames to $all
         foreach ($all as $d) {
             $ddn = people::getSpecialDotname($dn);
             if (!empty($ddn)) {
                 $all[$ddn] = 1;
             }
         }
         // Assign $all to return array
         foreach ($all as $d => $value) {
             $dotname[$d] = $all;
         }
         /*
               $dotname[$dn] = $all;
         	  foreach ($this->usernameFields as $field) {
         		if ($field=="av_identity") {
         		  foreach ($users as $usr) if (!empty($usr)) $dotname[$usr] = $all;
         		} elseif (!empty($rec[$field]) && !is_numeric($rec[$field])) {
         		  $dotname[$rec[$field]] = $all;
         		}
         	  } // end foreach
         */
     }
     // end while
     return $dotname;
 }