0){ return @chmod($filename, $mode); }else{ return false; } } return true; } /** * sugar_chown * Attempts to change the owner of the file filename to the user specified in the * default_permissions configuration; otherwise, it will use the user value. * * @param filename - Path to the file * @param user - A user name or number * @return boolean - Returns TRUE on success or FALSE on failure. */ function sugar_chown($filename, $user='') { if(!is_windows()){ if(strlen($user)){ return chown($filename, $user); }else{ if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){ $user = $GLOBALS['sugar_config']['default_permissions']['user']; return chown($filename, $user); }else{ return false; } } } return true; } /** * sugar_chgrp * Attempts to change the group of the file filename to the group specified in the * default_permissions configuration; otherwise it will use the group value. * * @param filename - Path to the file * @param group - A group name or number * @return boolean - Returns TRUE on success or FALSE on failure. */ function sugar_chgrp($filename, $group='') { if(!is_windows()){ if(!empty($group)){ return chgrp($filename, $group); }else{ if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ $group = $GLOBALS['sugar_config']['default_permissions']['group']; return chgrp($filename, $group); }else{ return false; } } } return true; } /** * get_mode * * Will check to see if there is a default mode defined in the config file, otherwise return the * $mode given as input * * @param int $mode - the mode being passed by the calling function. This value will be overridden by a value * defined in the config file. * @return int - the mode either found in the config file or passed in via the input parameter */ function get_mode($key = 'dir_mode', $mode=null) { if ( !is_int($mode) ) $mode = (int) $mode; if(!class_exists('SugarConfig', true)) { require 'include/SugarObjects/SugarConfig.php'; } if(!is_windows()){ $conf_inst=SugarConfig::getInstance(); $mode = $conf_inst->get('default_permissions.'.$key, $mode); } return $mode; } function sugar_is_dir($path, $mode='r'){ if(defined('TEMPLATE_URL'))return is_dir($path, $mode); return is_dir($path); } function sugar_is_file($path, $mode='r'){ if(defined('TEMPLATE_URL'))return is_file($path, $mode); return is_file($path); } ?>