Пример #1
0
 /**
  * Update Blocks of the module
  * @access private
  */
 function update_Blocks($modulenode, $moduleInstance)
 {
     if (empty($modulenode->blocks) || empty($modulenode->blocks->block)) {
         return;
     }
     foreach ($modulenode->blocks->block as $blocknode) {
         $this->listBlocks[] = strval($blocknode->label);
         $blockInstance = Vtiger_Block::getInstance((string) $blocknode->label, $moduleInstance);
         if (!$blockInstance) {
             $blockInstance = $this->import_Block($modulenode, $moduleInstance, $blocknode);
         } else {
             $this->update_Block($modulenode, $moduleInstance, $blocknode, $blockInstance);
         }
         $this->update_Fields($blocknode, $blockInstance, $moduleInstance);
     }
     // Deleting removed blocks
     $listBlockBeforeUpdate = Vtiger_Block::getAllForModule($moduleInstance);
     foreach ($listBlockBeforeUpdate as $blockInstance) {
         if (!in_array($blockInstance->label, $this->listBlocks)) {
             $blockInstance->delete();
         }
     }
 }
Пример #2
0
 /**
  * Function to retrieve block instances for a module
  * @param <type> $moduleModel - module instance
  * @return <array> - list of Vtiger_Block_Model
  */
 public static function getAllForModule($moduleModel)
 {
     $blockObjects = Vtiger_Cache::get('ModuleBlock', $moduleModel->getName());
     if (!$blockObjects) {
         $blockObjects = parent::getAllForModule($moduleModel);
         Vtiger_Cache::set('ModuleBlock', $moduleModel->getName(), $blockObjects);
     }
     $blockModelList = array();
     if ($blockObjects) {
         foreach ($blockObjects as $blockObject) {
             $blockModelList[] = self::getInstanceFromBlockObject($blockObject);
         }
     }
     return $blockModelList;
 }
