clockworksms_plugin.class.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * @author Imanol Losada <imanol.losada@beeznest.com>
  9. * @author Julio Montoya - Refactor code
  10. */
  11. class ClockworksmsPlugin extends SmsPlugin
  12. {
  13. /**
  14. * create (a singleton function that ensures ClockworksmsPlugin instance is
  15. * created only once. If it is already created, it returns the instance)
  16. * @return object ClockworksmsPlugin instance
  17. */
  18. public static function create()
  19. {
  20. static $result = null;
  21. return $result ? $result : $result = new self();
  22. }
  23. /**
  24. * Constructor
  25. */
  26. public function __construct()
  27. {
  28. $fields = array('tool_enable' => 'boolean', 'api_key' => 'text');
  29. $smsTypeOptions = $this->getSmsTypeOptions();
  30. foreach ($smsTypeOptions as $smsTypeOption) {
  31. $fields[$smsTypeOption] = 'checkbox';
  32. }
  33. parent::__construct('0.1', 'Imanol Losada', $fields);
  34. }
  35. /**
  36. * install (uninstalls the plugin and removes all plugin's tables and/or rows)
  37. * @return void
  38. */
  39. public function uninstall()
  40. {
  41. $tSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  42. $sql = "DELETE FROM $tSettings WHERE subkey = 'clockworksms'";
  43. Database::query($sql);
  44. }
  45. }