[geeklog-cvs] Geeklog-1.x/public_html/admin/plugins/links category.php, 1.1, 1.2 index.php, 1.46, 1.47 install.php, 1.19, 1.20
Oliver
ospiess at qs1489.pair.com
Wed Aug 29 00:27:24 EDT 2007
Update of /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links
In directory qs1489.pair.com:/tmp/cvs-serv5150
Modified Files:
category.php index.php install.php
Log Message:
new version from Euan (2nd try)
Index: install.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links/install.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** install.php 28 Aug 2007 07:34:12 -0000 1.19
--- install.php 29 Aug 2007 04:27:22 -0000 1.20
***************
*** 1,5 ****
<?php
! // Reminder: always indent with 4 spaces (no tabs).
// +---------------------------------------------------------------------------+
// | Links plugin 1.0 for Geeklog |
--- 1,5 ----
<?php
! // Reminder: always indent with 4 spaces (no tabs).
// +---------------------------------------------------------------------------+
// | Links plugin 1.0 for Geeklog |
***************
*** 38,45 ****
//
! /**
! * This file installs and removes the data structures for the
! * Links plugin for Geeklog.
! *
* @package Links
* @subpackage admin
--- 38,45 ----
//
! /**
! * This file installs and removes the data structures for the
! * Links plugin for Geeklog.
! *
* @package Links
* @subpackage admin
***************
*** 48,52 ****
* @since GL 1.4.0
* @copyright Copyright © 2005-2006
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @author Trinity Bays <trinity93 at steubentech.com>
* @author Tony Bibbs <tony at tonybibbs.com>
--- 48,52 ----
* @since GL 1.4.0
* @copyright Copyright © 2005-2006
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @author Trinity Bays <trinity93 at steubentech.com>
* @author Tony Bibbs <tony at tonybibbs.com>
***************
*** 54,58 ****
* @author Blaine Lang <langmail at sympatico.ca>
* @author Dirk Haun <dirk at haun-online.de>
! *
*/
// $Id$
--- 54,58 ----
* @author Blaine Lang <langmail at sympatico.ca>
* @author Dirk Haun <dirk at haun-online.de>
! *
*/
// $Id$
***************
*** 97,101 ****
* the plugin's groups - assumes first group to be the Admin group
* @global array $GROUPS
! *
*/
$GROUPS = array();
--- 97,101 ----
* the plugin's groups - assumes first group to be the Admin group
* @global array $GROUPS
! *
*/
$GROUPS = array();
***************
*** 104,108 ****
/**
* @global array $FEATURES
! *
*/
$FEATURES = array();
--- 104,108 ----
/**
* @global array $FEATURES
! *
*/
$FEATURES = array();
***************
*** 113,117 ****
/**
* @global array $MAPPINGS
! *
*/
$MAPPINGS = array();
--- 113,117 ----
/**
* @global array $MAPPINGS
! *
*/
$MAPPINGS = array();
***************
*** 131,137 ****
$blockadmin_id = DB_GetItem ($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'");
! $DEFVALUES[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('site', 'root', 'Root', 'Website root', '', NOW(), NOW(), 5, 2, 3, 3, 2, 2)";
! $DEFVALUES[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('20070122143647631', 'site', 'Geeklog sites', 'Sites using or related to the Geeklog CMS', '', NOW(), NOW(), 5, 2, 3, 3, 2, 2)";
$DEFVALUES[] = "INSERT INTO {$_TABLES['links']} (lid, cid, url, description, title, hits, date, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklog.net', '20070122143647631', 'http://www.geeklog.net/', 'Visit the homepage for support, FAQs, updates, add-ons, and a great community.', 'Geeklog Project Homepage', 43, NOW(), 1, 5, 3, 3, 2, 2)";
--- 131,137 ----
$blockadmin_id = DB_GetItem ($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'");
! $DEFVALUES[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$_LI_CONF['root']}', 'root', 'Root', 'Website root', '', NOW(), NOW(), 5, 2, 3, 3, 2, 2)";
! $DEFVALUES[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('20070122143647631', '{$_LI_CONF['root']}', 'Geeklog sites', 'Sites using or related to the Geeklog CMS', '', NOW(), NOW(), 5, 2, 3, 3, 2, 2)";
$DEFVALUES[] = "INSERT INTO {$_TABLES['links']} (lid, cid, url, description, title, hits, date, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklog.net', '20070122143647631', 'http://www.geeklog.net/', 'Visit the homepage for support, FAQs, updates, add-ons, and a great community.', 'Geeklog Project Homepage', 43, NOW(), 1, 5, 3, 3, 2, 2)";
***************
*** 188,192 ****
exit;
}
!
/**
--- 188,192 ----
exit;
}
!
/**
***************
*** 215,220 ****
COM_errorLog ("Attempting to install the $pi_display_name plugin", 1);
- $uninstall_plugin = 'plugin_uninstall_' . $pi_name;
-
// create the plugin's groups
$admin_group_id = 0;
--- 215,218 ----
***************
*** 226,230 ****
DB_query ("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('$grp_name', '$grp_desc')", 1);
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 224,228 ----
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;
***************
*** 241,244 ****
--- 239,243 ----
// Create the plugin's table(s)
+ COM_errorLog ('Creating plugin tables...', 1);
$_SQL = array ();
if (file_exists ($base_path . 'sql/' . $_DB_dbms . '_install.php')) {
***************
*** 259,265 ****
}
DB_query ($sql);
if (DB_error ()) {
COM_errorLog ('Error creating table', 1);
! $uninstall_plugin ();
return false;
--- 258,265 ----
}
DB_query ($sql);
+ COM_errorLog ('...table', 1);
if (DB_error ()) {
COM_errorLog ('Error creating table', 1);
! PLG_uninstall ($pi_name);
return false;
***************
*** 277,281 ****
. "VALUES ('$ft_name', '$ft_desc')", 1);
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 277,281 ----
. "VALUES ('$ft_name', '$ft_desc')", 1);
if (DB_error ()) {
! PLG_uninstall ($pi_name);
return false;
***************
*** 289,293 ****
DB_query ("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, {$GROUPS[$group]})");
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 289,293 ----
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;
***************
*** 304,308 ****
. "($admin_group_id, NULL, 1)");
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 304,308 ----
. "($admin_group_id, NULL, 1)");
if (DB_error ()) {
! PLG_uninstall ($pi_name);
return false;
***************
*** 315,319 ****
DB_query ($sql, 1);
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 315,319 ----
DB_query ($sql, 1);
if (DB_error ()) {
! PLG_uninstall ($pi_name);
return false;
***************
*** 331,335 ****
if (DB_error ()) {
! $uninstall_plugin ();
return false;
--- 331,335 ----
if (DB_error ()) {
! PLG_uninstall ($pi_name);
return false;
***************
*** 339,343 ****
if (function_exists ('plugin_postinstall')) {
if (!plugin_postinstall ()) {
! $uninstall_plugin ();
return false;
--- 339,343 ----
if (function_exists ('plugin_postinstall')) {
if (!plugin_postinstall ()) {
! PLG_uninstall ($pi_name);
return false;
Index: category.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links/category.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** category.php 28 Aug 2007 07:34:12 -0000 1.1
--- category.php 29 Aug 2007 04:27:22 -0000 1.2
***************
*** 59,62 ****
--- 59,435 ----
+ // +-----------------------------------------------------------------------------------------------+
+ // | Category administration functions |
+ // | Located here so that in the future, users can also have their own link collections with |
+ // | categories over which they have edit access. |
+ // +-----------------------------------------------------------------------------------------------+
+
+
+
+ // Returns a category tree of categories in the database to which
+ // the user has edit access
+
+ function links_list_categories ($root)
+ {
+ global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_LINKS_ADMIN, $LANG_ACCESS, $_IMAGE_TYPE;
+ global $LANG_LINKS, $_USER, $_LI_CONF;
+ 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_LINKS_ADMIN[44], 'field' => 'addchild', 'sort' => false),
+ array('text' => $LANG_LINKS_ADMIN[30], 'field' => 'category', 'sort' => true),
+ array('text' => $LANG_ACCESS['access'], 'field' => 'access', 'sort' => false),
+ array('text' => $LANG_LINKS_ADMIN[33], 'field' => 'tid', 'sort' => true),
+ array('text' => $LANG_ADMIN['delete'], 'field' => 'delete', 'sort' => false));
+
+ $defsort_arr = array('field' => 'category', 'direction' => 'asc');
+
+ $menu_arr = array (
+ array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php',
+ 'text' => $LANG_LINKS_ADMIN[53]),
+ array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit',
+ 'text' => $LANG_LINKS_ADMIN[51]),
+ array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?checkhtml=true',
+ 'text' => $LANG_LINKS_ADMIN[26]),
+ array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php',
+ 'text' => $LANG_LINKS_ADMIN[50]),
+ array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php?mode=edit',
+ 'text' => $LANG_LINKS_ADMIN[52]),
+ array('url' => $_CONF['site_admin_url'],
+ 'text' => $LANG_ADMIN['admin_home']));
+
+ $text_arr = array('has_menu' => true,
+ 'has_extras' => true,
+ 'title' => $LANG_LINKS_ADMIN[54], 'instructions' => $LANG_LINKS_ADMIN[55],
+ 'icon' => plugin_geticon_links(),
+ 'form_url' => $_CONF['site_admin_url'] . "/plugins/links/category.php");
+
+ $dummy = array();
+ $data_arr = links_list_categories_recursive ($dummy, $_LI_CONF['root'], 0);
+
+ $retval .= ADMIN_simpleList ("plugin_getListField_categories", $header_arr, $text_arr,
+ $data_arr, $menu_arr);
+
+ return $retval;
+ }
+
+ function links_list_categories_recursive (&$data_arr, $cid, $indent) {
+
+ global $_CONF, $_TABLES, $_LI_CONF, $LANG_LINKS_ADMIN;
+
+ $indent = $indent+1;
+
+ // get all children of present category
+ $sql = "SELECT cid,category,tid,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']}
+ WHERE (pid='{$cid}')" . COM_getPermSQL('AND',0,3) . "ORDER BY pid,category";
+ $result = DB_QUERY($sql);
+ $nrows = DB_numRows($result);
+
+ if ($nrows>0) {
+ for ($i = 0; $i < $nrows; $i++) {
+ $A = DB_fetchArray ($result);
+ $topic = DB_getItem ($_TABLES['topics'], 'topic', "tid='{$tid}'");
+ $A['topic_text'] = $topic;
+ $A['indent'] = $indent;
+ $data_arr[] = $A;
+ if (DB_COUNT($_TABLES['linkcategories'], 'pid', $A['cid']) > 0) {
+ $dummy = links_list_categories_recursive(&$data_arr, $A['cid'], $indent);
+ }
+ }
+ }
+
+ return $data_arr;
+ }
+
+
+
+ // Returns form to create a new category or edit an existing one
+
+ function links_edit_category ($cid,$pid) {
+
+ global $_TABLES, $LANG_LINKS_ADMIN, $LANG_ADMIN, $LANG_ACCESS, $_CONF, $_USER;
+
+ $retval = '';
+
+ if ($pid <> '') {
+ // have parent id, so making a new subcategory
+ // get parent access rights
+ $result = DB_Query("SELECT group_id,perm_owner,perm_group, perm_members,perm_anon
+ FROM {$_TABLES['linkcategories']} WHERE cid='{$pid}'");
+ $A = DB_fetchArray($result);
+ $A['username'] = DB_getItem ($_TABLES['users'], 'username', "uid={$_USER['uid']}");
+ $A['owner_id'] = $_USER['uid'];
+ $A['pid'] = $pid;
+ } elseif ($cid <> '') {
+ // have category id, so editing a category
+ $sql = "SELECT * FROM {$_TABLES['linkcategories']}
+ WHERE cid='{$cid}'" . COM_getPermSQL('AND');
+ $result = DB_Query($sql);
+ $A = DB_fetchArray($result);
+ $A['username'] = DB_getItem ($_TABLES['users'], 'username', "uid={$A['owner_id']}");
+ } else {
+ // nothing, so making a new top-level category
+ // get default access rights
+ $A['group_id'] = DB_getItem ($_TABLES['groups'], 'grp_id', "grp_name='Links Admin'");
+ SEC_setDefaultPermissions ($A, $_LI_CONF['default_permissions']);
+ $A['username'] = DB_getItem ($_TABLES['users'], 'username', "uid={$_USER['uid']}");
+ $A['owner_id'] = $_USER['uid'];
+ $A['pid'] = $_LI_CONF['root'];
+ }
+
+ $access = SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
+ $A['perm_group'], $A['perm_members'], $A['perm_anon']);
+
+ if ($access < 3) {
+ return $LANG_LINKS[47];
+ }
+
+ $retval .= COM_startBlock ($LANG_LINKS_ADMIN[56], '', COM_getBlockTemplate ('_admin_block', 'header'));
+
+ $T = new Template($_CONF['path'] . 'plugins/links/templates/admin');
+ $T->set_file(array('page'=>'categoryeditor.thtml'));
+
+ $T->set_var('site_url', $_CONF['site_url']);
+ $T->set_var('site_admin_url', $_CONF['site_admin_url']);
+ $T->set_var('layout_url', $_CONF['layout_url']);
+ $T->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
+ $T->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
+ $T->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
+ $T->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
+ $T->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
+ $T->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
+ $T->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
+ $T->set_var('instructions', $LANG_LINKS_ADMIN[29]);
+ $T->set_var('lang_category', $LANG_LINKS_ADMIN[30]);
+ $T->set_var('lang_cid', $LANG_LINKS_ADMIN[32]);
+ $T->set_var('lang_description', $LANG_LINKS_ADMIN[31]);
+ $T->set_var('lang_topic', $LANG_LINKS_ADMIN[33]);
+ $T->set_var('lang_parent', $LANG_LINKS_ADMIN[34]);
+ $T->set_var('lang_save', $LANG_ADMIN['save']);
+ if (!empty($cid)) {
+ $T->set_var('delete_option', '<input type="submit" value="'.$LANG_ADMIN['delete'].'" name="mode">');
+ } else {
+ $T->set_var('delete_option', '');
+ }
+ $T->set_var('lang_cancel', $LANG_ADMIN['cancel']);
+
+ if ($cid <> '') {
+ $T->set_var('cid_value', $A['cid']);
+ $T->set_var('old_cid_value', $A['cid']);
+ $T->set_var('title_id', $A['title_id']);
+ $T->set_var('desc_id', $A['desc_id']);
+ $T->set_var('category_options', links_select_box (3,$A['pid']));
+ $T->set_var('category_value', $A['category']);
+ $T->set_var('description_value', $A['description']);
+ $T->set_var('icon_value', $A['icon']);
+ $T->set_var('topic_list', COM_topicList ('tid,topic', $A['tid'],1,true));
+ } else {
+ $A['cid'] = COM_makeSID ();
+ $T->set_var('cid_value', $A['cid']);
+ $T->set_var('category_options', links_select_box (3,$A['pid']));
+ $T->set_var('category_value', '');
+ $T->set_var('description_value', '');
+ $T->set_var('icon_value', '');
+ $T->set_var('topic_list', COM_topicList ('tid,topic','',1,true));
+ }
+
+ // user access info
+ $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
+ $T->set_var('lang_owner', $LANG_ACCESS['owner']);
+ $T->set_var('owner_name', COM_getDisplayName ($A['owner_id']));
+ $T->set_var('cat_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->parse('output','page');
+ $retval .= $T->finish($T->get_var('output'));
+ $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));
+
+ return $retval;
+
+ }
+
+
+
+ /*
+ * Save changes to category information
+ * input array values from form (unvalidated, unsafe)
+ * output string message giving outcome status of requested operation
+ */
+
+ function links_save_category ($cid, $old_cid, $pid, $category, $description, $tid, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon) {
+ global $_TABLES, $_CONF, $_USER, $LANG_LINKS, $LANG_LINKS_ADMIN;
+
+ // Convert array values to numeric permission values
+ if (is_array($perm_owner) OR is_array($perm_group) OR is_array($perm_members) OR is_array($perm_anon)) {
+ list($perm_owner,$perm_group,$perm_members,$perm_anon) = SEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);
+ }
+
+ // clean 'em up
+ $description = addslashes (COM_checkHTML (COM_checkWords ($description)));
+ $category = addslashes (COM_checkHTML (COM_checkWords ($category)));
+
+ // Check cid to make sure not illegal
+ if (($cid==$_LI_CONF['root']) || ($cid=='user')) {
+ $result = $LANG_LINKS_ADMIN[35];
+ return $result;
+ }
+ // check that they didn't delete the cid. If so, get the hidden one
+ if ($cid=='' && $old_cid<>'') {
+ $cid = $old_cid;
+ }
+ // Make sure they aren't making a parent category child of one of it's own children
+ // This would create orphans
+ if ($cid==DB_getItem($_TABLES['linkcategories'], 'pid',"cid='{$pid}'")) {
+ return $LANG_LINKS_ADMIN['48'];
+ }
+
+ $access = 0;
+ if (DB_count ($_TABLES['linkcategories'], 'cid', $old_cid) > 0) {
+ // update existing item, but new cid so get access from database with old cid
+ $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,
+ perm_members,perm_anon FROM {$_TABLES['linkcategories']}
+ WHERE cid='{$old_cid}'");
+ $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']);
+ // set flag
+ $update = "existing";
+ } else if (DB_count ($_TABLES['linkcategories'], 'cid', $cid) > 0) {
+ // update existing item, same cid, so get access from database with existing cid
+ $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,
+ perm_members,perm_anon FROM {$_TABLES['linkcategories']}
+ WHERE cid='{$cid}'");
+ $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']);
+ // set flag
+ $update = "same";
+ } else {
+ // new item, so use passed values
+ $access = SEC_hasAccess($owner_id,$group_id,$perm_owner,
+ $perm_group,$perm_members,$perm_anon);
+ // set flag
+ $update = "new";
+ }
+
+ if ($access < 3) {
+ // no access rights: user should not be here
+ $display .= COM_siteHeader ('menu');
+ $display .= COM_startBlock ($LANG_LINKS[41], '',
+ COM_getBlockTemplate ('_msg_block', 'header'));
+ $display .= $LANG_LINKS[44];
+ $display .= COM_endBlock(COM_getBlockTemplate ('_msg_block', 'footer'));
+ $display .= COM_siteFooter ();
+ COM_accessLog(sprintf($LANG_LINKS[45], $_USER['username']));
+ echo $display;
+ exit;
+ } else {
+ // save item
+ if ($update=="existing") {
+ // update an existing item but new cid
+ $sql = "UPDATE {$_TABLES['linkcategories']}
+ SET cid='{$cid}',
+ pid='{$pid}',
+ tid='{$tid}',category='{$category}',
+ description='{$description}',
+ modified=NOW(),
+ 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 cid = '{$old_cid}'";
+ $result = DB_query($sql);
+ // Also need to update links for this category
+ $sql = "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$old_cid}'";
+ $result = DB_query($sql);
+ } else if ($update=="same") {
+ // update an existing item
+ $sql = "UPDATE {$_TABLES['linkcategories']}
+ SET pid='{$pid}',
+ tid='{$tid}',category='{$category}',
+ description='{$description}',
+ modified=NOW(),
+ 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 cid = '{$cid}'";
+ $result = DB_query($sql);
+ } else {
+ // insert a new item
+ $cid = COM_makesid();
+ $sql = "INSERT INTO {$_TABLES['linkcategories']}
+ (cid, pid, category, description, tid,
+ created,modified,
+ owner_id, group_id, perm_owner, perm_group,
+ perm_members, perm_anon)
+ VALUES
+ ('{$cid}','{$pid}','{$category}',
+ '{$description}','{$tid}',
+ NOW(),NOW(),
+ '{$owner_id}','{$group_id}','{$perm_owner}',
+ '{$perm_group}','{$perm_members}','{$perm_anon}')";
+ $result = DB_query($sql);
+ }
+ }
+
+ return PLG_afterSaveSwitch (
+ $_LI_CONF['aftersave'],
+ COM_buildURL ("{$_CONF['site_url']}/links/portal.php?what=category&item={$cid}"),
+ 'links',
+ 2
+ );
+
+ // return $result;
+ }
+
+
+ /*
+ * Delete a category
+ * input $cid string category id number
+ * output string message about success of requested operation
+ */
+
+ function links_delete_category ($cid)
+ {
+ global $_TABLES, $LANG_LINKS_ADMIN;
+
+ if (DB_count ($_TABLES['linkcategories'], 'cid', $cid) > 0) {
+ // item exists so check access rights
+ $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,
+ perm_members,perm_anon FROM {$_TABLES['linkcategories']}
+ WHERE cid='{$cid}'");
+ $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>2) {
+ // has edit rights
+ // Check for subfolders and sublinks
+ $sf = DB_count ($_TABLES['linkcategories'], 'pid', $cid);
+ $sl = DB_count ($_TABLES['links'], 'cid', $cid);
+ if (($sf=='0') && ($sl=='0')) {
+ // No subfolder/links so OK to delete
+ DB_delete ( $_TABLES['linkcategories'], 'cid', $cid);
+ return $LANG_LINKS_ADMIN[37];
+ } else {
+ // Subfolders and/or sublinks exist so return a message
+ return $LANG_LINKS_ADMIN[38];
+ }
+ } else {
+ // no access
+ return $LANG_LINKS_ADMIN[45];
+ COM_accessLog(sprintf($LANG_LINKS_ADMIN[46], $_USER['username']));
+ }
+ } else {
+ // no such category
+ return $LANG_LINKS_ADMIN[47];
+ }
+ }
+
// MAIN
***************
*** 67,71 ****
}
! $root = 'site';
// delete category
--- 440,444 ----
}
! $root = $_LI_CONF['root'];
// delete category
***************
*** 111,115 ****
// edit category
} else if ($mode == "edit") {
! $display .= COM_siteHeader ('menu', $LANG_LINKS_ADMIN[11]);
$pid = COM_applyFilter ($_GET['pid']);
$cid = COM_applyFilter ($_GET['cid']);
--- 484,488 ----
// edit category
} else if ($mode == "edit") {
! $display .= COM_siteHeader ('menu', $LANG_LINKS_ADMIN[56]);
$pid = COM_applyFilter ($_GET['pid']);
$cid = COM_applyFilter ($_GET['cid']);
Index: index.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links/index.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** index.php 28 Aug 2007 07:34:12 -0000 1.46
--- index.php 29 Aug 2007 04:27:22 -0000 1.47
***************
*** 105,112 ****
$link_templates->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
! $link_templates->set_var('lang_link_list', $LANG_LINKS_ADMIN[27]);
! $link_templates->set_var('lang_new_link', $LANG_LINKS_ADMIN[25]);
! $link_templates->set_var('lang_list_categories', $LANG_LINKS_ADMIN[24]);
! $link_templates->set_var('lang_new_category', $LANG_LINKS_ADMIN[26]);
$link_templates->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
$link_templates->set_var('instructions', $LANG_LINKS_ADMIN[29]);
--- 105,113 ----
$link_templates->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
! $link_templates->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
! $link_templates->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
! $link_templates->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
! $link_templates->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
! $link_templates->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
$link_templates->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
$link_templates->set_var('instructions', $LANG_LINKS_ADMIN[29]);
***************
*** 114,117 ****
--- 115,125 ----
if ($mode <> 'editsubmission' AND !empty($lid)) {
$result = DB_query("SELECT * FROM {$_TABLES['links']} WHERE lid ='$lid'");
+ if (DB_numRows($result) !== 1) {
+ $msg = COM_startBlock ($LANG_LINKS_ADMIN[24], '',
+ COM_getBlockTemplate ('_msg_block', 'header'));
+ $msg .= $LANG_LINKS_ADMIN[25];
+ $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']);
***************
*** 134,140 ****
$A['description'] = '';
$A['title']= '';
}
$A['hits'] = 0;
- $A['owner_id'] = $_USER['uid'];
if (isset ($_GROUPS['Links Admin'])) {
$A['group_id'] = $_GROUPS['Links Admin'];
--- 142,148 ----
$A['description'] = '';
$A['title']= '';
+ $A['owner_id'] = $_USER['uid'];
}
$A['hits'] = 0;
if (isset ($_GROUPS['Links Admin'])) {
$A['group_id'] = $_GROUPS['Links Admin'];
***************
*** 230,234 ****
function savelink ($lid, $old_lid, $cid, $categorydd, $url, $description, $title, $hits, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
! global $_CONF, $_GROUPS, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN;
$retval = '';
--- 238,242 ----
function savelink ($lid, $old_lid, $cid, $categorydd, $url, $description, $title, $hits, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
! global $_CONF, $_GROUPS, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $_LI_CONF;
$retval = '';
***************
*** 305,309 ****
COM_rdfUpToDateCheck ('links', $category, $lid);
! return COM_refresh ($_CONF['site_admin_url'] . '/plugins/links/index.php?msg=2');
} else { // missing fields
$retval .= COM_siteHeader('menu', $LANG_LINKS_ADMIN[1]);
--- 313,323 ----
COM_rdfUpToDateCheck ('links', $category, $lid);
! return PLG_afterSaveSwitch (
! $_LI_CONF['aftersave'],
! COM_buildURL ("{$_CONF['site_url']}/links/portal.php?what=link&item=$lid"),
! 'links',
! 2
! );
!
} else { // missing fields
$retval .= COM_siteHeader('menu', $LANG_LINKS_ADMIN[1]);
***************
*** 354,364 ****
// 'text' => $LANG_LINKS_ADMIN[27]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit',
! 'text' => $LANG_LINKS_ADMIN[25]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?checkhtml=true',
! 'text' => $LANG_LINKS_ADMIN[49]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php',
! 'text' => $LANG_LINKS_ADMIN[24]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php?mode=edit',
! 'text' => $LANG_LINKS_ADMIN[26]),
array('url' => $_CONF['site_admin_url'],
'text' => $LANG_ADMIN['admin_home']));
--- 368,378 ----
// 'text' => $LANG_LINKS_ADMIN[27]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit',
! 'text' => $LANG_LINKS_ADMIN[51]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php?checkhtml=true',
! 'text' => $LANG_LINKS_ADMIN[26]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php',
! 'text' => $LANG_LINKS_ADMIN[50]),
array('url' => $_CONF['site_admin_url'] . '/plugins/links/category.php?mode=edit',
! 'text' => $LANG_LINKS_ADMIN[52]),
array('url' => $_CONF['site_admin_url'],
'text' => $LANG_ADMIN['admin_home']));
***************
*** 367,371 ****
'has_extras' => true,
'title' => $LANG_LINKS_ADMIN[11], 'instructions' => $LANG_LINKS_ADMIN[12],
! 'icon' => $_CONF['site_url'] . '/links/images/links.png',
'form_url' => $_CONF['site_admin_url'] . "/plugins/links/index.php$validate");
--- 381,385 ----
'has_extras' => true,
'title' => $LANG_LINKS_ADMIN[11], 'instructions' => $LANG_LINKS_ADMIN[12],
! 'icon' => plugin_geticon_links(),
'form_url' => $_CONF['site_admin_url'] . "/plugins/links/index.php$validate");
More information about the geeklog-cvs
mailing list