Skip to content

Instantly share code, notes, and snippets.

View kalabro's full-sized avatar
😻

Kate Marshalkina kalabro

😻
View GitHub Profile
@kalabro
kalabro / duuu.php
Created November 21, 2016 07:25
Duuu! Drupal Auto-Update script. Dirty and Old fashioned.
<?php
/**
* Duuu! Drupal Auto-Update script. Last tested with Drush 7.0.
* TODO:
* - convert to command.
*
* Requirements:
* - Drush 7 **OR** Core Update module enabled.
* - curl (optionally for HTTP site check).
*
@kalabro
kalabro / ajax.php
Last active December 29, 2015 11:49
Lightweight AJAX Drupal entry point. There is also https://drupal.org/project/js module for this purpose.
<?php
/**
* @file
* Custom ajax handler for custom_fast_ajax module.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
// Include utils.
require_once DRUPAL_ROOT . '/includes/common.inc';
@kalabro
kalabro / kalabro.module
Last active December 10, 2015 01:28
Drupal 7: Define Age formatter for date fields.
<?php
/**
* Define Age formatter for date fields.
*/
/**
* Implements hook_field_formatter_info().
*/
function kalabro_field_formatter_info() {
$formatters = array(
@kalabro
kalabro / dl_missing.php
Created November 12, 2012 12:15
Drupal 7: download missing modules with Drush
#!/usr/bin/env drush
<?php
/**
* Download modules which are not found on disk but exist in system table.
* Tested on Drupal 7.
*/
$result = db_query('SELECT * FROM system ORDER BY name');
foreach ($result as $record) {
if (!file_exists($record->filename)) {
@kalabro
kalabro / gist:3643917
Last active October 10, 2015 05:48
Drupal 7: Update pathauto aliases
<?php
/*
* Use in devel/php or with drush scr.
* Compatible with http://drupal.org/project/redirect module.
*/
// Some query.
$result = db_select('node', 'n')
->fields('n', array('nid'))
->condition('n.type', 'article')
->condition('n.status', 1)
@kalabro
kalabro / countries_disable.php
Created August 30, 2012 08:53
Drupal 7: Only CIS countries for http://drupal.org/project/countries module.
#!/usr/bin/env drush
<?php
/**
* This is Drush script.
* Only CIS countries for http://drupal.org/project/countries module.
* Оставить включенными только страны СНГ в модуле Сountries 7.x-2.x.
*/
// Disable all counties.
$cnt = db_update('countries_country')
@kalabro
kalabro / _auth_as_1.php
Created August 16, 2012 14:56
Drupal 6/7: Auth as first admin if no ssh no Drush no money no honey...
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$user = user_load(1);
if ($user) {
$edit = (array)$user;
@kalabro
kalabro / pm_lost.drush.inc.php
Created July 27, 2012 11:28
Drupal 7: Drush command 'pm-lost' lists projects which are not installed or disabled.
<?php
/**
* @file pm_lost.drush.inc
* Drush command 'pm-lost' lists projects which are not installed or disabled.
*
* It can be useful to detect waste modules which was downloaded once and then forgotten.
*/
/**
* Implementation of hook_drush_command().