Ejemplo n.º 1
0
/**
 * Returns a input field from the passed data, used by Users::search()
 */
function getUserdataSearch($row)
{
    switch ($row['fieldType']) {
        case USERDATA_TYPE_IMAGE:
            $result = '<td colspan="2"><input name="userdata_' . $row['fieldId'] . '" id="userdata_' . $row['fieldId'] . '" type="checkbox" value="1" class="checkbox"/>';
            $result .= ' <label for="userdata_' . $row['fieldId'] . '">' . t('Has image') . '</label></td>';
            break;
        case USERDATA_TYPE_LOCATION_SWE:
            $result = '<td>' . ZipLocation::regionSelect() . '</td>';
            $result .= '<td><div id="ajax_cities"></div></td>';
            break;
        case USERDATA_TYPE_BIRTHDATE:
        case USERDATA_TYPE_BIRTHDATE_SWE:
            $result = '<td>' . t('Age') . ':</td>';
            $result .= '<td><select name="userdata_' . $row['fieldId'] . '">';
            $result .= '<option value="0">' . t('Select age') . '</option>';
            $low_age = 18;
            $hi_age = 65;
            $inc = 6;
            $date = new DateTime();
            $date->modify('-' . $low_age . ' years');
            $from = $date->format('Y-m-d');
            $result .= '<option value="' . $from . '_">' . t('Below ' . $low_age) . '</option>';
            for ($i = $low_age; $i <= $hi_age; $i += $inc) {
                $date = new DateTime();
                $date->modify('-' . $i . ' years');
                $date->modify('-1 days');
                $to = $date->format('Y-m-d');
                $date->modify('-' . $inc . ' years');
                $date->modify('+1 days');
                $from = $date->format('Y-m-d');
                $result .= '<option value="' . $from . '_' . $to . '">' . $i . ' ' . t('to') . ' ' . ($i + ($inc - 1)) . '</option>';
            }
            $date = new DateTime();
            $date->modify('-' . ($hi_age + 1) . ' years');
            $date->modify('-1 days');
            $to = $date->format('Y-m-d');
            $result .= '<option value="_' . $to . '">' . t('Above ' . $hi_age) . '</option>';
            $result .= '</select></td>';
            break;
        default:
            $result = getUserdataInput($row);
            break;
    }
    return $result;
}