Skip to content

Instantly share code, notes, and snippets.

View pcave's full-sized avatar

Phillip Cave pcave

View GitHub Profile
<?php
/**
* @file
* Repairs the date mode dates.
*
* Requires the fundraiser_recurring table to be populated
* and the uc_orders table to have at least order_id and created columns.
*
* Run with something like "drush php-script save_the_day.php > results.txt"
*/
@pcave
pcave / gist:9512002
Last active August 29, 2015 13:57
VBO for refreshing view item
/**
* Refresh queue item VBO action.
*/
function salesforce_queue_salesforce_queue_item_refresh_item_action($item) {
// Let the individual modules handle the actual object refreshing and queuing.
// Check for a TRUE return value because we'll want to leave the item
// alone if it is not requeued successfully.
if (module_invoke_all('salesforce_queue_refresh_queue_item', $item)) {
// Force the item back into the new queue.
db_query("UPDATE {saleforce_queue} SET queue = 'new', retries = 0 WHERE item_id = :item_id",
@pcave
pcave / gist:9532353
Created March 13, 2014 16:58
Submit a VBO action with simpletest
<?php
// Create and log in a user that has access to the queue log report.
$this->privileged_user = $this->drupalCreateUser(array(
'view salesforce batch logs',
));
$this->drupalLogin($this->privileged_user);
$this->drupalGet('admin/reports/salesforce/queue');
$this->assertNoOptionSelected('edit-operation', 'action::salesforce_queue_salesforce_queue_item_refresh_item_action', 'Refresh VBO action exists but is not selected.');
@pcave
pcave / gist:5a7ab2adcc59829e6c72
Created October 10, 2014 19:54
UpdatePathTestCase attempt
<?php
class SpringboardSocialUpdradePathTestCase extends UpdatePathTestCase {
public static function getInfo() {
return array(
'name' => 'Springboard Social update path',
'description' => 'Tests update from 4.4 to 4.5.',
'group' => 'Update path',
);
@pcave
pcave / gist:8ec768094bbe5da89d50
Created October 15, 2014 17:48
Admin ui menu title callbacks
/**
* Title callback used to change the menu titles based on whether a user gets
* the Springboard admin UI.
*
* @param $original_title
* Original title for users who do not get the Springboard admin ui.
*
* @param $new_title
* Replacement title for users who get the the Springboard admin ui.
*/
@pcave
pcave / gist:a3f2ecd9b0d3e8afb1ad
Created January 23, 2015 20:22
Target Resolution: Single message, multiple resolved targets
{
"alert_id":"54c2ad5f978b5",
"contact":{
"id":10,
"firstName":"Joe",
"lastName":"Joe",
"email":"[email protected]"
},
"messages":{
"54c2ad5f978a8":{
@pcave
pcave / gist:3853af5734dd1dbff8ea
Created January 23, 2015 20:40
Target Resolution: Multiple messages, single and multiple resolved targets
{
"contact":{
"id":10,
"firstName":"Joe",
"lastName":"Joe",
"email":"[email protected]"
},
"messages":{
"54c2b1632a91d":{
"alert_id":"54c2b1632a931",
@pcave
pcave / gist:bfcbd9b1fc1b800c3c4c
Created January 26, 2015 20:40
Target Resolution: Single message, multiple resolved targets (not keyed on message id)
{
"alert_id":"54c6a5784a5cf",
"contact":{
"id":10,
"firstName":"Joe",
"lastName":"Joe",
"email":"[email protected]"
},
"messages":[
{
@pcave
pcave / gist:92fbcde854755f51f41e
Created January 26, 2015 20:46
Target Resolution: Multiple messages, single and multiple resolved targets (not keyed on message id)
{
"alert_id":"54c6a763c00d7",
"contact":{
"id":10,
"firstName":"Joe",
"lastName":"Joe",
"email":"[email protected]"
},
"messages":[
{
@pcave
pcave / gist:5572e561f61fd9d11c3c
Created January 26, 2015 21:33
Message Grinder
/**
* Takes a set of messages and converts them to target messages
* based on how many deliverable targets were resolved.
*
* @param array $alert
* An array of messages from target resolution or direct API call.
*/
function grindMessages($alert) {
$target_messages = array();