当前位置: 首页>>代码示例>>PHP>>正文


PHP sugar_rename函数代码示例

本文整理汇总了PHP中sugar_rename函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_rename函数的具体用法?PHP sugar_rename怎么用?PHP sugar_rename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sugar_rename函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renameDisabled

 public function renameDisabled($files)
 {
     foreach ($files as $fileFrom => $fileTo) {
         sugar_mkdir(dirname($fileTo), null, true);
         sugar_rename($fileFrom, $fileTo);
         $this->log('Custom view ' . $fileFrom . ' should be disabled (moved to ' . $fileTo . ')');
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:8,代码来源:7_DisableViews.php

示例2: run

 public function run()
 {
     if (version_compare($this->from_version, 7, '<')) {
         $path = 'custom/Extension/application/Ext/Include/';
         sugar_mkdir($path . 'Disabled/', null, true);
         foreach ($this->modules as $module) {
             $file = $module . '.php';
             if (file_exists($path . $file)) {
                 sugar_rename($path . $file, $path . "Disabled/" . $file);
                 $this->log("Unsupported module {$module} disabled");
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:14,代码来源:8_RemoveModules.php

示例3: upgrade_aos

function upgrade_aos()
{
    global $sugar_config, $db;
    if (!isset($sugar_config['aos']['version']) || $sugar_config['aos']['version'] < 5.2) {
        $db->query("UPDATE  aos_pdf_templates SET type = 'AOS_Quotes' WHERE type = 'Quotes'");
        $db->query("UPDATE  aos_pdf_templates SET type = 'AOS_Invoices' WHERE type = 'Invoices'");
        require_once 'include/utils/file_utils.php';
        $old_files = array('custom/Extension/modules/Accounts/Ext/Layoutdefs/Account.php', 'custom/Extension/modules/Accounts/Ext/Vardefs/Account.php', 'custom/Extension/modules/Contacts/Ext/Layoutdefs/Contact.php', 'custom/Extension/modules/Contacts/Ext/Vardefs/Contact.php', 'custom/Extension/modules/Opportunities/Ext/Layoutdefs/Opportunity.php', 'custom/Extension/modules/Opportunities/Ext/Vardefs/Opportunity.php', 'custom/Extension/modules/Project/Ext/Layoutdefs/Project.php', 'custom/Extension/modules/Project/Ext/Vardefs/Project.php', 'modules/AOS_Quotes/js/Quote.js');
        foreach ($old_files as $old_file) {
            if (file_exists($old_file)) {
                create_custom_directory('bak_aos/' . $old_file);
                sugar_rename($old_file, 'custom/bak_aos/' . $old_file);
            }
        }
    }
}
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:16,代码来源:AdvancedOpenSales.php

示例4: rollLog

 private function rollLog($force = false)
 {
     if (!$this->initialized || empty($this->logSize)) {
         return;
     }
     // lets get the number of megs we are allowed to have in the file
     $megs = substr($this->logSize, 0, strlen($this->logSize) - 2);
     //convert it to bytes
     $rollAt = (int) $megs * 1024 * 1024;
     //check if our log file is greater than that or if we are forcing the log to roll
     if ($force || filesize($this->logfile . $this->ext) >= $rollAt) {
         //now lets move the logs starting at the oldest and going to the newest
         for ($i = $this->maxLogs - 2; $i > 0; $i--) {
             if (file_exists($this->logfile . $i . $this->ext)) {
                 $to = $i + 1;
                 $old_name = $this->logfile . $i . $this->ext;
                 $new_name = $this->logfile . $to . $this->ext;
                 //nsingh- Bug 22548  Win systems fail if new file name already exists. The fix below checks for that.
                 //if/else branch is necessary as suggested by someone on php-doc ( see rename function ).
                 sugar_rename($old_name, $new_name);
                 //rename ( $this->logfile . $i . $this->ext, $this->logfile . $to . $this->ext );
             }
         }
         //now lets move the current .log file
         sugar_rename($this->logfile . $this->ext, $this->logfile . '1' . $this->ext);
     }
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:27,代码来源:SugarLogger.php

示例5: addFont

 /**
  * This method add a font to SugarCRM from a font file and a metric file using MakeFont()
  * @param $font_file string
  * @param $metric_file string
  * @param $embedded boolean
  * @param $encoding_table string
  * @param $patch array
  * @param $cid_info string
  * @param $style string
  * @return boolean true on success
  * @see MakeFont() in K_PATH_FONTS/utils
  */
 public function addFont($font_file, $metric_file, $embedded = true, $encoding_table = 'cp1252', $patch = array(), $cid_info = "", $style = "regular")
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $error = false;
     $oldStr = ob_get_contents();
     ob_clean();
     require_once "include/tcpdf/fonts/utils/makefont.php";
     $filename = MakeFont($font_file, $metric_file, $embedded, $encoding_table, $patch, $cid_info);
     unlink($font_file);
     unlink($metric_file);
     $this->log = ob_get_contents();
     ob_clean();
     echo $oldStr;
     if (empty($filename)) {
         array_push($this->errors, translate("ERR_FONT_MAKEFONT", "Configurator"));
         $error = true;
     } else {
         require_once "include/utils/file_utils.php";
         $this->filename = basename($filename . ".php");
         if (!$this->loadFontFile()) {
             if (!mkdir_recursive(K_PATH_CUSTOM_FONTS)) {
                 array_push($this->errors, "Error : Impossible to create the custom font directory.");
                 $error = true;
             } else {
                 $styleLetter = "";
                 switch ($style) {
                     case "italic":
                         $styleLetter = "i";
                         break;
                     case "bold":
                         $styleLetter = "b";
                         break;
                     case "boldItalic":
                         $styleLetter = "bi";
                         break;
                     default:
                         $styleLetter = "";
                 }
                 sugar_rename($filename . ".php", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".php"));
                 $this->log .= "\n" . translate("LBL_FONT_MOVE_DEFFILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".php");
                 if (file_exists($filename . ".z")) {
                     sugar_rename($filename . ".z", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".z"));
                     $this->log .= "\n" . translate("LBL_FONT_MOVE_FILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".z");
                 }
                 if (file_exists($filename . ".ctg.z")) {
                     sugar_rename($filename . ".ctg.z", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".ctg.z"));
                     $this->log .= "\n" . translate("LBL_FONT_MOVE_FILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".ctg.z");
                 }
             }
         } else {
             array_push($this->errors, "\n" . translate("ERR_FONT_ALREADY_EXIST", "Configurator"));
             $error = true;
         }
         if ($error) {
             if (file_exists($filename . ".php")) {
                 unlink($filename . ".php");
             }
             if (file_exists($filename . ".ctg.z")) {
                 unlink($filename . ".ctg.z");
             }
             if (file_exists($filename . ".z")) {
                 unlink($filename . ".z");
             }
         }
     }
     $this->clearCachedFile();
     return $error;
 }
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:83,代码来源:FontManager.php

示例6: restoreFiles

 /**
  * Restores files from deleted folder
  *
  * @return bool success of operation
  */
 protected function restoreFiles()
 {
     if (!$this->id) {
         return true;
     }
     if (!$this->haveFiles()) {
         return true;
     }
     $files = $this->getFiles();
     if (empty($files)) {
         return true;
     }
     $directory = $this->deleteFileDirectory();
     foreach ($files as $file) {
         if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) {
             if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) {
                 $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory');
             }
         }
     }
     /**
      * @var DBManager $db
      */
     global $db;
     $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id));
     return true;
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:32,代码来源:SugarBean.php

示例7: foreach

 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
require "include/modules.php";
require_once "include/utils/sugar_file_utils.php";
foreach ($beanFiles as $classname => $filename) {
    if (file_exists($filename)) {
        // Rename the class and its constructor adding SugarCore at the beginning  (Ex: class SugarCoreCall)
        $handle = file_get_contents($filename);
        $patterns = array('/class ' . $classname . '/', '/function ' . $classname . '/');
        $replace = array('class SugarCore' . $classname, 'function SugarCore' . $classname);
        $data = preg_replace($patterns, $replace, $handle);
        sugar_file_put_contents($filename, $data);
        // Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php)
        $pos = strrpos($filename, "/");
        $newfilename = substr_replace($filename, 'SugarCore.', $pos + 1, 0);
        sugar_rename($filename, $newfilename);
        //Create a new SugarBean that extends CoreBean
        $fileHandle = sugar_fopen($filename, 'w');
        $newclass = <<<FABRICE
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*
 * Your installation or use of this SugarCRM file is subject to the applicable
 * terms available at
 * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
 * If you do not agree to all of the applicable terms or do not have the
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:31,代码来源:updateclass.php

示例8: upload_doc

 /**
  * Upload document to external service
  * @param SugarBean $bean Related bean
  * @param string $bean_id
  * @param string $doc_type
  * @param string $file_name
  * @param string $mime_type
  */
 function upload_doc($bean, $bean_id, $doc_type, $file_name, $mime_type)
 {
     if (!empty($doc_type) && $doc_type != 'Sugar') {
         global $sugar_config;
         $destination = $this->get_upload_path($bean_id);
         sugar_rename($destination, str_replace($bean_id, $bean_id . '_' . $file_name, $destination));
         $new_destination = $this->get_upload_path($bean_id . '_' . $file_name);
         try {
             $this->api = ExternalAPIFactory::loadAPI($doc_type);
             if (isset($this->api) && $this->api !== false) {
                 $result = $this->api->uploadDoc($bean, $new_destination, $file_name, $mime_type);
             } else {
                 $result['success'] = FALSE;
                 // FIXME: Translate
                 $GLOBALS['log']->error("Could not load the requested API (" . $doc_type . ")");
                 $result['errorMessage'] = 'Could not find a proper API';
             }
         } catch (Exception $e) {
             $result['success'] = FALSE;
             $result['errorMessage'] = $e->getMessage();
             $GLOBALS['log']->error("Caught exception: (" . $e->getMessage() . ") ");
         }
         if (!$result['success']) {
             sugar_rename($new_destination, str_replace($bean_id . '_' . $file_name, $bean_id, $new_destination));
             $bean->doc_type = 'Sugar';
             // FIXME: Translate
             if (!is_array($_SESSION['user_error_message'])) {
                 $_SESSION['user_error_message'] = array();
             }
             $error_message = isset($result['errorMessage']) ? $result['errorMessage'] : $GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL'];
             $_SESSION['user_error_message'][] = $error_message;
         } else {
             unlink($new_destination);
         }
     }
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:44,代码来源:upload_file.php

示例9: testsugar_rename

 public function testsugar_rename()
 {
     //execute the method and test if it returns true/success
     $dir = 'vfs://root';
     $file = 'test.txt';
     $vfs = $this->rootFs;
     if ($vfs->hasChild($file) != true) {
         write_array_to_file('', '', $dir . '/' . $file);
     }
     //test with empty file names
     $actual = sugar_rename('', '');
     $this->assertFalse($actual);
     //test with valid file names
     $actual = sugar_rename($dir . '/' . $file, $dir . '/' . 'newtest.txt');
     $this->assertTrue($actual);
     unlink($dir . '/' . 'newtest.txt');
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:17,代码来源:fileUtilsTest.php

示例10: deleteFiles

 /**
  * Moves file to deleted folder
  *
  * @return bool success of movement
  */
 public function deleteFiles()
 {
     if (!$this->id) {
         return true;
     }
     if (!$this->haveFiles()) {
         return true;
     }
     $files = $this->getFiles();
     if (empty($files)) {
         return true;
     }
     $directory = $this->deleteFileDirectory();
     $isCreated = sugar_is_dir('upload://deleted/' . $directory);
     if (!$isCreated) {
         sugar_mkdir('upload://deleted/' . $directory, 0777, true);
         $isCreated = sugar_is_dir('upload://deleted/' . $directory);
     }
     if (!$isCreated) {
         return false;
     }
     foreach ($files as $file) {
         if (file_exists('upload://' . $file)) {
             if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) {
                 $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory');
             }
         }
     }
     /**
      * @var DBManager $db
      */
     global $db;
     $record = array('bean_id' => $db->quoted($this->id), 'module' => $db->quoted($this->module_name), 'date_modified' => $db->convert($db->quoted(date('Y-m-d H:i:s')), 'datetime'));
     $recordDB = $db->fetchOne("SELECT id FROM cron_remove_documents WHERE module={$record['module']} AND bean_id={$record['bean_id']}");
     if (!empty($recordDB)) {
         $record['id'] = $db->quoted($recordDB['id']);
     }
     if (empty($record['id'])) {
         $record['id'] = $db->quoted(create_guid());
         $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')');
     } else {
         $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}");
     }
     return true;
 }
开发者ID:auf,项目名称:crm_auf_org,代码行数:50,代码来源:SugarBean.php

示例11: rollLog

 /**
  * rolls the logger file to start using a new file
  */
 protected function rollLog($force = false)
 {
     if (!$this->initialized || empty($this->logSize)) {
         return;
     }
     // bug#50265: Parse the its unit string and get the size properly
     $units = array('b' => 1, 'k' => 1024, 'm' => 1024 * 1024, 'g' => 1024 * 1024 * 1024);
     if (preg_match('/^\\s*([0-9]+\\.[0-9]+|\\.?[0-9]+)\\s*(k|m|g|b)(b?ytes)?/i', $this->logSize, $match)) {
         $rollAt = (int) $match[1] * $units[strtolower($match[2])];
     }
     //check if our log file is greater than that or if we are forcing the log to roll if and only if roll size assigned the value correctly
     if ($force || $rollAt && filesize($this->full_log_file) >= $rollAt) {
         //now lets move the logs starting at the oldest and going to the newest
         for ($i = $this->maxLogs - 2; $i > 0; $i--) {
             if (file_exists($this->log_dir . $this->logfile . $this->date_suffix . '_' . $i . $this->ext)) {
                 $to = $i + 1;
                 $old_name = $this->log_dir . $this->logfile . $this->date_suffix . '_' . $i . $this->ext;
                 $new_name = $this->log_dir . $this->logfile . $this->date_suffix . '_' . $to . $this->ext;
                 //nsingh- Bug 22548  Win systems fail if new file name already exists. The fix below checks for that.
                 //if/else branch is necessary as suggested by someone on php-doc ( see rename function ).
                 sugar_rename($old_name, $new_name);
                 //rename ( $this->logfile . $i . $this->ext, $this->logfile . $to . $this->ext );
             }
         }
         //now lets move the current .log file
         sugar_rename($this->full_log_file, $this->log_dir . $this->logfile . $this->date_suffix . '_1' . $this->ext);
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:31,代码来源:SugarLogger.php


注:本文中的sugar_rename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。