clockworksms_plugin.class.php 1.4 KB

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