You are here

function _user_expire_save in User Expire 7

Same name and namespace in other branches
  1. 8 user_expire.module \_user_expire_save()

Save expiration date from user edit form.

Parameters

object $account: A user object to modify.

2 calls to _user_expire_save()
user_expire_user_insert in ./user_expire.module
Implements hook_user_insert().
user_expire_user_update in ./user_expire.module
Implements hook_user_update().

File

./user_expire.module, line 164
Main module file for User expire module.

Code

function _user_expire_save($account) {
  if (isset($account->user_expiration) && $account->user_expiration) {
    if (is_array($account->user_expiration_date) && isset($account->user_expiration_date['month'])) {
      $time_for_datetime = $account->user_expiration_date['year'] . '-' . $account->user_expiration_date['month'] . '-' . $account->user_expiration_date['day'];
    }
    else {
      $time_for_datetime = $account->user_expiration_date;
    }
    $new_date = new DateTime($time_for_datetime, new DateTimeZone(date_default_timezone_get()));
    $timestamp = $new_date
      ->getTimestamp();
    user_expire_set_expiration($account, $timestamp);
  }
  else {
    user_expire_set_expiration($account);
  }
}