diff --git a/composer.json b/composer.json index cc4d5bf..150678d 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "alfnru/password_recovery", "type": "roundcube-plugin", "description": "Plugin that adds functionality so that a user can create a new password if the original is lost.", - "version": "1.1", + "version": "1.2", "license": "GPL-3.0-or-later", "homepage": "https://github.com/AlfnRU/roundcube-password_recovery/", "authors": [ diff --git a/password_recovery.php b/password_recovery.php index 4d334c1..0355c17 100644 --- a/password_recovery.php +++ b/password_recovery.php @@ -58,12 +58,21 @@ class password_recovery extends rcube_plugin { $this->use_password = ($this->rc->config->get('pr_use_password_plugin') && $this->rc->plugins->load_plugin('password', true)); - foreach($this->fields as $field => $field_name){ + $new_fields = [ + 'email_other' => ['type' => 'VARCHAR(255)', 'default' => ''], + 'phone' => ['type' => 'VARCHAR(30)' , 'default' => ''], + 'question' => ['type' => 'VARCHAR(255)', 'default' => ''], + 'answer' => ['type' => 'VARCHAR(255)', 'default' => ''], + 'token' => ['type' => 'VARCHAR(255)', 'default' => ''], + 'token_validity' => ['type' => 'DATETIME' , 'default' => '2000-01-01 00:00:00'] + ]; + + foreach($new_fields as $field_name => $field_props){ $query = "SELECT " . $field_name . " FROM " . $this->rc->config->get('pr_users_table'); $result = $this->db->query($query); if (!$result) { $type = ($field == 'phone' ? 'VARCHAR(30)' : 'VARCHAR(255)'); - $query = "ALTER TABLE " . $this->rc->config->get('pr_users_table') . " ADD " . $field_name . " " . $type . " CHARACTER SET utf8 NOT NULL"; + $query = "ALTER TABLE " . $this->rc->config->get('pr_users_table') . " ADD " . $field_name . " " . $field_props['type'] . " DEFAULT " . $field_props['default'] . " CHARACTER SET utf8 NOT NULL"; $result = $this->db->query($query); } }