コード例 #1
0
 public function run()
 {
     /**
      * @var \Civi\Angular\Manager $angular
      */
     //Use our manager instead of the one provided by core
     $angular = new Civi\Angular\VolunteerManager(\CRM_Core_Resources::singleton());
     $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
     switch (\CRM_Utils_Request::retrieve('format', 'String')) {
         case 'json':
         case '':
             $this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular)));
             break;
         case 'js':
             $digest = $this->digestJs($angular->getResources($moduleNames, 'js', 'path'));
             //Tell crmResource to use our ajax end-point
             $digest = str_replace("ajax/angular-modules", "ajax/volunteer-angular-modules", $digest);
             $this->send('application/javascript', $digest);
             break;
         case 'css':
             $this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n"));
             break;
         default:
             \CRM_Core_Error::fatal("Unrecognized format");
     }
     \CRM_Utils_System::civiExit();
 }
/**
 * Implements hook_civicrm_install().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function offlinerecurringcontributions_civicrm_install()
{
    $extensionDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
    $sqlName = $extensionDir . 'sql' . DIRECTORY_SEPARATOR . 'update.sql';
    CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $sqlName);
    _offlinerecurringcontributions_civix_civicrm_install();
}
コード例 #3
0
ファイル: File.php プロジェクト: hampelm/Ginsberg-CiviDemo
 function run()
 {
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/DAO.php';
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     require_once 'CRM/Core/BAO/File.php';
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::delete($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
         }
     } else {
         require_once 'CRM/Utils/File.php';
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
コード例 #4
0
ファイル: File.php プロジェクト: kcristiano/civicrm-core
 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
コード例 #5
0
ファイル: GroupTest.php プロジェクト: nganivet/civicrm-core
 /**
  * Load saved search sql files into the DB.
  */
 public function loadSavedSearches()
 {
     $dsn = CRM_Core_Config::singleton()->dsn;
     foreach (glob(dirname(__FILE__) . "/SavedSearchDataSets/*.sql") as $file) {
         CRM_Utils_File::sourceSQLFile($dsn, $file);
     }
 }
コード例 #6
0
ファイル: Speakcivi.php プロジェクト: WeMoveEU/speakcivi
function civicrm_api3_speakcivi_update_stats($params)
{
    $config = CRM_Core_Config::singleton();
    $sql = file_get_contents(dirname(__FILE__) . '/../../sql/update.sql', true);
    CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
    return civicrm_api3_create_success(array("query" => $sql), $params);
}
 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);
     }
 }
コード例 #8
0
ファイル: Headless.php プロジェクト: kcristiano/civicrm-core
 /**
  * Perform an upgrade without using the web-frontend
  *
  * @param bool $enablePrint
  *
  * @throws Exception
  * @return array, with keys:
  *   - message: string, HTML-ish blob
  */
 public function run($enablePrint = TRUE)
 {
     // lets get around the time limit issue if possible for upgrades
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $upgrade = new CRM_Upgrade_Form();
     list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
     if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
         throw new Exception($error);
     }
     // Disable our SQL triggers
     CRM_Core_DAO::dropTriggers();
     // CRM-11156
     $preUpgradeMessage = NULL;
     $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
     $postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
     $queueRunner = new CRM_Queue_Runner(array('title' => ts('CiviCRM Upgrade Tasks'), 'queue' => CRM_Upgrade_Form::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile)));
     $queueResult = $queueRunner->runAll();
     if ($queueResult !== TRUE) {
         $errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
         CRM_Core_Error::debug_log_message($errorMessage);
         if ($enablePrint) {
             print $errorMessage;
         }
         throw $queueResult['exception'];
         // FIXME test
     }
     CRM_Upgrade_Form::doFinish();
     $message = file_get_contents($postUpgradeMessageFile);
     return array('latestVer' => $latestVer, 'message' => $message, 'text' => CRM_Utils_String::htmlToText($message));
 }
