Skip to content
Snippets Groups Projects
Commit f630425f authored by Prasad's avatar Prasad
Browse files

Merged migration changes

parent 2a89391c
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,55 @@
*********************************************************************************/
if(defined('VTIGER_UPGRADE')) {
global $adb;
global $adb; $db = $adb;
// Migration for - #117 - Convert lead field mapping NULL values and redundant rows
$phoneFieldId = getFieldid(getTabid('Leads'), 'phone');
$db->pquery('UPDATE vtiger_convertleadmapping SET editable=? WHERE leadfid=?', array(1, $phoneFieldId));
// Migration for #261 - vtiger_portalinfo doesn't update contact
$current_user = Users_Record_Model::getInstanceFromPreferenceFile(1);
$result = $db->pquery('SELECT workflow_id FROM com_vtiger_workflows WHERE test LIKE ? AND module_name=? AND defaultworkflow=?', array('%portal%', 'Contacts', 1));
if ($db->num_rows($result) == 1) {
$workflowId = $db->query_result($result, 0, 'workflow_id');
$workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);
$workflowModel->set('execution_condition', 3);
$conditions = array(
array(
'fieldname' => 'portal',
'operation' => 'is',
'value' => '1',
'valuetype' => 'rawtext',
'joincondition' => 'and',
'groupjoin' => 'and',
'groupid' => '0'
),
array(
'fieldname' => 'email',
'operation' => 'has changed',
'value' => '',
'valuetype' => 'rawtext',
'joincondition' => 'and',
'groupjoin' => 'and',
'groupid' => '0',
),
array(
'fieldname' => 'email',
'operation' => 'is not empty',
'value' => '',
'valuetype' => 'rawtext',
'joincondition' => '',
'groupjoin' => 'and',
'groupid' => '0'
)
);
$workflowModel->set('conditions', $conditions);
$workflowModel->set('filtersavedinnew', 6);
$workflowModel->save();
echo '<b>"#261 - vtiger_portalinfo doesnt update contact"</b> fixed';
}
$current_user = null;
}
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
ini_set('error_reporting', 6135);
ini_set('display_errors', 'On');
require_once 'include/utils/utils.php';
require_once 'includes/runtime/LanguageHandler.php';
require_once 'includes/main/WebUI.php';
global $current_user;
$current_user = Users_Record_Model::getInstanceFromPreferenceFile(1);
//migration script started
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT workflow_id FROM com_vtiger_workflows WHERE test LIKE ? AND module_name=? AND defaultworkflow=?', array('%portal%', 'Contacts', 1));
if ($db->num_rows($result) == 1) {
$workflowId = $db->query_result($result, 0, 'workflow_id');
$workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);
$workflowModel->set('execution_condition', 3);
$conditions = array(
array(
'fieldname' => 'portal',
'operation' => 'is',
'value' => '1',
'valuetype' => 'rawtext',
'joincondition' => 'and',
'groupjoin' => 'and',
'groupid' => '0'
),
array(
'fieldname' => 'email',
'operation' => 'has changed',
'value' => '',
'valuetype' => 'rawtext',
'joincondition' => 'and',
'groupjoin' => 'and',
'groupid' => '0',
),
array(
'fieldname' => 'email',
'operation' => 'is not empty',
'value' => '',
'valuetype' => 'rawtext',
'joincondition' => '',
'groupjoin' => 'and',
'groupid' => '0'
)
);
$workflowModel->set('conditions', $conditions);
$workflowModel->set('filtersavedinnew', 6);
$workflowModel->save();
echo '<b>"#261 - vtiger_portalinfo doesnt update contact"</b> fixed';
}
  • Manuel @manuelgit ·
    Contributor

    @prasad and @satish.dvnk This $conditions result in a failure at first creation of a contact because this two operations as code means needs to operate at the same time.

    So if you create a contact with portal "access on", email "is not empty" AND at the same time email "has changed" wil not send email with access to portal because it's a non sense.

    'fieldname' => 'email', 'operation' => 'has changed',

    AND

    'fieldname' => 'email', 'operation' => 'is not empty',

  • Manuel @manuelgit ·
    Contributor

    @prasad and @satish.dvnk , this merge has one bug:

    This condition should be removed because is handled in ContactsHandler.php:

    array( 'fieldname' => 'email', 'operation' => 'has changed', 'value' => '', 'valuetype' => 'rawtext', 'joincondition' => 'and', 'groupjoin' => 'and', 'groupid' => '0', ),

  • Satish @satish.dvnk ·
    Contributor

    Hi @manuelgit,

    I agree with you. But user wants to know, On which conditions workflow has triggered. Its validating twice and its not a bug.

  • Manuel @manuelgit ·
    Contributor

    @satish.dvnk well it is not a bug but is not sending email with access to portal to client. Will test on a clean system and report back

  • Manuel @manuelgit ·
    Contributor

    @satish.dvnk tested and verified that the conditions you introduced, only send email to cliente with access details if you change email address of the contact as you can see here: array( 'fieldname' => 'email', 'operation' => 'has changed', 'value' => '', 'valuetype' => 'rawtext', 'joincondition' => 'and', 'groupjoin' => 'and', 'groupid' => '0', ),

    This is not ok because you create a contact with access to portal activated and the contact never receives email. You have to change email address and rechange back to send email.

  • Satish @satish.dvnk ·
    Contributor

    Thanks @manuelgit. I will fix and update you.

  • Manuel @manuelgit ·
    Contributor

    Thanks for looking at this, and as has some relation also check: in modules/Contacts/ContactsHandler.php $isactive == 0 is not updating isactive in database vtiger_portalinfo when access to portal is disabled.

  • Satish @satish.dvnk ·
    Contributor

    Yes @manuelgit, you are right. Should remove "email has changed" condition in workflows then only it will trigger on contact creation.

  • Manuel @manuelgit ·
    Contributor

    Yes and if you want to send email if email has changed, maybe the best thing is create another workflow for that.

  • Satish @satish.dvnk ·
    Contributor

    No need of another workflow @manuelgit. This workflow is already handling about creation / updation of a Contact.

    But "email has changed" condition will be used while updating a contact. Code is already handling that.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment