Advertisement
globiws

restart all syncs

Mar 27th, 2024
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. // restart all syncs
  2.  
  3. $org = 12345                          // insert your ORG ID
  4. global $conn = "connection-name"      // insert your mysql connection name as per the integrations page
  5.  
  6. global $refreshed = 0
  7.  
  8. doOrg($org)
  9. print "Refreshed "+$refreshed+" syncs"
  10. end
  11.  
  12. function doOrg($org) {
  13.     $spaces = podio_org_get_spaces($org)
  14.     foreach ( $spaces as $space ) {
  15.         if ( $space.type == "emp_network" ) continue
  16.         ini_set("max_execution_time", 30)
  17.         doSpace($space)
  18.     }
  19. }
  20.  
  21. function doSpace($space) {
  22.     print "Space: "+$space.space_id+": "+$space.name
  23.     $apps = podio_space_get_apps($space.space_id)
  24.     foreach ( $apps as $app ) {
  25.         ini_set("max_execution_time", 30)
  26.         checkApp($app)
  27.     }
  28. }
  29.  
  30. function checkApp($app) {
  31.     $appid = $app.app_id
  32.     $sync = pf_sync_get_for_app("p", $appid)
  33.     if ( $sync == false ) {
  34.         return
  35.     }
  36.     print "Restart sync "+$sync.sync_id+" for app "+$appid+": "+$app.config.name
  37.     $refreshed = $refreshed + 1
  38.     pf_sync_restart($sync.sync_id)
  39. }
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement