Ejemplo n.º 1
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     $db = PearDatabase::getInstance();
     if ($eventType == 'module.postinstall') {
         require_once 'modules/OSSDocumentControl/helpers/Tool.php';
         Oss_Tool::addUitype15Field('Documents', 'LBL_NOTE_INFORMATION', array('None', 'Checked'), 'ossdc_status');
         $this->addLink($moduleName);
         $db->query("UPDATE vtiger_tab SET customized=0 WHERE name='{$moduleName}'");
     } else {
         if ($eventType == 'module.enabled') {
         } else {
             if ($eventType == 'module.disabled') {
             } 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.
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Dodaje od modułu pole uitype 15 (select / picklist)
  *
  * @param string $moduleName - nazwa modułu
  * @param string $blockLabel - etykieta bloku
  * @param array $pickValue - tablica zawierająca listę opcji do wyboru
  * @param string $fieldName - nazwa pola 
  * @param string $defaultvalue - domyślnie zaznaczona wartośc
  * @param bool $mandatory - czy pole ma być obowiązkowe
  * @param string $fieldLabel - etykieta pola, jeśli nie jest podany etykieta jest taka jak nazwa pola
  */
 public static function addUitype15Field($moduleName, $blockLabel, $pickValue, $fieldName = NULL, $defaultvalue = NULL, $mandatory = false, $fieldLabel = NULL)
 {
     if (self::checkArg(func_get_args(), 3)) {
         //vglobal('Vtiger_Utils_Log', TRUE);
         $tabid = Vtiger_Functions::getModuleId($moduleName);
         $blockId = getBlockId($tabid, $blockLabel);
         include_once 'vtlib/Vtiger/Module.php';
         $moduleInstance = Vtiger_Module::getInstance($moduleName);
         $blockInstance = Vtiger_Block::getInstance($blockId, $moduleInstance);
         $field = new Vtiger_Field();
         if ($fieldName) {
             $field->name = strtolower($fieldName);
         } else {
             $field->name = Oss_Tool::generateFieldName();
         }
         if ($fieldLabel) {
             $field->label = $fieldLabel;
         } else {
             $field->label = $fieldName;
         }
         if (!$fieldName) {
             if (isset($moduleInstance->customFieldTable)) {
                 $field->table = $moduleInstance->customFieldTable[0];
             } else {
                 $field->table = 'vtiger_' . strtolower($moduleName) . 'cf';
             }
         } else {
             $field->table = $moduleInstance->table_name;
         }
         $field->uitype = 15;
         if ($mandatory) {
             $field->typeofdata = 'V~M';
         } else {
             $field->typeofdata = 'V~O';
         }
         $field->readonly = 1;
         $field->displaytype = 1;
         $field->masseditable = 1;
         $field->quickcreate = 1;
         $field->columntype = 'VARCHAR(255)';
         if ($defaultvalue) {
             $field->defaultvalue = $defaultvalue;
         }
         $blockInstance->addField($field);
         $field->setPicklistValues($pickValue);
     }
 }