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();
 }
Exemple #2
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version,parent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, -1, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version, $this->parent));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
         $menuInstance = Vtiger_Menu::getInstance($parentTab);
         $menuInstance->addModule($moduleInstance);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     $adb = PearDatabase::getInstance();
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->insert('vtiger_tab', ['tabid' => $this->id, 'name' => $this->name, 'presence' => $this->presence, 'tabsequence' => -1, 'tablabel' => $this->label, 'modifiedby' => NULL, 'modifiedtime' => NULL, 'customized' => $customized, 'ownedby' => $this->ownedby, 'version' => $this->version, 'parent' => $this->parent, 'isentitytype' => $this->isentitytype ? 1 : 0, 'type' => $this->type]);
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version) VALUES (?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, $this->tabsequence, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }