plugin-functions.php 1.1 KB

123456789101112131415161718192021222324252627
  1. <?php
  2. function installPlugin($plugin)
  3. {
  4. //$array['data']['action']
  5. /*
  6. *
  7. * if (downloadFileToPath($from, $to, $path)) {
  8. writeLog('success', 'Update Function - Downloaded Update File for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
  9. return true;
  10. } else {
  11. writeLog('error', 'Update Function - Downloaded Update File Failed for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
  12. return false;
  13. }
  14. */
  15. foreach ($plugin['data']['plugin']['downloadList'] as $k => $v) {
  16. $file = array(
  17. 'from' => $v['githubPath'],
  18. 'to' => str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['root'] . $v['path'] . $v['fileName']),
  19. 'path' => str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['root'] . $v['path'])
  20. );
  21. if (!downloadFileToPath($file['from'], $file['to'], $file['path'])) {
  22. writeLog('error', 'Update Function - Downloaded File Failed for: ' . $v['githubPath'], $GLOBALS['organizrUser']['username']);
  23. return false;
  24. }
  25. }
  26. return true;
  27. }