[geeklog-cvs] Geeklog-1.x/public_html/admin/plugins/links category.php, 1.6, 1.7

Dirk Haun dhaun at qs1489.pair.com
Sat Dec 29 14:06:25 EST 2007


Update of /cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links
In directory qs1489.pair.com:/tmp/cvs-serv49125/public_html/admin/plugins/links

Modified Files:
	category.php 
Log Message:
Removed "Delete" column (for consistency with the other Admin screens). Fixed category ID being overwritten for new categories. Fixed warnings etc. Some source code cosmetics.


Index: category.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/links/category.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** category.php	25 Nov 2007 06:58:55 -0000	1.6
--- category.php	29 Dec 2007 19:06:23 -0000	1.7
***************
*** 3,7 ****
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Geeklog 1.3                                                               |
  // +---------------------------------------------------------------------------+
  // | category.php                                                              |
--- 3,7 ----
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Links Plugin 2.0                                                          |
  // +---------------------------------------------------------------------------+
  // | category.php                                                              |
***************
*** 9,19 ****
  // | Geeklog links category administration page.                               |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2004 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony at tonybibbs.com                           |
! // |          Mark Limburg      - mlimburg at users.sourceforge.net               |
! // |          Jason Whittenburg - jwhitten at securitygeeks.com                   |
! // |          Dirk Haun         - dirk at haun-online.de                          |
! // |          Euan McKay        - info at heatherengineering.com                  |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
--- 9,19 ----
  // | Geeklog links category administration page.                               |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2007 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
! // |          Mark Limburg      - mlimburg AT users.sourceforge DOT net        |
! // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
! // |          Dirk Haun         - dirk AT haun-online DOT de                   |
! // |          Euan McKay        - info AT heatherengineering DOT com           |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
***************
*** 34,41 ****
  // +---------------------------------------------------------------------------+
  //
! // $Id:
  
! require_once ('../../../lib-common.php');
! require_once($_CONF['path'] . 'plugins/links/config.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
--- 34,41 ----
  // +---------------------------------------------------------------------------+
  //
! // $Id$
  
! require_once '../../../lib-common.php';
! require_once '../../auth.inc.php';
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
***************
*** 59,67 ****
  
  
! // +-----------------------------------------------------------------------------------------------+
! // | 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.                                                  |
! // +-----------------------------------------------------------------------------------------------+
  
  
--- 59,67 ----
  
  
! // +--------------------------------------------------------------------------+
! // | 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.            |
! // +--------------------------------------------------------------------------+
  
  
***************
*** 70,78 ****
  // 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 = '';
  
--- 70,80 ----
  // the user has edit access
  
! function links_list_categories($root)
  {
!     global $_CONF, $_TABLES, $_USER, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_ACCESS,
!            $LANG_LINKS_ADMIN, $LANG_LINKS, $_LI_CONF;
! 
!     require_once $_CONF['path_system'] . 'lib-admin.php';
! 
      $retval = '';
  
***************
*** 82,87 ****
                      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');
--- 84,88 ----
                      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));
  
      $defsort_arr = array('field' => 'category', 'direction' => 'asc');
***************
*** 106,110 ****
          'has_extras'   => true,
          'title' => $LANG_LINKS_ADMIN[54],
!         'form_url' => $_CONF['site_admin_url'] . "/plugins/links/category.php"
      );
  
--- 107,111 ----
          'has_extras'   => true,
          'title' => $LANG_LINKS_ADMIN[54],
!         'form_url' => $_CONF['site_admin_url'] . '/plugins/links/category.php'
      );
  
***************
*** 112,142 ****
      $data_arr = links_list_categories_recursive ($dummy, $_LI_CONF['root'], 0);
  
!     $retval .= ADMIN_simpleList ("plugin_getListField_categories", $header_arr, $text_arr,
!                             $data_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) {
                  $data_arr = links_list_categories_recursive($data_arr, $A['cid'], $indent);
              }
--- 113,144 ----
      $data_arr = links_list_categories_recursive ($dummy, $_LI_CONF['root'], 0);
  
!     $retval .= ADMIN_simpleList('plugin_getListField_categories', $header_arr,
!                                 $text_arr, $data_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='{$A['tid']}'");
              $A['topic_text'] = $topic;
              $A['indent'] = $indent;
              $data_arr[] = $A;
!             if (DB_count($_TABLES['linkcategories'], 'pid', $A['cid']) > 0) {
                  $data_arr = links_list_categories_recursive($data_arr, $A['cid'], $indent);
              }
***************
*** 151,156 ****
  // 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;
  
--- 153,158 ----
  // 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;
  
***************
*** 223,232 ****
          $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 {
--- 225,234 ----
          $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 {
***************
*** 257,261 ****
  
      return $retval;
- 
  }
  
--- 259,262 ----
***************
*** 268,273 ****
  */
  
! 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
--- 269,275 ----
  */
  
! 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, $_LI_CONF;
  
      // Convert array values to numeric permission values
***************
*** 281,290 ****
  
      // 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;
      }
--- 283,292 ----
  
      // 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 (empty($cid) && !empty($old_cid)) {
          $cid = $old_cid;
      }
***************
*** 292,296 ****
      // This would create orphans
      if ($cid==DB_getItem($_TABLES['linkcategories'], 'pid',"cid='{$pid}'")) {
!         return $LANG_LINKS_ADMIN['48'];
      }
  
--- 294,298 ----
      // This would create orphans
      if ($cid==DB_getItem($_TABLES['linkcategories'], 'pid',"cid='{$pid}'")) {
!         return $LANG_LINKS_ADMIN[48];
      }
  
***************
*** 318,325 ****
      } 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";
      }
  
--- 320,327 ----
      } 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';
      }
  
***************
*** 337,341 ****
      } else {
          // save item
!         if ($update=="existing") {
              // update an existing item but new cid
              $sql = "UPDATE {$_TABLES['linkcategories']}
--- 339,343 ----
      } else {
          // save item
!         if ($update == 'existing') {
              // update an existing item but new cid
              $sql = "UPDATE {$_TABLES['linkcategories']}
***************
*** 353,357 ****
              $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']}
--- 355,359 ----
              $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']}
***************
*** 367,371 ****
          } else {
              // insert a new item
!             $cid = COM_makesid();
              $sql = "INSERT INTO {$_TABLES['linkcategories']}
                      (cid, pid, category, description, tid,
--- 369,375 ----
          } else {
              // insert a new item
!             if (empty($cid)) {
!                 $cid = COM_makesid();
!             }
              $sql = "INSERT INTO {$_TABLES['linkcategories']}
                      (cid, pid, category, description, tid,
***************
*** 487,495 ****
  
  // edit category
! } else if ($mode == "edit") {
      $display .= COM_siteHeader ('menu', $LANG_LINKS_ADMIN[56]);
!     $pid   = COM_applyFilter ($_GET['pid']);
!     $cid   = COM_applyFilter ($_GET['cid']);
!     $display .= links_edit_category ($cid,$pid);
      $display .= COM_siteFooter();
  
--- 491,505 ----
  
  // edit category
! } else if ($mode == 'edit') {
      $display .= COM_siteHeader ('menu', $LANG_LINKS_ADMIN[56]);
!     $pid = '';
!     if (isset($_GET['pid'])) {
!         $pid = COM_applyFilter($_GET['pid']);
!     }
!     $cid = '';
!     if (isset($_GET['cid'])) {
!         $cid = COM_applyFilter($_GET['cid']);
!     }
!     $display .= links_edit_category($cid,$pid);
      $display .= COM_siteFooter();
  




More information about the geeklog-cvs mailing list