Skip to content

Instantly share code, notes, and snippets.

View amcgowanca's full-sized avatar

Aaron McGowan amcgowanca

View GitHub Profile
@amcgowanca
amcgowanca / EntityFieldPropertyQuery.php
Last active August 29, 2015 14:03
Drupal 7 - EntityFieldPropertyQuery class
<?php
/**
* @file
* Contains class EntityFieldPropertyQuery.
*/
/**
* EntityFieldQuery class allowing for base table properties to be returned.
*/
class EntityFieldPropertyQuery extends EntityFieldQuery {
@amcgowanca
amcgowanca / test.php
Created June 25, 2014 17:35
PHP's array_key_exists vs. isset
<?php
$array = array(
'a' => 'A',
'b' => 'B',
'c' => 'C',
);
$st = microtime(TRUE);
@amcgowanca
amcgowanca / MODULENAME.module
Created February 4, 2014 14:17
Turn default caching and "use slave" option on for Views 3 in Drupal 7.
/**
* Implements hook_views_default_views_alter().
*/
function MODULENAME_views_default_views_alter(&$views) {
foreach ($views as $view_name => &$view) {
// If the view is disabled, simply continue onto the next.
if (TRUE == $view->disabled) {
continue;
}
@amcgowanca
amcgowanca / imagex_installkit_ops.inc
Last active December 30, 2015 09:09
A rough prototype of an example of how drush can recursively do a git pull on origin remote for the current branch.
<?php
/**
* @file
*/
function imagex_installkit_ops_drush_command() {
$commands = array();
$commands['installkit-ops-update'] = array(
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'aliases' => array('ops-update'),
diff --git a/vote_up_down/vud_node/README.txt b/vote_up_down/vud_node/README.txt
new file mode 100644
index 0000000..31c622c
--- /dev/null
+++ b/vote_up_down/vud_node/README.txt
@@ -0,0 +1,81 @@
+Aug 5, 2013
+
+This README addresses the *Port vud_node to D7* issue
+

GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to

@amcgowanca
amcgowanca / gist:6827696
Created October 4, 2013 15:19
PHP's break; with numeric indicator of number of scope structures to break.
<?php
do {
for ($i = 0; $i < 10; $i++) {
print $i . ', ';
if ($i == 1) {
break 2;
}
}
}
#!/bin/bash
if [ $(id -u) != 0 ]; then
printf "This script must be run as root.\n"
exit 1
fi
drupal_path=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"
@amcgowanca
amcgowanca / answers-block-node-add-2079955-2.patch
Created September 19, 2013 13:27
Drupal 7 contrib module Answers patch: answers-block-node-add-2079955-2.patch
diff --git a/answers.module b/answers.module
index ed2364b..43209f4 100644
--- a/answers.module
+++ b/answers.module
@@ -140,6 +140,12 @@ function answers_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'answers_answer_node_form') {
// Disallow manually assigning an answer to a question.
hide($form['answers_related_question']);
+ $node = $form['#node'];
+ if (!isset($node->answers_related_question[LANGUAGE_NONE][0]['target_id'])) {
@amcgowanca
amcgowanca / 1356276-D7-inheritable-profiles-multi
Last active December 22, 2015 08:19
Allows for a multiple inheritance of installation profiles to exist in Drupal 7.
diff --git a/includes/common.inc b/includes/common.inc
index 262e1c5..b38425a 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -232,6 +232,24 @@ function drupal_get_profile() {
return $profile;
}
+/**
+ * Returns an array of the installation profile hierarchy.