Skip to content

Instantly share code, notes, and snippets.

View evandonovan's full-sized avatar

Evan Donovan evandonovan

View GitHub Profile
@evandonovan
evandonovan / gist:1515657
Created December 23, 2011 23:26
Assignment of Contacts Class
/* Class */
public with sharing class CityvisionContactAssigner {
static final Id OWNER_NYOUNG;
static final Id OWNER_AWEBB;
static {
List<User> users = [SELECT Id, Alias FROM User WHERE Alias = 'nyoung' OR Alias = 'awebb' OR Alias = 'MOmori' OR Alias = 'ASears'];
for(User u : users) {
// Switch which user to use based on whether we are in production environment, since partner users don't carry across to sandboxes.
if((CityvisionConstants.onProduction == true && u.Alias == 'nyoung')
@evandonovan
evandonovan / TestCityvisionScheduledTasks.cls
Created December 15, 2011 22:46
Test for my scheduled Apex
@isTest
private class TestCityvisionScheduledTasks {
// just tests whether the scheduled classes run.
static testMethod void testRunsScheduled() {
CityvisionScheduledLeadScorer cvSLS = new CityvisionScheduledLeadScorer();
String sch = '0 0 23 * * ?';
Test.startTest();
Id jobId = System.schedule('City Vision Lead Scoring', sch, cvSLS);
@evandonovan
evandonovan / location.inc.php
Created June 30, 2010 20:04
Feeds mapping for location_cck.module
<?php
// $Id$
/**
* @file
* On behalf implementation of Feeds mapping API for location_cck.module (Location CCK).
*/
/**
* Implementation of hook_feeds_node_processor_targets_alter().
<?php
// convenience theming function for taxonomy lists -- ead 6.10.10
function taxonomy_node_list_terms_by_vocabulary($nid, $voc_id, $link = FALSE, $ul = FALSE) {
/* loads a "dummy" node in order to use taxonomy_node_get_terms_by_vocabulary()
to get an array of taxonomy terms */
$node = new stdClass();
$node->vid = db_result(db_query("SELECT MAX(vid) FROM {node_revisions} WHERE nid = %d", $nid));
$terms = taxonomy_node_get_terms_by_vocabulary($node, $voc_id);
if(!isset($terms) || !is_array($terms) || empty($terms)) { return ''; }
@evandonovan
evandonovan / user-profile.tpl.php
Created May 19, 2010 22:42
user-profile.tpl.php with embedded view
<?php
// $Id: user-profile.tpl.php,v 1.2.2.1 2008/10/15 13:52:04 dries Exp $
/**
* @file user-profile.tpl.php
* Default theme implementation to present all user profile data.
*
* This template is used when viewing a registered member's profile page,
* e.g., example.com/user/123. 123 being the users ID.
*
@evandonovan
evandonovan / url_outbound_alter_example.php
Created May 18, 2010 03:13
url_outbound_alter set absolute domain
<?php
/**
* Implements hook_url_outbound_alter() - from URL Alter module
*/
function YOURMODULE_url_outbound_alter(&$path, &$options, $original_path) {
// Rewrite paths for rices4peru.com
if ($_SERVER['HTTP_HOST'] == "www.rices4peru.com") {
$options['absolute'] = TRUE;
@evandonovan
evandonovan / marker-popup_code.php
Created May 17, 2010 22:01
gmap marker popup via AHAH code
<?php
// following is excerpted from um_common.module:
// service area vid
define("SERVICE_AREA_VID", 32);
/**
* Implements hook_menu()
* Creates Gmap rendering callbacks for popups.
@evandonovan
evandonovan / find_hook_implementations.php
Created May 17, 2010 18:45
find implementations of a given hook in Drupal
<ol>
<?php
foreach(module_implements("block") as $module) {
print "<li>" . $module . "</li>";
}
?>
</ol>
@evandonovan
evandonovan / gmap_plugin_style_gmap-with_remote_callback.php
Created May 15, 2010 00:50
gmap plugin style with remote callback
<?php
// $Id: gmap_plugin_style_gmap.inc,v 1.7 2009/02/05 21:51:53 bdragon Exp $
/**
* @file
* GMap style plugin.
*/
/**
* Style plugin to render a map.
@evandonovan
evandonovan / find_element()
Created May 14, 2010 14:24 — forked from wimleers/find_element()
Wim Leers' recursive code - find form elements of given type
<?php
function find_element($form, $element_type) {
if (isset($form['#type']) && $form['#type'] == $element_type) {
return $form;
}
else {
foreach (element_children($form) as $name) {
if (is_array($form[$name])) {
$element = find_element($form[$name], $element_type);
if ($element !== FALSE) {