function _ed_classified_get_longest_duration in Classified Ads 7.2
Same name and namespace in other branches
- 5.2 ed_classified_utils.inc \_ed_classified_get_longest_duration()
 - 5 ed_classified_utils.inc \_ed_classified_get_longest_duration()
 - 6.2 ed_classified_utils.inc \_ed_classified_get_longest_duration()
 
Find the longest duration, in days, for a given set of terms
Parameters
$terms, an array of vid/tid pairs with vid as the key: sub-arrays are allowed, for example: Array = ( [63]=>5, [10]=> Array ([0]=>234, [1]=>984) ) equivalent to: Array = ( [63]=>5, [10]=>234, [10]=>984 )
Return value
the duration, in days, of the largest duration found.
1 call to _ed_classified_get_longest_duration()
- _ed_classified_form_submit in ./
ed_classified.module  - Implementation of form submission handler
 
File
- ./
ed_classified_utils.inc, line 144  - Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…
 
Code
function _ed_classified_get_longest_duration($terms) {
  $duration = 0;
  if (!empty($terms)) {
    // Normally we expect an array of taxonomy terms
    if (is_array($terms)) {
      reset($terms);
      while (list($key, $val) = each($terms)) {
        if (is_array($val)) {
          reset($val);
          while (list($subkey, $subval) = each($val)) {
            $d = _ed_classified_get_duration(array(
              $key => $subval,
            ));
            if ($d > $duration) {
              $duration = $d;
            }
          }
        }
        else {
          $d = _ed_classified_get_duration(array(
            $key => $val,
          ));
          if ($d > $duration) {
            $duration = $d;
          }
        }
      }
    }
  }
  // If we couldn't find a duration then set to default rather than zero
  if (0 == $duration) {
    $duration = _ed_classified_get_default_ad_duration_in_seconds();
  }
  return $duration;
}