[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/utils/ -> CommonUtils.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header$
  17   * Description:  Includes generic helper functions used throughout the application.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   * ****************************************************************************** */
  22  
  23  require_once ('include/utils/utils.php'); //new
  24  require_once ('include/utils/RecurringType.php');
  25  require_once ('include/utils/EmailTemplate.php');
  26  require_once  'include/QueryGenerator/QueryGenerator.php';
  27  require_once  'include/ListView/ListViewController.php';
  28  require_once  'includes/runtime/Cache.php';
  29  
  30  function is_admin($user) {
  31      return Vtiger_Functions::userIsAdministrator($user);
  32  }
  33  
  34  function parse_calendardate($local_format) {
  35      return Vtiger_Functions::currentUserJSDateFormat($local_format);
  36  }
  37  
  38  function from_html($string, $encode = true) {
  39      return Vtiger_Functions::fromHTML($string, $encode);
  40  }
  41  
  42  function fck_from_html($string) {
  43      return Vtiger_Functions::fromHTML_FCK($string);
  44  }
  45  
  46  function popup_from_html($string, $encode = true) {
  47      return Vtiger_Functions::fromHTML_Popup($string, $encode);
  48  }
  49  
  50  function fetchCurrency($id) {
  51      return Vtiger_Functions::userCurrencyId($id);
  52  }
  53  
  54  function getCurrencyName($currencyid, $show_symbol = true) {
  55      return Vtiger_Functions::getCurrencyName($currencyid, $show_symbol);
  56  }
  57  
  58  function getTabid($module) {
  59      return Vtiger_Functions::getModuleId($module);
  60      }
  61  
  62  function getFieldid($tabid, $fieldname, $onlyactive = true) {
  63      return Vtiger_Functions::getModuleFieldId($tabid, $fieldname, $onlyactive);
  64  }
  65  
  66  function getTabOwnedBy($module) {
  67      return Vtiger_Functions::getModuleOwner($module);
  68  }
  69  
  70  function getSalesEntityType($crmid) {
  71      return Vtiger_Functions::getCRMRecordType($crmid);
  72  }
  73  
  74  function getAccountName($account_id) {
  75      return Vtiger_Functions::getCRMRecordLabel($account_id);
  76  }
  77  
  78  function getProductName($product_id) {
  79      return Vtiger_Functions::getCRMRecordLabel($product_id);
  80  }
  81  
  82  function getPotentialName($potential_id) {
  83      return Vtiger_Functions::getCRMRecordLabel($potential_id);
  84  }
  85  
  86  function getContactName($contact_id) {
  87      return Vtiger_Functions::getCRMRecordLabel($contact_id);
  88  }
  89  
  90  function getFullNameFromQResult($result, $row_count, $module) {
  91      return Vtiger_Deprecated::getFullNameFromQResult($result, $row_count, $module);
  92  }
  93  
  94  function getFullNameFromArray($module, $fieldValues) {
  95      return Vtiger_Deprecated::getFullNameFromArray($module, $fieldValues);
  96  }
  97  
  98  function getCampaignName($campaign_id) {
  99      return Vtiger_Functions::getCRMRecordLabel($campaign_id);
 100  }
 101  
 102  function getVendorName($vendor_id) {
 103      return Vtiger_Functions::getCRMRecordLabel($vendor_id);
 104  }
 105  
 106  function getQuoteName($quote_id) {
 107      return Vtiger_Functions::getCRMRecordLabel($quote_id);
 108  }
 109  
 110  function getPriceBookName($pricebookid) {
 111      return Vtiger_Functions::getCRMRecordLabel($pricebookid);
 112  }
 113  
 114  function getSoName($so_id) {
 115      return Vtiger_Functions::getCRMRecordLabel($so_id);
 116  }
 117  
 118  function getGroupName($groupid) {
 119      return Vtiger_Functions::getGroupName($groupid);
 120  }
 121  
 122  function getUserName($userid) {
 123      return Vtiger_Functions::getUserName($userid);
 124  }
 125  
 126  function getUserFullName($userid) {
 127      return Vtiger_Functions::getUserRecordLabel($userid);
 128  }
 129  
 130  function getParentName($parent_id) {
 131      return Vtiger_Functions::getCRMRecordLabel($parent_id);
 132      }
 133  
 134  function getValidDisplayDate($cur_date_val) {
 135      return Vtiger_Functions::currentUserDisplayDate($cur_date_val);
 136  }
 137  
 138  function getNewDisplayDate() {
 139      return Vtiger_Functions::currentUserDisplayDateNew();
 140  }
 141  
 142  /** This function returns the conversion rate and vtiger_currency symbol
 143   * in array format for a given id.
 144   * param $id - vtiger_currency id.
 145   */
 146  function getCurrencySymbolandCRate($id) {
 147      return Vtiger_Functions::getCurrencySymbolandRate($id);
 148  }
 149  
 150  /** This function returns the terms and condition from the database.
 151   * Takes no param and the return type is text.
 152   */
 153  function getTermsandConditions() {
 154      return Vtiger_Functions::getInventoryTermsAndCondition();
 155  }
 156  
 157  /** This function returns a string with removed new line character, single quote, and back slash double quoute.
 158   * param $str - string to be converted.
 159   */
 160  function br2nl($str) {
 161      return Vtiger_Functions::br2nl($str);
 162  }
 163  
 164  /**
 165   * This function is used to get the blockid of the customblock for a given module.
 166   * Takes the input parameter as $tabid - module tabid and $label - custom label
 167   * This returns string type value
 168   */
 169  function getBlockId($tabid, $label) {
 170      return Vtiger_Deprecated::getBlockId($tabid, $label);
 171  }
 172  
 173  /**
 174   * This function is used to get the Parent Tab name for a given module.
 175   * Takes the input parameter as $module - module name
 176   * This returns value string type
 177   */
 178  function getParentTabFromModule($module) {
 179      return Vtiger_Deprecated::getParentTabFromModule($module);
 180  }
 181  
 182  /**
 183   * This function is used to get the Parent Tab name for a given module.
 184   * Takes no parameter but gets the vtiger_parenttab value from form request
 185   * This returns value string type
 186   */
 187  function getParentTab() {
 188      return Vtiger_Deprecated::getParentTab();
 189  }
 190  
 191  /**
 192   * This function is used to set the Object values from the REQUEST values.
 193   * @param  object reference $focus - reference of the object
 194   */
 195  function setObjectValuesFromRequest($focus) {
 196      return Vtiger_Deprecated::copyValuesFromRequest($focus);
 197  }
 198  
 199  function create_tab_data_file() {
 200      return Vtiger_Deprecated::createModuleMetaFile();
 201  }
 202  
 203  /**
 204   * Function to write the vtiger_parenttabid and name to a flat file parent_tabdata.txt so that the data
 205   * is obtained from the file instead of repeated queries
 206   * returns null
 207   */
 208  function create_parenttab_data_file() {
 209      return Vtiger_Deprecated::createModuleGroupMetaFile();
 210  }
 211  
 212  function getEntityName($module, $ids_list, $compute=true) {
 213      if ($compute) {
 214          return Vtiger_Functions::computeCRMRecordLabels($module, $ids_list);
 215      } else {
 216          return Vtiger_Functions::getCRMRecordLabels($module, $ids_list);
 217      }
 218  }
 219  
 220  /**
 221   *     This function is used to decide the File Storage Path in where we will upload the file in the server.
 222   *     return string $filepath  - filepath inwhere the file should be stored in the server will be return
 223   */
 224  function decideFilePath() {
 225      return Vtiger_Functions::initStorageFileDirectory();
 226  }
 227  
 228  /**
 229   *     This function is used to check whether the attached file is a image file or not
 230   *     @param string $file_details  - vtiger_files array which contains all the uploaded file details
 231   *     return string $save_image - true or false. if the image can be uploaded then true will return otherwise false.
 232   */
 233  function validateImageFile($file_details) {
 234      return Vtiger_Functions::validateImage($file_details);
 235  }
 236  
 237  /**
 238   *     This function is used to get the Email Template Details like subject and content for particular template.
 239   *     @param integer $templateid  - Template Id for an Email Template
 240   *     return array $returndata - Returns Subject, Body of Template of the the particular email template.
 241   */
 242  function getTemplateDetails($templateid) {
 243      return Vtiger_Deprecated::getTemplateDetails($templateid);
 244  }
 245  
 246  /**
 247   *     This function is used to merge the Template Details with the email description
 248   *  @param string $description  -body of the mail(ie template)
 249   *     @param integer $tid  - Id of the entity
 250   *  @param string $parent_type - module of the entity
 251   *     return string $description - Returns description, merged with the input template.
 252   */
 253  function getMergedDescription($description, $id, $parent_type) {
 254      return Vtiger_Functions::getMergedDescription($description, $id, $parent_type);
 255  }
 256  
 257  /**     Function used to retrieve a single field value from database
 258   *     @param string $tablename - tablename from which we will retrieve the field value
 259   *     @param string $fieldname - fieldname to which we want to get the value from database
 260   *     @param string $idname     - idname which is the name of the entity id in the table like, inoviceid, quoteid, etc.,
 261   *     @param int    $id     - entity id
 262   *     return string $fieldval  - field value of the needed fieldname from database will be returned
 263   */
 264  function getSingleFieldValue($tablename, $fieldname, $idname, $id) {
 265      return Vtiger_Functions::getSingleFieldValue($tablename, $fieldname, $idname, $id);
 266  }
 267  
 268  /**     Function used to retrieve the announcements from database
 269   *     The function accepts no argument and returns the announcements
 270   *     return string $announcement  - List of announments for the CRM users
 271   */
 272  function get_announcements() {
 273      return Vtiger_Deprecated::getAnnouncements();
 274  }
 275  
 276  /**
 277   *  Function to get recurring info depending on the recurring type
 278   *  return  $recurObj       - Object of class RecurringType
 279   */
 280  function getrecurringObjValue() {
 281      return Vtiger_Functions::getRecurringObjValue();
 282  }
 283  
 284  function getTranslatedString($str, $module = 'Vtiger') {
 285      return Vtiger_Functions::getTranslatedString($str, $module);
 286  }
 287  
 288  /**
 289   * Get translated currency name string.
 290   * @param String $str - input currency name
 291   * @return String $str - translated currency name
 292   */
 293  function getTranslatedCurrencyString($str) {
 294      return Vtiger_Deprecated::getTranslatedCurrencyString($str);
 295      }
 296  
 297  function getTicketComments($ticketid) {
 298      return Vtiger_Functions::getTicketComments($ticketid);
 299  }
 300  
 301  function makeRandomPassword() {
 302      return Vtiger_Functions::generateRandomPassword();
 303  }
 304  
 305  /**
 306   * This function is used to get cvid of default "all" view for any module.
 307   * @return a cvid of a module
 308   */
 309  function getCvIdOfAll($module) {
 310      return Vtiger_Deprecated::getIdOfCustomViewByNameAll($module);
 311  }
 312  
 313  /** gives the option  to display  the tagclouds or not for the current user
 314   * * @param $id -- user id:: Type integer
 315   * * @returns true or false in $tag_cloud_view
 316   * * Added to provide User based Tagcloud
 317   * */
 318  function getTagCloudView($id = "") {
 319      return Vtiger_Functions::getTagCloudView($id);
 320  }
 321  
 322  /** Stores the option in database to display  the tagclouds or not for the current user
 323   * * @param $id -- user id:: Type integer
 324   * * Added to provide User based Tagcloud
 325   * */
 326  function SaveTagCloudView($id = "") {
 327      return Vtiger_Deprecated::SaveTagCloudView($id);
 328  }
 329  
 330  /**     function used to change the Type of Data for advanced filters in custom view and Reports
 331   * *     @param string $table_name - tablename value from field table
 332   * *     @param string $column_nametable_name - columnname value from field table
 333   * *     @param string $type_of_data - current type of data of the field. It is to return the same TypeofData
 334   * *            if the  field is not matched with the $new_field_details array.
 335   * *     return string $type_of_data - If the string matched with the $new_field_details array then the Changed
 336   * *           typeofdata will return, else the same typeofdata will return.
 337   * *
 338   * *     EXAMPLE: If you have a field entry like this:
 339   * *
 340   * *         fieldlabel         | typeofdata | tablename            | columnname       |
 341   * *            -------------------+------------+----------------------+------------------+
 342   * *        Potential Name     | I~O        | vtiger_quotes        | potentialid      |
 343   * *
 344   * *     Then put an entry in $new_field_details  like this:
 345   * *
 346   * *                "vtiger_quotes:potentialid"=>"V",
 347   * *
 348   * *    Now in customview and report's advance filter this field's criteria will be show like string.
 349   * *
 350   * */
 351  function ChangeTypeOfData_Filter($table_name, $column_name, $type_of_data) {
 352      return Vtiger_Functions::transformFieldTypeOfData($table_name, $column_name, $type_of_data);
 353  }
 354  
 355  /** Clear the Smarty cache files(in Smarty/smarty_c)
 356   * * This function will called after migration.
 357   * */
 358  function clear_smarty_cache($path = null) {
 359      Vtiger_Deprecated::clearSmartyCompiledFiles($path);
 360  }
 361  
 362  /** Get Smarty compiled file for the specified template filename.
 363   * * @param $template_file Template filename for which the compiled file has to be returned.
 364   * * @return Compiled file for the specified template file.
 365   * */
 366  function get_smarty_compiled_file($template_file, $path = null) {
 367      return Vtiger_Deprecated::getSmartyCompiledTemplateFile($template_file, $path);
 368  }
 369  
 370  /** Function to carry out all the necessary actions after migration */
 371  function perform_post_migration_activities() {
 372      Vtiger_Deprecated::postApplicationMigrationTasks();
 373  }
 374  
 375  /** Function to get picklist values for the given field that are accessible for the given role.
 376   *  @ param $tablename picklist fieldname.
 377   *  It gets the picklist values for the given fieldname
 378   *      $fldVal = Array(0=>value,1=>value1,-------------,n=>valuen)
 379   *  @return Array of picklist values accessible by the user.
 380   */
 381  function getPickListValues($tablename, $roleid) {
 382      return Vtiger_Functions::getPickListValuesFromTableForRole($tablename, $roleid);
 383  }
 384  
 385  /** Function to check the file access is made within web root directory and whether it is not from unsafe directories */
 386  function checkFileAccessForInclusion($filepath) {
 387      Vtiger_Deprecated::checkFileAccessForInclusion($filepath);
 388  }
 389  
 390  /** Function to check the file deletion within the deletable (safe) directories*/
 391  function checkFileAccessForDeletion($filepath) {
 392      Vtiger_Deprecated::checkFileAccessForDeletion($filepath);
 393  }
 394  
 395  /** Function to check the file access is made within web root directory. */
 396  function checkFileAccess($filepath) {
 397      Vtiger_Deprecated::checkFileAccess($filepath);
 398  }
 399  
 400  /**
 401   * function to return whether the file access is made within vtiger root directory
 402   * and it exists.
 403   * @global String $root_directory vtiger root directory as given in config.inc.php file.
 404   * @param String $filepath relative path to the file which need to be verified
 405   * @return Boolean true if file is a valid file within vtiger root directory, false otherwise.
 406   */
 407  function isFileAccessible($filepath) {
 408      return Vtiger_Deprecated::isFileAccessible($filepath);
 409  }
 410  
 411  /** Function to get the ActivityType for the given entity id
 412   *  @param entityid : Type Integer
 413   *  return the activity type for the given id
 414   */
 415  function getActivityType($id) {
 416      return Vtiger_Functions::getActivityType($id);
 417  }
 418  
 419  /** Function to get owner name either user or group */
 420  function getOwnerName($id) {
 421      return Vtiger_Functions::getOwnerRecordLabel($id);
 422  }
 423  
 424  /** Function to get owner name either user or group */
 425  function getOwnerNameList($idList) {
 426      return Vtiger_Functions::getOwnerRecordLabels($idList);
 427  }
 428  
 429  /**
 430   * This function is used to get the blockid of the settings block for a given label.
 431   * @param $label - settings label
 432   * @return string type value
 433   */
 434  function getSettingsBlockId($label) {
 435      return Vtiger_Deprecated::getSettingsBlockId($label);
 436  }
 437  
 438  /**
 439   * this function returns the entity field name for a given module; for e.g. for Contacts module it return concat(lastname, ' ', firstname)
 440   * @param string $module - the module name
 441   * @return string $fieldsname - the entity field name for the module
 442   */
 443  function getEntityField($module) {
 444      return Vtiger_Functions::getEntityModuleSQLColumnString($module);
 445  }
 446  
 447  /**
 448   * this function returns the entity information for a given module; for e.g. for Contacts module
 449   * it returns the information of tablename, modulename, fieldsname and id gets from vtiger_entityname
 450   * @param string $module - the module name
 451   * @return array $data - the entity information for the module
 452   */
 453  function getEntityFieldNames($module) {
 454      return Vtiger_Functions::getEntityModuleInfoFieldsFormatted($module);
 455  }
 456  
 457  /**
 458   * this function returns the entity field name for a given module; for e.g. for Contacts module it return concat(lastname, ' ', firstname)
 459   * @param1 $module - name of the module
 460   * @param2 $fieldsName - fieldname with respect to module (ex : 'Accounts' - 'accountname', 'Contacts' - 'lastname','firstname')
 461   * @param3 $fieldValues - array of fieldname and its value
 462   * @return string $fieldConcatName - the entity field name for the module
 463   */
 464  function getEntityFieldNameDisplay($module, $fieldsName, $fieldValues) {
 465      return Vtiger_Deprecated::getCurrentUserEntityFieldNameDisplay($module, $fieldsName, $fieldValues);
 466  }
 467  
 468  // vtiger cache utility
 469  require_once ('include/utils/VTCacheUtils.php');
 470  
 471  // vtlib customization: Extended vtiger CRM utlitiy functions
 472  require_once ('include/utils/VtlibUtils.php');
 473  
 474  // END
 475  
 476  function vt_suppressHTMLTags($string) {
 477      return Vtiger_Functions::suppressHTMLTags($string);
 478  }
 479  
 480  function getSqlForNameInDisplayFormat($input, $module, $glue = ' ') {
 481      return Vtiger_Deprecated::getSqlForNameInDisplayFormat($input, $module, $glue);
 482  }
 483  
 484  function getModuleSequenceNumber($module, $recordId) {
 485      return Vtiger_Deprecated::getModuleSequenceNumber($module, $recordId);
 486      }
 487  
 488  function getInvoiceStatus($invoiceId) {
 489      return Vtiger_Functions::getInvoiceStatus($invoiceId);
 490  }
 491  
 492  function decimalFormat($value){
 493      return Vtiger_Functions::formatDecimal($value);
 494  }
 495  
 496  function updateRecordLabel($module,$recordId){
 497      return Vtiger_Functions::updateCRMRecordLabel($module, $recordId);
 498  }
 499  
 500  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1