Skip to content

Instantly share code, notes, and snippets.

<?php
// User settings
define('userDataName', 'EXAMPLE');
define('userDataUsername', 'example');
define('userDataEmail', 'info@example.com');
define('userDataPassword', 'YOURPASSWORD');
// Detect the Joomla! directory
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
@yireo
yireo / moodle_iframe_detect.md
Last active December 29, 2015 12:59
Sample code to allow a Moodle theme to detect IFRAMES, for instance when wrapping the Moodle theme into Joomla! using Joomdle.

Detect IFRAME in Moodle theme

This gist contains code-suggestions to allow for a Moodle-theme to detect IFRAMES, and accordingly use a PHP-flag to hide blocks within the theme. Using that PHP-flag, allows you to use the same theme for Moodle-administration (by accessing the Moodle application directly), as well as for wrapping things within Joomla!.

The technique involves setting a cookie from both the Moodle-theme (using JavaScript) as well as the Joomdle component (using PHP). The cookie will then be used within the PHP-code of the Moodle-theme to hide columns - how to do that part depends entirely on the code of your specific Moodle theme. Note that the cookie is initialized on purpose with a lifetime of 0 (browser-session related) and a path of / (assuming both Joomla! as Moodle are installed in the same domain).

Place this PHP-code within the components/com_joomdle/joomdle.php file just after the defined()-check

setcookie('joomdle_iframe', 1, 0, '/');

@yireo
yireo / yireo_googletranslate_product.php
Created November 3, 2013 09:17
Magento script to automate product-translations using the Yireo GoogleTranslate extension
<?php
// Basic settings
$storeCodes = array('french', 'german', 'danish', 'dutch');
$productAttributes = array('name', 'short_description', 'description');
// Initialize Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@yireo
yireo / yireo_googletranslate_basic.php
Created November 3, 2013 09:16
Magento script to translate a specific text using the Yireo GoogleTranslate extension
<?php
// Basic settings
$text = 'Hello World';
$source = 'en';
$destination = 'fr';
// Startup the application
require_once 'app/Mage.php';
Mage::app();
@yireo
yireo / yr_magento_order_send_unsent.php
Created October 20, 2013 08:06
Cronjob for Magento to send any order-emails that have not been sent yet
<?php
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$from_date = date('Y-m-d', time() - (60*60*24*14));
$orders = Mage::getModel('sales/order')->getCollection()
->addAttributeToFilter('created_at', array('from' => $from_date))
->addAttributeToFilter('email_sent', array('null' => true))
;
@yireo
yireo / yr_magento_invoice_send_unsent.php
Last active December 26, 2015 00:39
Cronjob for Magento to send any invoice-emails that have not been sent yet
<?php
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$from_date = date('Y-m-d', time() - (60*60*24*14));
$invoices = Mage::getModel('sales/order_invoice')->getCollection()
->addAttributeToFilter('created_at', array('from' => $from_date))
->addAttributeToFilter('email_sent', array('null' => true))
;
@yireo
yireo / yr_joomla_discover.php
Last active December 19, 2015 17:19
PHP-script to discover Joomla! extensions that were uploaded to the Joomla! filesystem, and install them automatically. It also installs any database-fixes that might be pending after upgrading through patch-files.
<?php
// Define variables
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
define('_JEXEC', 1);
define('JPATH_BASE', DOCUMENT_ROOT);
define('DS', DIRECTORY_SEPARATOR );
if(!isset($_SERVER['REQUEST_METHOD'])) $_SERVER['REQUEST_METHOD'] = null;
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null;
if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = null;
@yireo
yireo / yr_rename_database_table_prefix.php
Created July 3, 2013 15:23
PHP-script to rename MySQL database tables in a MySQL database - for instance when using Joomla!
<?php
$database_host = 'localhost'; // Database hostname
$database_user = 'root'; // Database username
$database_password = ''; // Database password
$database_name = 'myjoomla'; // Database name
$new_table_prefix = 'zkl_'; // New table prefix
$old_table_prefix = 'jos_'; // Old table prefix (optional)
$test = false; // Test-run (true or false)
// NO NEED TO EDIT BELOW THIS LINE
@yireo
yireo / yr_simplelists_spupgrade_remap_items.php
Created June 28, 2013 10:13
PHP-script to remap old SimpleLists category-IDs (Joomla! 1.5) to new SimpleLists category-IDs (Joomla! 2.5 or higher). Make sure to run the script "yr_simplelists_spupgrade_categories.php" first and make sure that all SimpleLists categories are working as they should. For instance, open up a SimpleLists category and save it, to see if that work…
<?php
// Define variables
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
define('_JEXEC', 1);
define('JPATH_BASE', DOCUMENT_ROOT);
define('DS', DIRECTORY_SEPARATOR );
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null;
if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = null;
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
@yireo
yireo / yr_simplelists_spupgrade_categories.php
Created June 28, 2013 10:04
PHP-script to migrate SimpleLists categories from Joomla! 1.5 to Joomla! 2.5 or 3.0 by using the SPUpgrade component. Note that SPUpgrade component needs to be installed when running this script. The original category-ID is not re-used in Joomla!, but saved in the category-field "note". This is used in another script "yr_simplelists_spupgrade_re…
<?php
// Define variables
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
define('_JEXEC', 1);
define('JPATH_BASE', DOCUMENT_ROOT);
define('DS', DIRECTORY_SEPARATOR );
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null;
if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = null;
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );