Need new hook

By jenolan - March 28, 2011

I am writing a new plugin ((secret name))

One thing I want to do is a similar thing to the breadcrumb, when a record is created/saved I need to set a value before the record is updated. The existing 'record_presave' doesn't actually let you set a value that is set to none as putting the value into the $_REQUEST array is ignored by the function _getRecordValuesFromFormInput, and if it is not 'none' then it is included in the edit when it is a 'display only' value.

I can do it by re-reading the record and then doing a save but that seems hugely wasteful. What would be the nicest is a new field type of 'hidden' that could still be set in the presave call but not displayed for edit.

Thanks,
Larry
---



Peace and Long Life

Re: [jenolan] Need new hook

By jenolan - March 29, 2011

Another issue .. can't create an index for a table in the schema ini (at least that I can find).

Oh yeah .. being able to hide a table totally, I know I could create one outside the name space but I want to keep everything installable/uninstallable from within cms Builder [cool]
---



Peace and Long Life

Re: [Dave] Need new hook

By jenolan - March 29, 2011

Me really lost...

There is no hook called for plugin activate/deactivate for a hook pr have I missed something obvious?

Larry
---



Peace and Long Life

Re: [jenolan] Need new hook

By jenolan - March 29, 2011

In plugin functions can you add a hook plugin_activate and plugin_deactivate (as per below) so that a plugin can do post process stuff.
function activatePlugin($file) {
global $SETTINGS;

// test for errors - if this dies it won't activate the plugin
$pluginsDir = "{$GLOBALS['PROGRAM_DIR']}/plugins";
include "$pluginsDir/$file";

// add plugin to list
$activePluginFiles = array();
$activePluginFiles[$file] = 1;
foreach (preg_split('/,\s+/', $SETTINGS['activePlugins']) as $activeFile) {
$activePluginFiles[$activeFile] = 1;

}

// save settings
$GLOBALS['SETTINGS']['activePlugins'] = join(', ', array_keys($activePluginFiles));
saveINI(SETTINGS_FILEPATH, $SETTINGS, 'sortKeys');
doAction( 'plugin_activate', $file );

}

function deactivatePlugin($file) {
global $SETTINGS;

// remove plugin from list
$activePluginFiles = array();
foreach (preg_split('/,\s+/', $SETTINGS['activePlugins']) as $activeFile) {
$activePluginFiles[$activeFile] = 1;
}
unset($activePluginFiles[$file]);

// save settings
$GLOBALS['SETTINGS']['activePlugins'] = join(', ', array_keys($activePluginFiles));
saveINI(SETTINGS_FILEPATH, $SETTINGS, 'sortKeys');
doAction( 'plugin_deactivate', $file );

}

---



Peace and Long Life

Re: [jenolan] Need new hook

By Dave - March 31, 2011

Hi jenolan,

That's a good idea, I've added both of those to 2.08. You can add them to your code manually and know they'll be in the next release.

Another way I sometimes create schemas is like this (from outgoing SMSl):

$GLOBALS['OUTGOING_SMS_TABLENAME'] = '_outgoing_sms';
addAction('admin_postlogin', '_outgoingSMS_createSchema', null, 0);
...

//
function _outgoingSMS_createSchema() {
$tableName = $GLOBALS['OUTGOING_SMS_TABLENAME'];
$sourcePath = dirname(__FILE__) . "/$tableName.ini.php";
createSchemaFromFile( $sourcePath );
}


And then I add other code in there as needed.

Let me know any other questions or suggestions. Thanks!
Dave Edis - Senior Developer
interactivetools.com