コード例 #9
0
 /**
  * handler for upload requests
  */
 static function processUpload()
 {
     $config = self::getConfig();
     global $http_return_code;
     $files = array();
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         $dir = scandir($config['BASE_DIR']);
         foreach ($dir as $file_name) {
             //issue - https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/28
             //Change file name to unique by adding hash so every time uploading same image it will create new image name
             $file_name = CRM_Utils_File::makeFileName($file_name);
             $file_path = $config['BASE_DIR'] . $file_name;
             if (is_file($file_path)) {
                 $size = filesize($file_path);
                 $file = ["name" => $file_name, "url" => $config['BASE_URL'] . $file_name, "size" => $size];
                 if (file_exists($config['BASE_DIR'] . $config[THUMBNAILS_DIR] . $file_name)) {
                     $file["thumbnailUrl"] = $config['BASE_URL'] . $config[THUMBNAILS_URL] . $file_name;
                 }
                 $files[] = $file;
             }
         }
     } else {
         if (!empty($_FILES)) {
             foreach ($_FILES["files"]["error"] as $key => $error) {
                 if ($error == UPLOAD_ERR_OK) {
                     $tmp_name = $_FILES["files"]["tmp_name"][$key];
                     $file_name = $_FILES["files"]["name"][$key];
                     //issue - https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/28
                     //Change file name to unique by adding hash so every time uploading same image it will create new image name
                     $file_name = CRM_Utils_File::makeFileName($file_name);
                     $file_path = $config['BASE_DIR'] . $file_name;
                     if (move_uploaded_file($tmp_name, $file_path) === TRUE) {
                         $size = filesize($file_path);
                         $image = new Imagick($file_path);
                         $image->resizeImage($config[THUMBNAIL_WIDTH], $config[THUMBNAIL_HEIGHT], Imagick::FILTER_LANCZOS, 1.0, TRUE);
                         // $image->writeImage( $config['BASE_DIR'] . $config[ THUMBNAILS_DIR ] . $file_name );
                         if ($f = fopen($config['BASE_DIR'] . $config[THUMBNAILS_DIR] . $file_name, "w")) {
                             $image->writeImageFile($f);
                         }
                         $image->destroy();
                         $file = array("name" => $file_name, "url" => $config['BASE_URL'] . $file_name, "size" => $size, "thumbnailUrl" => $config['BASE_URL'] . $config[THUMBNAILS_URL] . $file_name);
                         $files[] = $file;
                     } else {
                         $http_return_code = 500;
                         return;
                     }
                 } else {
                     $http_return_code = 400;
                     return;
                 }
             }
         }
     }
     header("Content-Type: application/json; charset=utf-8");
     header("Connection: close");
     echo json_encode(array("files" => $files));
     CRM_Utils_System::civiExit();
 }
コード例 #10
0
/**
 * Implementation of hook_civicrm_uninstall
 */
function eventcalendar_civicrm_uninstall()
{
    $cividiscountRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
    $cividiscountSQL = $cividiscountRoot . DIRECTORY_SEPARATOR . 'uninstall.sql';
    CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $cividiscountSQL);
    // rebuild the menu so our path is picked up
    CRM_Core_Invoke::rebuildMenuAndCaches();
    //return _eventcalendar_civix_civicrm_uninstall();
}
コード例 #11
0
ファイル: Browser.php プロジェクト: kidaa30/yes
 /**
  * @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);
     }
 }
コード例 #12
0
ファイル: File.php プロジェクト: archcidburnziso/civicrm-core
 /**
  * Find files in several directories using several filename patterns
  *
  * @param array $pairs each item is an array(0 => $searchBaseDir, 1 => $filePattern)
  * @return array of file paths
  */
 static function findManyFiles($pairs)
 {
     $files = array();
     foreach ($pairs as $pair) {
         list($dir, $pattern) = $pair;
         $files = array_merge($files, CRM_Utils_File::findFiles($dir, $pattern));
     }
     return $files;
 }
コード例 #13
0
ファイル: HRAbsenceTest.php プロジェクト: JoeMurray/civihr
 /**
  * @dataProvider dataProvider
  */
 public function testReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile)
 {
     $config = CRM_Core_Config::singleton();
     CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}");
     $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams);
     $reportCsvArray = $this->getArrayFromCsv($reportCsvFile);
     $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}");
     $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
 }
