コード例 #1
0
ファイル: init.php プロジェクト: rcrrich/UpdatePackages
 function postupdate()
 {
     global $adb;
     Vtiger_Deprecated::createModuleMetaFile();
     Vtiger_Access::syncSharingAccess();
     return true;
 }
コード例 #2
0
ファイル: init.php プロジェクト: noclav/UpdatePackages
 function postupdate()
 {
     global $log, $adb;
     if ($this->filesToDeleteNew) {
         foreach ($this->filesToDeleteNew as $path) {
             $this->recurseDelete($path);
         }
     }
     $result = true;
     self::recurseCopy('cache/updates/files_new', '', true);
     $this->recurseDelete('cache/updates');
     Vtiger_Deprecated::createModuleMetaFile();
     Vtiger_Access::syncSharingAccess();
     $adb->query('SET FOREIGN_KEY_CHECKS = 1;');
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $adb->query("INSERT INTO `yetiforce_updates` (`user`, `name`, `from_version`, `to_version`, `result`) VALUES ('" . $currentUser->get('user_name') . "', '" . $this->modulenode->label . "', '" . $this->modulenode->from_version . "', '" . $this->modulenode->to_version . "','" . $result . "');", true);
     if ($result) {
         $adb->query("UPDATE vtiger_version SET current_version = '" . $this->modulenode->to_version . "';");
     }
     $dirName = 'cache/updates';
     $this->recurseDelete($dirName . '/files');
     $this->recurseDelete($dirName . '/init.php');
     $this->recurseDelete('cache/templates_c');
     header('Location: ' . vglobal('site_URL'));
     exit;
     return true;
 }
コード例 #3
0
ファイル: init.php プロジェクト: rcrrich/UpdatePackages
 function postupdate()
 {
     global $adb;
     $adb->query("UPDATE vtiger_version SET `current_version` = '" . $this->modulenode->to_version . "';");
     Vtiger_Deprecated::createModuleMetaFile();
     Vtiger_Access::syncSharingAccess();
     return true;
 }
