From codesite-noreply @ google.com Wed Oct 1 00:44:53 2008 From: codesite-noreply @ google.com (codesite-noreply @ google.com) Date: Tue, 30 Sep 2008 08:44:53 -0700 Subject: [geeklog-jp-addon commit] r56 - in trunk/upkit: . plugin_1.5.0 plugin_1.5.0/admin plugin_1.5.0/language plugin_1.5.0/public... Message-ID: <00151751146c6a65e004581eddb3@google.com> Author: dengenxp Date: Tue Sep 30 08:43:18 2008 New Revision: 56 Added: trunk/upkit/ trunk/upkit/make_pi.php (contents, props changed) trunk/upkit/make_pi_config.php (contents, props changed) trunk/upkit/plugin_1.5.0/ trunk/upkit/plugin_1.5.0/INSTALL (contents, props changed) trunk/upkit/plugin_1.5.0/admin/ trunk/upkit/plugin_1.5.0/admin/index.php (contents, props changed) trunk/upkit/plugin_1.5.0/admin/install.php (contents, props changed) trunk/upkit/plugin_1.5.0/config.php (contents, props changed) trunk/upkit/plugin_1.5.0/functions-advanced.inc (contents, props changed) trunk/upkit/plugin_1.5.0/functions.inc (contents, props changed) trunk/upkit/plugin_1.5.0/install.html (contents, props changed) trunk/upkit/plugin_1.5.0/install_defaults.php (contents, props changed) trunk/upkit/plugin_1.5.0/install_ja.html (contents, props changed) trunk/upkit/plugin_1.5.0/language/ trunk/upkit/plugin_1.5.0/language/english.php (contents, props changed) trunk/upkit/plugin_1.5.0/language/english_utf-8.php (contents, props changed) trunk/upkit/plugin_1.5.0/language/japanese_utf-8.php (contents, props changed) trunk/upkit/plugin_1.5.0/public_html/ trunk/upkit/plugin_1.5.0/public_html/images/ trunk/upkit/plugin_1.5.0/public_html/images/plugin.gif (contents, props changed) trunk/upkit/plugin_1.5.0/public_html/index.php (contents, props changed) trunk/upkit/plugin_1.5.0/sql/ trunk/upkit/plugin_1.5.0/sql/mysql_install.php (contents, props changed) trunk/upkit/plugin_1.5.0/templates/ trunk/upkit/plugin_1.5.0/templates/admin/ trunk/upkit/plugin_1.5.0/templates/admin/editor.thtml (contents, props changed) trunk/upkit/plugin_1.5.0/templates/index.thtml (contents, props changed) trunk/upkit/universal.html (contents, props changed) trunk/upkit/universal_ja.html (contents, props changed) Log: 汎用プラグインツールキット(Universal Plugin Toolkit) for Geeklog 1.5 をコミ ットします。 Added: trunk/upkit/make_pi.php ============================================================================== --- (empty file) +++ trunk/upkit/make_pi.php Tue Sep 30 08:43:18 2008 @@ -0,0 +1,267 @@ +#!/usr/bin/php + \ No newline at end of file Added: trunk/upkit/make_pi_config.php ============================================================================== --- (empty file) +++ trunk/upkit/make_pi_config.php Tue Sep 30 08:43:18 2008 @@ -0,0 +1,25 @@ + \ No newline at end of file Added: trunk/upkit/plugin_1.5.0/INSTALL ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/INSTALL Tue Sep 30 08:43:18 2008 @@ -0,0 +1,40 @@ +Install/Uninstall instruction for the Geeklog {plugin} plugin. + +INSTALL: + +Step 1: Back up your Geeklog Database. The {plugin} plugin adds tables to your Geeklog database. You can do +this with the built in admin backup facility. + +Step 2: Uncompress the {plugin} plugin archive while in the /plugins directory. The archive will +create a directory called {plugin} in the plugins directory. + +Step 3: Create the public_html and admin directories. Under your html directory (usually public_html) +create a directory called {plugin}. Under your admin/plugins/ directory create a directory called {plugin}. + +Step 4: Change to your /plugins/{plugin}/ directory. Copy the files in the admin directory +to the admin/plugins/{plugin}/ directory your created in step 3. Copy the files and directories in the +public_html directory to the public_html/{plugin}/ directory your created in step 3. + +Step 5: Edit the config.php in the {plugin} directory and confirm the table prefix and anonymous access +settings and other display settings. The default is to use the geeklog table prefix and not allow +anonymous access. + +Step 6: Log in to your Geeklog as a root user and run install.php in your admin/plugins/{plugin}/ directory. +The install page will tell you if the install was successful or not. If not examine Geeklog system errorlog +for possible problems. + +The {plugin} plugin should now be installed and functioning. Clicking on the {plugin} Icon will +take you to the admin page. + +Step 7: Set up security. On install only the root users have access to {plugin} administration and Viewing. +You can delegate control for either of these functions through the user and group editors. + +UNINSTALL: + +Step 1: Run the install.php page in your admin/plugins/{plugin} directory. This will remove all the data from +your database. + +Step 2: Delete the three plugin directories created in the install process: plugins/{plugin}/ +/{plugin}/ and /plugins/{plugin}/ + +That's it. Added: trunk/upkit/plugin_1.5.0/admin/index.php ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/admin/index.php Tue Sep 30 08:43:18 2008 @@ -0,0 +1,377 @@ +set_file('editor', 'editor.thtml'); + $T->set_var('xhtml', XHTML); + $T->set_var('site_url', $_CONF['site_url']); + $T->set_var('icon_url', plugin_geticon_{plugin}()); + $T->set_var('site_admin_url', $_CONF['site_admin_url']); + $T->set_var('layout_url', $_CONF['layout_url']); + + if (!empty($up_id)) { + + $result = DB_query("SELECT * FROM {$_TABLES['{plugin}']} WHERE up_id = '$up_id'"); + + if (DB_numRows($result) !== 1) { + $msg = COM_startBlock($LANG_{lang_var_postfix}['stats_no_value'], '', + COM_getBlockTemplate('_msg_block', 'header')); + $msg .= $LANG_{lang_var_postfix}['stats_no_value']; + $msg .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); + return $msg; + } + + $A = DB_fetchArray($result); + + $access = SEC_hasAccess($A['owner_id'], $A['group_id'], + $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); + if ($access == 0 OR $access == 2) { + $retval .= COM_startBlock($LANG_{lang_var_postfix}['access_denied'], '', + COM_getBlockTemplate('_msg_block', 'header')); + $retval .= $LANG_{lang_var_postfix}['access_denied_msg']; + $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); + COM_accessLog("User {$_USER['username']} tried to illegally submit or edit {plugin} $up_id."); + return $retval; + } + + } else { + + $A['up_id'] = ''; + $A['up_title'] = ''; + $A['up_value'] = ''; + $A['owner_id'] = $_USER['uid']; + if (isset($_GROUPS['{display_name} Admin'])) { + $A['group_id'] = $_GROUPS['{display_name} Admin']; + } else { + $A['group_id'] = SEC_getFeatureGroup('{plugin}.edit'); + } + SEC_setDefaultPermissions($A, $_{conf_var_prefix}_CONF['default_permissions']); + $access = 3; + } + $retval .= COM_startBlock($LANG_{lang_var_postfix}['{plugin}editor'], '', + COM_getBlockTemplate ('_admin_block', 'header')); + + $T->set_var('up_id', $A['up_id']); + if (!empty($up_id) && SEC_hasRights('{plugin}.edit')) { + $delbutton = ''; + $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; + $T->set_var('delete_option', sprintf($delbutton, $jsconfirm)); + $T->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); + } + + $T->set_var('lang_title', $LANG_{lang_var_postfix}['stats_title']); + $T->set_var('lang_value', $LANG_{lang_var_postfix}['stats_value']); + $T->set_var('val_title', htmlspecialchars(stripslashes ($A['up_title']))); + $T->set_var('val_value', $A['up_value']); + $T->set_var('lang_save', $LANG_ADMIN['save']); + $T->set_var('lang_cancel', $LANG_ADMIN['cancel']); + + // user access info + $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); + $T->set_var('lang_owner', $LANG_ACCESS['owner']); + $ownername = COM_getDisplayName ($A['owner_id']); + $T->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}")); + $T->set_var('owner_name', $ownername); + $T->set_var('owner', $ownername); + $T->set_var('{plugin}_ownerid', $A['owner_id']); + $T->set_var('lang_group', $LANG_ACCESS['group']); + $T->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access)); + $T->set_var('lang_permissions', $LANG_ACCESS['permissions']); + $T->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']); + $T->set_var('permissions_editor', + SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'])); + $T->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']); + $T->set_var('gltoken_name', CSRF_TOKEN); + $T->set_var('gltoken', SEC_createToken()); + + $T->parse('output', 'editor'); + $retval .= $T->finish($T->get_var('output')); + + $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); + + return $retval; +} + + +/** +* Save a data to the database +* +*/ +function save{plugin}($up_id, $title, $value, $owner_id, $group_id, + $perm_owner, $perm_group, $perm_members, $perm_anon) +{ + global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG_{lang_var_postfix}, $_{conf_var_prefix}_CONF; + + $retval = ''; + + // Convert array values to numeric permission values + list($perm_owner, $perm_group, $perm_members, $perm_anon) + = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); + + $title = addslashes(COM_checkHTML(COM_checkWords($title))); + $value = addslashes($value); + + if (empty($owner_id)) { + // this is new link from admin, set default values + $owner_id = $_USER['uid']; + if (isset($_GROUPS['{display_name} Admin'])) { + $group_id = $_GROUPS['{display_name} Admin']; + } else { + $group_id = SEC_getFeatureGroup ('{plugin}.edit'); + } + $perm_owner = 3; + $perm_group = 2; + $perm_members = 2; + $perm_anon = 2; + } + + $access = 0; + $up_id = addslashes($up_id); + if (DB_count($_TABLES['{plugin}'], 'up_id', $up_id) > 0) { + $result = DB_query ("SELECT owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon " + ."FROM {$_TABLES['{plugin}']} WHERE up_id = '$up_id'"); + $A = DB_fetchArray($result); + $access = SEC_hasAccess($A['owner_id'], $A['group_id'], + $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); + } else { + $access = SEC_hasAccess($owner_id, $group_id, + $perm_owner, $perm_group, $perm_members, $perm_anon); + } + + if (($access < 3) || !SEC_inGroup($group_id)) { + $display .= COM_siteHeader('menu', $MESSAGE[30]); + $display .= COM_startBlock($LANG_{lang_var_postfix}['access_denied'], '', + COM_getBlockTemplate('_msg_block', 'header')); + $display .= $LANG_{lang_var_postfix}['access_denied_msg']; + $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); + $display .= COM_siteFooter(); + COM_accessLog("User {$_USER['username']} tried to illegally submit or edit {plugin} $up_id."); + echo $display; + exit; + } + + if (!empty($title) && !empty($value)) { + + if (DB_count($_TABLES['{plugin}'], 'up_id', $up_id) > 0) { + $sql = "UPDATE {$_TABLES['{plugin}']} " + . "SET up_title='$title', up_value=$value, owner_id=$owner_id, group_id=$group_id, " + . "perm_owner=$perm_owner, perm_group=$perm_group, perm_members=$perm_members, perm_anon=$perm_anon " + . "WHERE up_id = $up_id"; + } else { + $sql = "INSERT INTO {$_TABLES['{plugin}']} " + . '(up_title, up_value, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) ' + . "VALUES ('$title', $value, $owner_id , $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)"; + } + DB_query($sql); + + return PLG_afterSaveSwitch( + $_{conf_var_prefix}_CONF['aftersave'], + $_CONF['site_url'] . '/{plugin}/index.php?up_id=' . $up_id, + '{plugin}', 2); + + } else { // missing fields + + $retval .= COM_siteHeader('menu', $LANG_LINKS_ADMIN['manager']); + $retval .= COM_errorLog($LANG_{lang_var_postfix}['missing_fields'], 2); + if (DB_count($_TABLES['{plugin}'], 'up_id', $up_id) > 0) { + $retval .= edit{plugin}($up_id); + } else { + $retval .= edit{plugin}(); + } + $retval .= COM_siteFooter(); + + return $retval; + } +} + +/** +* Delete a data from the database +* +*/ +function delete{plugin}($up_id) +{ + global $_CONF, $_TABLES, $_USER; + + $result = DB_query("SELECT owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon " + ."FROM {$_TABLES['{plugin}']} WHERE up_id = '$up_id'"); + $A = DB_fetchArray($result); + $access = SEC_hasAccess($A['owner_id'], $A['group_id'], + $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); + if ($access < 3) { + COM_accessLog("User {$_USER['username']} tried to illegally delete {plugin} $up_id."); + + return COM_refresh($_CONF['site_admin_url'] . '/plugins/{plugin}/index.php'); + } + + DB_delete($_TABLES['{plugin}'], 'up_id', $up_id); + + return COM_refresh($_CONF['site_admin_url'] . '/plugins/{plugin}/index.php?msg=3'); +} + + +function list{plugin}() +{ + global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_{lang_var_postfix}; + + require_once $_CONF['path_system'] . 'lib-admin.php'; + + $retval = ''; + + $header_arr = array( // display 'text' and use table field 'field' + array( 'text' => $LANG_ADMIN['edit'], + 'field' => 'edit', + 'sort' => false + ), + array( 'text' => $LANG_{lang_var_postfix}['stats_title'], + 'field' => 'up_title', + 'sort' => true + ), + array( 'text' => $LANG_{lang_var_postfix}['stats_value'], + 'field' => 'up_value', + 'sort' => true + ) + ); + + $defsort_arr = array( + 'field' => 'up_title', + 'direction' => 'desc' + ); + + $menu_arr = array( + array( 'url' => $_CONF['site_admin_url'] . '/plugins/{plugin}/index.php?mode=edit', + 'text' => $LANG_ADMIN['create_new'] + ), + array( 'url' => $_CONF['site_admin_url'], + 'text' => $LANG_ADMIN['admin_home'] + ) + ); + + $retval .= COM_startBlock($LANG_{lang_var_postfix}['manager'], '', + COM_getBlockTemplate('_admin_block', 'header')); + + $retval .= ADMIN_createMenu($menu_arr, $LANG_{lang_var_postfix}['instructions'], plugin_geticon_{plugin}()); + + $text_arr = array( + 'has_extras' => true, + 'form_url' => $_CONF['site_admin_url'] . "/plugins/{plugin}/index.php" + ); + + $query_arr = array( + 'table' => '{plugin}', + 'sql' => "SELECT * FROM {$_TABLES['{plugin}']} WHERE 1=1", + 'query_fields' => array('up_title'), + 'default_filter' => COM_getPermSql ('AND') + ); + + $retval .= ADMIN_list('{plugin}', 'plugin_getListField_{plugin}', + $header_arr, $text_arr, $query_arr, $defsort_arr); + $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); + + return $retval; +} + +// MAIN + +$mode = (!empty($_REQUEST['mode'])) ? COM_applyFilter($_REQUEST['mode']) : ''; + +$up_id = (!empty($_REQUEST['up_id'])) ? COM_applyFilter($_REQUEST['up_id'], true) : ''; + +if (($mode == $LANG_ADMIN['save']) && !empty($LANG_ADMIN['save']) && SEC_checkToken()) { // save mode + + $display .= save{plugin}( + $up_id, + COM_applyFilter($_POST['title']), + COM_applyFilter($_POST['value']), + COM_applyFilter($_POST['owner_id'], true), + COM_applyFilter($_POST['group_id'], true), + $_POST['perm_owner'], $_POST['perm_group'], + $_POST['perm_members'], $_POST['perm_anon']); + +} else if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete']) && SEC_checkToken()) { // delete mode + + $display .= delete{plugin}($up_id); + +} else if ($mode == 'edit') { // edit mode + + $display .= COM_siteHeader('menu', $LANG_{lang_var_postfix}['{plugin}editor']); + $display .= edit{plugin}($up_id); + $display .= COM_siteFooter(); + +} else { // 'cancel' or no mode at all + + $display .= COM_siteHeader('menu', $LANG_{lang_var_postfix}['manager']); + if (isset ($_REQUEST['msg'])) { + $msg = COM_applyFilter($_REQUEST['msg'], true); + if ($msg > 0) { + $display .= COM_showMessage($msg, '{plugin}'); + } + } + $display .= list{plugin}(); + $display .= COM_siteFooter(); +} + +echo $display; + +?> \ No newline at end of file Added: trunk/upkit/plugin_1.5.0/admin/install.php ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/admin/install.php Tue Sep 30 08:43:18 2008 @@ -0,0 +1,386 @@ +get_config('{plugin}'); + + $admin_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = '{$pi_admin}'"); + $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'"); + + $DEFVALUES = array(); + $DEFVALUES[] = "INSERT INTO {$_TABLES['{plugin}']} (up_title, up_value, owner_id, group_id) " + . "VALUES ('Sample Data', 100, 2, #group#)"; + $DEFVALUES[] = "INSERT INTO {$_TABLES['{plugin}']} (up_title, up_value, owner_id, group_id) " + . "VALUES ('More Sample Data', 200, 2, #group#)"; + + foreach ($DEFVALUES as $sql) { + $sql = str_replace('#group#', $admin_group_id, $sql); + DB_query($sql, 1); + if (DB_error()) { + COM_error("SQL error in {plugin} plugin postinstall, SQL: " . $sql); + return false; + } + } + + return true; +} + + +// +// ---------------------------------------------------------------------------- +// +// The code below should be the same for most plugins and usually won't +// require modifications. + +$langfile = $base_path . $_CONF['language'] . '.php'; +if (file_exists($langfile)) { + require_once $langfile; +} else { + require_once $base_path . 'language/english.php'; +} +require_once $base_path . 'functions.inc'; + + +// Only let Root users access this page +if (!SEC_inGroup('Root')) { + // Someone is trying to illegally access this page + COM_accessLog("Someone has tried to illegally access the {$pi_display_name} install/uninstall page. " + . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1); + $display = COM_siteHeader('menu', $LANG_ACCESS['accessdenied']) + . COM_startBlock($LANG_ACCESS['accessdenied']) + . $LANG_ACCESS['plugin_access_denied_msg'] + . COM_endBlock() + . COM_siteFooter(); + + echo $display; + exit; +} + + +/** +* Puts the datastructures for this plugin into the Geeklog database +* +*/ +function plugin_install_now() +{ + global $_CONF, $_TABLES, $_USER, $_DB_dbms, + $GROUPS, $FEATURES, $MAPPINGS, $DEFVALUES, $base_path, + $pi_name, $pi_display_name, $pi_version, $gl_version, $pi_url; + + COM_errorLog("Attempting to install the $pi_display_name plugin", 1); + + // create the plugin's groups + $admin_group_id = 0; + foreach ($GROUPS as $name => $desc) { + COM_errorLog("Attempting to create $name group", 1); + + $grp_name = addslashes($name); + $grp_desc = addslashes($desc); + DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('$grp_name', '$grp_desc')", 1); + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + + // replace the description with the new group id so we can use it later + $GROUPS[$name] = DB_insertId(); + + // assume that the first group is the plugin's Admin group + if ($admin_group_id == 0) { + $admin_group_id = $GROUPS[$name]; + } + } + + // Create the plugin's table(s) + $_SQL = array(); + if (file_exists($base_path . 'sql/' . $_DB_dbms . '_install.php')) { + require_once $base_path . 'sql/' . $_DB_dbms . '_install.php'; + } + + if (count($_SQL) > 0) { + $use_innodb = false; + if (($_DB_dbms == 'mysql') && + (DB_getItem($_TABLES['vars'], 'value', "name = 'database_engine'") + == 'InnoDB')) { + $use_innodb = true; + } + foreach ($_SQL as $sql) { + $sql = str_replace('#group#', $admin_group_id, $sql); + if ($use_innodb) { + $sql = str_replace('MyISAM', 'InnoDB', $sql); + } + DB_query($sql); + if (DB_error()) { + COM_errorLog('Error creating table', 1); + PLG_uninstall($pi_name); + + return false; + } + } + } + + // Add the plugin's features + COM_errorLog("Attempting to add $pi_display_name feature(s)", 1); + + foreach ($FEATURES as $feature => $desc) { + $ft_name = addslashes($feature); + $ft_desc = addslashes($desc); + DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " + . "VALUES ('$ft_name', '$ft_desc')", 1); + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + + $feat_id = DB_insertId(); + + if (isset($MAPPINGS[$feature])) { + foreach ($MAPPINGS[$feature] as $group) { + COM_errorLog("Adding $feature feature to the $group group", 1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, {$GROUPS[$group]})"); + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + } + } + } + + // Add plugin's Admin group to the Root user group + // (assumes that the Root group's ID is always 1) + COM_errorLog("Attempting to give all users in the Root group access to the $pi_display_name's Admin group", 1); + + DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES " + . "($admin_group_id, NULL, 1)"); + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + + // Pre-populate tables or run any other SQL queries + COM_errorLog('Inserting default data', 1); + foreach ($DEFVALUES as $sql) { + $sql = str_replace('#group#', $admin_group_id, $sql); + DB_query($sql, 1); + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + } + + // Load the online configuration records + if (function_exists('plugin_load_configuration')) { + if (!plugin_load_configuration()) { + PLG_uninstall($pi_name); + + return false; + } + } + + // Finally, register the plugin with Geeklog + COM_errorLog("Registering $pi_display_name plugin with Geeklog", 1); + + // silently delete an existing entry + DB_delete($_TABLES['plugins'], 'pi_name', $pi_name); + + DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) VALUES " + . "('$pi_name', '$pi_version', '$gl_version', '$pi_url', 1)"); + + if (DB_error()) { + PLG_uninstall($pi_name); + + return false; + } + + // give the plugin a chance to perform any post-install operations + if (function_exists('plugin_postinstall')) { + if (!plugin_postinstall()) { + PLG_uninstall($pi_name); + + return false; + } + } + + COM_errorLog("Successfully installed the $pi_display_name plugin!", 1); + + return true; +} + + +// MAIN +$display = ''; + +if (SEC_checkToken()) { + if ($_REQUEST['action'] == 'uninstall') { + $uninstall_plugin = 'plugin_uninstall_' . $pi_name; + if ($uninstall_plugin()) { + $display = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=45'); + } else { + $display = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=73'); + } + } else if (DB_count($_TABLES['plugins'], 'pi_name', $pi_name) == 0) { + // plugin not installed + + if (plugin_compatible_with_this_geeklog_version()) { + if (plugin_install_now()) { + $display = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=44'); + } else { + $display = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=72'); + } + } else { + // plugin needs a newer version of Geeklog + $display .= COM_siteHeader('menu', $LANG32[8]) + . COM_startBlock($LANG32[8]) + . '

