Browse Source

added the cron tie in

Shawna Spoor 6 years ago
parent
commit
c7823d7093
2 changed files with 18 additions and 3 deletions
  1. 5 2
      tripal/includes/tripal.registration.inc
  2. 13 1
      tripal/tripal.module

+ 5 - 2
tripal/includes/tripal.registration.inc

@@ -265,6 +265,8 @@ function tripal_registration_form_submit($form, &$form_state) {
     
   //Now send the updated info to the Tripal Site.
   tripal_registration_remote_submit($registration);
+
+  drupal_set_message(t('Thank you for registering. You can update your details at any time.'), 'status');
 }
 
 function tripal_registration_remote_submit($data) {
@@ -327,7 +329,8 @@ function tripal_registration_remote_submit($data) {
     'headers' => array('Content-Type' => 'application/json', 'Accept' => 'application/json'),
     'data' => json_encode($outgoing_data),
   ));
-  dpm($result);
-  drupal_set_message(t('Thank you for registering. You can update your details at any time.'), 'status');
 
+  variable_set('tripal_site_registration_last_update', time());
+  
+  return $result;
 }

+ 13 - 1
tripal/tripal.module

@@ -28,6 +28,7 @@ tripal_import_api();
 require_once "includes/tripal.field_storage.inc";
 require_once "includes/tripal.fields.inc";
 require_once "includes/tripal.entity.inc";
+require_once "includes/tripal.registration.inc";
 
 require_once "includes/TripalVocab.inc";
 require_once "includes/TripalVocabController.inc";
@@ -1359,7 +1360,7 @@ function tripal_cron() {
     $modules = module_implements('tripal_cron_notification');
     foreach ($modules as $module) {
       $function = $module . '_tripal_cron_notification';
-      tripal_add_job("Cron: Checking for '$module' notifications.", 'tripal',                                         // Module Name
+      tripal_add_job("Cron: Checking for '$module' notifications.", 'tripal',
         $function, $args, 1, 1, $includes, TRUE);
     }
   }
@@ -1371,6 +1372,17 @@ function tripal_cron() {
   tripal_add_job('Cron: Checking expired files', 'tripal',
     'tripal_expire_files', $args, 1, 1, $includes, TRUE);
 
+  // Update the registration information every month.  
+  if (variable_get('tripal_site_registration', FALSE)) {
+    $last_submit = variable_get('tripal_site_registration_last_update');
+    if ($last_submit) {
+      if ($last_submit <= strtotime('-1 month')) {
+        $registration = variable_get('tripal_site_registration', FALSE);
+        $success = tripal_registration_remote_submit($registration);
+        watchdog('Tripal Cron', 'Tripal registration has been successfull submitted to the remote service.', [], WATCHDOG_INFO);
+      }
+    }
+  }
 }
 
 /**