Пример #3
0
 public static function getFieldsWithBlocksForModule($module_name, $references = false, $refTemplate = "([source]: ([module]) [destination])")
 {
     $wmdpupqmkw = "modLang";
     global $current_language, $adb, $app_strings;
     $jyoclduhijw = "instance";
     if (empty(${${"GLOBALS"}["dtigqiycyl"]}) && ${${"GLOBALS"}["uoikifoisc"]} == true) {
         $hepidzbf = "refTemplate";
         ${$hepidzbf} = "([source]: ([module]) [destination])";
     }
     ${"GLOBALS"}["qdchdj"] = "module";
     ${"GLOBALS"}["dlxjxqbp"] = "current_language";
     $kquvbsysfcu = "moduleFields";
     include_once "vtlib/Vtiger/Module.php";
     ${${"GLOBALS"}["qdchdj"]} = ${${"GLOBALS"}["kgrlqorxi"]};
     ${${"GLOBALS"}["visvlqiwmar"]} = Vtiger_Module::getInstance(${${"GLOBALS"}["fmewvndt"]});
     ${"GLOBALS"}["gkjcbzii"] = "blocks";
     ${${"GLOBALS"}["tuyqii"]} = Vtiger_Block::getAllForModule(${$jyoclduhijw});
     ${"GLOBALS"}["otfgztbcykam"] = "module";
     ${"GLOBALS"}["dwkjhu"] = "addReferences";
     if (${${"GLOBALS"}["otfgztbcykam"]} != "Events") {
         ${"GLOBALS"}["isokwmqve"] = "langModule";
         ${${"GLOBALS"}["isokwmqve"]} = ${${"GLOBALS"}["fmewvndt"]};
     } else {
         $oivtxenk = "langModule";
         ${$oivtxenk} = "Calendar";
     }
     ${$wmdpupqmkw} = return_module_language(${${"GLOBALS"}["dlxjxqbp"]}, ${${"GLOBALS"}["pdnqbcq"]});
     ${$kquvbsysfcu} = array();
     ${${"GLOBALS"}["sereklx"]} = array();
     ${"GLOBALS"}["qpvmpezinov"] = "moduleFields";
     if (is_array(${${"GLOBALS"}["gkjcbzii"]})) {
         ${"GLOBALS"}["twqgybnkx"] = "block";
         $wmhyxeckigh = "blocks";
         foreach (${$wmhyxeckigh} as ${${"GLOBALS"}["twqgybnkx"]}) {
             $vsrjrtsyjwuy = "block";
             $jtvjnrg = "fields";
             ${"GLOBALS"}["fybcdi"] = "fields";
             $jiroosdtbga = "instance";
             ${"GLOBALS"}["wzbaaqfp"] = "fields";
             ${${"GLOBALS"}["wzbaaqfp"]} = Vtiger_Field::getAllForBlock(${$vsrjrtsyjwuy}, ${$jiroosdtbga});
             ${"GLOBALS"}["qindbfrv"] = "fields";
             if (empty(${${"GLOBALS"}["fybcdi"]}) || !is_array(${${"GLOBALS"}["qindbfrv"]})) {
                 continue;
             }
             foreach (${$jtvjnrg} as ${${"GLOBALS"}["iswxctbj"]}) {
                 ${"GLOBALS"}["gpvotsermfo"] = "module";
                 ${"GLOBALS"}["ltyuthgs"] = "references";
                 $field->label = getTranslatedString($field->label, ${${"GLOBALS"}["gpvotsermfo"]});
                 if (${${"GLOBALS"}["ltyuthgs"]} !== false) {
                     ${"GLOBALS"}["txxkntyfk"] = "addReferences";
                     $dcbsrjwyigh = "addReferences";
                     $qqmucyy = "field";
                     $svmyfptxpk = "field";
                     $msdeydhan = "addReferences";
                     ${"GLOBALS"}["kwkccfh"] = "field";
                     $amiqkcrlotrq = "result";
                     ${"GLOBALS"}["duvygkbpexkh"] = "addReferences";
                     $kxrugplfiqo = "result";
                     $bjhinyeqy = "addReferences";
                     $yiujkrbxum = "field";
                     ${"GLOBALS"}["ltyirzpnpba"] = "field";
                     $qynnew = "field";
                     $jrfetwc = "field";
                     ${"GLOBALS"}["roilmn"] = "addReferences";
                     switch ($field->uitype) {
                         case "51":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Accounts");
                             break;
                         case "52":
                             ${${"GLOBALS"}["txxkntyfk"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Users");
                             break;
                         case "53":
                             ${${"GLOBALS"}["roilmn"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Users");
                             break;
                         case "57":
                             ${${"GLOBALS"}["duvygkbpexkh"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Contacts");
                             break;
                         case "58":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${${"GLOBALS"}["kwkccfh"]}, "Campaigns");
                             break;
                         case "59":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${${"GLOBALS"}["ltyirzpnpba"]}, "Products");
                             break;
                         case "73":
                             ${$bjhinyeqy}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Accounts");
                             break;
                         case "75":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${$svmyfptxpk}, "Vendors");
                             break;
                         case "81":
                             ${$dcbsrjwyigh}[] = array(${$qynnew}, "Vendors");
                             break;
                         case "76":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Potentials");
                             break;
                         case "78":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${$qqmucyy}, "Quotes");
                             break;
                         case "80":
                             ${${"GLOBALS"}["sereklx"]}[] = array(${$yiujkrbxum}, "SalesOrder");
                             break;
                         case "68":
                             ${$msdeydhan}[] = array(${$jrfetwc}, "Accounts");
                             ${${"GLOBALS"}["sereklx"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Contacts");
                             break;
                         case "10":
                             ${$amiqkcrlotrq} = $adb->pquery("SELECT relmodule FROM `vtiger_fieldmodulerel` WHERE fieldid = ?", array($field->id));
                             while (${${"GLOBALS"}["omdiav"]} = $adb->fetch_array(${$kxrugplfiqo})) {
                                 ${"GLOBALS"}["rgsshwz"] = "addReferences";
                                 ${${"GLOBALS"}["rgsshwz"]}[] = array(${${"GLOBALS"}["iswxctbj"]}, ${${"GLOBALS"}["omdiav"]}["relmodule"]);
                             }
                             break;
                     }
                 }
                 ${${"GLOBALS"}["iewpnk"]}[getTranslatedString($block->label, ${${"GLOBALS"}["pdnqbcq"]})][] = ${${"GLOBALS"}["iswxctbj"]};
             }
         }
     }
     ${${"GLOBALS"}["vpjrpbb"]} = array("assigned_user_id" => "smownerid");
     if (${${"GLOBALS"}["uoikifoisc"]} !== false) {
         $rndvtlgy = "addReferences";
         ${${"GLOBALS"}["iswxctbj"]} = new StdClass();
         $field->name = "current_user";
         $field->label = getTranslatedString("LBL_CURRENT_USER", "Workflow2");
         ${$rndvtlgy}[] = array(${${"GLOBALS"}["iswxctbj"]}, "Users");
     }
     if (is_array(${${"GLOBALS"}["dwkjhu"]})) {
         ${"GLOBALS"}["fkzheawwtu"] = "refField";
         foreach (${${"GLOBALS"}["sereklx"]} as ${${"GLOBALS"}["fkzheawwtu"]}) {
             $yomtemg = "refField";
             $ibdrafmbgfb = "fields";
             ${"GLOBALS"}["etscfhrvmxy"] = "fields";
             ${${"GLOBALS"}["etscfhrvmxy"]} = self::getFieldsForModule(${$yomtemg}[1]);
             foreach (${$ibdrafmbgfb} as ${${"GLOBALS"}["iswxctbj"]}) {
                 ${"GLOBALS"}["oxjphormw"] = "refTemplate";
                 ${"GLOBALS"}["krkdwlrntjd"] = "refField";
                 $cbsqpgxe = "app_strings";
                 ${"GLOBALS"}["jqkudkkmpy"] = "refField";
                 ${"GLOBALS"}["mjtljotq"] = "rewriteFields";
                 $itkvhkri = "refField";
                 $field->label = "(" . (isset(${$cbsqpgxe}[${${"GLOBALS"}["lontvhvwcnep"]}[1]]) ? ${${"GLOBALS"}["wmngovs"]}[${${"GLOBALS"}["krkdwlrntjd"]}[1]] : ${$itkvhkri}[1]) . ") " . $field->label;
                 $akssqrew = "name";
                 $ccucleufm = "name";
                 if (!empty(${${"GLOBALS"}["mjtljotq"]}[${${"GLOBALS"}["lontvhvwcnep"]}[0]->name])) {
                     ${"GLOBALS"}["qnjuhnzf"] = "refField";
                     ${${"GLOBALS"}["qnjuhnzf"]}[0]->name = ${${"GLOBALS"}["vpjrpbb"]}[${${"GLOBALS"}["lontvhvwcnep"]}[0]->name];
                 }
                 ${$ccucleufm} = str_replace(array("[source]", "[module]", "[destination]"), array(${${"GLOBALS"}["lontvhvwcnep"]}[0]->name, ${${"GLOBALS"}["jqkudkkmpy"]}[1], $field->name), ${${"GLOBALS"}["oxjphormw"]});
                 $field->name = ${$akssqrew};
                 ${${"GLOBALS"}["iewpnk"]}["References (" . ${${"GLOBALS"}["lontvhvwcnep"]}[0]->label . ")"][] = ${${"GLOBALS"}["iswxctbj"]};
             }
         }
     }
     return ${${"GLOBALS"}["qpvmpezinov"]};
 }
Пример #4
0
	public function handle() {
		if ($this->interactive) {
			$uitypes = array (
				1 => array("columntype" => "VARCHAR(255)", "typeofdata" => "V~O", "descript" => "текстовое поле"),
				2 => array("columntype" => "VARCHAR(255)", "typeofdata" => "V~M", "descript" => "текстовое поле (обязательное)"),
				21 => array("columntype" => "TEXT", "typeofdata" => "V~O", "descript" => "textarea (в 1 поле)"),
				19 => array("columntype" => "TEXT", "typeofdata" => "V~O", "descript" => "textarea (широкое)"),
				6 => array("columntype" => "DATETIME", "typeofdata" => "DT~O", "descript" => "дата и время"),
				5 => array("columntype" => "DATE", "typeofdata" => "D~O", "descript" => "дата"),
				23 => array("columntype" => "DATE", "typeofdata" => "D~O", "descript" => "дата (конечная)"),
				14 => array("columntype" => "TIME", "typeofdata" => "T~O", "descript" => "время"),
				7 => array("columntype" => "INT(11)", "typeofdata" => "I~O", "descript" => "целое число"),
				9 => array("columntype" => "decimal(11,0)", "typeofdata" => "N~O", "descript" => "проценты"),
				71 => array("columntype" => "decimal(25,8)", "typeofdata" => "N~O", "descript" => "сумма в рублях"),
				17 => array("columntype" => "VARCHAR(255)", "typeofdata" => "V~O", "descript" => "ссылка"),
				15 => array("columntype" => "VARCHAR(60)", "typeofdata" => "V~O~LE~60", "descript" => "PickList (по Ролям)"),
				16 => array("columntype" => "VARCHAR(60)", "typeofdata" => "V~O~LE~60", "descript" => "PickList (для всех)"),
				56 => array("columntype" => "VARCHAR(3)", "typeofdata" => "C~O", "descript" => "галочка (да/нет)")
			);
			echo "------------------------------------ >>> CREATE FIELD <<< ---\n";
			$mmodule = $this->prompt("Module name: ", self::PROMPT_NAME);
			$mmoduleInstance = Vtiger_Module::getInstance($mmodule);
			if (!$mmoduleInstance) {
				echo "ERROR: Module $mmodule not found, try another.\n";
			} else {
				do {
					$field3 = new Vtiger_Field();
					$field3->table = $mmoduleInstance->basetable;
					$field3->masseditable = 2;
					
					$field3->label = $this->prompt("Field Label: ", self::PROMPT_NAME);

					$field3->name  = str_replace(" ", "_", strtolower($field3->label));
					$lfieldName = $this->prompt("Field Name (" . $field3->name . "?): ", self::PROMPT_OPTIONAL);
					if ($lfieldName) $field3->name = $lfieldName;
					$field3->column = $field3->name;
					
					foreach ($uitypes as $uikey => $uivalue) { echo "$uikey. ".$uivalue['descript'].".\n"; }
					$field3->uitype = $this->prompt("Select UI Type: ", self::PROMPT_NUMERIC);
					if (array_key_exists($field3->uitype, $uitypes)) {
						$field3->typeofdata = $uitypes[$field3->uitype]['typeofdata'];
						$field3->columntype = $uitypes[$field3->uitype]['columntype'];
					}
					$lfieldColumntype = $this->prompt("columntype: (" . $field3->columntype . "?)", self::PROMPT_OPTIONAL);
					if ($lfieldColumntype) $field3->columntype = $lfieldColumntype;
					$lfieldTypeofdata = $this->prompt("typeofdata: (" . $field3->typeofdata . "?)", self::PROMPT_OPTIONAL);
					if ($lfieldTypeofdata) $field3->typeofdata = $lfieldTypeofdata;
				
				
					echo "Field ".$field3->label." [".$field3->table.".".$field3->column."] creating ... ";
					$moduleBlocks = Vtiger_Block::getAllForModule($mmoduleInstance);
					$block1 = $moduleBlocks[0];	
					$block1->addField($field3);
					echo "DONE.\n";
				} while (true);
			}
			echo "----------------------------------\n\n";
		} else {
			echo "ERROR: Interactive only.\n";
		}
	}
Пример #5
0
 /**
  * Function to retrieve block instances for a module
  * @param <type> $moduleModel - module instance
  * @return <array> - list of Vtiger_Block_Model
  */
 public static function getAllForModule($moduleModel)
 {
     global $log;
     $log->debug("Entering ./models/Block.php::staticgetAllForModule");
     $blockObjects = Vtiger_Cache::get('ModuleBlock', $moduleModel->getName());
     if (!$blockObjects) {
         $blockObjects = parent::getAllForModule($moduleModel);
         Vtiger_Cache::set('ModuleBlock', $moduleModel->getName(), $blockObjects);
     }
     $blockModelList = array();
     if ($blockObjects) {
         foreach ($blockObjects as $blockObject) {
             $blockModelList[] = self::getInstanceFromBlockObject($blockObject);
         }
     }
     return $blockModelList;
 }