Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Contains class profilefield_social\networks
  19   *
  20   * @package    profilefield_social
  21   * @copyright  2020 Bas Brands
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace profilefield_social;
  26  
  27  /**
  28   * helper class for social profile fields.
  29   *
  30   * @copyright  2020 Bas Brands <bas@moodle.com>
  31   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  32   */
  33  class helper  {
  34  
  35      /**
  36       * Get the available social networks
  37       *
  38       * @return array list of social networks.
  39       */
  40      public static function get_networks(): array {
  41          return [
  42              'icq' => get_string('icqnumber', 'profilefield_social'),
  43              'msn' => get_string('msnid', 'profilefield_social'),
  44              'aim' => get_string('aimid', 'profilefield_social'),
  45              'yahoo' => get_string('yahooid', 'profilefield_social'),
  46              'skype' => get_string('skypeid', 'profilefield_social'),
  47              'url' => get_string('webpage', 'profilefield_social'),
  48          ];
  49      }
  50  
  51      /**
  52       * Get the translated fieldname string for a network.
  53       *
  54       * @param string $fieldname Network short name.
  55       * @return string network name.
  56       */
  57      public static function get_fieldname(string $fieldname): string {
  58          $networks = self::get_networks();
  59          return $networks[$fieldname];
  60      }
  61  
  62      /**
  63       * Get the available network url formats.
  64       *
  65       * @return array list network url strings.
  66       */
  67      public static function get_network_urls(): array {
  68          return [
  69              'skype' => '<a href="skype:%%ENCODED%%?call">%%PLAIN%%</a>',
  70              'icq' => '<a href="http://www.icq.com/whitepages/cmd.php?uin=%%ENCODED%%&action=message">%%PLAIN%%</a>',
  71              'url' => '<a href="%%PLAIN%%">%%PLAIN%%</a>'
  72          ];
  73      }
  74  }