query($sql); $tempArray = $adb->fetch_array($tempresult); $fileContent = $tempArray["body"]; $vtlog->logthis("the filecontent is ".$fileContent,'debug'); $handle = fopen($root_directory.'/modules/Emails/templates/'.$_REQUEST["templatename"],"wb") ; fwrite($handle,$fileContent,89999999); fclose($handle); //create a file and write to it so that it can be used as the emailtemplateusage.php file if (is_file($root_directory.'/modules/Emails/templates/testemailtemplateusage.php')) { $is_writable = is_writable($root_directory.'/modules/Emails/templates/testemailtemplateusage.php'); } else { $is_writable = is_writable('.'); } //$config = "logthis("the module is ".$module,'debug'); $vtlog->logthis("the template being used has id ".$recordid,'debug'); //get the module if($module == 'leads') { $focus = new Lead(); } else { $focus = new Contact(); } $focus->retrieve_entity_info($recordid,$module); //$focus->column_fields(); $i=0; $m=0; $n=0; $myString; //storing the columnname and the value pairs foreach ($focus->column_fields as $columnName=>$value) { $myString .= "$" .$module ."_" .$columnName.' = "'. $value."\";\n\n"; $colName[$i] = $columnName; $i++; $j=$i; } global $current_user; global $adb; $query = 'select * from users where id= '.$current_user->id; $result = $adb->query($query); $res_row = $adb->fetchByAssoc($result); foreach ($res_row as $columnName=>$value) { $myString .='$users_' .$columnName.' = "'. $value."\";\n\n"; $usercolName[$n] = $columnName; $n++; $m=$n; } $myString .= "\$globals = \""; for($i=0;$i<$j-1;$i++) { $myString .= "\\$" .$module ."_" .$colName[$i].", "; } for($n=0;$n<$m;$n++) { $myString .= '\\$users_' .$usercolName[$n].", "; } $myString .= "\\$" .$module ."_" .$colName[$i]; $myString .="\"; \n\n"; $myString .= "?> \n"; $vtlog->logthis("the string in totality is ".$myString,'debug'); if ($is_writable && ($config_file = @ fopen($root_directory.'/modules/Emails/templates/testemailtemplateusage.php', "w"))) { $vtlog->logthis("writing to the testemailtemplatuseage.php file",'debug'); fputs($config_file, $myString, strlen($myString)); fclose($config_file); } $templatename = $root_directory.'/modules/Emails/templates/'.$_REQUEST["templatename"]; header("Location:index.php?module=Users&action=TemplateMerge&templatename=".$templatename); ?>