' . $LANG32[9] . '

' + . COM_endBlock() + . COM_siteFooter(); + } + } else { + // plugin already installed + $display .= COM_siteHeader('menu', $LANG01[77]) + . COM_startBlock($LANG32[6]) + . '

' . $LANG32[7] . '

' + . COM_endBlock() + . COM_siteFooter(); + } +} else { + $display = COM_refresh($_CONF['site_admin_url'].'/plugins.php'); +} + +echo $display; + +?> \ No newline at end of file Added: trunk/upkit/plugin_1.5.0/config.php ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/config.php Tue Sep 30 08:43:18 2008 @@ -0,0 +1,45 @@ + \ No newline at end of file Added: trunk/upkit/plugin_1.5.0/functions-advanced.inc ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/functions-advanced.inc Tue Sep 30 08:43:18 2008 @@ -0,0 +1,467 @@ +set_file(array('itemstats'=>'itemstatistics.thtml', + 'statrow'=>'singlestat.thtml')); + $retval=''; + if ($showsitestats == 1) { + // This shows in the summary box + $total_pages=DB_count($_TABLES['upkit_name']); // Fill this with count for summary + $summary_label = "{plugin}"; // Fill this with label displayed + + $retval = ""; + $retval .= ""; + $retval .= "
$summary_label" . $total_pages . "  
"; + } else { + // This fills the top the box Use the following as a template + $result = DB_query("SELECT id, title, hits from {$_TABLES['upkit_name'] WHERE hits > 0 ORDER BY hits desc LIMIT 10"); + $nrows = DB_numRows($result); + $retval .= COM_startBlock("Top Ten Static Pages"); + if ($nrows > 0) { + $stat_templates->set_var('item_label',"Page Title"); + $stat_templates->set_var('stat_name',"Hits"); + for ($i = 0; $i < $nrows; $i++) { + $A = DB_fetchArray($result); + $stat_templates->set_var('item_url', $_CONF['site_url'] . '/{plugin}/index.php?item=' . $A['id']); + $stat_templates->set_var('item_text', $A['title']); + $stat_templates->set_var('item_stat', $A['hits']); + $stat_templates->parse('stat_row','statrow',true); + } + $stat_templates->parse('output','itemstats'); + $retval .= $stat_templates->finish($stat_templates->get_var('output')); + } else { + $retval .= 'It appears that there are no {plugin}s on this site or no one has ever viewed them.'; + } + $retval .= COM_endBlock(); + } + return $retval; +} + +/** +* Geeklog is asking us to provide any new items that show up in the type drop-down +* on search.php. Let's let users search! +* +*/ +function plugin_searchtypes_{plugin}() +{ + global $LANG_{lang_var_postfix}; + + $tmp['{plugin}'] = $LANG_{lang_var_postfix}['externpages']; + return $tmp; +} + + +/** +* this searches for pages matching the user query and returns an array of +* for the header and table rows back to search.php where it will be formated and +* printed +* +* @query string Keywords user is looking for +* @datestart date/time Start date to get results for +* @dateend date/time End date to get results for +* @topic string The topic they were searching in +* @type string Type of items they are searching +* @author string Get all results by this author +* +*/ +function plugin_dopluginsearch_{plugin}($query, $datestart, $dateend, $topic, $type, $author) +{ + global $_TABLES, $_CONF, $LANG_{lang_var_postfix}; + + if (empty($type)) { + $type = 'all'; + } + + // Bail if we aren't supppose to do our search + if ($type <> 'all' AND $type <> '{plugin}') { + $plugin_results = new Plugin(); + $plugin_results->plugin_name = '{plugin}'; + $plugin_results->searchlabel = $LANG_{lang_var_postfix}['externpages'] . $LANG_{lang_var_postfix}['results']; + return $plugin_results; + } + + // Build search SQL - Modified to exclude static PHP pages from search. + $sql = "SELECT * from " . $_TABLES['{plugin}']; + $result = DB_query($sql); + + + // OK, now create new plugin object and insert table header labels + require_once($_CONF['path_system'] . 'classes/plugin.class.php'); + $plugin_results = new Plugin(); + $plugin_results->plugin_name = '{plugin}'; + $plugin_results->searchlabel = $LANG_{lang_var_postfix}['externpages'] . $LANG_{lang_var_postfix}['results']; + $plugin_results->addSearchHeading($LANG_{lang_var_postfix}['titlemsg']); + $plugin_results->addSearchHeading($LANG_{lang_var_postfix}['urlmsg']); + $plugin_results->addSearchHeading($LANG_{lang_var_postfix}['hitsmsg']); + $mycount = DB_numRows($result); + + // NOTE if any of your data items need to be links then add them here! + // make sure data elements are in an array and in the same order as your + // headings above! + for ($i = 1; $i <= $mycount; $i++) { + $A = DB_fetchArray($result); + + if(SEC_hasAccess($A[owner_id],$A[group_id],$A[perm_owner],$A[perm_group],$A[perm_members],$A[perm_anon])){ + // Get text to search + $cnts = implode('',file($pth)); + // Search it + if (stristr($cnts,$query) != '') { + $rcnt++; + $A['title'] = stripslashes($A['title']); + $row = array($A['title'], + '' . $A['url'] . "", + $A['hits']); + $plugin_results->addSearchResult($row); + } + } + + } + $plugin_results->num_searchresults = $rcnt; + $plugin_results->num_itemssearched = DB_count($_TABLES['{plugin}']); + + return $plugin_results; +} + +/** +* +* Example Plugin Moderation Functions +* authored by Vincent Furia, http://furia.dyndns.org +* +*/ + +/** +* +* Checks that the current user has the rights to moderate the +* plugin, returns true if this is the case, false otherwise +* +* @return boolean Returns true if moderator +* +*/ +function plugin_ismoderator_lists() { + global $_USER, $_TABLES; + + return SEC_hasRights('lists.admin'); +} + +/** +* Returns the number of submissions waiting moderation +* +* Calculates the number of submissions that are currently waiting +* to be moderated and returns that number. +* +* @return int number of submissions awaiting moderation +*/ +function plugin_submissioncount_lists() { + global $_TABLES; + return DB_count($_TABLES['listssubmission']); +} + +/** +* Performs plugin exclusive work for items approved by moderation +* +* While moderation.php handles the actual move from submission +* to tables, within the function we handle all other approval +* relate tasks +* +* @param string $id Identifying string +* @return string Any wanted HTML output +* +*/ +function plugin_moderationapprove_lists($id) { + global $_TABLES, $_USER, $_CONF; + + $result = DB_query("SELECT * FROM " . $_TABLES['groups'] + . " WHERE grp_name = 'lists Admin'"); + $group = DB_fetchArray($result); + if ($_CONF['listsarchive'] == 'optional') { + $archive = $_CONF['listsarchivedefault']; + } elseif ($_CONF['listsarchive'] == 'no') { + $archive = 0; + } else { // $_CONF['listsarchive'] == 'yes' + $archive = 1; + } + $sql = "UPDATE " . $_TABLES['lists'] . " SET owner_id = " . $_USER['uid'] + . ", group_id = " . $group['grp_id'] . ", html = " . $_CONF['listshtml'] + . ", archive = $archive WHERE ml_id = '$id'"; + $result = DB_query($sql); + + if (DB_error()) { + return 'Error'; + } + return ''; +} + +/** +* Performs plugin exclusive work for items deleted by moderation +* +* While moderation.php handles the actual removal from submission +* table, within this function we handle all other deletion +* relate tasks +* +* @param string $id Identifying string +* @return string Any wanted HTML output +* +*/ +function plugin_moderationdelete_lists($id) { + global $_TABLES; + + // these tables should not contain any rows with ml_id = $id + // this is done 'just in case' + DB_delete($_TABLES['listsubscriptions'], 'ml_id', $id); + DB_delete($_TABLES['listarchive'], 'ml_id', $id); + DB_delete($_TABLES['listpermissions'], 'ml_id', $id); +} + +/** +* saves submission to listssubmission table +* +* takes data input by submission form and populates the submission +* table. +* +* @param array $A array (key => value) of form items +* @return boolean returns true if successful +* +*/ +function plugin_savesubmission_lists($A) { + global $_TABLES, $_USER, $_CONF; + + // check for missing fields + if (empty($A['ml_name']) || empty($A['ml_descr'])) { + return false; + } + + if (empty($_USER['uid'])) { + $owner_id = 1; + } else { + $owner_id = $_USER['uid']; + } + + if (SEC_hasRights('links.admin')) { + $result = DB_getItem($_TABLES['groups'], '*', "grp_name = 'lists Admin'"); + if ($_CONF['listsarchive'] == 'optional') { + $archive = $_CONF['listsarchivedefault']; + } elseif ($_CONF['listsarchive'] == 'no') { + $archive = 0; + } else { // $_CONF['listsarchive'] == 'yes' + $archive = 1; + } + DB_save($_TABLES['lists'], 'ml_id, ml_name, ml_descr, html, archive, owner_id, group_id', + "'" . COM_makeSid() . "', '" . $A['ml_name'] . "', '" . $A['ml_descr'] + . "', " . $_CONF['listshtml'] . ", $archive, $owner_id, " . $result['grp_id']); + } elseif ($_CONF['listssubmission'] == 1) { + DB_save($_TABLES['listssubmission'], + 'ml_id, ml_name, ml_descr', + "'" . COM_makeSid() . "', '" . $A['ml_name'] . "', '" + . $A['ml_descr'] . "'"); + } else { + return false; + } + + if (DB_error()) { + return false; + } + + return true; +} + +/** +* returns list of moderation values +* +* The array returned contains (in order): the row 'id' label, main plugin +* table, moderation fields (comma seperated), and plugin submission table +* +* @return array Returns array of useful moderation values +* +*/ +function plugin_moderationvalues_lists() { + global $_TABLES; + + return array('ml_id', $_TABLES['lists'], 'ml_id, ml_name, ml_descr' + , $_TABLES['listssubmission']); +} + +/** +* show lists for moderation on submissions page +* +* Uses the Plugin class to return data required by moderation.php to list +* plugin objects that need to be moderated. +* +* @return Plugin return Plugin class containing submission data +* +*/ +function plugin_itemlist_lists() { + global $_TABLES; + + if (plugin_ismoderator_lists()) { + $plugin = new Plugin(); + $plugin->submissionlabel = 'Mailing List Submissions'; + $plugin->getsubmissionssql = "SELECT ml_id as id, ml_name, ml_descr FROM " + . $_TABLES['listssubmission']; + $plugin->addSubmissionHeading('List Name'); + $plugin->addSubmissionHeading('List Description'); + + return $plugin; + } +} + +/** +* Returns the plugins submission form +* +* Returns a string contain the HTML of the submission form for the plugin. +* +* @return string The HTML form +* +*/ +function plugin_submit_lists() { + global $_CONF, $LANG12, $HTTP_POST_VARS; + + if ($_CONF['listssubmission'] == 0 && !SEC_hasRights('lists.admin')) { + return "Submission queue disabled for mailing lists"; + } + + if ($HTTP_POST_VARS['mode'] == $LANG12[32]) { // preview + $A = $HTTP_POST_VARS; + $ml_id = $A['ml_id']; + } else { + $ml_id = COM_makesid(); + } + + $template = new Template($_CONF['path'] . "plugins/lists/templates/public"); + $template->set_file(array('form' => 'submit_form.thtml')); + $template->set_var('site_url', $_CONF['site_url']); + $template->set_var('lang_name', 'List Name'); + $template->set_var('ml_name', $A['ml_name']); + $template->set_var('lang_descr', 'Description'); + $template->set_var('ml_descr', $A['ml_descr']); + $template->set_var('ml_id', $ml_id); + $template->set_var('lang_preview', $LANG12[32]); + $template->set_var('lang_save', $LANG12[8]); + + return $template->parse('output', 'form'); +} + + +?> \ No newline at end of file Added: trunk/upkit/plugin_1.5.0/functions.inc ============================================================================== --- (empty file) +++ trunk/upkit/plugin_1.5.0/functions.inc Tue Sep 30 08:43:18 2008 @@ -0,0 +1,350 @@ +get_config('{plugin}'); +} + +/* +* Include {plugin} config file +*/ +require_once $plugin_path . 'config.php'; + +// +---------------------------------------------------------------------------+ +// | Geeklog Plugin API Implementation | +// +---------------------------------------------------------------------------+ + +/** +* Returns the items for this plugin that should appear on the main menu +* +* NOTE: this MUST return the url/value pairs in the following format +* $[