Skip to content

Instantly share code, notes, and snippets.

View aqualad's full-sized avatar

Bryan Dodd aqualad

  • OnShift
  • Cleveland, OH
View GitHub Profile
@aqualad
aqualad / langvalidate.php
Created March 7, 2013 20:50
validatelang
<?php
class langvalidate extends lang
{
public $v1='is required';
public $v2='must be between';
public $v3='and';
public $v4='must be between 2 and 32 characters long';
public $v5='must only contain letters, numbers and ! # $ % * / ? | ^ { } ` ~ & + - = _ and must start with a letter';
public $stringMsg = 'characters long';
@aqualad
aqualad / validate.php
Last active December 14, 2015 15:59
validate string
<?php
public static function string(&$value, $display, $min, $max, $required=false)
{
$lang = lang :: get("validate");
$value = trim(strip_tags($value));
$len = strlen($value);
if($len == 0)
if(!$required)
<?php
/* *
* Usage:
* CrmEmployees :: getUsers();
*/
public static function getUsers($userid=null, $cols=null)
{
$valid_columns = array(
'UID'=>1,
@aqualad
aqualad / Function Arguments.php
Last active December 15, 2015 10:39
PHP - Function Arguments (func_get_args and extract)
<?php
function fun()
{
echo " ";
$argv = func_get_args();
switch(count($argv))
{
case 1:
echo is_array($argv[0]) ? "Value is an array" : "Value is NOT an array";
@aqualad
aqualad / gist:5397547
Created April 16, 2013 16:53
HTTP redirect with params
HTTP::redirect(Route::url('site/admin', [
'controller' => 'import',
'action' => 'decline_staff',
'id' => $request->param('id'),
]));
@aqualad
aqualad / gist:5461333
Last active December 16, 2015 16:09
adapter_ratings
{ "unrestricted":
{
"supervision":
{
"question":"What describes your assessment of the Supervision and Guidance you typically received",
"answers":
{
"1":"Need much more",
"2":"Need a little more",
"3":"Just Right",
@aqualad
aqualad / WebCRM_snippet.php
Last active December 17, 2015 02:19
Recursive Control Functions
<?php
// Returns an associative array of the lowest ctlControl objects
// @return Associative array [ $control_name => $control_property ]
// @param $control Control Object to scan
// @param $ctlControls Always send an empty array, it's the same array that is passed through recursion
// @param $type Associate array [$control_type => $control_property, $control_type=>$control_property, ... ]
// Valid types ($control_type) [ ctlControl | ctlTextBox | ctlSelect | etc.. ]
// Valid properties ($control_property) [ null | name | value | style | properties | etc ]
// Note: If no $control_property is set, the function defaults to the actual ctl Object
<?php
// Validate that the email isn't used by another staff user
elseif ($this->web_enabled)
{
$rules['email'][] = [
['Model_Account_User_Site_Staff', 'unique_staff_email']];
}
@aqualad
aqualad / augz_CRMInvoice_onEdit.php
Last active December 17, 2015 21:19
onEdit Anonymous Function
<?php
/*
onEdit:
1. Clear the form
2. Select query for the CustomerID on invoices table
3. Call WebCRM::populateControls()
4. Call a method named populateItemList($invoice_id)
4a) populateItemList() should query the invoice_lines table where InvoiceID = $invoice_id
4b) It should then iterate through the results and create the controls for each row (ctlLabel x5, ctlLinkButton x2)
@aqualad
aqualad / class_inheritance.php
Created May 29, 2013 22:27
Example of Inheritance in PHP
<?php
class aParent {
public $a = 'a';
protected $b = 'b';
private $c = 'c';
}
class aChild extends aParent {