function applyChange()
 {
     global $adb;
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $em = new VTEventsManager($adb);
         $em->registerHandler('vtiger.entity.aftersave', 'modules/Emails/evcbrcHandler.php', 'evcbrcHandler');
         $modPrj = Vtiger_Module::getInstance('Project');
         $modPrjTsk = Vtiger_Module::getInstance('ProjectTask');
         $modPot = Vtiger_Module::getInstance('Potentials');
         $modHD = Vtiger_Module::getInstance('HelpDesk');
         $modEmail = Vtiger_Module::getInstance('Emails');
         $modPrj->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails');
         $modPrjTsk->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails');
         $modPot->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails');
         $modHD->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails');
         $block = VTiger_Block::getInstance('LBL_PROJECT_INFORMATION', $modPrj);
         $field = Vtiger_Field::getInstance('email', $modPrj);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'email';
             $field->uitype = 13;
             $field->label = 'Email';
             $field->columntype = 'VARCHAR(150)';
             $field->typeofdata = 'E~O';
             $field->displaytype = 2;
             $block->addField($field);
         }
         $block = VTiger_Block::getInstance('LBL_PROJECT_TASK_INFORMATION', $modPrjTsk);
         $field = Vtiger_Field::getInstance('email', $modPrjTsk);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'email';
             $field->uitype = 13;
             $field->label = 'Email';
             $field->columntype = 'VARCHAR(150)';
             $field->typeofdata = 'E~O';
             $field->displaytype = 2;
             $block->addField($field);
         }
         $block = VTiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $modPot);
         $field = Vtiger_Field::getInstance('email', $modPot);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'email';
             $field->uitype = 13;
             $field->label = 'Email';
             $field->columntype = 'VARCHAR(150)';
             $field->typeofdata = 'E~O';
             $field->displaytype = 2;
             $block->addField($field);
         }
         $block = VTiger_Block::getInstance('LBL_TICKET_INFORMATION', $modHD);
         $field = Vtiger_Field::getInstance('email', $modHD);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'email';
             $field->uitype = 13;
             $field->label = 'Email';
             $field->columntype = 'VARCHAR(150)';
             $field->typeofdata = 'E~O';
             $field->displaytype = 2;
             $block->addField($field);
         }
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
Example #2
0
 /**
  * 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)
 {
     if ($event_type == 'module.postinstall') {
         // TODO Handle post installation actions
         $modGV = Vtiger_Module::getInstance('GlobalVariable');
         $modMap = Vtiger_Module::getInstance('cbMap');
         if ($modGV) {
             $blockInstance = VTiger_Block::getInstance('LBL_GLOBAL_VARIABLE_INFORMATION', $modGV);
             $field = new Vtiger_Field();
             $field->name = 'bmapid';
             $field->label = 'cbMap';
             $field->table = $module->basetable;
             $field->column = 'bmapid';
             $field->columntype = 'INT(11)';
             $field->uitype = 10;
             $field->displaytype = 1;
             $field->typeofdata = 'V~O';
             $field->presence = 0;
             $blockInstance->addField($field);
             $field->setRelatedModules(array('cbMap'));
             $modMap->setRelatedList($modGV, 'GlobalVariable', array('ADD'), 'get_dependents_list');
         }
         $this->setModuleSeqNumber('configure', $modulename, 'BMAP-', '0000001');
     } else {
         if ($event_type == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($event_type == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } 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.
                         }
                     }
                 }
             }
         }
     }
 }