本文整理汇总了PHP中CRM_Utils_File::createDir方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::createDir方法的具体用法?PHP CRM_Utils_File::createDir怎么用?PHP CRM_Utils_File::createDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_File
的用法示例。
在下文中一共展示了CRM_Utils_File::createDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
public static function upload($params)
{
if (!$_FILES) {
throw new CRM_Extension_Exception('Sorry, the file you uploaded was too large or invalid. Code 1', 500);
}
if (empty($_FILES['file']['size'])) {
throw new CRM_Extension_Exception('Sorry, the file you uploaded was too large or invalid. Code 2', 500);
}
$tempFile = $_FILES['file']['tmp_name'];
$originalFilename = CRM_Simplemail_BAO_SimpleMailHelper::cleanFilename($_FILES['file']['name']);
$fileName = CRM_Utils_File::makeFileName(CRM_Simplemail_BAO_SimpleMailHelper::cleanFilename($_FILES['file']['name']));
$dirName = CRM_Simplemail_BAO_SimpleMailHelper::getUploadDirPath(static::DIRECTORY);
// Create the upload directory, if it doesn't already exist
CRM_Utils_File::createDir($dirName);
$file = $dirName . $fileName;
// Move the uploaded file to the upload directory
if (move_uploaded_file($tempFile, $file)) {
$url = CRM_Simplemail_BAO_SimpleMailHelper::getUploadUrl($fileName, static::DIRECTORY);
$databaseId = static::saveToDatabase($params['simplemail_id'], $originalFilename, $url);
$result['values'] = array(array('url' => $url, 'filename' => $originalFilename, 'databaseId' => $databaseId));
return $result;
} else {
throw new CRM_Extension_Exception('Failed to move the uploaded file', 500);
}
}
开发者ID:jaapjansma,项目名称:uk.co.compucorp.civicrm.simplemail,代码行数:25,代码来源:SimpleMailInlineAttachment.php
示例2: __construct
/**
* @param string $repoUrl
* URL of the remote repository.
* @param string $indexPath
* Relative path of the 'index' file within the repository.
* @param string $cacheDir
* Local path in which to cache files.
*/
public function __construct($repoUrl, $indexPath, $cacheDir)
{
$this->repoUrl = $repoUrl;
$this->cacheDir = $cacheDir;
$this->indexPath = empty($indexPath) ? self::SINGLE_FILE_PATH : $indexPath;
if ($cacheDir && !file_exists($cacheDir) && is_dir(dirname($cacheDir)) && is_writable(dirname($cacheDir))) {
CRM_Utils_File::createDir($cacheDir, FALSE);
}
}
示例3: filePostProcess
public function filePostProcess($data, $fileID, $entityTable, $entityID, $entitySubtype, $overwrite = true, $fileParams = null, $uploadName = 'uploadFile', $mimeType)
{
require_once 'CRM/Core/DAO/File.php';
$config =& CRM_Core_Config::singleton();
$path = explode('/', $data);
$filename = $path[count($path) - 1];
// rename this file to go into the secure directory
if ($entitySubtype) {
$directoryName = $config->customFileUploadDir . $entitySubtype . DIRECTORY_SEPARATOR . $entityID;
} else {
$directoryName = $config->customFileUploadDir;
}
require_once "CRM/Utils/File.php";
CRM_Utils_File::createDir($directoryName);
if (!rename($data, $directoryName . DIRECTORY_SEPARATOR . $filename)) {
CRM_Core_Error::fatal(ts('Could not move custom file to custom upload directory'));
break;
}
// to get id's
if ($overwrite && $fileID) {
list($sql, $params) = self::sql($entityTable, $entityID, $fileID);
} else {
list($sql, $params) = self::sql($entityTable, $entityID, 0);
}
$dao =& CRM_Core_DAO::executeQuery($sql, $params);
$dao->fetch();
if (!$mimeType) {
CRM_Core_Error::fatal();
}
require_once "CRM/Core/DAO/File.php";
$fileDAO =& new CRM_Core_DAO_File();
if (isset($dao->cfID) && $dao->cfID) {
$fileDAO->id = $dao->cfID;
unlink($directoryName . DIRECTORY_SEPARATOR . $dao->uri);
}
if (!empty($fileParams)) {
$fileDAO->copyValues($fileParams);
}
$fileDAO->uri = $filename;
$fileDAO->mime_type = $mimeType;
$fileDAO->file_type_id = $fileID;
$fileDAO->upload_date = date('Ymdhis');
$fileDAO->save();
// need to add/update civicrm_entity_file
require_once "CRM/Core/DAO/EntityFile.php";
$entityFileDAO =& new CRM_Core_DAO_EntityFile();
if (isset($dao->cefID) && $dao->cefID) {
$entityFileDAO->id = $dao->cefID;
}
$entityFileDAO->entity_table = $entityTable;
$entityFileDAO->entity_id = $entityID;
$entityFileDAO->file_id = $fileDAO->id;
$entityFileDAO->save();
}
示例4: initialize
private function initialize()
{
$config = CRM_Core_Config::singleton();
if (isset($config->customTemplateDir) && $config->customTemplateDir) {
$this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
} else {
$this->template_dir = $config->templateDir;
}
$this->compile_dir = CRM_Utils_File::addTrailingSlash(CRM_Utils_File::addTrailingSlash($config->templateCompileDir) . $this->getLocale());
CRM_Utils_File::createDir($this->compile_dir);
CRM_Utils_File::restrictAccess($this->compile_dir);
// check and ensure it is writable
// else we sometime suppress errors quietly and this results
// in blank emails etc
if (!is_writable($this->compile_dir)) {
echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
exit;
}
//Check for safe mode CRM-2207
if (ini_get('safe_mode')) {
$this->use_sub_dirs = FALSE;
} else {
$this->use_sub_dirs = TRUE;
}
$customPluginsDir = NULL;
if (isset($config->customPHPPathDir)) {
$customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
if (!file_exists($customPluginsDir)) {
$customPluginsDir = NULL;
}
}
$smartyDir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR;
$pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
if ($customPluginsDir) {
$this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir);
} else {
$this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir);
}
// add the session and the config here
$session = CRM_Core_Session::singleton();
$this->assign_by_ref('config', $config);
$this->assign_by_ref('session', $session);
global $tsLocale;
$this->assign('tsLocale', $tsLocale);
// CRM-7163 hack: we don’t display langSwitch on upgrades anyway
if (!CRM_Core_Config::isUpgradeMode()) {
$this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
}
$this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
$this->load_filter('pre', 'resetExtScope');
$this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
}
示例5: createDir
function createDir()
{
require_once 'CRM/Utils/File.php';
// ensure that $this->_mailDir is a directory and is writable
if (!is_dir($this->_mailDir) || !is_readable($this->_mailDir)) {
echo "Could not read from {$this->_mailDir}\n";
exit;
}
$config =& CRM_Core_Config::singleton();
$dir = $config->uploadDir . DIRECTORY_SEPARATOR . 'mail';
$this->_processedDir = $dir . DIRECTORY_SEPARATOR . 'processed';
CRM_Utils_File::createDir($this->_processedDir);
$this->_errorDir = $dir . DIRECTORY_SEPARATOR . 'error';
CRM_Utils_File::createDir($this->_errorDir);
// create a date string YYYYMMDD
require_once 'CRM/Utils/Date.php';
$date = CRM_Utils_Date::getToday(null, 'Ymd');
$this->_processedDir = $this->_processedDir . DIRECTORY_SEPARATOR . $date;
CRM_Utils_File::createDir($this->_processedDir);
$this->_errorDir = $this->_errorDir . DIRECTORY_SEPARATOR . $date;
CRM_Utils_File::createDir($this->_errorDir);
}
示例6: filePostProcess
static function filePostProcess($data, $fileTypeID, $entityTable, $entityID, $entitySubtype, $overwrite = TRUE, $fileParams = NULL, $uploadName = 'uploadFile', $mimeType = null)
{
if (!$mimeType) {
CRM_Core_Error::fatal(ts('Mime Type is now a required parameter'));
}
$config = CRM_Core_Config::singleton();
$path = explode('/', $data);
$filename = $path[count($path) - 1];
// rename this file to go into the secure directory
if ($entitySubtype) {
$directoryName = $config->customFileUploadDir . $entitySubtype . DIRECTORY_SEPARATOR . $entityID;
} else {
$directoryName = $config->customFileUploadDir;
}
CRM_Utils_File::createDir($directoryName);
if (!rename($data, $directoryName . DIRECTORY_SEPARATOR . $filename)) {
CRM_Core_Error::fatal(ts('Could not move custom file to custom upload directory'));
break;
}
// to get id's
if ($overwrite && $fileTypeID) {
list($sql, $params) = self::sql($entityTable, $entityID, $fileTypeID);
} else {
list($sql, $params) = self::sql($entityTable, $entityID, 0);
}
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$dao->fetch();
$fileDAO = new CRM_Core_DAO_File();
$op = 'create';
if (isset($dao->cfID) && $dao->cfID) {
$op = 'edit';
$fileDAO->id = $dao->cfID;
unlink($directoryName . DIRECTORY_SEPARATOR . $dao->uri);
}
if (!empty($fileParams)) {
$fileDAO->copyValues($fileParams);
}
$fileDAO->uri = $filename;
$fileDAO->mime_type = $mimeType;
$fileDAO->file_type_id = $fileTypeID;
$fileDAO->upload_date = date('Ymdhis');
$fileDAO->save();
// need to add/update civicrm_entity_file
$entityFileDAO = new CRM_Core_DAO_EntityFile();
if (isset($dao->cefID) && $dao->cefID) {
$entityFileDAO->id = $dao->cefID;
}
$entityFileDAO->entity_table = $entityTable;
$entityFileDAO->entity_id = $entityID;
$entityFileDAO->file_id = $fileDAO->id;
$entityFileDAO->save();
//save static tags
if (!empty($fileParams['tag'])) {
CRM_Core_BAO_EntityTag::create($fileParams['tag'], 'civicrm_file', $entityFileDAO->id);
}
//save free tags
if (isset($fileParams['attachment_taglist']) && !empty($fileParams['attachment_taglist'])) {
CRM_Core_Form_Tag::postProcess($fileParams['attachment_taglist'], $entityFileDAO->id, 'civicrm_file', CRM_Core_DAO::$_nullObject);
}
// lets call the post hook here so attachments code can do the right stuff
CRM_Utils_Hook::post($op, 'File', $fileDAO->id, $fileDAO);
}
示例7: cleanup
/**
* Deletes the web server writable directories.
*
* @param int $value
* 1: clean templates_c, 2: clean upload, 3: clean both
* @param bool $rmdir
*/
public function cleanup($value, $rmdir = TRUE)
{
$value = (int) $value;
if ($value & 1) {
// clean templates_c
CRM_Utils_File::cleanDir($this->templateCompileDir, $rmdir);
CRM_Utils_File::createDir($this->templateCompileDir);
}
if ($value & 2) {
// clean upload dir
CRM_Utils_File::cleanDir($this->uploadDir);
CRM_Utils_File::createDir($this->uploadDir);
}
// Whether we delete/create or simply preserve directories, we should
// certainly make sure the restrictions are enforced.
foreach (array($this->templateCompileDir, $this->uploadDir, $this->configAndLogDir, $this->customFileUploadDir) as $dir) {
if ($dir && is_dir($dir)) {
CRM_Utils_File::restrictAccess($dir);
}
}
}
示例8: setValues
/**
* Set the default values.
* in an empty db, also called when setting component using GUI
*
* @param array $defaults
* Associated array of form elements.
* @param bool $formMode
* this variable is set true for GUI
* mode (eg: Global setting >> Components)
*
*/
public static function setValues(&$defaults, $formMode = FALSE)
{
$config = CRM_Core_Config::singleton();
$baseURL = $config->userFrameworkBaseURL;
// CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
// which needs to be stripped before we start basing ResourceURL on it
if ($config->userSystem->is_drupal) {
global $language;
if (isset($language->prefix) and $language->prefix) {
if (substr($baseURL, -(strlen($language->prefix) + 1)) == $language->prefix . '/') {
$baseURL = substr($baseURL, 0, -(strlen($language->prefix) + 1));
}
}
}
$baseCMSURL = CRM_Utils_System::baseCMSURL();
if ($config->templateCompileDir) {
$path = CRM_Utils_File::baseFilePath($config->templateCompileDir);
}
if (!isset($defaults['enableSSL'])) {
$defaults['enableSSL'] = 0;
}
//set defaults if not set in db
if (!isset($defaults['userFrameworkResourceURL'])) {
if ($config->userFramework == 'Joomla') {
$defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
} elseif ($config->userFramework == 'WordPress') {
$defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/";
} else {
// Drupal setting
// check and see if we are installed in sites/all (for D5 and above)
// we dont use checkURL since drupal generates an error page and throws
// the system for a loop on lobo's macosx box
// or in modules
global $civicrm_root;
$cmsPath = $config->userSystem->cmsRootPath();
$defaults['userFrameworkResourceURL'] = $baseURL . str_replace("{$cmsPath}/", '', str_replace('\\', '/', $civicrm_root));
if (strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules') === FALSE) {
$startPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR);
$endPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR);
if ($startPos && $endPos) {
// if component is in sites/SITENAME/modules
$siteName = substr($civicrm_root, $startPos + 7, $endPos - $startPos - 7);
$civicrmDirName = trim(basename($civicrm_root));
$defaults['userFrameworkResourceURL'] = $baseURL . "sites/{$siteName}/modules/{$civicrmDirName}/";
if (!isset($defaults['imageUploadURL'])) {
$defaults['imageUploadURL'] = $baseURL . "sites/{$siteName}/files/civicrm/persist/contribute/";
}
}
}
}
}
if (!isset($defaults['imageUploadURL'])) {
if ($config->userFramework == 'Joomla') {
// gross hack
// we need to remove the administrator/ from the end
$tempURL = str_replace("/administrator/", "/", $baseURL);
$defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
} elseif ($config->userFramework == 'WordPress') {
//for standalone no need of sites/defaults directory
$defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/";
} else {
$defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
}
}
if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir)) {
$imgDir = $path . "persist/contribute/";
CRM_Utils_File::createDir($imgDir);
$defaults['imageUploadDir'] = $imgDir;
}
if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir)) {
$uploadDir = $path . "upload/";
CRM_Utils_File::createDir($uploadDir);
CRM_Utils_File::restrictAccess($uploadDir);
$defaults['uploadDir'] = $uploadDir;
}
if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir)) {
$customDir = $path . "custom/";
CRM_Utils_File::createDir($customDir);
CRM_Utils_File::restrictAccess($customDir);
$defaults['customFileUploadDir'] = $customDir;
}
// FIXME: hack to bypass the step for generating defaults for components,
// while running upgrade, to avoid any serious non-recoverable error
// which might hinder the upgrade process.
$args = array();
if (isset($_GET[$config->userFrameworkURLVar])) {
$args = explode('/', $_GET[$config->userFrameworkURLVar]);
}
if (isset($defaults['enableComponents'])) {
//.........这里部分代码省略.........
示例9: cleanup
/**
* delete the web server writable directories
*
* @param int $value 1 - clean templates_c, 2 - clean upload, 3 - clean both
*
* @access public
* @return void
*/
public function cleanup($value)
{
$value = (int) $value;
if ($value & 1) {
// clean templates_c
CRM_Utils_File::cleanDir($this->templateCompileDir);
CRM_Utils_File::createDir($this->templateCompileDir);
}
if ($value & 2) {
// clean upload dir
CRM_Utils_File::cleanDir($this->uploadDir);
CRM_Utils_File::createDir($this->uploadDir);
}
}
示例10: __get
public function __get($k)
{
if (!isset($this->map[$k])) {
throw new \CRM_Core_Exception("Cannot read unrecognized property CRM_Core_Config::\${$k}.");
}
if (isset($this->cache[$k])) {
return $this->cache[$k];
}
$type = $this->map[$k][0];
$name = isset($this->map[$k][1]) ? $this->map[$k][1] : $k;
switch ($type) {
case 'setting':
return $this->getSettings()->get($name);
case 'setting-path':
// Array(0 => $type, 1 => $setting, 2 => $actions).
$value = $this->getSettings()->get($name);
$value = Civi::paths()->getPath($value);
if ($value) {
$value = CRM_Utils_File::addTrailingSlash($value);
if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) {
CRM_Utils_File::createDir($value);
}
if (isset($this->map[$k][2]) && in_array('restrict', $this->map[$k][2])) {
CRM_Utils_File::restrictAccess($value);
}
}
$this->cache[$k] = $value;
return $value;
case 'setting-url-abs':
$value = $this->getSettings()->get($name);
$this->cache[$k] = Civi::paths()->getUrl($value, 'absolute');
return $this->cache[$k];
case 'setting-url-rel':
$value = $this->getSettings()->get($name);
$this->cache[$k] = Civi::paths()->getUrl($value, 'relative');
return $this->cache[$k];
case 'runtime':
return \Civi\Core\Container::getBootService('runtime')->{$name};
case 'boot-svc':
$this->cache[$k] = \Civi\Core\Container::getBootService($name);
return $this->cache[$k];
case 'local':
$this->initLocals();
return $this->locals[$name];
case 'user-system':
$userSystem = \Civi\Core\Container::getBootService('userSystem');
$this->cache[$k] = call_user_func(array($userSystem, $name));
return $this->cache[$k];
case 'service':
return \Civi::service($name);
case 'callback':
// Array(0 => $type, 1 => $obj, 2 => $getter, 3 => $setter, 4 => $unsetter).
if (!isset($this->map[$k][1], $this->map[$k][2])) {
throw new \CRM_Core_Exception("Cannot find getter for property CRM_Core_Config::\${$k}");
}
return \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][2]), array($k));
default:
throw new \CRM_Core_Exception("Cannot read property CRM_Core_Config::\${$k} ({$type})");
}
}
示例11: logger
function logger(&$to, &$headers, &$message)
{
if (is_array($to)) {
$toString = implode(', ', $to);
$fileName = $to[0];
} else {
$toString = $fileName = $to;
}
$content = "To: " . $toString . "\n";
foreach ($headers as $key => $val) {
$content .= "{$key}: {$val}\n";
}
$content .= "\n" . $message . "\n";
if (is_numeric(CIVICRM_MAIL_LOG)) {
$config = CRM_Core_Config::singleton();
// create the directory if not there
$dirName = $config->configAndLogDir . 'mail' . DIRECTORY_SEPARATOR;
CRM_Utils_File::createDir($dirName);
$fileName = md5(uniqid(CRM_Utils_String::munge($fileName))) . '.txt';
file_put_contents($dirName . $fileName, $content);
} else {
file_put_contents(CIVICRM_MAIL_LOG, $content, FILE_APPEND);
}
}
示例12: createDir
/**
* create a directory given a path name, creates parent directories
* if needed
*
* @param string $path the path name
* @param boolean $abort should we abort or just return an invalid code
*
* @return void
* @access public
* @static
*/
function createDir($path, $abort = true)
{
if (is_dir($path) || empty($path)) {
return;
}
CRM_Utils_File::createDir(dirname($path), $abort);
if (@mkdir($path, 0777) == false) {
if ($abort) {
$docLink = CRM_Utils_System::docURL2('Moving an Existing Installation to a New Server or Location', false, 'Moving an Existing Installation to a New Server or Location');
echo "Error: Could not create directory: {$path}.<p>If you have moved an existing CiviCRM installation from one location or server to another there are several steps you will need to follow. They are detailed on this CiviCRM wiki page - {$docLink}. A fix for the specific problem that caused this error message to be displayed is to set the value of the config_backend column in the civicrm_domain table to NULL. However we strongly recommend that you review and follow all the steps in that document.</p>";
exit;
} else {
return false;
}
}
return true;
}
示例13: cleanup
/**
* delete the web server writable directories
*
* @param int $value 1 - clean templates_c, 2 - clean upload, 3 - clean both
*
* @access public
*
* @return void
*/
public function cleanup($value, $rmdir = TRUE)
{
$value = (int) $value;
if ($value & 1) {
// clean templates_c
CRM_Utils_File::cleanDir($this->templateCompileDir, $rmdir);
CRM_Utils_File::createDir($this->templateCompileDir);
}
if ($value & 2) {
// clean upload dir
CRM_Utils_File::cleanDir($this->uploadDir);
CRM_Utils_File::createDir($this->uploadDir);
CRM_Utils_File::restrictAccess($this->uploadDir);
}
}
示例14: CRM_Core_Config
/**
* The constructor. Basically redefines the class variables if
* it finds a constant definition for that class variable
*
* @return object
* @access private
*/
function CRM_Core_Config()
{
require_once 'CRM/Core/Session.php';
$session =& CRM_Core_Session::singleton();
if (defined('CIVICRM_DOMAIN_ID')) {
$GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = CIVICRM_DOMAIN_ID;
} else {
$GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = 1;
}
$session->set('domainID', $GLOBALS['_CRM_CORE_CONFIG']['_domainID']);
// we figure this out early, since some config parameters are loaded
// based on what components are enabled
if (defined('ENABLE_COMPONENTS')) {
$this->enableComponents = explode(',', ENABLE_COMPONENTS);
for ($i = 0; $i < count($this->enableComponents); $i++) {
$this->enableComponents[$i] = trim($this->enableComponents[$i]);
}
}
if (defined('CIVICRM_DSN')) {
$this->dsn = CIVICRM_DSN;
}
if (defined('UF_DSN')) {
$this->ufDSN = UF_DSN;
}
if (defined('UF_USERTABLENAME')) {
$this->ufUserTableName = UF_USERTABLENAME;
}
if (defined('CIVICRM_DEBUG')) {
$this->debug = CIVICRM_DEBUG;
}
if (defined('CIVICRM_DAO_DEBUG')) {
$this->daoDebug = CIVICRM_DAO_DEBUG;
}
if (defined('CIVICRM_DAO_FACTORY_CLASS')) {
$this->DAOFactoryClass = CIVICRM_DAO_FACTORY_CLASS;
}
if (defined('CIVICRM_SMARTYDIR')) {
$this->smartyDir = CIVICRM_SMARTYDIR;
}
if (defined('CIVICRM_PLUGINSDIR')) {
$this->pluginsDir = CIVICRM_PLUGINSDIR;
}
if (defined('CIVICRM_TEMPLATEDIR')) {
$this->templateDir = CIVICRM_TEMPLATEDIR;
}
if (defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
$this->templateCompileDir = CIVICRM_TEMPLATE_COMPILEDIR;
// make sure this directory exists
CRM_Utils_File::createDir($this->templateCompileDir);
}
if (defined('CIVICRM_RESOURCEBASE')) {
$this->resourceBase = CRM_Core_Config::addTrailingSlash(CIVICRM_RESOURCEBASE, '/');
}
if (defined('CIVICRM_UPLOADDIR')) {
$this->uploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_UPLOADDIR);
CRM_Utils_File::createDir($this->uploadDir);
}
if (defined('CIVICRM_IMAGE_UPLOADDIR')) {
$this->imageUploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADDIR);
CRM_Utils_File::createDir($this->imageUploadDir);
}
if (defined('CIVICRM_IMAGE_UPLOADURL')) {
$this->imageUploadURL = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADURL, '/');
}
if (defined('CIVICRM_CLEANURL')) {
$this->cleanURL = CIVICRM_CLEANURL;
}
if (defined('CIVICRM_COUNTRY_LIMIT')) {
$isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_COUNTRY_LIMIT);
$this->countryLimit = array_filter($isoCodes);
}
if (defined('CIVICRM_PROVINCE_LIMIT')) {
$isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_PROVINCE_LIMIT);
$provinceLimitList = array_filter($isoCodes);
if (!empty($provinceLimitList)) {
$this->provinceLimit = array_filter($isoCodes);
}
}
// Note: we can't change the ISO code to country_id
// here, as we can't access the database yet...
if (defined('CIVICRM_DEFAULT_CONTACT_COUNTRY')) {
$this->defaultContactCountry = CIVICRM_DEFAULT_CONTACT_COUNTRY;
}
if (defined('CIVICONTRIBUTE_DEFAULT_CURRENCY') and CRM_Utils_Rule::currencyCode(CIVICONTRIBUTE_DEFAULT_CURRENCY)) {
$this->defaultCurrency = CIVICONTRIBUTE_DEFAULT_CURRENCY;
}
if (defined('CIVICRM_LC_MESSAGES')) {
$this->lcMessages = CIVICRM_LC_MESSAGES;
}
if (defined('CIVICRM_ADDRESS_FORMAT')) {
// trim the format and unify line endings to LF
$format = trim(CIVICRM_ADDRESS_FORMAT);
$format = str_replace(array("\r\n", "\r"), "\n", $format);
//.........这里部分代码省略.........
示例15: civicrm_api3_civi_outlook_processattachments
function civicrm_api3_civi_outlook_processattachments($params)
{
//Get mime type of the attachment
$mimeType = CRM_Utils_Type::escape($_REQUEST['mimeType'], 'String');
$params['mime_type'] = $mimeType;
$config = CRM_Core_Config::singleton();
$directoryName = $config->customFileUploadDir;
CRM_Utils_File::createDir($directoryName);
//Process the below only if there is any attachment found
if (CRM_Utils_Array::value("name", $_FILES['file'])) {
$tmp_name = $_FILES['file']['tmp_name'];
$name = str_replace(' ', '_', $_FILES['file']['name']);
//Replace any spaces in name with underscore
$fileExtension = new SplFileInfo($name);
if ($fileExtension->getExtension()) {
$explodeName = explode("." . $fileExtension->getExtension(), $name);
$name = $explodeName[0] . "_" . md5($name) . "." . $fileExtension->getExtension();
}
$_FILES['file']['uri'] = $name;
move_uploaded_file($tmp_name, "{$directoryName}{$name}");
foreach ($_FILES['file'] as $key => $value) {
$params[$key] = $value;
}
$result = civicrm_api3('File', 'create', $params);
if (CRM_Utils_Array::value('id', $result)) {
if (CRM_Utils_Array::value('activityID', $params)) {
$lastActivityID = $params['activityID'];
}
$entityFileDAO = new CRM_Core_DAO_EntityFile();
$entityFileDAO->entity_table = 'civicrm_activity';
$entityFileDAO->entity_id = $lastActivityID;
$entityFileDAO->file_id = $result['id'];
$entityFileDAO->save();
}
}
return civicrm_api3_create_success($entityFileDAO, $params);
}