Пример #1
0
 /**
  * Constructor method.
  *
  * Pulls out the options for the menu from the database and sets the the corresponding key for the data if it exists.
  *
  * @param int $fieldid
  * @param int $userid
  */
 public function __construct($fieldid = 0, $userid = 0)
 {
     // First call parent constructor.
     parent::__construct($fieldid, $userid);
     // Param 1 for menu type is the options.
     if (isset($this->field->param1)) {
         $options = explode("\n", $this->field->param1);
     } else {
         $options = array();
     }
     $this->options = array();
     if (!empty($this->field->required)) {
         $this->options[''] = get_string('choose') . '...';
     }
     foreach ($options as $key => $option) {
         $this->options[$option] = format_string($option);
         // Multilang formatting with filters.
     }
     // Set the data key.
     if ($this->data !== null) {
         $key = $this->data;
         if (isset($this->options[$key]) || ($key = array_search($key, $this->options)) !== false) {
             $this->data = $key;
             $this->datakey = $key;
         }
     }
 }
Пример #2
0
 /**
  * Accessor method: Load the field record and user data associated with the
  * object's fieldid and userid
  * @internal This method should not generally be overwritten by child classes.
  */
 public function load_data()
 {
     parent::load_data();
     if (!empty($this->field)) {
         $this->field->name = get_string('pluginname', 'profilefield_o365');
     }
 }
Пример #3
0
 /**
  * Accessor method: Load the field record and user data associated with the
  * object's fieldid and userid
  * @internal This method should not generally be overwritten by child classes.
  */
 public function load_data()
 {
     parent::load_data();
     if (!empty($this->field)) {
         $label = get_string('pluginname', 'profilefield_oidc');
         $authconfig = get_config('auth_oidc');
         if (!empty($authconfig->opname)) {
             $label = $authconfig->opname;
         }
         $this->field->name = $label;
     }
 }
Пример #4
0
 /**
  * Constructor method.
  * Pulls out the options for the checkbox from the database and sets the
  * the corresponding key for the data if it exists
  *
  * @param int $fieldid
  * @param int $userid
  */
 public function __construct($fieldid = 0, $userid = 0)
 {
     global $DB;
     // First call parent constructor.
     parent::__construct($fieldid, $userid);
     if (!empty($this->field)) {
         $datafield = $DB->get_field('user_info_data', 'data', array('userid' => $this->userid, 'fieldid' => $this->fieldid));
         if ($datafield !== false) {
             $this->data = $datafield;
         } else {
             $this->data = $this->field->defaultdata;
         }
     }
 }
Пример #5
0
 /**
  * Overwrite the base class to display the data for this field
  */
 public function display_data()
 {
     // Default formatting.
     $data = parent::display_data();
     // Are we creating a link?
     if (!empty($this->field->param4) and !empty($data)) {
         // Define the target.
         if (!empty($this->field->param5)) {
             $target = 'target="' . $this->field->param5 . '"';
         } else {
             $target = '';
         }
         // Create the link.
         $data = '<a href="' . str_replace('$$', urlencode($data), $this->field->param4) . '" ' . $target . '>' . htmlspecialchars($data) . '</a>';
     }
     return $data;
 }