Skip to content

Instantly share code, notes, and snippets.

View davidpede's full-sized avatar

David Pede davidpede

View GitHub Profile
@Jako
Jako / gist:0679e1b23cb8f5c5494c6826eba0f6a9
Created October 18, 2019 17:41
MODX FormIt Email Selector
<?php
$selectField = $modx->getOption('emailSelectField', $scriptProperties, 'department');
$selectTo = $modx->getOption('emailSelectTo', $scriptProperties, '');
$selectTo = ($selectTo) ? explode(',', $selectTo) : array();
if ($selectField && $selectTo) {
$selected = intval($hook->getValue($selectField)) - 1;
if ($selected && isset($selectTo[$selected])) {
$hook->formit->config['emailTo'] = $selectTo[$selected];
}
@ravibhure
ravibhure / git_rebase.md
Last active April 3, 2024 08:38
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@Mark-H
Mark-H / connector.php
Created April 12, 2016 11:10
Connector for MODX Revolution with whitelist of permitted actions accessible from the web
<?php
// set context
$_REQUEST['ctx'] = 'web';
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
require_once MODX_CONNECTORS_PATH . 'index.php';
// define allowed actions
$webActions = array(
'one/allowed/action',
@gserrano
gserrano / recursive_copy_files.php
Created November 19, 2015 22:14
PHP Recursive copy files
/*
* This function copy $source directory and all files
* and sub directories to $destination folder
*/
function recursive_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
@goldsky
goldsky / connector.php
Last active November 25, 2020 20:30
Ajax's connector file using MODX's main index.php
<?php
/**
* Ajax Connector
*
* @package mypackage
*/
$validActions = array(
'web/data/delete',
'web/data/edit'
@krismas
krismas / syncpage.php
Last active October 14, 2021 14:03
A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a resource
<?php
/*
* A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a cached resource - (c) 2012 ackwa.fr
*
* @version : 1.0.0
* @see : https://gist.github.com/gists/3639503
* @name : syncpage.php
* @author : g.noel@ackwa.fr
*
* @event : OnDocFormSave, OnDocFormPrerender