/**
  * Update the user profile.
  * 
  * @param int $user_id
  */
 public static function edit_user_profile_update($user_id)
 {
     global $wpdb;
     if (current_user_can(GROUPS_ADMINISTER_GROUPS)) {
         if (!empty($_POST['gw-ts']) && is_array($_POST['gw-ts'])) {
             foreach ($_POST['gw-ts'] as $group_id => $timestamps) {
                 foreach ($timestamps as $ts => $date) {
                     $year = !empty($date['year']) ? intval($date['year']) : null;
                     $month = !empty($date['month']) ? intval($date['month']) : 1;
                     $day = !empty($date['day']) ? intval($date['day']) : 1;
                     $hour = !empty($date['hour']) ? intval($date['hour']) : 0;
                     $minute = !empty($date['minute']) ? intval($date['minute']) : 0;
                     $second = !empty($date['second']) ? intval($date['second']) : 0;
                     if ($year !== null) {
                         $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
                         if ($ts != $timestamp) {
                             // Only allow extensions.
                             // If the time is set to a point in the past and the
                             // core groups field still has the group entry (which would
                             // need to be expected, then the eternity timestamp would
                             // be removed form the bucket but the user-group
                             // assignment would still be intact.
                             // Instead of setting the time to a point in the past,
                             // the group can simply be removed from the core
                             // groups field (by the user who is editing the profile).
                             if ($timestamp > time()) {
                                 Groups_WS_Terminator::lift_scheduled_terminations($user_id, $group_id, false);
                                 Groups_WS_Terminator::schedule_termination($timestamp, $user_id, $group_id);
                             }
                         }
                     } else {
                         if ($ts !== Groups_WS_Terminator::ETERNITY) {
                             Groups_WS_Terminator::lift_scheduled_terminations($user_id, $group_id);
                             Groups_WS_Terminator::mark_as_eternal($user_id, $group_id);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Hooked on user removed from group.
  * @param int $user_id
  * @param int $group_id
  */
 public static function groups_deleted_user_group($user_id, $group_id)
 {
     Groups_WS_Terminator::lift_scheduled_terminations($user_id, $group_id, false);
 }