コード例 #14
0
/**
 * Implementation of hook_civicrm_enable
 */
function banking_civicrm_enable()
{
    //add the required option groups
    banking_civicrm_install_options(_banking_options());
    // run the update script
    $config = CRM_Core_Config::singleton();
    $sql = file_get_contents(dirname(__FILE__) . '/sql/upgrade.sql', true);
    CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
    return _banking_civix_civicrm_enable();
}
コード例 #15
0
 function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     $extenDr = $config->extensionsDir;
     $sDbScriptsDir = $extenDr . DIRECTORY_SEPARATOR . 'uk.co.vedaconsulting.recurdatafix' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
     CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, sprintf("%supdate.sql", $sDbScriptsDir));
     //CRM_Core_Session::setStatus('Updated table civicrm_recur table with membership id', 'Success', 'info');
     CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/recurdatafix/create', 'reset=1'));
     CRM_Utils_System::civiExit();
 }
コード例 #16
0
ファイル: IIF.php プロジェクト: prashantgajare/civicrm-core
 /**
  * @param $out
  *
  * @return string
  */
 function putFile($out)
 {
     $config = CRM_Core_Config::singleton();
     $fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
     $this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
     $buffer = fopen($fileName, 'w');
     fwrite($buffer, $out);
     fclose($buffer);
     return $fileName;
 }
コード例 #17
0
ファイル: Smarty.php プロジェクト: hyebahi/civicrm-core
 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());
 }
コード例 #18
0
/**
 * Load the navigation sql for the domain with the given name.
 *
 * @param string $domainName
 * @param int $domainID
 */
function _civicrm_load_navigation($domainName, $domainID)
{
    global $civicrm_root;
    $sqlPath = $civicrm_root . DIRECTORY_SEPARATOR . 'sql';
    $config = CRM_Core_Config::singleton();
    $generatedFile = $config->uploadDir . DIRECTORY_SEPARATOR . str_replace(' ', '_', $domainName) . uniqid() . 'nav.mysql';
    //read the entire string
    $str = file_get_contents($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_navigation.mysql');
    $str = str_replace('SELECT @domainID := id FROM civicrm_domain where name = \'Default Domain Name\'', "SELECT @domainID := {$domainID}", $str);
    file_put_contents($generatedFile, $str);
    CRM_Utils_File::sourceSQLFile($config->dsn, $generatedFile, NULL, FALSE);
    CRM_Core_DAO::executeQuery("UPDATE civicrm_navigation SET label = name WHERE label = ''");
}
コード例 #19
0
ファイル: FileTest.php プロジェクト: nielosz/civicrm-core
 /**
  * Test is child path.
  */
 public function testIsChildPath()
 {
     $testCases = array();
     $testCases[] = array('/ab/cd/ef', '/ab/cd', FALSE);
     $testCases[] = array('/ab/cd', '/ab/cd/ef', TRUE);
     $testCases[] = array('/ab/cde', '/ab/cd/ef', FALSE);
     $testCases[] = array('/ab/cde', '/ab/cd', FALSE);
     $testCases[] = array('/ab/cd', 'ab/cd/ef', FALSE);
     foreach ($testCases as $testCase) {
         $actual = CRM_Utils_File::isChildPath($testCase[0], $testCase[1], FALSE);
         $this->assertEquals($testCase[2], $actual, sprintf("parent=[%s] child=[%s] expected=[%s] actual=[%s]", $testCase[0], $testCase[1], $testCase[2], $actual));
     }
 }
コード例 #20
0
ファイル: Get.php プロジェクト: civicrm/api4
 /**
  * Scan all api directories to discover entities
  *
  * @param \Civi\API\Result $result
  */
 public function _run(Result $result)
 {
     $entities = array();
     foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
         $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/Api4';
         if (is_dir($dir)) {
             foreach (glob("{$dir}/*.php") as $file) {
                 $matches = array();
                 preg_match('/(\\w*).php/', $file, $matches);
                 $entities[$matches[1]] = $matches[1];
             }
         }
     }
     $result->exchangeArray(array_values($entities));
 }
