~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to mod/data/field/menu/field.class.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php // $Id: field.class.php,v 1.11 2006/12/13 20:26:12 skodak Exp $
 
1
<?php // $Id: field.class.php,v 1.12.2.1 2008/04/19 21:20:56 skodak Exp $
2
2
///////////////////////////////////////////////////////////////////////////
3
3
//                                                                       //
4
4
// NOTICE OF COPYRIGHT                                                   //
56
56
 
57
57
        return $str;
58
58
    }
 
59
    
 
60
    function display_search_field($content = '') {
 
61
        global $CFG;
 
62
 
 
63
        $usedoptions = array();
 
64
        $sql = "SELECT DISTINCT content
 
65
                  FROM {$CFG->prefix}data_content
 
66
                 WHERE fieldid={$this->field->id} AND content IS NOT NULL";
 
67
        if ($used = get_records_sql($sql)) {
 
68
            foreach ($used as $data) {
 
69
                $value = $data->content;
 
70
                if ($value === '') {
 
71
                    continue;
 
72
                }
 
73
                $usedoptions[$value] = $value;
 
74
            }
 
75
        }
 
76
 
 
77
        $options = array();
 
78
        foreach (explode("\n",$this->field->param1) as $option) {
 
79
            $option = trim($option);
 
80
            if (!isset($usedoptions[$option])) {
 
81
                continue;
 
82
            }
 
83
            $options[$option] = $option;
 
84
        }
 
85
        if (!$options) {
 
86
            // oh, nothing to search for
 
87
            return '';
 
88
        }
 
89
 
 
90
        return choose_from_menu($options, 'f_'.$this->field->id, stripslashes($content), '&nbsp;', '', 0, true);    
 
91
    }
 
92
 
 
93
     function parse_search_field() {
 
94
            return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
 
95
     }
 
96
 
 
97
    function generate_sql($tablealias, $value) {
 
98
        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') "; 
 
99
    }
59
100
 
60
101
}
61
102