YammerImportPlugin.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2010, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * @package YammerImportPlugin
  21. * @maintainer Brion Vibber <brion@status.net>
  22. */
  23. if (!defined('STATUSNET')) { exit(1); }
  24. class YammerImportPlugin extends Plugin
  25. {
  26. /**
  27. * Hook for RouterInitialized event.
  28. *
  29. * @param URLMapper $m path-to-action mapper
  30. * @return boolean hook return
  31. */
  32. public function onRouterInitialized(URLMapper $m)
  33. {
  34. $m->connect('panel/yammer',
  35. array('action' => 'yammeradminpanel'));
  36. $m->connect('panel/yammer/auth',
  37. array('action' => 'yammerauth'));
  38. return true;
  39. }
  40. /**
  41. * Set up queue handlers for import processing
  42. * @param QueueManager $qm
  43. * @return boolean hook return
  44. */
  45. function onEndInitializeQueueManager(QueueManager $qm)
  46. {
  47. $qm->connect('yammer', 'YammerQueueHandler');
  48. return true;
  49. }
  50. /**
  51. * Set up all our tables...
  52. */
  53. function onCheckSchema()
  54. {
  55. $schema = Schema::get();
  56. $tables = array('Yammer_state',
  57. 'Yammer_user',
  58. 'Yammer_group',
  59. 'Yammer_notice',
  60. 'Yammer_notice_stub');
  61. foreach ($tables as $table) {
  62. $schemaDef = call_user_func(array($table, 'schemaDef'));
  63. $schema->ensureTable(strtolower($table), $schemaDef);
  64. }
  65. return true;
  66. }
  67. /**
  68. * If the plugin's installed, this should be accessible to admins.
  69. */
  70. function onAdminPanelCheck($name, &$isOK)
  71. {
  72. if ($name == 'yammer') {
  73. $isOK = true;
  74. return false;
  75. }
  76. return true;
  77. }
  78. /**
  79. * Add the Yammer admin panel to the list...
  80. */
  81. function onEndAdminPanelNav($nav)
  82. {
  83. if (AdminPanelAction::canAdmin('yammer')) {
  84. $action_name = $nav->action->trimmed('action');
  85. $nav->out->menuItem(common_local_url('yammeradminpanel'),
  86. // TRANS: Menu item for Yammer import.
  87. _m('MENU','Yammer'),
  88. // TRANS: Menu item title for Yammer import.
  89. _m('Yammer import module.'),
  90. $action_name == 'yammeradminpanel',
  91. 'nav_yammer_admin_panel');
  92. }
  93. return true;
  94. }
  95. }