Skip to content

Instantly share code, notes, and snippets.

View alexweissman's full-sized avatar
💭
For the glory of the swarm

Alex Weissman alexweissman

💭
For the glory of the swarm
View GitHub Profile
@alexweissman
alexweissman / counter_builder.php
Last active August 29, 2015 14:10
Custom class for rendering counters with UserFrosting
<?php
require_once("template_functions.php");
class CounterBuilder {
/* Information about the counters to render.
* Allowed options:
* 'label'
* 'display': 'hidden', 'show'
@alexweissman
alexweissman / create_user.php
Created December 24, 2014 17:13
adding study_in field
<?php
// Create a new user.
require_once("../models/config.php");
set_error_handler('logAllErrors');
// Request method: POST
$ajax = checkRequestMode("post");
@alexweissman
alexweissman / dropdown
Last active August 29, 2015 14:13
Example loading a dropdown
<?php
$user_choices = [];
if (checkActionPermission('loadUsers', array())) {
if (($users = loadUsers()) === false) {
apiReturnError($ajax, ACCOUNT_ROOT);
}
foreach ($users as $user_id => $user){
@alexweissman
alexweissman / index.php
Created August 30, 2015 00:02
PHP loop to display posts in themes/theme-name/
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* @link http://codex.wordpress.org/Template_Hierarchy
@alexweissman
alexweissman / contact.json
Last active March 5, 2016 20:01
My website's contact form (for UserFrosting v0.3.1)
Put this in userfrosting/schema/forms/ and delete this comment
{
"name" : {
"validators" : {
"length" : {
"min" : 1,
"max" : 200,
"message" : "Please enter a name between 1 and 200 characters."
},
"required" : {
@alexweissman
alexweissman / install.php
Created October 21, 2015 20:23
New tables
--
-- Table structure for table `uf_user`
--
CREATE TABLE IF NOT EXISTS `uf_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(50) NOT NULL,
`display_name` varchar(50) NOT NULL,
`email` varchar(150) NOT NULL,
`title` varchar(150) NOT NULL,
@alexweissman
alexweissman / custom-hash.js
Last active November 9, 2015 03:26
Custom hash transformations for tablesorter.js
sort2Hash_encodeHash : function( config, tableId, component, value, rawValue ) {
var wo = config.widgetOptions;
if ( component === 'filter' ) {
// rawValue is an array of filter values, numerically indexed
var encodedFilters = "";
var len = rawValue.length;
for ( index = 0; index < len; index++ ) {
if (rawValue[index]) {
var columnName = $(config.$headerIndexed[ index ][0]).attr(wo.sort2Hash_headerTextAttr);
encodedFilters += '&filter[' + tableId + '][' + columnName + ']=' + encodeURIComponent(rawValue[index]);
@alexweissman
alexweissman / README.md
Last active January 23, 2021 18:18
Migrating email accounts from a cPanel hosting environment to Mail-in-a-Box

Migrating email accounts from a cPanel hosting environment to Mail-in-a-Box

Part 1: Pregame

  1. Send a mass email to all of your account holders, letting them know that you will be migrating their email accounts to a new server. Send them the instructions from MiaB control panel for connecting to your MiaB server from their mobile/Outlook/Gmail/etc, if applicable. Also, send them a link to the new webmail address. Be sure to give adequate advanced notice (several days, if possible). Advise them to not change their passwords during this time (their passwords will be preserved during migration).
  2. Create a new "test" email account in the MiaB control panel for your domain. This will let MiaB set up the DNS records needed for the domain.

Part 2: Copy credentials

Copy the email account credentials from your cPanel host to MiaB:

@alexweissman
alexweissman / Tutor.php
Last active January 11, 2016 18:40
hasOne relationship modeling in Eloquent
namespace UserFrosting;
class Tutor extends UFModel {
/**
* Get the User object for this Tutor.
*/
public function user() {
return $this->belongsTo('UserFrosting\User');
}
@alexweissman
alexweissman / collegeparktutors.php
Created January 12, 2016 01:11
Custom Grav theme to interact with UserFrosting
<?php
namespace Grav\Theme;
class CollegeParkTutors extends Antimatter {
public function onTwigTemplatePaths() {
$grav_twig = $this->grav['twig'];
$uf_dir = realpath(ROOT_DIR . '/..') . '/common/';
$grav_twig->twig_paths[] = $uf_dir . "templates/collegeparktutors";
}