kannelsms_plugin.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /* For licensing terms, see /vendor/license.txt */
  3. /**
  4. * Class KannelsmsPlugin
  5. * This script contains SMS type constants and basic plugin functions.
  6. *
  7. * @package chamilo.plugin.kannelsms.lib
  8. *
  9. * @author Imanol Losada <imanol.losada@beeznest.com>
  10. * @author Julio Montoya Refactor code
  11. */
  12. class KannelsmsPlugin extends SmsPlugin
  13. {
  14. /**
  15. * Constructor.
  16. */
  17. public function __construct()
  18. {
  19. $fields = [
  20. 'tool_enable' => 'boolean',
  21. 'hostAddress' => 'text',
  22. 'username' => 'text',
  23. 'password' => 'text',
  24. 'from' => 'text',
  25. ];
  26. $smsTypeOptions = $this->getSmsTypeOptions();
  27. foreach ($smsTypeOptions as $smsTypeOption) {
  28. $fields[$smsTypeOption] = 'checkbox';
  29. }
  30. parent::__construct('0.1', 'Imanol Losada', $fields);
  31. }
  32. /**
  33. * create (a singleton function that ensures KannelsmsPlugin instance is
  34. * created only once. If it is already created, it returns the instance).
  35. *
  36. * @return object KannelsmsPlugin instance
  37. */
  38. public static function create()
  39. {
  40. static $result = null;
  41. return $result ? $result : $result = new self();
  42. }
  43. /**
  44. * install (uninstalls the plugin and removes all plugin's tables and/or rows).
  45. */
  46. public function uninstall()
  47. {
  48. $tSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  49. $sql = "DELETE FROM $tSettings WHERE subkey = 'kannelsms'";
  50. Database::query($sql);
  51. }
  52. }