Skip to content

Instantly share code, notes, and snippets.

/ext.sc_test.php

Created Jan 4, 2013
Embed
What would you like to do?
SafeCracker field population test
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ExpressionEngine - by EllisLab
*
* @package ExpressionEngine
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2003 - 2011, EllisLab, Inc.
* @license http://expressionengine.com/user_guide/license.html
* @link http://expressionengine.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SC Test Extension
*
* @package ExpressionEngine
* @subpackage Addons
* @category Extension
* @author Dom Stubbs
* @link http://www.vayadesign.net
*/
class Sc_test_ext {
public $settings = array();
public $description = 'Populate extra SafeCracker fields';
public $docs_url = '';
public $name = 'SC Test';
public $settings_exist = 'n';
public $version = '0.1';
private $EE;
/**
* Constructor
*
* @param mixed Settings array or empty string if none exist.
*/
public function __construct($settings = '')
{
$this->EE =& get_instance();
$this->settings = $settings;
}// ----------------------------------------------------------------------
/**
* Activate Extension
*
* This function enters the extension into the exp_extensions table
*
* @see http://codeigniter.com/user_guide/database/index.html for
* more information on the db class.
*
* @return void
*/
public function activate_extension()
{
// Setup custom settings in this array.
$this->settings = array();
$data = array(
'class' => __CLASS__,
'method' => 'safecracker_submit_entry_start',
'hook' => 'safecracker_submit_entry_start',
'settings' => serialize($this->settings),
'version' => $this->version,
'enabled' => 'y'
);
$this->EE->db->insert('extensions', $data);
}
// ----------------------------------------------------------------------
/**
* safecracker_submit_entry_start
*
* @param
* @return
*/
public function safecracker_submit_entry_start()
{
$_POST['news_body'] = 'Test';
}
// ----------------------------------------------------------------------
/**
* Disable Extension
*
* This method removes information from the exp_extensions table
*
* @return void
*/
function disable_extension()
{
$this->EE->db->where('class', __CLASS__);
$this->EE->db->delete('extensions');
}
// ----------------------------------------------------------------------
/**
* Update Extension
*
* This function performs any necessary db updates when the extension
* page is visited
*
* @return mixed void on update / false if none
*/
function update_extension($current = '')
{
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
}
// ----------------------------------------------------------------------
}
/* End of file ext.sc_test.php */
/* Location: /system/expressionengine/third_party/sc_test/ext.sc_test.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment