Skip to content

Instantly share code, notes, and snippets.

View DuaelFr's full-sized avatar

Edouard Cunibil DuaelFr

View GitHub Profile
@DuaelFr
DuaelFr / i18n_check.drush.inc
Last active December 20, 2015 00:18
Drush i18ncheck
<?php
/**
* @file
* Drush module to check if all translatable strings are safe to translate.
*/
/**
* Implements hook_drush_help().
*/
function i18n_check_drush_help($section) {
@DuaelFr
DuaelFr / blocks.inc
Created July 18, 2013 09:39
Show an image field using field_view_field and colorbox
$build = field_view_field('user', $context['entity'], 'field_picture', array(
'label' => 'hidden',
'type' => 'colorbox',
'settings' => array(
'colorbox_node_style' => 'user_large',
'colorbox_image_style' => 'colorbox',
),
));
'settings' => array(
'handler' => 'og',
'handler_settings' => array(
'behaviors' => array(
'og_behavior' => array(
'status' => TRUE,
),
'views-select-list' => array(
'status' => 1,
),
<?php
/**
* Get all users of a group who contributed.
*/
function _events_resource_get_users_in_group($gid) {
$query = db_select('og_membership', 'ogm');
$query->join('node', 'n', "n.nid = ogm.etid AND ogm.entity_type = 'node'");
$query->join('user', 'u', 'n.uid = u.uid');
$query->fields('n', array('uid'))
function entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);
}
}
/**
* View a tracking item.
*/
function ise_tracking_item_view($tracking_item) {
$semaphore = &drupal_static(__FUNCTION__, FALSE);
if (empty($semaphore)) {
$semaphore = TRUE;
return entity_view('tracking_item', array($tracking_item));
}
}
@DuaelFr
DuaelFr / gist:5686084
Created May 31, 2013 16:16
Get webform submission data keyed by component's machine names instead of component's ids
<?php
/**
* Implements hook_mail_alter().
*
* Add the wanted attachment to submission email.
*
* @param Array $message
*/
function MODULE_mail_alter(&$message) {
@DuaelFr
DuaelFr / .gitconfig
Last active February 1, 2023 23:34
Useful git config
[alias]
a = add
aa = add -A
ac = "!f() { curl $@ | git apply --index; }; f"
ac3 = "!f() { curl $@ | git apply -3 --index; }; f"
amend = commit --amend -C HEAD
ap = add -p
app = apply --index
br = branch
cb = checkout -b
@DuaelFr
DuaelFr / feature_content_timelines.install
Created May 5, 2013 18:05
Waiting for Reply's Features integration
<?php
/**
* @file
* Code for the Feature Content Timelines feature.
*/
/**
* Implements hook_install().
*/
function feature_content_timelines_install() {
@DuaelFr
DuaelFr / gist:4664660
Created January 29, 2013 14:32
hook_default_rules_configuration() advanced sample.
<?php
/**
* Implements hook_default_rules_configuration().
*/
function MYMODULE_default_rules_configuration() {
$rules = array();
// Custom rule : calculate the weight of a line item
$rule = rule($variables, $provides);