Skip to content

Instantly share code, notes, and snippets.

@mpstenson
mpstenson / request.history.tpl.php
Created October 5, 2016 20:02
Adds an open / closed indicator to the request history template in helpspot
<?php
//Set page title
$this->assign('pg_title',lg_portal_checkrequest);
include $this->loadTemplate('header.tpl.php');
include $this->loadTemplate('navigation.tpl.php');
?>
<h1><?php echo lg_portal_requesthistory ?></h1>
@mpstenson
mpstenson / reporting_tag_check.sql
Created September 1, 2016 15:37
Find requests in automations that don't have a reporting tag
/* add this as a custom where clause in an automation */
xRequest NOT IN (select `xRequest` from HS_Request_ReportingTags)
@mpstenson
mpstenson / Resize_Column_Based_On_Content.sql
Created August 31, 2016 15:52
Resize Column Based On Content (for mysql
SET @column_name = 'Custom2';
select @column_name;
SET @width_query = CONCAT('SET @max_width = (SELECT CHAR_LENGTH(' , @column_name , ') AS mlen FROM `HS_Request` ORDER BY mlen DESC LIMIT 1)+10;');
PREPARE stmt FROM @width_query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @query = CONCAT('ALTER TABLE HS_Request MODIFY ', @column_name, ' VARCHAR(', @max_width, ');');
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@mpstenson
mpstenson / unserializetEmailHeaders.php
Created June 20, 2016 15:20
unserialize tEmailHeaders from the HelpSpot API
<?php
$var=html_entity_decode("a:25:{s:12:&quot;delivered-to&quot;;a:2:{i:0;s:32:&quot;matts-test-instance@helpspot.com&quot;;i:1;s:32:&quot;matts-test-instance@helpspot.com&quot;;}s:11:&quot;return-path&quot;;a:2:{i:0;s:24:&quot;&lt;matt.stenson@gmail.com&gt;&quot;;i:1;s:24:&quot;&lt;matt.stenson@gmail.com&gt;&quot;;}s:8:&quot;received&quot;;a:4:{i:0;s:208:&quot;from director7.mail.ord1c.rsapps.net ([172.28.128.196]) by store367a.mail.iad3a.rsapps.net (Dovecot) with LMTP id N2bALtrEWlfIbgAASskMtg for &lt;matts-test-instance@helpspot.com&gt;; Fri, 10 Jun 2016 10:45:29 -0400&quot;;i:1;s:214:&quot;from smtp44.gate.ord1c ([172.28.255.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) by director7.mail.ord1c.rsapps.net (Dovecot) with LMTP id bjRlPqWWDVcXCQAAqdfm7w ; Fri, 10 Jun 2016 10:45:29 -0400&quot;;i:2;s:349:&quot;from [209.85.218.68] ([209.85.218.68:33976] helo=mail-oi0-f68.google.com) by smtp44.gate.ord1c.rsapps.net (envelope-from &lt;matt.stenson@gmail.com&gt;) (ecelerity 2.2.3.49 r(42060/42
@mpstenson
mpstenson / unread messages.sql
Last active October 10, 2016 13:57
Unread Messages across an installation
select * from HS_Request
where xRequest
in
(select xRequest from
`HS_Request` as RH
where `iLastReadCount` < (select COUNT(*) from `HS_Request_History`
where xRequest = RH.xRequest)
)
/*
1. Create an automation in Admin > Rules and Triggers > Automations
2. Then add a Custom "WHERE" Clause criteria along with other criteria.
*/
xRequest in (select xRequest from (select sum(iSeconds)
TotalTime, xRequest from HS_Time_Tracker group by xRequest) as
TimeList where TotalTime > 3000)
/*
You will want to replace "3000" in this code with the number of seconds that you want to check for. 35 minutes would be 2100 second I believe. Then add your actions that you want to perform on the request. Your completed automation should look something like this http://drop.userscape.com/Ep5g/1nXCRqpE.
Note that you want to make sure that you have a condition in the automation that will prevent it from running more than once. So in my example I'm checking if the request has already been escalated and if it has, the request won't meet the criteria.
<?php
// Be sure to send milliseconds
$now = time() * 1000; //gives milliseconds
$starttime = $now - 604800000; //7 days ago.
// endpoint for aviso orientation complete data. Requires a startdate in milliseconds and an end date in milliseconds
$aviso_url = 'https://youravisoinstall/aviso/api/2/person/orientationCompleteDate?startDate='.$starttime.'&endDate='.$now;//***Edit This Line
//Aviso API key generated in admin
$aviso_password = ''; //***Edit This Line
// The salt is for one time use, it must be generated for every request
/*This script will handle a url input on a hubspot landing page such at http://hubpostlp.com/landing-page/?source=Newsletter10
It will then take that url variable store it in a 90 day cookie and then insert it into the marketing_source fields on the hubspot
forms. This script does account for multiple forms on the same page. */
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
<?xml version="1.0" encoding="UTF-8"?>
<!-- dirty trick -->
<koken:include file="_includes/sitemappart.html" />
<!-- the included file (in this example sitemappart.html) contains just one line
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
-->
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<koken:load source="essays">
<koken:loop>
<url>