コード例 #21
0
 /**
  * Ensure that the required SQL table exists
  *
  * @return bool TRUE if table now exists
  */
 static function findCreateTable()
 {
     $checkTableSql = "show tables like 'civicrm_queue_item'";
     $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
     if ($foundName == 'civicrm_queue_item') {
         return TRUE;
     }
     // civicrm/sql/civicrm_queue_item.mysql
     $fileName = dirname(__FILE__) . '/../../../sql/civicrm_queue_item.mysql';
     $config = CRM_Core_Config::singleton();
     CRM_Utils_File::sourceSQLFile($config->dsn, $fileName);
     // Make sure it succeeded
     $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
     return $foundName == 'civicrm_queue_item';
 }
コード例 #22
0
ファイル: CSV.php プロジェクト: hguru/224Civi
 function putFile($export)
 {
     $config = CRM_Core_Config::singleton();
     $fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
     $this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
     $out = fopen($fileName, 'w');
     fputcsv($out, $export['headers']);
     unset($export['headers']);
     if (!empty($export)) {
         foreach ($export as $fields) {
             fputcsv($out, $fields);
         }
         fclose($out);
     }
     return $fileName;
 }
コード例 #23
0
 /**
  * @param $reportClass
  * @param array $inputParams
  *
  * @return string
  * @throws Exception
  */
 public function getReportOutputAsCsv($reportClass, $inputParams)
 {
     $config = CRM_Core_Config::singleton();
     $config->keyDisable = TRUE;
     $controller = new CRM_Core_Controller_Simple($reportClass, ts('some title'));
     $tmpReportVal = explode('_', $reportClass);
     $reportName = array_pop($tmpReportVal);
     $reportObj =& $controller->_pages[$reportName];
     $tmpGlobals = array();
     $tmpGlobals['_REQUEST']['force'] = 1;
     $tmpGlobals['_GET'][$config->userFrameworkURLVar] = 'civicrm/placeholder';
     $tmpGlobals['_SERVER']['QUERY_STRING'] = '';
     if (!empty($inputParams['fields'])) {
         $fields = implode(',', $inputParams['fields']);
         $tmpGlobals['_GET']['fld'] = $fields;
         $tmpGlobals['_GET']['ufld'] = 1;
     }
     if (!empty($inputParams['filters'])) {
         foreach ($inputParams['filters'] as $key => $val) {
             $tmpGlobals['_GET'][$key] = $val;
         }
     }
     if (!empty($inputParams['group_bys'])) {
         $groupByFields = implode(' ', $inputParams['group_bys']);
         $tmpGlobals['_GET']['gby'] = $groupByFields;
     }
     CRM_Utils_GlobalStack::singleton()->push($tmpGlobals);
     try {
         $reportObj->storeResultSet();
         $reportObj->buildForm();
         $rows = $reportObj->getResultSet();
         $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv');
         $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows);
         file_put_contents($tmpFile, $csvContent);
     } catch (Exception $e) {
         // print_r($e->getCause()->getUserInfo());
         CRM_Utils_GlobalStack::singleton()->pop();
         throw $e;
     }
     CRM_Utils_GlobalStack::singleton()->pop();
     return $tmpFile;
 }
コード例 #24
0
ファイル: Menu.php プロジェクト: archcidburnziso/civicrm-core
 static function &xmlItems()
 {
     if (!self::$_items) {
         $config = CRM_Core_Config::singleton();
         // We needs this until Core becomes a component
         $coreMenuFilesNamespace = 'CRM_Core_xml_Menu';
         $coreMenuFilesPath = str_replace('_', DIRECTORY_SEPARATOR, $coreMenuFilesNamespace);
         global $civicrm_root;
         $files = CRM_Utils_File::getFilesByExtension($civicrm_root . DIRECTORY_SEPARATOR . $coreMenuFilesPath, 'xml');
         // Grab component menu files
         $files = array_merge($files, CRM_Core_Component::xmlMenu());
         // lets call a hook and get any additional files if needed
         CRM_Utils_Hook::xmlMenu($files);
         self::$_items = array();
         foreach ($files as $file) {
             self::read($file, self::$_items);
         }
     }
     return self::$_items;
 }
