Index: branches/5.3.x/core/install/upgrades.php =================================================================== diff -u -N -r15584 -r15677 --- branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15584) +++ branches/5.3.x/core/install/upgrades.php (.../upgrades.php) (revision 15677) @@ -1,6 +1,6 @@ Array ('from' => 'Category', 'to' => 'Categories'), 'cf' => Array ('from' => 'CustomField', 'to' => 'CustomFields'), 'draft' => Array ('from' => 'Drafts', 'to' => 'FormSubmissionReplyDrafts'), - 'emailevents' => Array ('from' => 'Events', 'to' => 'EmailEvents'), + 'email-template' => Array ('from' => 'Events', 'to' => 'EmailEvents'), 'fav' => Array ('from' => 'Favorites', 'to' => 'UserFavorites'), 'img' => Array ('from' => 'Images', 'to' => 'CatalogImages'), '#file' => Array ('from' => 'ItemFiles', 'to' => 'CatalogFiles'), @@ -164,9 +164,9 @@ if ($mode == 'after') { // 1. get event ids based on their name and type combination $event_names = Array ( - 'USER.PSWD_' . EmailEvent::EVENT_TYPE_ADMIN, - 'USER.PSWD_' . EmailEvent::EVENT_TYPE_FRONTEND, - 'USER.PSWDC_' . EmailEvent::EVENT_TYPE_FRONTEND, + 'USER.PSWD_' . EmailTemplate::TEMPLATE_TYPE_ADMIN, + 'USER.PSWD_' . EmailTemplate::TEMPLATE_TYPE_FRONTEND, + 'USER.PSWDC_' . EmailTemplate::TEMPLATE_TYPE_FRONTEND, ); $event_sql = Array (); @@ -1212,7 +1212,7 @@ // partially delete events $sql = 'SELECT EventId FROM ' . TABLE_PREFIX . 'Events - WHERE (Event IN ("CATEGORY.APPROVE", "CATEGORY.DENY")) AND (Type = ' . EmailEvent::EVENT_TYPE_ADMIN . ')'; + WHERE (Event IN ("CATEGORY.APPROVE", "CATEGORY.DENY")) AND (Type = ' . EmailTemplate::TEMPLATE_TYPE_ADMIN . ')'; $event_ids = $this->Conn->GetCol($sql); if ($event_ids) { @@ -1485,12 +1485,12 @@ /* @var $ml_helper kMultiLanguageHelper */ $ml_helper->createFields('phrases'); - $ml_helper->createFields('emailevents'); + $ml_helper->createFields('email-template'); $languages = $ml_helper->getLanguages(); if ($this->Conn->TableFound(TABLE_PREFIX . 'EmailMessage', true)) { - $email_message_helper = $this->Application->recallObject('kEmailMessageHelper'); - /* @var $email_message_helper kEmailMessageHelper */ + $email_template_helper = $this->Application->recallObject('kEmailTemplateHelper'); + /* @var $email_template_helper kEmailTemplateHelper */ foreach ($languages as $language_id) { $sql = 'SELECT EmailMessageId, Template, EventId @@ -1499,7 +1499,7 @@ $translations = $this->Conn->Query($sql, 'EventId'); foreach ($translations as $event_id => $translation_data) { - $parsed = $email_message_helper->parseTemplate($translation_data['Template'], 'html'); + $parsed = $email_template_helper->parseTemplate($translation_data['Template'], 'html'); $fields_hash = Array ( 'l' . $language_id . '_Subject' => $parsed['Subject'], @@ -1702,22 +1702,22 @@ continue; } - if ($event_data['Type'] == EmailEvent::EVENT_TYPE_FRONTEND) { + if ($event_data['Type'] == EmailTemplate::TEMPLATE_TYPE_FRONTEND) { // from user $fields_hash = Array ( 'CustomSender' => 1, - 'SenderAddressType' => EmailEvent::ADDRESS_TYPE_USER, + 'SenderAddressType' => EmailTemplate::ADDRESS_TYPE_USER, 'SenderAddress' => $username ); } - if ($event_data['Type'] == EmailEvent::EVENT_TYPE_ADMIN) { + if ($event_data['Type'] == EmailTemplate::TEMPLATE_TYPE_ADMIN) { // to user $records = Array ( Array ( - 'RecipientType' => EmailEvent::RECIPIENT_TYPE_TO, + 'RecipientType' => EmailTemplate::RECIPIENT_TYPE_TO, 'RecipientName' => '', - 'RecipientAddressType' => EmailEvent::ADDRESS_TYPE_USER, + 'RecipientAddressType' => EmailTemplate::ADDRESS_TYPE_USER, 'RecipientAddress' => $username ) ); @@ -2054,8 +2054,8 @@ */ private function _splitEmailBody() { - $id_field = $this->Application->getUnitOption('emailevents', 'IDField'); - $table_name = $this->Application->getUnitOption('emailevents', 'TableName'); + $id_field = $this->Application->getUnitOption('email-template', 'IDField'); + $table_name = $this->Application->getUnitOption('email-template', 'TableName'); $fields = $this->Conn->Query('DESCRIBE ' . $table_name, 'Field'); if ( !isset($fields['l1_Body']) ) { @@ -2067,7 +2067,7 @@ /* @var $ml_helper kMultiLanguageHelper */ $languages = $ml_helper->getLanguages(); - $ml_helper->createFields('emailevents'); + $ml_helper->createFields('email-template'); $sql = 'SELECT * FROM ' . $table_name; @@ -2111,7 +2111,7 @@ $languages = $ml_helper->getLanguages(); - $event_table = $this->Application->getUnitOption('emailevents', 'TableName'); + $event_table = $this->Application->getUnitOption('email-template', 'TableName'); $sql = 'SELECT * FROM ' . $event_table . ' @@ -2189,7 +2189,7 @@ // fix e-mail event translations $languages = $ml_helper->getLanguages(); - $table_name = $this->Application->getUnitOption('emailevents', 'TableName'); + $table_name = $this->Application->getUnitOption('email-template', 'TableName'); $change_fields = Array ('Subject', 'HtmlBody', 'PlainTextBody'); @@ -2206,7 +2206,7 @@ // add new ml columns to phrases/e-mail events $ml_helper->createFields('phrases'); - $ml_helper->createFields('emailevents'); + $ml_helper->createFields('email-template'); } /** @@ -2297,6 +2297,49 @@ } /** + * Update to 5.2.1-B1 + * + * @param string $mode when called mode {before, after) + */ + public function Upgrade_5_2_1_B1($mode) + { + if ( $mode != 'after' ) { + return; + } + + $this->_updateUserPasswords(); + } + + protected function _updateUserPasswords() + { + $user_table = $this->Application->getUnitOption('u', 'TableName'); + + $sql = 'SELECT Password, PortalUserId + FROM ' . $user_table . ' + WHERE PasswordHashingMethod = ' . PasswordHashingMethod::MD5; + $user_passwords = $this->Conn->GetColIterator($sql, 'PortalUserId'); + + if ( !count($user_passwords) ) { + // no users at all or existing users have converted passwords already + return; + } + + kUtil::setResourceLimit(); + + $password_formatter = $this->Application->recallObject('kPasswordFormatter'); + /* @var $password_formatter kPasswordFormatter */ + + foreach ($user_passwords as $user_id => $user_password) { + $fields_hash = Array ( + 'Password' => $password_formatter->hashPassword($user_password, '', PasswordHashingMethod::MD5_AND_PHPPASS), + 'PasswordHashingMethod' => PasswordHashingMethod::MD5_AND_PHPPASS, + ); + + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Users', 'PortalUserId = ' . $user_id); + } + } + + /** * Update to 5.3.0-B1 * * @param string $mode when called mode {before, after)