Welcome to Geeklog, Anonymous Tuesday, October 04 2022 @ 06:34 am EDT

Geeklog Forums

Patch: plugin support for story admin


Status: offline

DasFreak

Forum User
Newbie
Registered: 10/06/04
Posts: 1
(posted on geeklog-devtalk but no response)

Hi all. I'm doing some modifications for macosxhints.com which uses Geeklog.
As part of this, I've been making some additions to story submissions
which I've wrapped around plugins. To achieve this I've had to modify
geeklog code to allow plugin support for the story admin page.

I've attached the relevant diffs against 1.3.9sr1 for possible
inclusion in to the source tree. Apologies for tab stripping by forum.

I've probably missed a bit but hope it's a enough to be accepted. I've
a niggling feeling I've missed the equivalent function to
PLG_profileVariablesDisplay but I've not found a requirement for it
as yet.

Cheers,
Graeme

--- lib-plugins.php 2004-06-01 22:17:54.000000000 +1000
+++ /var/www/html/geeklog/system/lib-plugins.php 2004-10-04 16:32:13.000000000 +1000
@@ -60,7 +60,6 @@
function PLG_callFunctionForAllPlugins($function_name)
{
global $_TABLES;
-
$result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1&quotWink;
$nrows = DB_numRows($result);
for ($i = 1; $i <= $nrows; $i++) {
@@ -684,6 +683,49 @@
}

/**
+* Geeklog is about to display the edit form for a story. Plugins
+* now get a chance to add their own variables and input fields to the form.
+*
+* @param int $sid story id of the story to be edited
+* @param ref $template reference of the Template for the story edit form
+*
+* NOTE: new function
+*/
+function PLG_storyVariablesEdit($sid, &$template)
+{
+ global $_TABLES;
+
+ $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1&quotWink;
+ $nrows = DB_numRows($result);
+ for ($i = 1; $i <= $nrows; $i++) {
+ $A = DB_fetchArray($result);
+ $function = 'plugin_storyvariablesedit_' . $A['pi_name'];
+ if (function_exists($function)) {
+ $function ($sid, $template);
+ }
+ }
+
+}
+
+/**
+* When a story is saved by the admin this function fires to allow plgins to
+* receive and manipulate the form data
+* Plugins will have to refer to the global $HTTP_POST_VARS array to get the
+* actual data.
+*
+* @param string $plugin name of a specific plugin or empty (all plugins)
+*
+*/
+function PLG_storyExtrasSave ($plugin = ''Wink
+{
+ if (empty ($plugin)) {
+ PLG_callFunctionForAllPlugins ('plugin_storyextrassave_'Wink;
+ } else {
+ PLG_callFunctionForOnePlugin ('plugin_storyextrassave_' . $plugin);
+ }
+}
+
+/**
* Geeklog is about to display the edit form for the user's profile. Plugins
* now get a chance to add their own variables and input fields to the form.
*

--- story.php 2004-06-01 22:17:53.000000000 +1000
+++ /var/www/html/geeklog/public_html/admin/story.php 2004-10-04 16:33:44.000000000 +1000
@@ -397,7 +397,11 @@
$story_templates->set_var('lang_preview', $LANG24[9]);
$story_templates->set_var('lang_cancel', $LANG24[10]);
$story_templates->set_var('lang_delete', $LANG24[11]);
+
+ PLG_storyVariablesEdit($sid, &$story_templates);
$story_templates->parse('output','editor'Wink;
+
+
$display .= $story_templates->finish($story_templates->get_var('output'Wink);
$display .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'Wink);

@@ -1099,6 +1103,7 @@
}
$unixdate = strtotime("$publish_month/$publish_day/$publish_year $publish_hour:$publish_minute:$publish_second&quotWink;
submitstory($type,$sid,$uid,$tid,$title,$introtext,$bodytext,$hits,$unixdate,$comments,$featured,$commentcode,$statuscode,$postmode,$frontpage, $draft_flag,$numemails,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$delete,$show_topic_icon);
+ PLG_storyExtrasSave ();
} else { // 'cancel' or no mode at all
if (($mode == $LANG24[10]) && !empty ($LANG24[10]) &&
($type == 'submission'Wink) {
 Quote

All times are EDT. The time is now 06:34 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content