Skip to content

Instantly share code, notes, and snippets.

View pgorod's full-sized avatar

pgorod

View GitHub Profile
@pgorod
pgorod / gist:c838f258fadf9528b61183e763e978a8
Last active October 8, 2017 18:11 — forked from jmertic/gist:3684162
HOWTO: Adding your own ListView action items - Part 2
<?php
class CustomAccountsController extends SugarController
{
public function action_displaypassedids() {
if ( !empty($_REQUEST['uid']) ) {
$recordIds = explode(',',$_REQUEST['uid']);
foreach ( $recordIds as $recordId ) {
$bean = SugarModule::get($_REQUEST['module'])->loadBean();
$bean->retrieve($recordId);
@pgorod
pgorod / Fix "selected" in Listviews, SuiteR
Created October 10, 2017 14:59
Fix "selected" in Listviews, SuiteR
jssource/src_files/include/javascript/sugar_3.js
Line 2432
sugarListView.prototype.toggleSelected = function () {
var numSelected = sugarListView.get_num_selected();
var selectedRecords = document.getElementById("selectedRecordsTop");
var selectActions = document.getElementById("selectActions");
var selectActionsDisabled = document.getElementById("selectActionsDisabled");
Dumps backtrace into log, with chronological order
Call with
$GLOBALS['log']->debug(generateCallTrace());
----------------
function generateCallTrace()
{
@pgorod
pgorod / gist:c535ba65ee81e1e9893d90097a899236
Created March 28, 2018 08:49
Populate a dropdown from the database (SuiteCRM)
https://web.archive.org/web/20140116145925/http://www.eggsurplus.com/home/content/populate-a-dropdown-from-the-database/
@pgorod
pgorod / Undo a commit and redo
Created April 2, 2018 17:00 — forked from tkersey/Undo a commit and redo
Git: undo a commit and redo
http://stackoverflow.com/questions/927358/git-undo-last-commit
Undo a commit and redo
$ git commit ...
$ git reset --soft HEAD^ (1)
$ edit (2)
$ git commit -a -c ORIG_HEAD (3)
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset".
@pgorod
pgorod / repair.php
Created December 12, 2018 18:04 — forked from chicks/repair.php
Quick Repair and Rebuild Sugar from the Command line - adapted from Jeff Bickhart's version.
#! /usr/bin/env php
<?php
# Stuff we have to do
if(!defined('sugarEntry'))define('sugarEntry', true);
function usage() {
global $argv;
return "\n" . $argv[0] . " <path to sugar>\n";
}
@pgorod
pgorod / showAsPrint.js
Created June 25, 2019 09:51 — forked from jscher2000/showAsPrint.js
Emulate print media in Firefox 62 (userscript work in progress)
// For Firefox's Web Console, creates the functions showAsPrint() and undoShowAsPrint()
// to roughly emulate print media and revert
function showAsPrint(){
var docSS = document.styleSheets, ss, oldMedia, newMedia, rules;
var p2s = function(media){
if (media.indexOf('all') > -1) return media; //no need to change
if (media == 'print') return 'all, wasprint'; //show on screen, too
if (media.indexOf('print') > -1 && media.indexOf('screen') > -1) return media; //no need to change
if (media == 'screen') return 'wasscreen'; //hide these rules
if (media.indexOf('screen') > -1) return media.replace('screen', 'wasscreen'); //hide these rules
@pgorod
pgorod / gist:bd53339fbf6bddbed824c762539ed058
Last active March 12, 2020 14:20 — forked from jmertic/gist:5660495
Programmatically Find the Name of the Relationship between two Modules
<?php
function getRelationshipByModules ($m1, $m2)
{
global $db,$dictionary,$beanList;
$rel = new Relationship;
if($rel_info = $rel->retrieve_by_sides($m1, $m2, $db)){
$bean = BeanFactory::getBean($m1);
$rel_name = $rel_info['relationship_name'];
foreach($bean->field_defs as $field=>$def){
@pgorod
pgorod / base.rb
Created January 31, 2023 11:35
importing-from-kunena-3-to-discourse
# frozen_string_literal: true
if ARGV.include?('bbcode-to-md')
# Replace (most) bbcode with markdown before creating posts.
# This will dramatically clean up the final posts in Discourse.
#
# In a temp dir:
#
# git clone https://github.com/nlalonde/ruby-bbcode-to-md.git
# cd ruby-bbcode-to-md
@pgorod
pgorod / kunena3.rb
Created January 31, 2023 11:39
importing-from-kunena-3-to-discourse-2
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# If you change this script's functionality, please consider making a note here:
# https://meta.discourse.org/t/importing-from-kunena-3/
# Before running this script, paste these lines into your shell,
# then use arrow keys to edit the values
=begin