Ejemplo n.º 1
0
 /**
  * Magic getter to get parameter values
  */
 public function __get($name)
 {
     if (strncmp($name, 'param_', 6) == 0) {
         $paramname = substr($name, 6);
         $params = unserialize($this->params);
         return $params[$paramname];
     }
     if ($name == 'owners') {
         if (!$this->_owners) {
             $this->_owners = field_owner::get_for_field($this);
         }
         return $this->_owners;
     }
     return parent::__get($name);
 }
 /**
  * Return a boolean to indicate whether or not this filter is displayed
  * depending upon whether any custom fields are found for this user
  * @param string       $field_type  type of custom field to check
  * @return boolean  true if the filter is to show
  */
 function check_for_custom_fields($field_type)
 {
     // Get custom course fields by context level
     $context = context_level_base::get_custom_context_level($field_type, 'block_curr_admin');
     $fields = field::get_for_context_level($context);
     $fields = $fields ? $fields : array();
     $testfields = array();
     foreach ($fields as $field) {
         //make sure the current user can access this field in at least one
         //course context
         $owners = field_owner::get_for_field($field);
         if (!block_php_report_field_accessible($owners)) {
             continue;
         }
         return true;
     }
     return false;
 }
    $fieldnamelist = @unserialize(base64_decode($fieldnamelist));
}
$categories = field_category::get_for_context_level($context);
$categories = $categories ? $categories : array();
// divide the fields into categories
$fieldsbycategory = array();
foreach ($categories as $category) {
    $fieldsbycategory[$category->name] = array();
}
foreach ($fields as $field) {
    if (is_array($fieldidlist) && in_array($field->id, $fieldidlist)) {
        continue;
    }
    //make sure the current user can access this field in at least one
    //course context
    $owners = field_owner::get_for_field($field);
    if (!block_php_report_field_accessible($owners)) {
        continue;
    }
    $fieldsbycategory[$field->categoryname][] = $field;
}
print_header($site->shortname . ': ' . get_string('selectcustomfields', $lang_file));
// show list of available fields
if (empty($fieldsbycategory)) {
    echo '<div>' . get_string('nofieldsfound', $lang_file) . '</div>';
} else {
    echo '<div>' . get_string('customfields', $lang_file) . '</div>';
    $table = null;
    $columns = array('category' => get_string('category', $lang_file), 'name' => get_string('name', $lang_file));
    foreach ($columns as $column => $cdesc) {
        ${$column} = $cdesc;
Ejemplo n.º 4
0
 function __isset($name)
 {
     if (strncmp($name, 'param_', 6) == 0) {
         $paramname = substr($name, 6);
         $params = unserialize($this->params);
         return isset($params[$paramname]);
     } elseif ($name == 'owners') {
         $this->owners = field_owner::get_for_field($this);
         return $this->owners;
     } else {
         return false;
     }
 }