Exemple #1
0
 $pid = $row[0];
 // Find the address which would be selected as "AX mail"
 // But don't update anything
 $best_mail = Address::updateBestMail($pid, true);
 if (is_null($best_mail)) {
     continue;
 }
 // Just continue if the returned address is already selected
 $flags = new PlFlagSet($best_mail['flags']);
 if ($flags->hasFlag('dn_best_mail')) {
     continue;
 }
 // The current profile is buggy.
 // Let's fetch more data to print detailed information
 $profile = Profile::get($pid);
 $addresses = ProfileField::getForPID('ProfileAddresses', array($pid), $admin_visibility);
 $addresses = $addresses->get(Profile::ADDRESS_POSTAL);
 $old_mail = null;
 $new_mail = null;
 foreach ($addresses as $addr) {
     if ($addr->flags->hasFlag('dn_best_mail')) {
         $old_mail = $addr;
     } else {
         if ($addr->id == $best_mail['id']) {
             $new_mail = $addr;
         }
     }
 }
 echo "Profile " . $profile->hrid() . " ({$pid}) has a wrongly selected best mail.\n";
 if (is_null($old_mail)) {
     echo "... no currently selected best mail\n";
Exemple #2
0
 /** If not already done, fetches data for the given field
  * @param $field One of the Profile::FETCH_*
  * @return A ProfileField, or null
  */
 private function getProfileField($field)
 {
     if (!array_key_exists($field, ProfileField::$fields)) {
         Platal::page()->kill("Invalid field: {$field}");
     }
     if ($this->fetched($field)) {
         return null;
     } else {
         $this->fetched_fields = $this->fetched_fields | $field;
     }
     $cls = ProfileField::$fields[$field];
     return ProfileField::getForPID($cls, $this->id(), $this->visibility);
 }