コード例 #25
0
ファイル: IDS.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * This function includes the IDS vendor parts and runs the
  * detection routines on the request array.
  *
  * @param object cake controller object
  * @return boolean
  */
 public function check(&$args)
 {
     // lets bypass a few civicrm urls from this check
     static $skip = array('civicrm/ajax', 'civicrm/admin/setting/updateConfigBackend', 'civicrm/admin/messageTemplates');
     $path = implode('/', $args);
     if (in_array($path, $skip)) {
         return;
     }
     #add request url and user agent
     $_REQUEST['IDS_request_uri'] = $_SERVER['REQUEST_URI'];
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $_REQUEST['IDS_user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     }
     require_once 'IDS/Init.php';
     // init the PHPIDS and pass the REQUEST array
     $config =& CRM_Core_Config::singleton();
     $configFile = $config->configAndLogDir . 'Config.IDS.ini';
     if (!file_exists($configFile)) {
         $tmpDir = empty($config->uploadDir) ? CIVICRM_TEMPLATE_COMPILEDIR : $config->uploadDir;
         // also clear the stat cache in case we are upgrading
         clearstatcache();
         global $civicrm_root;
         $contents = "\n[General]\n    filter_type         = xml\n    filter_path         = {$civicrm_root}/packages/IDS/default_filter.xml\n    tmp_path            = {$tmpDir}\n    HTML_Purifier_Path  = IDS/vendors/htmlpurifier/HTMLPurifier.auto.php\n    HTML_Purifier_Cache = {$tmpDir}\n    scan_keys           = false\n    exceptions[]        = __utmz\n    exceptions[]        = __utmc\n    exceptions[]        = widget_code\n    exceptions[]        = html_message\n    exceptions[]        = body_html\n    exceptions[]        = msg_html\n    exceptions[]        = msg_text\n    exceptions[]        = msg_subject\n    exceptions[]        = description\n    html[]              = intro\n    html[]              = thankyou_text\n    html[]              = intro_text\n    html[]              = body_text\n    html[]              = footer_text\n    html[]              = thankyou_text\n    html[]              = thankyou_footer\n    html[]              = thankyou_footer_text\n    html[]              = new_text\n    html[]              = renewal_text\n    html[]              = help_pre\n    html[]              = help_post\n    html[]              = confirm_title\n    html[]              = confirm_text\n    html[]              = confirm_footer_text\n    html[]              = confirm_email_text\n    html[]              = report_header\n    html[]              = report_footer\n    html[]              = data\n    html[]              = instructions\n";
         if (file_put_contents($configFile, $contents) === false) {
             require_once 'CRM/Core/Error.php';
             CRM_Core_Error::movedSiteError($configFile);
         }
         // also create the .htaccess file so we prevent the reading of the log and ini files
         // via a browser, CRM-3875
         require_once 'CRM/Utils/File.php';
         CRM_Utils_File::restrictAccess($config->configAndLogDir);
     }
     $init = IDS_Init::init($configFile);
     $ids = new IDS_Monitor($_REQUEST, $init);
     $result = $ids->run();
     if (!$result->isEmpty()) {
         $this->react($result);
     }
     return true;
 }
コード例 #26
0
ファイル: Files.php プロジェクト: JoeMurray/civihr
 function fileUpload()
 {
     $config = CRM_Core_Config::singleton();
     $postParams = $_POST;
     if ($postParams['entityID'] == 'undefined') {
         $result = civicrm_api3('HRJob', 'get', array('options' => array('sort' => "id DESC")));
         foreach ($result['values'] as $key => $val) {
             $id = $val['id'];
             break;
         }
         $postParams['entityID'] = ++$id;
     }
     $files = $_FILES;
     if (is_array($files) && !empty($files)) {
         foreach ($files as $k => $v) {
             $fileName = CRM_Utils_File::makeFileName(basename($v['name']));
             $maxSize = @filesize($v['tmp_name']);
             $dest = $config->customFileUploadDir;
             if ($dest != '' && substr($dest, -1) != '/') {
                 $dest .= '/';
             }
             $fileName = $fileName != '' ? $fileName : basename($v['name']);
             if (is_uploaded_file($v['tmp_name'])) {
                 if (move_uploaded_file($v['tmp_name'], $dest . $fileName)) {
                     $fileparam['name'] = $fileName;
                     $fileparam['uri'] = $fileName;
                     $file_params = array('version' => 3, 'file_type_id' => null, 'mime_type' => $v['type'], 'name' => $fileName, 'uri' => $fileName, 'upload_date' => date('Y-m-d h:i:s', time()));
                     $file_save = civicrm_api('File', 'Create', $file_params);
                     $newEntityFile = new CRM_Core_DAO_EntityFile();
                     $newEntityFile->entity_id = $postParams['entityID'];
                     $newEntityFile->entity_table = $postParams['entityTable'];
                     $newEntityFile->file_id = $file_save['id'];
                     $newEntityFile->save();
                     $fileName = basename($v['name']);
                 }
             }
         }
     }
     CRM_Utils_System::civiExit();
 }
コード例 #27
0
ファイル: Email2Activity.php プロジェクト: ksecor/civicrm
 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);
 }
