kannelsms_plugin.class.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. * @author Imanol Losada <imanol.losada@beeznest.com>
  9. * @author Julio Montoya Refactor code
  10. */
  11. class KannelsmsPlugin extends SmsPlugin
  12. {
  13. /**
  14. * create (a singleton function that ensures KannelsmsPlugin instance is
  15. * created only once. If it is already created, it returns the instance)
  16. * @return object KannelsmsPlugin 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. protected function __construct()
  27. {
  28. $fields = array(
  29. 'tool_enable' => 'boolean',
  30. 'hostAddress' => 'text',
  31. 'username' => 'text',
  32. 'password' => 'text',
  33. 'from' => 'text'
  34. );
  35. $smsTypeOptions = $this->getSmsTypeOptions();
  36. foreach ($smsTypeOptions as $smsTypeOption) {
  37. $fields[$smsTypeOption] = 'checkbox';
  38. }
  39. parent::__construct('0.1', 'Imanol Losada', $fields);
  40. }
  41. /**
  42. * install (uninstalls the plugin and removes all plugin's tables and/or rows)
  43. * @return void
  44. */
  45. public function uninstall()
  46. {
  47. $tSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  48. $sql = "DELETE FROM $tSettings WHERE subkey = 'kannelsms'";
  49. Database::query($sql);
  50. }
  51. }