[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Users/ -> populatetemplate.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9  *
  10   ********************************************************************************/
  11  //query the specific vtiger_table and then get the data and write the data here 
  12  require_once ('include/database/PearDatabase.php');
  13  include_once ('modules/Contacts/Contacts.php');
  14  include_once ('modules/Leads/Leads.php');
  15  include_once ('modules/Users/Users.php');
  16  global $log;
  17  
  18  //download the template file and store it in some specific location
  19  $sql = "select templatename,body from vtiger_emailtemplates where templateid='".$_REQUEST["templateid"] ."'";
  20  $tempresult = $adb->query($sql);
  21  $tempArray = $adb->fetch_array($tempresult);
  22  $fileContent = $tempArray["body"];
  23      $log->debug("the filecontent is ".$fileContent);
  24  $handle = fopen($root_directory.'/modules/Emails/templates/'.$_REQUEST["templatename"],"wb") ;
  25  fwrite($handle,$fileContent,89999999);
  26  fclose($handle);
  27  
  28  //create a file and write to it so that it can be used as the emailtemplateusage.php file
  29  
  30  if (is_file($root_directory.'/modules/Emails/templates/testemailtemplateusage.php')) {
  31      $is_writable = is_writable($root_directory.'/modules/Emails/templates/testemailtemplateusage.php');
  32  }
  33  else {
  34      $is_writable = is_writable('.');
  35  }
  36  
  37  
  38  //$config = "<?php \n";
  39  // $config .= "/*********************************************************************************\n";
  40  //$config .= " * The contents of this file are subject to the vtigerCRM License \n";
  41  // $config .= " * All Rights Reserved.\n";
  42  // $config .= " * Contributor(s): ______________________________________.\n";
  43  // $config .= "********************************************************************************/\n\n";
  44  
  45  
  46   
  47    $myString = "<?php \n";
  48     $myString .= "/*********************************************************************************\n";
  49    $myString .= " * The contents of this file are subject to the vtigerCRM License \n";
  50    $myString .= " * All Rights Reserved.\n";
  51    $myString .= " * Contributor(s): ______________________________________.\n";
  52    $myString .= "********************************************************************************/\n\n";
  53  
  54  
  55   $module = $_REQUEST['entity'];
  56  $recordid = $_REQUEST['entityid'];
  57  
  58      $log->debug("the module is ".$module);
  59          $log->debug("the template being used has id  ".$recordid);
  60  //get the module
  61  if($module == 'leads')
  62  {
  63    $focus = new Leads();
  64  }
  65  else
  66  {
  67    $focus = new Contacts();
  68  }
  69  
  70  $focus->retrieve_entity_info($recordid,$module);
  71  //$focus->column_fields();
  72  $i=0;
  73  $m=0;
  74  $n=0;
  75  $myString;
  76  
  77  //storing the columnname and the value pairs
  78  foreach ($focus->column_fields as $columnName=>$value)
  79  {
  80    $myString .= "$" .$module ."_" .$columnName.' = "'. $value."\";\n\n";
  81    $colName[$i] = $columnName;
  82    $i++;
  83    $j=$i;
  84  
  85  }
  86  
  87  global $current_user;
  88  global $adb;
  89  $query = 'select * from vtiger_users where id= '.$current_user->id;
  90  $result = $adb->query($query);
  91  $res_row = $adb->fetchByAssoc($result);
  92  foreach ($res_row as $columnName=>$value)
  93  {
  94        $myString .='$users_' .$columnName.' = "'. $value."\";\n\n";
  95        $usercolName[$n] = $columnName;
  96        $n++;
  97        $m=$n;
  98  }
  99  
 100  $myString .= "\$globals = \"";
 101  
 102  for($i=0;$i<$j-1;$i++)
 103  {
 104    $myString .= "\\$" .$module ."_" .$colName[$i].", ";
 105  }
 106  for($n=0;$n<$m;$n++)
 107  {
 108    $myString .= '\\$users_' .$usercolName[$n].", ";
 109  }
 110  
 111  $myString .= "\\$" .$module ."_" .$colName[$i];
 112  $myString .="\"; \n\n";
 113  
 114  $myString .= "?> \n";
 115      $log->debug("the string in totality is  ".$myString);
 116  if ($is_writable && ($config_file = @ fopen($root_directory.'/modules/Emails/templates/testemailtemplateusage.php', "w"))) 
 117      {
 118              $log->debug("writing to the testemailtemplatuseage.php file");
 119          fputs($config_file, $myString, strlen($myString));
 120              fclose($config_file);
 121      }
 122  $templatename = $root_directory.'/modules/Emails/templates/'.$_REQUEST["templatename"];
 123  header("Location:index.php?module=Users&action=TemplateMerge&templatename=".$templatename);
 124  
 125  ?>
 126  <script>
 127  window.close()
 128  </script>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7