コード例 #28
0
ファイル: GetActions.php プロジェクト: civicrm/api4
 public function _run(Result $result)
 {
     $includePaths = array_unique(explode(PATH_SEPARATOR, get_include_path()));
     $entityReflection = new \ReflectionClass('\\Civi\\Api4\\' . $this->getEntity());
     // First search entity-specific actions (including those provided by extensions
     foreach ($includePaths as $path) {
         $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Entity/' . $this->getEntity();
         $this->scanDir($dir);
     }
     // Scan all generic actions unless this entity does not extend generic entity
     if ($entityReflection->getParentClass()) {
         foreach ($includePaths as $path) {
             $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Action';
             $this->scanDir($dir);
         }
     } else {
         foreach ($entityReflection->getMethods(\ReflectionMethod::IS_STATIC) as $method) {
             $this->loadAction($method->getName());
         }
     }
     $result->exchangeArray(array_values($this->_actions));
 }
コード例 #29
0
ファイル: Modules.php プロジェクト: FundingWorks/civicrm-core
 /**
  * See class description.
  */
 public function run()
 {
     /**
      * @var \Civi\Angular\Manager $angular
      */
     $angular = \Civi::service('angular');
     $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
     switch (\CRM_Utils_Request::retrieve('format', 'String')) {
         case 'json':
         case '':
             $this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular)));
             break;
         case 'js':
             $this->send('application/javascript', $this->digestJs($angular->getResources($moduleNames, 'js', 'path')));
             break;
         case 'css':
             $this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n"));
             break;
         default:
             \CRM_Core_Error::fatal("Unrecognized format");
     }
     \CRM_Utils_System::civiExit();
 }
コード例 #30
0
ファイル: api4.civix.php プロジェクト: civicrm/api4
/**
 * Search directory tree for files which match a glob pattern
 *
 * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
 * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
 *
 * @param $dir string, base dir
 * @param $pattern string, glob pattern, eg "*.txt"
 * @return array(string)
 */
function _api4_civix_find_files($dir, $pattern)
{
    if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
        return CRM_Utils_File::findFiles($dir, $pattern);
    }
    $todos = array($dir);
    $result = array();
    while (!empty($todos)) {
        $subdir = array_shift($todos);
        foreach (_api4_civix_glob("{$subdir}/{$pattern}") as $match) {
            if (!is_dir($match)) {
                $result[] = $match;
            }
        }
        if ($dh = opendir($subdir)) {
            while (FALSE !== ($entry = readdir($dh))) {
                $path = $subdir . DIRECTORY_SEPARATOR . $entry;
                if ($entry[0] == '.') {
                } elseif (is_dir($path)) {
                    $todos[] = $path;
                }
            }
            closedir($dh);
        }
    }
    return $result;
}