Skip to content

Instantly share code, notes, and snippets.

View olafgrabienski's full-sized avatar

Olaf Grabienski olafgrabienski

View GitHub Profile
@opi
opi / backdrop_import_user.php
Created March 1, 2018 21:45
Backdrop import user from csv
<?php
function MYMODULE_import() {
// Path relative to document root
$csv_filepath = backdrop_get_path('module', 'MYMODULE');
$csv_filepath .= '/user_list.csv';
if ($handle = fopen($csv_filepath, 'r') ) {
// Read from CSV
@jackaponte
jackaponte / manage_unmanaged_files.php
Last active January 31, 2020 02:25
Scan directories for files and add them to the Backdrop managed file system
<?php
// Load file from disk.
echo 'Managing unmanaged files:\n';
// Change the DIRECTORY_NAME below for each directory you'd like to process.
foreach (new DirectoryIterator('DIRECTORY_NAME') as $unmanaged_file) {
if(($unmanaged_file->isDir()) | ($unmanaged_file->isDot()) | (!$unmanaged_file->valid())) continue;
$filename = $unmanaged_file->getFilename();
if($filename == '.htaccess') continue;
$pathname = $unmanaged_file->getPathname();