Skip to content

Instantly share code, notes, and snippets.

View mlutfy's full-sized avatar

Mathieu Lu mlutfy

View GitHub Profile
From d9540e65b7ef2faba3c32ff9a25d5fffca3a9995 Mon Sep 17 00:00:00 2001
From: Mathieu Lutfy <mathieu@symbiotic.coop>
Date: Sat, 7 Oct 2017 16:07:52 -0400
Subject: [PATCH] Add alterPriceSet hook.
---
.../civicrm/CRM/Member/Form.php | 3 +
.../civicrm/CRM/Utils/Hook.php | 19 ++++++
.../civicrm/Civi/Core/Event/AlterPriceSet.php | 69 ++++++++++++++++++++++
3 files changed, 91 insertions(+)
@mlutfy
mlutfy / civicrm_CRM_Logging_Schema.php
Last active September 9, 2017 21:01
CiviCRM logging timestamp weird bug (CRM/Logging/Schema.php)
/**
* Fix timestamp.
*
* Log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date,
* so there's no need for a default timestamp and therefore we remove such default timestamps
* also eliminate the NOT NULL constraint, since we always copy and schema can change down the road)
*
* @param string $query
*
* @return mixed
#!/bin/bash
# Helps apply a CiviCRM github pull-request.
# Based on a script by @litespeedmarc
if [ $# -ne 1 ]
then
echo "Invalid syntax. Syntax is $0 <PR> <CRM> <DESC>"
fi
@mlutfy
mlutfy / gist:9971f0e2501ef1a0778b5b921965c34c
Last active September 7, 2017 16:00
CiviCRM activity report with attachments
?php
/**
* Displays and filters activities with file attachments.
*
* Based on https://github.com/MegaphoneJon/activityAttachmentReport by Jon G.
*/
class CRM_SymbioTIC_Form_Report_ActivitiesWithAttachments extends CRM_Report_Form_Activity {
function __construct() {
@mlutfy
mlutfy / gist:4efd128ef8b04a3eab2c286b2dcb4bbf
Created September 7, 2017 02:01
Disable community messages in CiviCRM
drush @example.org api Setting.create communityMessagesUrl=FALSE
class CRM_SymbioTIC_Utils_Check_Permissions {
function check(&$messages) {
$config = CRM_Core_Config::singleton();
$error = FALSE;
$count = 0;
if ($config->userFramework == 'Drupal6') {
$count = CRM_Core_DAO::singleValueQuery("SELECT count(*)
FROM permission
@mlutfy
mlutfy / door-status.py
Last active March 18, 2017 21:49
Door status
import os
import RPi.GPIO as GPIO
import time
import http.client, urllib
# Based on:
# http://raspberry.io/projects/view/reading-and-writing-from-gpio-ports-from-python/
GPIO.setmode(GPIO.BCM)
@mlutfy
mlutfy / civi-rebuild-multilingual.sh
Last active April 24, 2024 13:04
CiviCRM: rebuild multilingual views
# Drupal 7
drush php-eval 'civicrm_initialize(); CRM_Core_I18n_Schema::rebuildMultilingualSchema(["en_US","fr_CA"], NULL);'
# Drupal 8
drush php-eval '\Drupal::service('civicrm')->initialize(); CRM_Core_I18n_Schema::rebuildMultilingualSchema(["en_US","fr_CA"], NULL);'
# WordPress
wp eval 'civicrm_initialize(); CRM_Core_I18n_Schema::rebuildMultilingualSchema(["en_US","fr_CA"], NULL);'
@mlutfy
mlutfy / myext.php
Created February 13, 2017 19:40
civicrm send to a friend sparkpost fix
<?php
/**
* Implements hook_civicrm_alterMailParams().
*
* Intercepts outgoing emails.
*/
function myext_civicrm_alterMailParams(&$params) {
// redmine:20627 Quickfix for PCP "send to a friend" enforce the 'from' email.
if ($params['valueName'] == 'friend') {
/**
* Implements hook_civicrm_buildForm() is a completely overkill way.
* Searches for an override class named after the initial $formName
* and calls its buildForm().
*
* Ex: for a $formName "CRM_Case_Form_CaseView", it will:
* - try to find * CRM/Symbiotic/Case/Form/CaseView.php,
* - require_once the file, instanciate an object, and
* - call its buildForm() function.
*