Exemple #1
0
    /**
     * Submit profile field for validation
     */
    public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
    {
        $sql_where = '';
        switch ($mode) {
            case 'register':
                // If the field is required we show it on the registration page
                $sql_where .= ' AND f.field_show_on_reg = 1';
                break;
            case 'profile':
                // Show hidden fields to moderators/admins
                if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) {
                    $sql_where .= ' AND f.field_show_profile = 1';
                }
                break;
            default:
                trigger_error('Wrong profile mode specified', E_USER_ERROR);
                break;
        }
        $sql = 'SELECT l.*, f.*
			FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
			WHERE l.lang_id = ' . (int) $lang_id . "\n\t\t\t\tAND f.field_active = 1\n\t\t\t\t{$sql_where}\n\t\t\t\tAND l.field_id = f.field_id\n\t\t\tORDER BY f.field_order";
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $profile_field = $this->type_collection[$row['field_type']];
            $cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);
            $check_value = $cp_data['pf_' . $row['field_ident']];
            if (($cp_result = $profile_field->validate_profile_field($check_value, $row)) !== false) {
                // If the result is not false, it's an error message
                $cp_error[] = $cp_result;
            }
        }
        $this->db->sql_freeresult($result);
    }