Пример #1
0
 /**
  * NEVER CHANGE THIS METHOD SIGNATURE, USER BY THIRD PARTY PLUGINS.
  *
  * Saves a new user on the database. Return false if the email (that must be unique) is already
  * there. For a new users set the token and creation time if not passed.
  *
  * @param array|object $user
  */
 function save_user($user, $return_format = OBJECT)
 {
     if (is_object($user)) {
         $user = (array) $user;
     }
     if (empty($user['id'])) {
         $existing = $this->get_user($user['email']);
         if ($existing != null) {
             return false;
         }
         if (empty($user['token'])) {
             $user['token'] = NewsletterModule::get_token();
         }
         //if (empty($user['created'])) $user['created'] = time();
         // Database default
         //if (empty($user['status'])) $user['status'] = 'S';
     }
     // Due to the unique index on email field, this can fail.
     return $this->store->save(NEWSLETTER_USERS_TABLE, $user, $return_format);
 }