function translatePath($file) { if (empty($file)) { return null; } jimport('joomla.client.ftp'); // Initialize variables jimport('joomla.client.helper'); $FTPOptions = JClientHelper::getCredentials('ftp'); if (JD_Ftp::getFtpHandle()) { // Translate path for the FTP account and use FTP write buffer to file return JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); } return $file; }
function chmod($permission) { $permission = (int) $permission & 0777; // First, try simple chmod if (@chmod($this->_filename, $permission)) { return true; } else { // try FTP $ftp =& JD_Ftp::getFtpHandle(); // FTP Mode enabled if ($ftp) { $file = JD_Ftp::translatePath($this->_filename); // ignore ftp errors messages JD_Error::unsetErrorHandlers(); $result = $ftp->chmod($file, $permission); JD_Error::putErrorHandlersBack(); if (false === $result) { $this->setError($this->_getPersmissionError($permission)); return false; } return true; } else { // Return the error $error = $this->_getPersmissionError($permission); $this->setError($error); return false; } } }