コード例 #4
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     require_once 'include/utils/utils.php';
     global $adb;
     if ($eventType == 'module.postinstall') {
         //Add Assets Module to Customer Portal
         global $adb;
         include_once 'vtlib/Vtiger/Module.php';
         // Mark the module as Standard module
         $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
         //adds sharing accsess
         $AssetsModule = Vtiger_Module::getInstance($moduleName);
         Vtiger_Access::setDefaultSharing($AssetsModule);
         //Showing Assets module in the related modules in the More Information Tab
         $assetInstance = Vtiger_Module::getInstance($moduleName);
         $accountInstance = Vtiger_Module::getInstance('Accounts');
         $accountInstance->setRelatedlist($assetInstance, $moduleName, array('ADD'), 'get_dependents_list');
         $productInstance = Vtiger_Module::getInstance('Products');
         $productInstance->setRelatedlist($assetInstance, $moduleName, array('ADD'), 'get_dependents_list');
         $InvoiceInstance = Vtiger_Module::getInstance('Invoice');
         $InvoiceInstance->setRelatedlist($assetInstance, $moduleName, array('ADD'), 'get_dependents_list');
         $InvoiceInstance = Vtiger_Module::getInstance('Leads');
         $InvoiceInstance->setRelatedlist($assetInstance, $moduleName, array('ADD'), 'get_dependents_list');
         $result = $adb->pquery("SELECT 1 FROM vtiger_modentity_num WHERE semodule = ? AND active = 1", array($moduleName));
         if (!$adb->num_rows($result)) {
             //Initialize module sequence for the module
             $adb->pquery("INSERT INTO vtiger_modentity_num values(?,?,?,?,?,?)", array($adb->getUniqueId("vtiger_modentity_num"), $moduleName, 'UP', 1, 1, 1));
         }
     } else {
         if ($eventType == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($eventType == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($eventType == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($eventType == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($eventType == 'module.postupdate') {
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
 function applyChange()
 {
     global $adb;
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $vendorsInstance = Vtiger_Module::getInstance('Vendors');
         $blockInstance = Vtiger_Block::getInstance('LBL_VENDOR_INFORMATION', $vendorsInstance);
         $field = Vtiger_Field::getInstance('assigned_user_id', $vendorsInstance);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'assigned_user_id';
             $field->label = 'Assigned To';
             $field->table = 'vtiger_crmentity';
             $field->column = 'smownerid';
             $field->columntype = 'INT(11)';
             $field->uitype = 53;
             $field->displaytype = 1;
             $field->typeofdata = 'V~M';
             $field->presence = 2;
             $field->quickcreate = 0;
             $field->quicksequence = 5;
             $blockInstance->addField($field);
             // Allow Sharing access and role-based security for Vendors
             Vtiger_Access::deleteSharing($vendorsInstance);
             Vtiger_Access::initSharing($vendorsInstance);
             Vtiger_Access::allowSharing($vendorsInstance);
             Vtiger_Access::setDefaultSharing($vendorsInstance);
         }
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
コード例 #6
0
ファイル: makeEmailsShareable.php プロジェクト: kduqi/corebos
 function applyChange()
 {
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         $emailsInstance = Vtiger_Module::getInstance('Emails');
         // Allow Sharing access and role-based security for Vendors
         Vtiger_Access::deleteSharing($emailsInstance);
         Vtiger_Access::initSharing($emailsInstance);
         Vtiger_Access::allowSharing($emailsInstance);
         Vtiger_Access::setDefaultSharing($emailsInstance, 'private');
         Vtiger_Profile::initForModule($emailsInstance);
         // Email Reporting - set reports to public because access is private by default and configurable now
         $emrpts = "UPDATE vtiger_report SET sharingtype='Public' WHERE reportname in ('Contacts Email Report','Accounts Email Report','Leads Email Report','Vendors Email Report')";
         $this->ExecuteQuery($emrpts, array());
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
コード例 #7
0
ファイル: ModuleBasic.php プロジェクト: cin-system/cinrepo
 /**
  * Disable tools for this module
  * @param mixed String or Array with value ['Import', 'Export', 'Merge']
  */
 function disableTools($tools)
 {
     if (is_string($tools)) {
         $tools = array(0 => $tools);
     }
     foreach ($tools as $tool) {
         Vtiger_Access::updateTool($this, $tool, false);
     }
 }
コード例 #8
0
ファイル: Services.php プロジェクト: mslokhat/corebos
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     require_once 'include/utils/utils.php';
     global $adb;
     if ($eventType == 'module.postinstall') {
         require_once 'vtlib/Vtiger/Module.php';
         $moduleInstance = Vtiger_Module::getInstance($moduleName);
         $moduleInstance->allowSharing();
         $ttModuleInstance = Vtiger_Module::getInstance('HelpDesk');
         $ttModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'));
         $leadModuleInstance = Vtiger_Module::getInstance('Leads');
         $leadModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'));
         $accModuleInstance = Vtiger_Module::getInstance('Accounts');
         $accModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'));
         $conModuleInstance = Vtiger_Module::getInstance('Contacts');
         $conModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'));
         $potModuleInstance = Vtiger_Module::getInstance('Potentials');
         $potModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'));
         $pbModuleInstance = Vtiger_Module::getInstance('PriceBooks');
         $pbModuleInstance->setRelatedList($moduleInstance, 'Services', array('select'), 'get_pricebook_services');
         // Initialize module sequence for the module
         $adb->pquery("INSERT into vtiger_modentity_num values(?,?,?,?,?,?)", array($adb->getUniqueId("vtiger_modentity_num"), $moduleName, 'SER', 1, 1, 1));
         // Mark the module as Standard module
         $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
     } else {
         if ($eventType == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($eventType == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($eventType == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($eventType == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($eventType == 'module.postupdate') {
                             // TODO Handle actions after this module is updated.
                             //adds sharing accsess
                             $ServicesModule = Vtiger_Module::getInstance('Services');
                             Vtiger_Access::setDefaultSharing($ServicesModule);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
ファイル: SMSNotifierBase.php プロジェクト: kduqi/corebos
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
  */
 function vtlib_handler($modulename, $event_type)
 {
     //adds sharing accsess
     $SMSNotifierModule = Vtiger_Module::getInstance('SMSNotifier');
     Vtiger_Access::setDefaultSharing($SMSNotifierModule);
     $registerLinks = false;
     $unregisterLinks = false;
     if ($event_type == 'module.postinstall') {
         global $adb;
         $unregisterLinks = true;
         $registerLinks = true;
         // Mark the module as Standard module
         $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($modulename));
     } else {
         if ($event_type == 'module.disabled') {
             $unregisterLinks = true;
         } else {
             if ($event_type == 'module.enabled') {
                 $registerLinks = true;
             } else {
                 if ($event_type == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($event_type == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($event_type == 'module.postupdate') {
                             // TODO Handle actions after this module is updated.
                         }
                     }
                 }
             }
         }
     }
     if ($unregisterLinks) {
         $smsnotifierModuleInstance = Vtiger_Module::getInstance('SMSNotifier');
         $smsnotifierModuleInstance->deleteLink("HEADERSCRIPT", "SMSNotifierCommonJS", "modules/SMSNotifier/SMSNotifierCommon.js");
         $leadsModuleInstance = Vtiger_Module::getInstance('Leads');
         $leadsModuleInstance->deleteLink('LISTVIEWBASIC', 'Send SMS');
         $leadsModuleInstance->deleteLink('DETAILVIEWBASIC', 'Send SMS');
         $contactsModuleInstance = Vtiger_Module::getInstance('Contacts');
         $contactsModuleInstance->deleteLink('LISTVIEWBASIC', 'Send SMS');
         $contactsModuleInstance->deleteLink('DETAILVIEWBASIC', 'Send SMS');
         $accountsModuleInstance = Vtiger_Module::getInstance('Accounts');
         $accountsModuleInstance->deleteLink('LISTVIEWBASIC', 'Send SMS');
         $accountsModuleInstance->deleteLink('DETAILVIEWBASIC', 'Send SMS');
     }
     if ($registerLinks) {
         $smsnotifierModuleInstance = Vtiger_Module::getInstance('SMSNotifier');
         $smsnotifierModuleInstance->addLink("HEADERSCRIPT", "SMSNotifierCommonJS", "modules/SMSNotifier/SMSNotifierCommon.js");
         $leadsModuleInstance = Vtiger_Module::getInstance('Leads');
         $leadsModuleInstance->addLink("LISTVIEWBASIC", "Send SMS", "SMSNotifierCommon.displaySelectWizard(this, '\$MODULE\$');");
         $leadsModuleInstance->addLink("DETAILVIEWBASIC", "Send SMS", "javascript:SMSNotifierCommon.displaySelectWizard_DetailView('\$MODULE\$', '\$RECORD\$');");
         $contactsModuleInstance = Vtiger_Module::getInstance('Contacts');
         $contactsModuleInstance->addLink('LISTVIEWBASIC', 'Send SMS', "SMSNotifierCommon.displaySelectWizard(this, '\$MODULE\$');");
         $contactsModuleInstance->addLink("DETAILVIEWBASIC", "Send SMS", "javascript:SMSNotifierCommon.displaySelectWizard_DetailView('\$MODULE\$', '\$RECORD\$');");
         $accountsModuleInstance = Vtiger_Module::getInstance('Accounts');
         $accountsModuleInstance->addLink('LISTVIEWBASIC', 'Send SMS', "SMSNotifierCommon.displaySelectWizard(this, '\$MODULE\$');");
         $accountsModuleInstance->addLink("DETAILVIEWBASIC", "Send SMS", "javascript:SMSNotifierCommon.displaySelectWizard_DetailView('\$MODULE\$', '\$RECORD\$');");
     }
 }
コード例 #10
0
ファイル: Assets.php プロジェクト: mslokhat/corebos
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     require_once 'include/utils/utils.php';
     global $adb;
     if ($eventType == 'module.postinstall') {
         //Add Assets Module to Customer Portal
         global $adb;
         $this->addModuleToCustomerPortal();
         include_once 'vtlib/Vtiger/Module.php';
         // Mark the module as Standard module
         $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
         //adds sharing accsess
         $AssetsModule = Vtiger_Module::getInstance('Assets');
         Vtiger_Access::setDefaultSharing($AssetsModule);
         //Showing Assets module in the related modules in the More Information Tab
         $assetInstance = Vtiger_Module::getInstance('Assets');
         $assetLabel = 'Assets';
         $accountInstance = Vtiger_Module::getInstance('Accounts');
         $accountInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
         $productInstance = Vtiger_Module::getInstance('Products');
         $productInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
         $InvoiceInstance = Vtiger_Module::getInstance('Invoice');
         $InvoiceInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
     } else {
         if ($eventType == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($eventType == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($eventType == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($eventType == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($eventType == 'module.postupdate') {
                             $this->addModuleToCustomerPortal();
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #11
0
Migration_Index_View::ExecuteQuery('DELETE FROM vtiger_settings_field WHERE name=?', array('EMAILTEMPLATES'));
$tabIdList = array();
$tabIdList[] = getTabid('Invoice');
$tabIdList[] = getTabid('PurchaseOrder');
$query = 'SELECT fieldid FROM vtiger_field WHERE (fieldname=? or fieldname=? or fieldname=? ) AND tabid IN (' . generateQuestionMarks($tabIdList) . ')';
$result = $adb->pquery($query, array('received', 'paid', 'balance', $tabIdList));
$numrows = $adb->num_rows($result);
for ($i = 0; $i < $numrows; $i++) {
    $fieldid = $adb->query_result($result, $i, 'fieldid');
    $query = 'Update vtiger_profile2field set readonly = 0 where fieldid=?';
    Migration_Index_View::ExecuteQuery($query, array($fieldid));
}
$actions = array('Import', 'Export');
$moduleInstance = Vtiger_Module::getInstance('Calendar');
foreach ($actions as $actionName) {
    Vtiger_Access::updateTool($moduleInstance, $actionName, true, '');
}
//Update leads salutation value of none to empty value
Migration_Index_View::ExecuteQuery("UPDATE vtiger_leaddetails SET salutation='' WHERE salutation = ?", array('--None--'));
//Update contacts salutation value of none to empty value
Migration_Index_View::ExecuteQuery("UPDATE vtiger_contactdetails SET salutation='' WHERE salutation = ?", array('--None--'));
// END 2013-06-25
// Start 2013-09-24
Migration_Index_View::ExecuteQuery('UPDATE vtiger_eventhandlers SET handler_path = ? WHERE handler_class = ?', array('modules/Vtiger/handlers/RecordLabelUpdater.php', 'Vtiger_RecordLabelUpdater_Handler'));
$inventoryModules = array('Invoice', 'Quotes', 'PurchaseOrder', 'SalesOrder');
foreach ($inventoryModules as $key => $moduleName) {
    $moduleInstance = Vtiger_Module::getInstance($moduleName);
    $focus = CRMEntity::getInstance($moduleName);
    $blockInstance = Vtiger_Block::getInstance('LBL_ITEM_DETAILS', $moduleInstance);
    $field = new Vtiger_Field();
    $field->name = 'hdnS_H_Percent';
コード例 #12
0
ファイル: 530_to_540rc.php プロジェクト: mslokhat/corebos
ExecuteQuery("UPDATE vtiger_crmentity, vtiger_service SET vtiger_crmentity.smownerid = vtiger_service.handler WHERE vtiger_crmentity.crmid = vtiger_service.serviceid");
ExecuteQuery("ALTER TABLE vtiger_service DROP COLUMN handler");
ExecutePQuery("UPDATE vtiger_field SET columnname = 'smownerid', tablename = 'vtiger_crmentity', uitype = '53', typeofdata = 'V~M', info_type = 'BAS', quickcreate = 0, quickcreatesequence = 4\r\n\t\t\t\tWHERE columnname = 'handler' AND tablename = 'vtiger_service' AND tabid = ?", array($servicesTabId));
$oldServiceOwnerColumnName = 'vtiger_service:handler:assigned_user_id:Services_Owner:V';
$newServiceOwnerColumnName = 'vtiger_crmentity:smownerid:assigned_user_id:Services_Owner:V';
ExecutePQuery("UPDATE vtiger_cvcolumnlist SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName));
ExecutePQuery("UPDATE vtiger_cvadvfilter SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName));
// Allow Sharing access and role-based security for Products and Services
Vtiger_Access::deleteSharing($productInstance);
Vtiger_Access::initSharing($productInstance);
Vtiger_Access::allowSharing($productInstance);
Vtiger_Access::setDefaultSharing($productInstance);
Vtiger_Access::deleteSharing($serviceInstance);
Vtiger_Access::initSharing($serviceInstance);
Vtiger_Access::allowSharing($serviceInstance);
Vtiger_Access::setDefaultSharing($serviceInstance);
Vtiger_Module::syncfile();
/* Replace 'Handler' field with 'Assigned to' field for Products and Services - ends */
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'firstname,lastname' WHERE tabid= ? ", array($contactTab));
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'firstname,lastname' WHERE tabid= ? ", array($leadTab));
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'first_name,last_name' WHERE tabid= ? ", array($usersTab));
require_once 'include/utils/utils.php';
$usersQuery = "SELECT * FROM vtiger_users";
$usersResult = $adb->query($usersQuery);
$usersCount = $adb->num_rows($usersResult);
for ($i = 0; $i < $usersCount; ++$i) {
    $userId = $adb->query_result($usersResult, $i, 'id');
    $userName = $adb->query_result($usersResult, $i, 'user_name');
    $firstName = $adb->query_result($usersResult, $i, 'first_name');
    $lastName = $adb->query_result($usersResult, $i, 'last_name');
    $fullName = getFullNameFromQResult($usersResult, $i, 'Users');
コード例 #13
0
ファイル: Assets.php プロジェクト: hbsman/vtigercrm-5.3.0-ja
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     require_once 'include/utils/utils.php';
     global $adb;
     if ($eventType == 'module.postinstall') {
         //Add Assets Module to Customer Portal
         global $adb;
         $visible = 1;
         $query = $adb->pquery("SELECT max(sequence) AS max_tabseq FROM vtiger_customerportal_tabs", array());
         $maxtabseq = $adb->query_result($query, 0, 'max_tabseq');
         $newTabSeq = ++$maxtabseq;
         $tabid = getTabid('Assets');
         $adb->pquery("INSERT INTO vtiger_customerportal_tabs(tabid, visible, sequence) VALUES(?,?,?)", array($tabid, $visible, $newTabSeq));
         include_once 'vtlib/Vtiger/Module.php';
         // Mark the module as Standard module
         $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
         //adds sharing accsess
         $AssetsModule = Vtiger_Module::getInstance('Assets');
         Vtiger_Access::setDefaultSharing($AssetsModule);
         //Showing Assets module in the related modules in the More Information Tab
         $assetInstance = Vtiger_Module::getInstance('Assets');
         $assetLabel = 'Assets';
         $accountInstance = Vtiger_Module::getInstance('Accounts');
         $accountInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
         $productInstance = Vtiger_Module::getInstance('Products');
         $productInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
         $InvoiceInstance = Vtiger_Module::getInstance('Invoice');
         $InvoiceInstance->setRelatedlist($assetInstance, $assetLabel, array(ADD), 'get_dependents_list');
     } else {
         if ($eventType == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($eventType == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($eventType == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($eventType == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($eventType == 'module.postupdate') {
                             // TODO Handle actions after this module is updated.
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #14
0
ファイル: InitSchema.php プロジェクト: rcrrich/YetiForceCRM
 public function executeMigrationSchema($system, $userName, $source)
 {
     include_once $this->migration_schema . $system . '.php';
     $migrationObject = new $system();
     Vtiger_Access::syncSharingAccess();
     $migrationObject->preProcess($userName, $source);
     $migrationObject->process();
     $return = $migrationObject->postProcess();
     Vtiger_Access::syncSharingAccess();
     Vtiger_Deprecated::createModuleMetaFile();
     return $return;
 }
コード例 #15
0
ファイル: init.php プロジェクト: rcrrich/UpdatePackages
    function databaseData()
    {
        global $log, $adb;
        $log->debug("Entering YetiForceUpdate::databaseData() method ...");
        $adb->pquery("UPDATE `vtiger_eventhandlers` SET `event_name` = ? WHERE `event_name` = ?", ['vtiger.entity.unlink.before', 'vtiger.entity.beforeunlink']);
        $adb->pquery("UPDATE `vtiger_eventhandlers` SET `event_name` = ? WHERE `event_name` = ?", ['vtiger.entity.unlink.after', 'vtiger.entity.afterunlink']);
        $addHandler[] = ['vtiger.entity.link.after', 'modules/ModTracker/handlers/ModTrackerHandler.php', 'ModTrackerHandler', '', 1, '[]'];
        $addHandler[] = ['vtiger.entity.unlink.after', 'modules/ModTracker/handlers/ModTrackerHandler.php', 'ModTrackerHandler', '', 1, '[]'];
        $addHandler[] = ['user.logout.before', 'modules/Users/handlers/LogoutHandler.php', 'LogoutHandler', '', 1, '[]'];
        foreach ($addHandler as $handler) {
            if (!$em) {
                $em = new VTEventsManager($adb);
            }
            $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", [$handler[0], $handler[3]]);
            if ($adb->num_rows($result) == 0) {
                $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]);
            }
        }
        $updateColumList = [];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_leaddetails:email:email:Leads_Email:E', 'after' => 'vtiger_leaddetails:email:email:Leads_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_contactdetails:email:email:Contacts_Email:E', 'after' => 'vtiger_contactdetails:email:email:Contacts_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_To:I', 'after' => 'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_To:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I', 'after' => 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I', 'after' => 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:I', 'after' => 'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I', 'after' => 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_invoice:total:hdnGrandTotal:Invoice_Total:I', 'after' => 'vtiger_invoice:total:hdnGrandTotal:Invoice_Total:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_pricebook:currency_id:currency_id:PriceBooks_Currency:I', 'after' => 'vtiger_pricebook:currency_id:currency_id:PriceBooks_Currency:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I', 'after' => 'vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I', 'after' => 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I', 'after' => 'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_vendor:email:email:Vendors_Email:E', 'after' => 'vtiger_vendor:email:email:Vendors_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_faq:product_id:product_id:Faq_Product_Name:I', 'after' => 'vtiger_faq:product_id:product_id:Faq_Product_Name:V'];
        foreach ($updateColumList as $column) {
            $result = $adb->pquery("SELECT * FROM `vtiger_cvcolumnlist` WHERE columnname = ?;", [$column['before']]);
            if ($adb->num_rows($result) > 0) {
                $adb->pquery("UPDATE `vtiger_cvcolumnlist` SET `columnname` = ? WHERE `columnname` = ? ;", [$column['after'], $column['before']]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_backup_settings` WHERE `type` = ? AND `param` = ?;", ['folder', 'storage_folder']);
        if ($adb->num_rows($result) == 2) {
            $adb->pquery("UPDATE `vtiger_backup_settings` SET `param` = ? WHERE `type` = ? AND `param` = ? LIMIT 1 ;", ['backup_folder', 'folder', 'storage_folder']);
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_backup_settings` WHERE `type` = ? AND `param` = ?;", ['notifications', 'users']);
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['notifications', 'users', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['main', 'type', 'false']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'host', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'login', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'password', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'port', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'path', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'active', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'status', '']);
        }
        $sql = "SELECT tabid  FROM `vtiger_tab` WHERE `name` = 'PriceBooks';";
        $result = $adb->query($sql);
        $id = $adb->query_result($result, 0, 'actionid');
        $sql = "SELECT * FROM `vtiger_actionmapping` WHERE `actionname` IN ('Export','Import','DuplicatesHandling');";
        $result = $adb->query($sql);
        $num = $adb->num_rows($result);
        for ($k = 0; $k < $num; $k++) {
            $key = $adb->query_result_raw($result, $k, 'actionid');
            $action = $adb->query_result_raw($result, $k, 'actionname');
            $permission = 1;
            if ($action == 'DuplicatesHandling') {
                $permission = 0;
            }
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            $numP = $adb->num_rows($resultP);
            for ($i = 0; $i < $numP; $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                $resultQ = $adb->pquery("SELECT * FROM vtiger_profile2utility WHERE profileid = ? AND tabid = ? AND activityid = ?;", [$profileId, $id, $key]);
                if ($adb->num_rows($resultQ)) {
                    $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", [$profileId, $id, $key, $permission]);
                }
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_no_of_currency_decimals` WHERE `no_of_currency_decimals` = 0;");
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `vtiger_no_of_currency_decimals`(`no_of_currency_decimalsid`,`no_of_currency_decimals`,`sortorderid`,`presence`) values (0,'0',0,1)");
            $adb->query("insert  into `vtiger_no_of_currency_decimals`(`no_of_currency_decimalsid`,`no_of_currency_decimals`,`sortorderid`,`presence`) values (1,'1',1,1)");
        }
        $this->picklists();
        $adb->pquery("UPDATE `vtiger_field` SET `generatedtype` = ?, `presence` = ?, `typeofdata` = ?, `quickcreate` = ? WHERE `columnname` = ? AND `tablename` = ?;", [1, 2, 'V~M', 2, 'related_to', 'vtiger_potential']);
        $adb->pquery("UPDATE `vtiger_ossmailtemplates_type` SET `presence` = 0 WHERE `ossmailtemplates_type` IN (?,?) ;", ['PLL_RECORD', 'PLL_MAIL']);
        $adb->pquery("UPDATE `vtiger_relatedlists` SET actions = '' WHERE tabid = ? AND related_tabid = ? AND name = ?;", [getTabid('Quotes'), getTabid('Calculations'), 'get_related_list']);
        $adb->pquery("UPDATE `com_vtiger_workflow_tasktypes` SET modules = ? WHERE tasktypename = ?;", ['{"include":["Contacts","OSSEmployees","Accounts","Leads","Vendors"],"exclude":[]}', 'VTAddressBookTask']);
        $adb->pquery("UPDATE `vtiger_links` \n\t\t\tSET\n\t\t\t  linkicon = (\n\t\t\t\tCASE\n\t\t\t\t  WHEN linkicon = 'icon-file' \n\t\t\t\t  THEN 'glyphicon glyphicon-file' \n\t\t\t\t  WHEN linkicon = 'icon-align-justify' \n\t\t\t\t  THEN 'glyphicon glyphicon-align-justify'\n\t\t\t\t  WHEN linkicon = 'icon-tasks' \n\t\t\t\t  THEN 'glyphicon glyphicon-tasks'\n\t\t\t\t  WHEN linkicon = 'icon-user' \n\t\t\t\t  THEN 'glyphicon glyphicon-user'\n\t\t\t\t  ELSE linkicon \n\t\t\t\tEND\n\t\t\t  ) \n\t\t\tWHERE linkicon IN ('icon-file','icon-align-justify','icon-tasks','icon-user');");
        $result = $adb->pquery("SELECT * FROM `vtiger_osspdf` WHERE `title` = 'Calculation PDF' AND `content` = '';");
        if ($adb->num_rows($result)) {
            $adb->pquery("UPDATE `vtiger_osspdf` SET `content` = ? WHERE `title` = ?;", ['<title></title>
<table width="537px">
	<tbody>
		<tr>
			<td colspan="6" rowspan="2"><img src="#special_function#siteUrl#end_special_function#storage/Logo/logo_yetiforce.png" style="width: 200px;" width="200" /></td>
			<td colspan="4"><span style="font-size:6px;">#company_organizationname# #company_address# #company_code# #company_city#. VAT:#company_vatid#</span></td>
		</tr>
		<tr>
			<td colspan="5">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Calculation confirmation: <strong>#calculations_no#</strong></span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Date: #special_function#CreatedDateTime#end_special_function#</span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="7">&nbsp;</td>
			<td colspan="5" rowspan="2">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="5">
							<tbody>
								<tr>
									<td>
									<table cellpadding="0" style="font-size:8px;">
										<tbody>
											<tr>
												<td colspan="2">Issued by:</td>
												<td colspan="3">#Users_first_name# #Users_last_name#</td>
											</tr>
											<tr>
												<td colspan="2">Email:</td>
												<td colspan="3">#Users_email1#</td>
											</tr>
										</tbody>
									</table>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="3">
			<table>
				<tbody>
					<tr>
						<td><span style="font-size:10px;">&nbsp;<span style="font-size:8px;">#Accounts_account_no#</span></span></td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<p><span style="font-size:10px;">#Accounts_accountname#<br />
									<span style="font-size:8px;">#Accounts_addresslevel8b# #Accounts_buildingnumberb# #Accounts_localnumberb#<br />
									#Accounts_addresslevel7b#, #Accounts_addresslevel5b#<br />
									<span style="font-size:10px;">#Accounts_addresslevel1b#</span><br />
									#Accounts_vat_id#</span></span></p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
			<td colspan="3">&nbsp;</td>
		</tr>
	</tbody>
</table>
&nbsp;

<table>
	<tbody>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>#special_function#replaceProductTable#end_special_function#</td>
		</tr>
	</tbody>
</table>', 'Calculation PDF']);
            $adb->pquery("UPDATE `vtiger_osspdf` SET `footer_content` = '' WHERE `title` = ?;", ['Calculation PDF']);
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE `param` = 'create_always';");
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('conversion','create_always','false')");
        }
        $adb->pquery("UPDATE `vtiger_field` SET `fieldlabel` = ? WHERE `columnname` = ? AND `tablename` = ?;", ['Id', 'id', 'vtiger_ossmailview']);
        $adb->pquery("UPDATE `vtiger_def_org_share` SET `editstatus` = ? WHERE `ruleid` = ? AND `tabid` = ?;", [0, 5, getTabid('Calendar')]);
        $actions = [26 => 'Dashboard', 27 => 'CreateDashboardFilter', 28 => 'QuickExportToExcel'];
        foreach ($actions as $key => $action) {
            $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
            if ($adb->num_rows($result) == 0) {
                $adb->pquery("INSERT INTO `vtiger_actionmapping` (`actionid`, `actionname`, `securitycheck`) VALUES (?, ?,'0');", [$key, $action]);
            }
            $sql = "SELECT tabid, `name`  FROM `vtiger_tab` WHERE `isentitytype` = '1' AND `name` not in ('SMSNotifier','ModComments','PBXManager','Events','Emails','CallHistory','OSSMailView','');";
            $result = $adb->query($sql);
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                for ($k = 0; $k < $adb->num_rows($result); $k++) {
                    $row = $adb->query_result_rowdata($result, $k);
                    $tabid = $row['tabid'];
                    $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $key]);
                    if ($adb->num_rows($resultC) == 0) {
                        $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $key, 0));
                    }
                }
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_osspdf`");
        $pdfContent = $this->pdfContent();
        while ($row = $adb->fetch_array($result)) {
            if (array_key_exists($row['title'], $pdfContent) && strpos($row['content'], '#Contacts_lastname#') !== FALSE) {
                $adb->pquery("UPDATE `vtiger_osspdf` SET `content` = ? WHERE `title` = ? ;", [$pdfContent[$row['title']], $row['title']]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE `type` = ? AND `name` = ? ", ['colors', 'Call']);
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('colors','Call','Call','#80B584');");
        }
        $result = $adb->query('SELECT MAX(linkid) AS max_linkId FROM `vtiger_links`;');
        $maxLink = $adb->query_result_rowdata($result, 0);
        if ($maxLink[0]) {
            $maxLink = $maxLink[0];
        } else {
            $maxLink = $maxLink['max_linkId'];
        }
        $adb->pquery("UPDATE `vtiger_links_seq` SET `id` = " . $maxLink . ";");
        //sequance
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [7, getTabid('HelpDesk'), 'smownerid']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [2, getTabid('HelpDesk'), 'parent_id']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [5, getTabid('HelpDesk'), 'priority']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [4, getTabid('HelpDesk'), 'status']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [6, getTabid('HelpDesk'), 'description']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [3, getTabid('HelpDesk'), 'projectid']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['V~M', getTabid('SalesOrder'), 'recurring_frequency']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['D~M', getTabid('SalesOrder'), 'start_period']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['D~M~OTH~G~start_period~Start Period', getTabid('SalesOrder'), 'end_period']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['V~M', getTabid('SalesOrder'), 'payment_duration']);
        $adb->pquery("UPDATE `vtiger_field` SET `summaryfield` = ? WHERE `tabid` = ? AND `columnname` = ?;", [0, getTabid('OSSPasswords'), 'link_adres']);
        $adb->pquery("UPDATE `vtiger_field` SET `generatedtype` = ? WHERE `tabid` = ? AND `columnname` = ?;", [1, getTabid('Contacts'), 'smownerid']);
        $adb->pquery("UPDATE `vtiger_field` \n\t\t\t\t\tSET\tfieldlabel = (\n\t\t\t\t\t\tCASE\n\t\t\t\t\t\t  WHEN columnname = 'name' \n\t\t\t\t\t\t  THEN 'LBL_ATTACHMENT' \n\t\t\t\t\t\t  WHEN columnname = 'from_email' \n\t\t\t\t\t\t  THEN 'LBL_FROM' \n\t\t\t\t\t\t  WHEN columnname = 'to_email' \n\t\t\t\t\t\t  THEN 'LBL_TO' \n\t\t\t\t\t\t  WHEN columnname = 'cc_email' \n\t\t\t\t\t\t  THEN 'LBL_CC' \n\t\t\t\t\t\t  WHEN columnname = 'bcc_email' \n\t\t\t\t\t\t  THEN 'LBL_BCC' \n\t\t\t\t\t\t  ELSE fieldlabel \n\t\t\t\t\t\tEND\n\t\t\t\t\t  ) \n\t\t\t\t\tWHERE tabid = ? AND columnname IN ('name','from_email','to_email','cc_email','bcc_email');", [getTabid('Emails')]);
        $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `module_name` = ? AND `summary` = ?;", ['[{"fieldname":"(related_to : (HelpDesk) from_portal)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'ModComments', 'New comment added to ticket from portal']);
        $adb->pquery("UPDATE `vtiger_field` SET `fieldlabel` = ? WHERE `fieldlabel` = ?;", ['Verification data', 'Werification data']);
        $result = $adb->pquery("SELECT * FROM `vtiger_settings_field` WHERE `name` = ? ", ['LBL_TIMECONTROL_PROCESSES']);
        if (!$adb->num_rows($result)) {
            $blockid = $adb->query_result($adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_PROCESSES'", array()), 0, 'blockid');
            $sequence = (int) $adb->query_result($adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?", array($blockid)), 0, 'sequence') + 1;
            $fieldid = $adb->getUniqueId('vtiger_settings_field');
            $adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)\n\t\t\tVALUES (?,?,?,?,?,?,?)", array($fieldid, $blockid, $sequence, 'LBL_TIMECONTROL_PROCESSES', '', 'LBL_TIMECONTROL_PROCESSES_DESCRIPTION', 'index.php?module=TimeControlProcesses&parent=Settings&view=Index'));
            $adb->pquery("insert  into `yetiforce_proc_tc`(`type`,`param`,`value`) values ('general','oneDay','false');");
            $adb->pquery("insert  into `yetiforce_proc_tc`(`type`,`param`,`value`) values ('general','timeOverlap','false')");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE `type` = ? AND `param` =? ;", ['conversion', 'mapping']);
        if (!$adb->num_rows($result)) {
            $adb->pquery("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values (?,?,?);", ['conversion', 'mapping', '[{"company":"accountname"}]']);
        }
        $adb->pquery("UPDATE `vtiger_currencies` SET `currency_symbol` = ? WHERE `currency_name` = ?;", ['₽', 'Russia, Rubles']);
        $adb->query('delete from vtiger_def_org_share where tabid NOT IN (SELECT tabid FROM `vtiger_field`)');
        $result = $adb->pquery("SELECT * FROM `vtiger_def_org_share` WHERE `tabid` IN (?,?) ", [getTabid('Faq'), getTabid('PriceBooks')]);
        if (!$adb->num_rows($result)) {
            $moduleInstance = Vtiger_Module::getInstance('Faq');
            Vtiger_Access::setDefaultSharing($moduleInstance, 'public_readwritedelete');
            Vtiger_Access::initSharing($moduleInstance);
            $moduleInstance = Vtiger_Module::getInstance('PriceBooks');
            Vtiger_Access::setDefaultSharing($moduleInstance, 'public_readwritedelete');
            Vtiger_Access::initSharing($moduleInstance);
        }
        $this->rebootSeq();
        $languageInformation = ['prefix' => 'nl_nl', 'label' => 'Dutch'];
        $result = $adb->pquery('SELECT * FROM `vtiger_language` WHERE `prefix` = ?;', ['nl_nl']);
        if (!$adb->num_rows($result)) {
            $adb->pquery('INSERT INTO vtiger_language (id,name,prefix,label,lastupdated,isdefault,active) VALUES(?,?,?,?,?,?,?)', [$adb->getUniqueId('vtiger_language'), $languageInformation['label'], $languageInformation['prefix'], $languageInformation['label'], date('Y-m-d H:i:s'), 0, 1]);
        }
        $actions = ['Import', 'Export', 'DuplicatesHandling', 'Dashboard', 'CreateDashboardFilter'];
        foreach ($actions as $action) {
            $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
            if ($adb->num_rows($result) == 0) {
                continue;
            } else {
                $actionId = $adb->query_result_raw($result, 0, 'actionid');
            }
            $tabids = [];
            if (in_array($action, ['Import', 'Export', 'DuplicatesHandling'])) {
                $tabids[] = getTabid('PriceBooks');
            } else {
                $tabids[] = getTabid('OSSMailView');
                $tabids[] = getTabid('CallHistory');
            }
            $permission = 0;
            if (in_array($action, ['Import', 'Export'])) {
                $permission = 1;
            }
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                foreach ($tabids as $tabid) {
                    $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $actionId]);
                    if ($adb->num_rows($resultC) == 0) {
                        $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $actionId, $permission));
                    }
                }
            }
        }
        $adb->query("UPDATE `yetiforce_menu` SET `label` = 'MEN_COMPANIES_CONTACTS' WHERE `label` = 'MEN_LEADS' AND `role` = 0;");
        $adb->pquery("UPDATE `yetiforce_menu` SET `sequence` = '24' WHERE `module` = ? AND `role` = 0 AND `type` = 0;", [getTabid('NewOrders')]);
        $adb->pquery("UPDATE `yetiforce_menu` SET `sequence` = '23' WHERE `module` = ? AND `role` = 0 AND `type` = 0;", [getTabid('Reports')]);
        $modules = [getTabid('Rss') => [0, 84, 0, 20, getTabid('Rss'), NULL, 0, NULL, 0, NULL, NULL, ''], getTabid('Portal') => [0, 84, 0, 21, getTabid('Portal'), NULL, 0, NULL, 0, NULL, NULL, ''], 'isNull' => [0, 84, 3, 22, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL]];
        $result2 = $adb->pquery('SELECT * FROM yetiforce_menu WHERE role = ? AND `label` = ? AND parentid = ?;', [0, 'MEN_DATABESES', 0]);
        $parent = (int) $adb->query_result_raw($result2, 0, 'id');
        foreach ($modules as $tabid => $params) {
            if ($tabid != 'isNull') {
                $result = $adb->pquery("SELECT * FROM `yetiforce_menu` WHERE `type` = ? AND `role` =? AND `module` = ? AND parentid = ?;", [0, 0, $tabid, $parent]);
            } else {
                $result = $adb->pquery("SELECT * FROM `yetiforce_menu` WHERE `type` = ? AND `role` =? AND parentid = ? AND `module` IS NULL ;", [3, 0, $parent]);
            }
            if (!$adb->num_rows($result) || $adb->num_rows($result) == 3) {
                $params[1] = $parent;
                $adb->pquery("insert  into `yetiforce_menu`(`role`,`parentid`,`type`,`sequence`,`module`,`label`,`newwindow`,`dataurl`,`showicon`,`icon`,`sizeicon`,`hotkey`) values (" . generateQuestionMarks($params) . ");", $params);
            }
        }
        $adb->query('delete from vtiger_def_org_share where tabid NOT IN (SELECT tabid FROM `vtiger_field`)');
        $adb->query('delete from vtiger_backup;');
        $adb->query('delete from vtiger_backup_db;');
        $adb->query('delete from vtiger_backup_files;');
        $adb->query('delete from vtiger_backup_tmp;');
        $adb->query("ALTER TABLE `vtiger_contactdetails` \n\t\t\t\t\tCHANGE `contactstatus` `contactstatus` varchar(255) NULL DEFAULT '' after `notifilanguage` , \n\t\t\t\t\tCHANGE `jobtitle` `jobtitle` varchar(100) NULL DEFAULT '' after `dav_status`;");
        $adb->query("UPDATE `vtiger_users` SET `theme` = 'twilight';");
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['process', 'vtiger_activity', getTabid('Calendar')]);
        $fieldId = $adb->query_result($result1, 0, 'fieldid');
        if ($fieldId) {
            $rel = ['HelpDesk', 'Campaigns', 'Potentials'];
            $adb->pquery('delete from vtiger_fieldmodulerel WHERE fieldid = ?;', [$fieldId]);
            foreach ($rel as $relmodule) {
                $adb->pquery("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (?,?,?);", [$fieldId, 'Calendar', $relmodule]);
            }
        }
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['link', 'vtiger_activity', getTabid('Calendar')]);
        $fieldId = $adb->query_result($result1, 0, 'fieldid');
        if ($fieldId) {
            $rel = ['Contacts', 'Leads', 'OSSEmployees', 'Vendors', 'Accounts'];
            $adb->pquery('delete from vtiger_fieldmodulerel WHERE fieldid = ?;', [$fieldId]);
            foreach ($rel as $relmodule) {
                $adb->pquery("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (?,?,?);", [$fieldId, 'Calendar', $relmodule]);
            }
        }
        // add new field
        $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['sum_time', 'vtiger_account', getTabid('Accounts')]);
        if (!$adb->num_rows($result)) {
            $moduleInstance = Vtiger_Module::getInstance('Accounts');
            $blockInstance = Vtiger_Block::getInstance('LBL_FINANSIAL_SUMMARY', $moduleInstance);
            $fieldInstance = new Vtiger_Field();
            $fieldInstance->name = 'sum_time';
            $fieldInstance->table = 'vtiger_account';
            $fieldInstance->label = 'Total time [h]';
            $fieldInstance->column = 'sum_time';
            $fieldInstance->columntype = 'decimal(10,2)';
            $fieldInstance->uitype = 7;
            $fieldInstance->displaytype = 10;
            $fieldInstance->typeofdata = 'NN~O';
            $blockInstance->addField($fieldInstance);
        }
        $adb->pquery('delete from vtiger_ws_referencetype WHERE `fieldtypeid` = ? AND `type` = ?;', [31, 'Campaigns']);
        $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['legal_form', 'vtiger_leaddetails', getTabid('Leads')]);
        $leadfid = $adb->query_result($result, 0, 'fieldid');
        if ($leadfid) {
            $result = $adb->pquery("SELECT * FROM `vtiger_convertleadmapping` WHERE leadfid = ?;", [$leadfid]);
            if (!$adb->num_rows($result)) {
                $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['legal_form', 'vtiger_account', getTabid('Accounts')]);
                $accountfid = $adb->query_result($result, 0, 'fieldid');
                $query = "INSERT INTO vtiger_convertleadmapping (leadfid, accountfid, contactfid, potentialfid, editable) values (?,?,?,?,?);";
                $adb->pquery($query, array($leadfid, $accountfid, 0, 0, 1));
            }
        }
        $result = $adb->query('SELECT accountid FROM `vtiger_account` INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_crmentity.deleted=0;');
        $num = $adb->num_rows($result);
        for ($i = 0; $i < $num; $i++) {
            $accountId = $adb->query_result($result, $i, 'accountid');
            $adb->query("UPDATE `vtiger_account` SET `sum_time` = (SELECT SUM(sum_time) FROM vtiger_osstimecontrol\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_osstimecontrol.osstimecontrolid\n\t\t\t\tWHERE vtiger_crmentity.deleted=0 AND  vtiger_osstimecontrol.accountid = " . $accountId . " AND osstimecontrol_status = '" . 'Accepted' . "') WHERE vtiger_account.accountid = " . $accountId . " ;");
        }
        $result = $adb->query("SELECT * FROM `vtiger_crmentity` WHERE `label` = 'Send Notification Email to Record Owner' AND `searchlabel` = 'Send Notification Email to Record Owner';");
        $num = $adb->num_rows($result);
        if ($num > 1) {
            $result = $adb->query("SELECT ossmailtemplatesid FROM `vtiger_ossmailtemplates` WHERE `name` = 'Send invitations';");
            $ossmailtemplatesid = $adb->query_result($result, 0, 'ossmailtemplatesid');
            $adb->pquery("UPDATE `vtiger_crmentity` SET `label` = ?, `searchlabel` = ? WHERE `crmid` = ? ;", ['Send invitations', 'Send invitations', $ossmailtemplatesid]);
        }
        $result = $adb->query('SELECT * FROM `vtiger_module_dashboard_widgets` WHERE `module` NOT IN (0)');
        if (!$adb->num_rows($result)) {
            $adb->query("UPDATE `vtiger_module_dashboard_widgets` w, `vtiger_links` l SET `module` = l.tabid WHERE w.linkid = l.linkid;");
        }
        $this->addFields();
        $log->debug("Exiting YetiForceUpdate::databaseData() method ...");
    }
コード例 #16
0
 public function actionMapping()
 {
     global $log, $adb;
     $log->debug("Entering VT620_to_YT::actionMapping() method ...");
     $actions = ['CreateCustomFilter', 'DuplicateRecord', 'EditableComments'];
     $count = self::countRow('vtiger_actionmapping', 'actionid');
     foreach ($actions as $action) {
         ++$count;
         $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
         if ($adb->num_rows($result) == 0) {
             $adb->pquery("INSERT INTO `vtiger_actionmapping` (`actionid`, `actionname`, `securitycheck`) VALUES (?, ?,'0');", [$count, $action]);
         }
         $modules = [getTabid('Services'), getTabid('ServiceContracts'), getTabid('SalesOrder'), getTabid('Reservations'), getTabid('Quotes'), getTabid('PurchaseOrder'), getTabid('ProjectTask'), getTabid('ProjectMilestone'), getTabid('Project'), getTabid('Products'), getTabid('PriceBooks'), getTabid('Potentials'), getTabid('OutsourcedProducts'), getTabid('OSSTimeControl'), getTabid('OSSSoldServices'), getTabid('OSSPdf'), getTabid('OSSPasswords'), getTabid('OSSOutsourcedServices'), getTabid('OSSMailView'), getTabid('OSSMailTemplates'), getTabid('OSSEmployees'), getTabid('OSSCosts'), getTabid('Leads'), getTabid('Invoice'), getTabid('HelpDesk'), getTabid('Faq'), getTabid('Documents'), getTabid('Contacts'), getTabid('Campaigns'), getTabid('Calendar'), getTabid('Calculations'), getTabid('Assets'), getTabid('Accounts'), getTabid('Events')];
         $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
         for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
             $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
             if ($action == 'EditableComments') {
                 $tabid = getTabid('ModComments');
                 $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $count]);
                 if ($adb->num_rows($resultC) == 0) {
                     $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $count, 0));
                 }
                 continue;
             }
             for ($k = 0; $k < count($modules); $k++) {
                 $tabid = $modules[$k];
                 if ($action != 'DuplicateRecord' && $tabid == getTabid('Events')) {
                     continue;
                 }
                 $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $count]);
                 if ($adb->num_rows($resultC) == 0) {
                     $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $count, 0));
                 }
             }
         }
     }
     $actions = [17 => 'MassEdit', 18 => 'MassDelete', 19 => 'MassAddComment', 20 => 'MassComposeEmail', 21 => 'MassSendSMS', 22 => 'MassTransferOwnership', 23 => 'MassMoveDocuments'];
     foreach ($actions as $key => $action) {
         ++$count;
         $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
         if ($adb->num_rows($result) == 0) {
             $adb->pquery("INSERT INTO `vtiger_actionmapping` (`actionid`, `actionname`, `securitycheck`) VALUES (?, ?,'0');", [$count, $action]);
         }
         $sql = "SELECT tabid, name  FROM `vtiger_tab` WHERE `isentitytype` = '1' AND name not in ('SMSNotifier','ModComments','PBXManager','Events','Emails','');";
         $result = $adb->query($sql);
         $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
         for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
             $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
             for ($k = 0; $k < $adb->num_rows($result); $k++) {
                 $insert = false;
                 $row = $adb->query_result_rowdata($result, $k);
                 $tabid = $row['tabid'];
                 if ($action == 'MassMoveDocuments' && $row['name'] == 'Documents') {
                     $insert = true;
                 }
                 if (($action == 'MassComposeEmail' || $action == 'MassSendSMS' || $action == 'MassTransferOwnership') && in_array($row['name'], ['Accounts', 'Contacts', 'Leads', 'Vendors'])) {
                     $insert = true;
                 }
                 if (!($action == 'MassTransferOwnership' && $row['name'] == 'PriceBooks') && $action != 'MassMoveDocuments' && $action != 'MassComposeEmail' && $action != 'MassSendSMS') {
                     $insert = true;
                 }
                 $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $count]);
                 if ($insert && $adb->num_rows($resultC) == 0) {
                     $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $count, 0));
                 }
             }
         }
     }
     $actions = ['ReadRecord', 'WorkflowTrigger'];
     foreach ($actions as $key => $action) {
         ++$count;
         $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
         if ($adb->num_rows($result) == 0) {
             $adb->pquery("INSERT INTO `vtiger_actionmapping` (`actionid`, `actionname`, `securitycheck`) VALUES (?, ?,'0');", [$count, $action]);
         }
         $sql = "SELECT tabid, name  FROM `vtiger_tab` WHERE `isentitytype` = '1' AND name not in ('SMSNotifier','ModComments','PBXManager','Events','Emails','CallHistory','OSSMailView','');";
         $result = $adb->query($sql);
         $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
         for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
             $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
             for ($k = 0; $k < $adb->num_rows($result); $k++) {
                 $row = $adb->query_result_rowdata($result, $k);
                 $tabid = $row['tabid'];
                 $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $count]);
                 if ($adb->num_rows($resultC) == 0) {
                     $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $count, 0));
                 }
             }
         }
     }
     Vtiger_Deprecated::createModuleMetaFile();
     Vtiger_Access::syncSharingAccess();
     $log->debug("Exiting VT620_to_YT::actionMapping() method ...");
 }