Links
[ class tree: Links ] [ index: Links ] [ all elements ]

Source for file category.php

Documentation is available at category.php

  1. <?php
  2.  
  3. /* Reminder: always indent with 4 spaces (no tabs). */
  4. // +---------------------------------------------------------------------------+
  5. // | Links Plugin 2.1                                                          |
  6. // +---------------------------------------------------------------------------+
  7. // | category.php                                                              |
  8. // |                                                                           |
  9. // | Geeklog links category administration page.                               |
  10. // +---------------------------------------------------------------------------+
  11. // | Copyright (C) 2000-2009 by the following authors:                         |
  12. // |                                                                           |
  13. // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
  14. // |          Mark Limburg      - mlimburg AT users.sourceforge DOT net        |
  15. // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
  16. // |          Dirk Haun         - dirk AT haun-online DOT de                   |
  17. // |          Euan McKay        - info AT heatherengineering DOT com           |
  18. // +---------------------------------------------------------------------------+
  19. // |                                                                           |
  20. // | This program is free software; you can redistribute it and/or             |
  21. // | modify it under the terms of the GNU General Public License               |
  22. // | as published by the Free Software Foundation; either version 2            |
  23. // | of the License, or (at your option) any later version.                    |
  24. // |                                                                           |
  25. // | This program is distributed in the hope that it will be useful,           |
  26. // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  27. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  28. // | GNU General Public License for more details.                              |
  29. // |                                                                           |
  30. // | You should have received a copy of the GNU General Public License         |
  31. // | along with this program; if not, write to the Free Software Foundation,   |
  32. // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  33. // |                                                                           |
  34. // +---------------------------------------------------------------------------+
  35.  
  36. /**
  37.  * Geeklog links categories administration page.
  38.  *
  39.  * @package Links
  40.  * @subpackage admin
  41.  * @filesource
  42.  * @version 2.1
  43.  * @since Geeklog 1.5.0
  44.  * @copyright Copyright &copy; 2000-2009
  45.  * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
  46.  * @author Tony Bibbs, tony AT tonybibbs DOT com
  47.  * @author Mark Limburg, mlimburg AT users.sourceforge DOT net
  48.  * @author Jason Whittenburg, jwhitten AT securitygeeks DOT com
  49.  * @author Dirk Haun, dirk AT haun-online DOT de
  50.  * @author Euan McKay, info AT heatherengineering DOT com
  51.  */
  52.  
  53. /** 
  54. * Geeklog common function library and Admin authentication
  55. */
  56. require_once '../../../lib-common.php';
  57. require_once '../../auth.inc.php';
  58.  
  59. // Uncomment the line below if you need to debug the HTTP variables being passed
  60. // to the script.  This will sometimes cause errors but it will allow you to see
  61. // the data being passed in a POST operation
  62. // echo COM_debug($_POST);
  63.  
  64. $display '';
  65.  
  66. if (!SEC_hasRights('links.edit')) {
  67.     $display .= COM_siteHeader('menu'$MESSAGE[30])
  68.              . COM_showMessageText($MESSAGE[29]$MESSAGE[30])
  69.              . COM_siteFooter();
  70.     COM_accessLog("User {$_USER['username']} tried to illegally access the link category administration screen.");
  71.     COM_output($display);
  72.     exit;
  73. }
  74.  
  75.  
  76. // +--------------------------------------------------------------------------+
  77. // | Category administration functions                                        |
  78. // | Located here so that in the future, users can also have their own link   |
  79. // | collections with categories over which they have edit access.            |
  80. // +--------------------------------------------------------------------------+
  81.  
  82.  
  83.  
  84. // Returns a category tree of categories in the database to which
  85. // the user has edit access
  86.  
  87. function links_list_categories($root)
  88. {
  89.     global $_CONF$_TABLES$_USER$_IMAGE_TYPE$LANG_ADMIN$LANG_ACCESS,
  90.            $LANG_LINKS_ADMIN$LANG_LINKS$_LI_CONF;
  91.  
  92.     require_once $_CONF['path_system''lib-admin.php';
  93.  
  94.     $retval '';
  95.  
  96.     $header_arr array(      # display 'text' and use table field 'field'
  97.                     array('text' => $LANG_ADMIN['edit']'field' => 'edit''sort' => false),
  98.                     array('text' => $LANG_LINKS_ADMIN[44]'field' => 'addchild''sort' => false),
  99.                     array('text' => $LANG_LINKS_ADMIN[30]'field' => 'category''sort' => true),
  100.                     array('text' => $LANG_ACCESS['access']'field' => 'access''sort' => false),
  101.                     array('text' => $LANG_LINKS_ADMIN[33]'field' => 'tid''sort' => true));
  102.  
  103.     $defsort_arr array('field' => 'category''direction' => 'asc');
  104.  
  105.     $links_url $_CONF['site_admin_url''/plugins/links';
  106.     $menu_arr array (
  107.         array('url'  => $links_url '/index.php',
  108.               'text' => $LANG_LINKS_ADMIN[53]),
  109.         array('url'  => $links_url '/index.php?mode=edit',
  110.               'text' => $LANG_LINKS_ADMIN[51]),
  111.         array('url'  => $links_url '/index.php?validate=enabled',
  112.               'text' => $LANG_LINKS_ADMIN[26]),
  113.         array('url'  => $links_url '/category.php',
  114.               'text' => $LANG_LINKS_ADMIN[50]),
  115.         array('url'  => $links_url '/category.php?mode=edit',
  116.               'text' => $LANG_LINKS_ADMIN[52]),
  117.         array('url'  => $_CONF['site_admin_url'],
  118.               'text' => $LANG_ADMIN['admin_home'])
  119.     );
  120.  
  121.     $retval .= COM_startBlock($LANG_LINKS_ADMIN[54]'',
  122.                               COM_getBlockTemplate('_admin_block''header'));
  123.  
  124.     $retval .= ADMIN_createMenu($menu_arr$LANG_LINKS_ADMIN[12]plugin_geticon_links());
  125.  
  126.     $text_arr array(
  127.         'has_extras' => true,
  128.         'form_url'   => $_CONF['site_admin_url''/plugins/links/category.php'
  129.     );
  130.  
  131.     $dummy array();
  132.     $data_arr links_list_categories_recursive ($dummy$_LI_CONF['root']0);
  133.  
  134.     $retval .= ADMIN_simpleList('plugin_getListField_categories'$header_arr,
  135.                                 $text_arr$data_arr);
  136.     $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block''footer'));
  137.  
  138.     return $retval;
  139. }
  140.  
  141. function links_list_categories_recursive($data_arr$cid$indent)
  142. {
  143.     global $_CONF$_TABLES$_LI_CONF$LANG_LINKS_ADMIN;
  144.  
  145.     $indent $indent 1;
  146.     $cid addslashes($cid);
  147.  
  148.     // get all children of present category
  149.     $sql "SELECT cid,category,tid,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon "
  150.         . "FROM {$_TABLES['linkcategories']} "
  151.         . "WHERE (pid='{$cid}')COM_getPermSQL('AND'03)
  152.         . "ORDER BY pid,category";
  153.     $result DB_query($sql);
  154.     $nrows DB_numRows($result);
  155.  
  156.     if ($nrows 0{
  157.         for ($i 0$i $nrows$i++{
  158.             $A DB_fetchArray($result);
  159.             $topic DB_getItem($_TABLES['topics']'topic'"tid='{$A['tid']}'");
  160.             $A['topic_text'$topic;
  161.             $A['indent'$indent;
  162.             $data_arr[$A;
  163.             if (DB_count($_TABLES['linkcategories']'pid'addslashes($A['cid'])) 0{
  164.                 $data_arr links_list_categories_recursive($data_arr$A['cid']$indent);
  165.             }
  166.         }
  167.     }
  168.  
  169.     return $data_arr;
  170. }
  171.  
  172.  
  173. // Returns form to create a new category or edit an existing one
  174.  
  175. function links_edit_category($cid$pid)
  176. {
  177.     global $_CONF$_TABLES$_USER$MESSAGE,
  178.            $LANG_LINKS_ADMIN$LANG_ADMIN$LANG_ACCESS$_LI_CONF;
  179.  
  180.     $retval '';
  181.  
  182.     $cid addslashes($cid);
  183.  
  184.     if (!empty($pid)) {
  185.         // have parent id, so making a new subcategory
  186.         // get parent access rights
  187.         $result DB_query("SELECT group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='addslashes($pid"'");
  188.         $A DB_fetchArray($result);
  189.         $A['owner_id'$_USER['uid'];
  190.         $A['pid'$pid;
  191.     elseif (!empty($cid)) {
  192.         // have category id, so editing a category
  193.         $sql "SELECT * FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'"
  194.              . COM_getPermSQL('AND');
  195.         $result DB_query($sql);
  196.         $A DB_fetchArray($result);
  197.     else {
  198.         // nothing, so making a new top-level category
  199.         // get default access rights
  200.         $A['group_id'DB_getItem($_TABLES['groups']'grp_id'"grp_name='Links Admin'");
  201.         SEC_setDefaultPermissions($A$_LI_CONF['category_permissions']);
  202.         $A['owner_id'$_USER['uid'];
  203.         $A['pid']      $_LI_CONF['root'];
  204.     }
  205.  
  206.     $access SEC_hasAccess($A['owner_id']$A['group_id']$A['perm_owner'],
  207.                             $A['perm_group']$A['perm_members']$A['perm_anon']);
  208.  
  209.     if ($access 3{
  210.         return COM_showMessage(6'links');
  211.     }
  212.  
  213.     $token SEC_createToken();
  214.  
  215.     $retval .= COM_startBlock($LANG_LINKS_ADMIN[56]'',
  216.                               COM_getBlockTemplate('_admin_block''header'));
  217.     $retval .= SEC_getTokenExpiryNotice($token);
  218.  
  219.     $T COM_newTemplate($_CONF['path''plugins/links/templates/admin');
  220.     $T->set_file(array('page' => 'categoryeditor.thtml'));
  221.  
  222.     $T->set_var('lang_pagetitle'$LANG_LINKS_ADMIN[28]);
  223.     $T->set_var('lang_link_list'$LANG_LINKS_ADMIN[53]);
  224.     $T->set_var('lang_new_link'$LANG_LINKS_ADMIN[51]);
  225.     $T->set_var('lang_validate_links'$LANG_LINKS_ADMIN[26]);
  226.     $T->set_var('lang_list_categories'$LANG_LINKS_ADMIN[50]);
  227.     $T->set_var('lang_new_category'$LANG_LINKS_ADMIN[52]);
  228.     $T->set_var('lang_admin_home'$LANG_ADMIN['admin_home']);
  229.     $T->set_var('instructions'$LANG_LINKS_ADMIN[29]);
  230.     $T->set_var('lang_category'$LANG_LINKS_ADMIN[30]);
  231.     $T->set_var('lang_cid'$LANG_LINKS_ADMIN[32]);
  232.     $T->set_var('lang_description'$LANG_LINKS_ADMIN[31]);
  233.     $T->set_var('lang_topic'$LANG_LINKS_ADMIN[33]);
  234.     $T->set_var('lang_parent'$LANG_LINKS_ADMIN[34]);
  235.     $T->set_var('lang_save'$LANG_ADMIN['save']);
  236.  
  237.     if (!empty($cid)) {
  238.         $delbutton '<input type="submit" value="' $LANG_ADMIN['delete']
  239.                    . '" name="mode"%s' XHTML '>';
  240.         $jsconfirm ' onclick="return confirm(\'' $MESSAGE[76'\');"';
  241.         $T->set_var('delete_option'sprintf($delbutton$jsconfirm));
  242.         $T->set_var('delete_option_no_confirmation'sprintf($delbutton''));
  243.     else {
  244.         $T->set_var('delete_option''');
  245.     }
  246.     $T->set_var('lang_cancel'$LANG_ADMIN['cancel']);
  247.  
  248.     if (!empty($cid)) {
  249.         $T->set_var('cid_value'$A['cid']);
  250.         $T->set_var('old_cid_value'$A['cid']);
  251.         $T->set_var('category_options'links_select_box(3$A['pid']));
  252.         $T->set_var('category_value'$A['category']);
  253.         $T->set_var('description_value'$A['description']);
  254.     else {
  255.         $A['cid'COM_makeSid();
  256.         $T->set_var('cid_value'$A['cid']);
  257.         $T->set_var('old_cid_value''');
  258.         $T->set_var('category_options'links_select_box(3$A['pid']));
  259.         $T->set_var('category_value''');
  260.         $T->set_var('description_value''');
  261.     }
  262.  
  263.     if (!isset($A['tid'])) {
  264.         $A['tid''all';
  265.     }
  266.     $topics COM_topicList('tid,topic'$A['tid']1true);
  267.     $T->set_var('topic_list'$topics);
  268.     $alltopics '<option value="all"';
  269.     if ($A['tid'== 'all'{
  270.         $alltopics .= ' selected="selected"';
  271.     }
  272.     $alltopics .= '>' $LANG_LINKS_ADMIN[35'</option>' LB;
  273.     $T->set_var('topic_selection''<select name="tid">' $alltopics
  274.                                    . $topics '</select>');
  275.  
  276.     if (empty($cid)) {
  277.         $num_links $LANG_ADMIN['na'];
  278.     else {
  279.         $nresult DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$cid}'COM_getPermSQL('AND'));
  280.         $N DB_fetchArray($nresult);
  281.         $num_links COM_numberFormat($N['count']);
  282.     }
  283.     $T->set_var('lang_num_links'$LANG_LINKS_ADMIN[61]);
  284.     $T->set_var('num_links'$num_links);
  285.  
  286.     // user access info
  287.     $T->set_var('lang_accessrights'$LANG_ACCESS['accessrights']);
  288.     $T->set_var('lang_owner'$LANG_ACCESS['owner']);
  289.     $T->set_var('owner_name'COM_getDisplayName($A['owner_id']));
  290.     $T->set_var('cat_ownerid'$A['owner_id']);
  291.     $T->set_var('lang_group'$LANG_ACCESS['group']);
  292.     $T->set_var('group_dropdown'SEC_getGroupDropdown($A['group_id']$access));
  293.     $T->set_var('lang_permissions'$LANG_ACCESS['permissions']);
  294.     $T->set_var('lang_permissionskey'$LANG_ACCESS['permissionskey']);
  295.     $T->set_var('lang_perm_key'$LANG_ACCESS['permissionskey']);
  296.     $T->set_var('permissions_editor'SEC_getPermissionsHTML($A['perm_owner'],
  297.             $A['perm_group']$A['perm_members']$A['perm_anon']));
  298.     $T->set_var('lang_permissions_msg'$LANG_ACCESS['permmsg']);
  299.     $T->set_var('lang_lockmsg'$LANG_ACCESS['permmsg']);
  300.     $T->set_var('gltoken_name'CSRF_TOKEN);
  301.     $T->set_var('gltoken'$token);
  302.  
  303.     $T->parse('output''page');
  304.     $retval .= $T->finish($T->get_var('output'));
  305.     $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block''footer'));
  306.  
  307.     return $retval;
  308. }
  309.  
  310.  
  311. /*
  312. * Save changes to category information
  313. * input     array       values from form (unvalidated, unsafe)
  314. * output    string      message giving outcome status of requested operation
  315. */
  316.  
  317. function links_save_category($cid$old_cid$pid$category$description$tid$owner_id$group_id$perm_owner$perm_group$perm_members$perm_anon)
  318. {
  319.     global $_CONF$_TABLES$_USER$LANG_LINKS$LANG_LINKS_ADMIN$_LI_CONF,
  320.            $PLG_links_MESSAGE17;
  321.  
  322.     // Convert array values to numeric permission values
  323.     if (is_array($perm_ownerOR is_array($perm_groupOR is_array($perm_membersOR is_array($perm_anon)) {
  324.         list($perm_owner,$perm_group,$perm_members,$perm_anonSEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);
  325.     }
  326.  
  327.     // Remove any autotags the user doesn't have permission to use
  328.     $description PLG_replaceTags($description''true);
  329.     // clean 'em up
  330.     $description addslashes(COM_checkHTML(COM_checkWords($description),
  331.                               'links.edit'));
  332.     $category    addslashes(COM_checkHTML(COM_checkWords($category),
  333.                               'links.edit'));
  334.     $pid         addslashes(strip_tags($pid));
  335.     $cid         addslashes(strip_tags($cid));
  336.     $old_cid     addslashes(strip_tags($old_cid));
  337.  
  338.     if (empty($category|| empty($description)) {
  339.         return 7;
  340.     }
  341.  
  342.     // Check cid to make sure not illegal
  343.     if (($cid == addslashes($_LI_CONF['root'])) || ($cid == 'user')) {
  344.         return 11;
  345.     }
  346.  
  347.     if (!empty($cid&& ($cid != $old_cid)) {
  348.         // this is either a new category or an attempt to change the cid
  349.         // - check that cid doesn't exist yet
  350.         $ctrl DB_getItem($_TABLES['linkcategories']'cid'"cid = '$cid'");
  351.         if (!empty($ctrl)) {
  352.             if (isset($PLG_links_MESSAGE17)) {
  353.                 return 17;
  354.             else {
  355.                 return 11;
  356.             }
  357.         }
  358.     }
  359.  
  360.     // Check that they didn't delete the cid. If so, get the hidden one
  361.     if (empty($cid&& !empty($old_cid)) {
  362.         $cid $old_cid;
  363.     }
  364.  
  365.     // Make sure they aren't making a parent category child of one of it's own
  366.     // children. This would create orphans
  367.     if ($cid == DB_getItem($_TABLES['linkcategories']'pid',"cid='{$pid}'")) {
  368.         return 12;
  369.     }
  370.  
  371.     $access 0;
  372.     if (DB_count ($_TABLES['linkcategories']'cid'$old_cid0{
  373.         // update existing item, but new cid so get access from database with old cid
  374.         $result DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$old_cid}'");
  375.         $A DB_fetchArray ($result);
  376.         $access SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],
  377.             $A['perm_group'],$A['perm_members'],$A['perm_anon']);
  378.         // set flag
  379.         $update "existing";
  380.     else if (DB_count ($_TABLES['linkcategories']'cid'$cid0{
  381.         // update existing item, same cid, so get access from database with existing cid
  382.         $result DB_query("SELECT owner_id,group_id,perm_owner,perm_group, perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'");
  383.         $A DB_fetchArray ($result);
  384.         $access SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],
  385.             $A['perm_group'],$A['perm_members'],$A['perm_anon']);
  386.         // set flag
  387.         $update "same";
  388.     else {
  389.         // new item, so use passed values
  390.         $access SEC_hasAccess($owner_id$group_id$perm_owner$perm_group,
  391.                                 $perm_members$perm_anon);
  392.         // set flag
  393.         $update 'new';
  394.     }
  395.  
  396.     if ($access 3{
  397.         // no access rights: user should not be here
  398.         COM_accessLog(sprintf($LANG_LINKS_ADMIN[60]$_USER['username']$cid));
  399.         return 6;
  400.     else {
  401.         // save item
  402.         if ($update == 'existing'{
  403.             // update an existing item but new cid
  404.             $sql "UPDATE {$_TABLES['linkcategories']}
  405.                     SET cid='{$cid}',
  406.                         pid='{$pid}',
  407.                         tid='{$tid}',category='{$category}',
  408.                         description='{$description}',
  409.                         modified=NOW(),
  410.                         owner_id='{$owner_id}',group_id='{$group_id}',
  411.                         perm_owner='{$perm_owner}',perm_group='{$perm_group}',
  412.                         perm_members='{$perm_members}',perm_anon='{$perm_anon}'
  413.                     WHERE cid = '{$old_cid}'";
  414.             $result DB_query($sql);
  415.             // Also need to update links for this category
  416.             $sql "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$old_cid}'";
  417.             $result DB_query($sql);
  418.         else if ($update == 'same'{
  419.             // update an existing item
  420.             $sql "UPDATE {$_TABLES['linkcategories']}
  421.                     SET pid='{$pid}',
  422.                         tid='{$tid}',category='{$category}',
  423.                         description='{$description}',
  424.                         modified=NOW(),
  425.                         owner_id='{$owner_id}',group_id='{$group_id}',
  426.                         perm_owner='{$perm_owner}',perm_group='{$perm_group}',
  427.                         perm_members='{$perm_members}',perm_anon='{$perm_anon}'
  428.                     WHERE cid = '{$cid}'";
  429.             $result DB_query($sql);
  430.         else {
  431.             // insert a new item
  432.             if (empty($cid)) {
  433.                 $cid COM_makeSid();
  434.             }
  435.             $sql "INSERT INTO {$_TABLES['linkcategories']}
  436.                     (cid, pid, category, description, tid,
  437.                     created,modified,
  438.                     owner_id, group_id, perm_owner, perm_group,
  439.                     perm_members, perm_anon)
  440.                     VALUES
  441.                     ('{$cid}','{$pid}','{$category}',
  442.                     '{$description}','{$tid}',
  443.                     NOW(),NOW(),
  444.                     '{$owner_id}','{$group_id}','{$perm_owner}',
  445.                     '{$perm_group}','{$perm_members}','{$perm_anon}')";
  446.             $result DB_query($sql);
  447.         }
  448.  
  449.         if (($update == 'existing'&& ($cid != $old_cid)) {
  450.             PLG_itemSaved($cid'links.category'$old_cid);
  451.         else {
  452.             PLG_itemSaved($cid'links.category');
  453.         }
  454.     }
  455.  
  456.     return 10// success message
  457. }
  458.  
  459.  
  460. /*
  461. * Delete a category
  462. * input     $cid    string      category id number
  463. * output            string      message about success of requested operation
  464. */
  465.  
  466. function links_delete_category($cid)
  467. {
  468.     global $_TABLES$LANG_LINKS_ADMIN;
  469.  
  470.     $cid addslashes($cid);
  471.     if (DB_count ($_TABLES['linkcategories']'cid'$cid0{
  472.         // item exists so check access rights
  473.         $result DB_query("SELECT owner_id,group_id,perm_owner,perm_group,
  474.             perm_members,perm_anon FROM {$_TABLES['linkcategories']}
  475.             WHERE cid='{$cid}'");
  476.         $A DB_fetchArray ($result);
  477.         $access SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],
  478.             $A['perm_group'],$A['perm_members'],$A['perm_anon']);
  479.         if ($access 2{
  480.             // has edit rights
  481.             // Check for subfolders and sublinks
  482.             $sf DB_count($_TABLES['linkcategories']'pid'$cid);
  483.             $sl DB_count($_TABLES['links']'cid'$cid);
  484.             if (($sf == 0&& ($sl == 0)) {
  485.                 // No subfolder/links so OK to delete
  486.                 DB_delete($_TABLES['linkcategories']'cid'$cid);
  487.                 PLG_itemDeleted($cid'links.category');
  488.                 return 13;
  489.             else {
  490.                 // Subfolders and/or sublinks exist so return a message
  491.                 return 14;
  492.             }
  493.         else {
  494.             // no access
  495.             return 15;
  496.             COM_accessLog(sprintf($LANG_LINKS_ADMIN[46]$_USER['username']));
  497.         }
  498.     else {
  499.         // no such category
  500.         return 16;
  501.     }
  502. }
  503.  
  504.  
  505. // MAIN
  506.  
  507. $mode '';
  508. if (isset ($_REQUEST['mode'])) {
  509.     $mode $_REQUEST['mode'];
  510. }
  511.  
  512. $root $_LI_CONF['root'];
  513.  
  514. // delete category
  515. if ((($mode == $LANG_ADMIN['delete']&& !empty ($LANG_ADMIN['delete'])) || ($mode=="delete")) {
  516.     $cid '';
  517.     if (isset($_REQUEST['cid'])) {
  518.         $cid strip_tags($_REQUEST['cid']);
  519.     }
  520.     if (empty($cid)) {
  521.         COM_errorLog('Attempted to delete empty category');
  522.         $display .= COM_refresh($_CONF['site_admin_url']
  523.                                 . '/plugins/links/category.php');
  524.     elseif (SEC_checkToken()) {
  525.         $msg links_delete_category($cid);
  526.  
  527.         $display .= COM_siteHeader('menu'$LANG_LINKS_ADMIN[11]);
  528.         $display .= COM_showMessage($msg'links');
  529.         $display .= links_list_categories($root);
  530.         $display .= COM_siteFooter();
  531.     else {
  532.         COM_accessLog("User {$_USER['username']} tried to illegally delete link category $cid and failed CSRF checks.");
  533.         echo COM_refresh($_CONF['site_admin_url''/index.php');
  534.     }
  535.  
  536. // save category
  537. elseif (($mode == $LANG_ADMIN['save']&& !empty($LANG_ADMIN['save']&& SEC_checkToken()) {
  538.     $msg links_save_category($_POST['cid']$_POST['old_cid'],
  539.                 $_POST['pid']$_POST['category'],
  540.                 $_POST['description']COM_applyFilter($_POST['tid']),
  541.                 COM_applyFilter($_POST['owner_id']true),
  542.                 COM_applyFilter($_POST['group_id']true),
  543.                 $_POST['perm_owner']$_POST['perm_group'],
  544.                 $_POST['perm_members']$_POST['perm_anon']);
  545.  
  546.     $display .= COM_siteHeader ('menu'$LANG_LINKS_ADMIN[11]);
  547.     $display .= COM_showMessage ($msg'links');
  548.     $display .= links_list_categories($root);
  549.     $display .= COM_siteFooter();
  550.  
  551. // edit category
  552. else if ($mode == 'edit'{
  553.     $display .= COM_siteHeader('menu'$LANG_LINKS_ADMIN[56]);
  554.     $pid '';
  555.     if (isset($_GET['pid'])) {
  556.         $pid strip_tags(COM_stripslashes($_GET['pid']));
  557.     }
  558.     $cid '';
  559.     if (isset($_GET['cid'])) {
  560.         $cid strip_tags(COM_stripslashes($_GET['cid']));
  561.     }
  562.     $display .= links_edit_category($cid$pid);
  563.     $display .= COM_siteFooter();
  564.  
  565. // nothing, so list categories
  566. else {
  567.     $display .= COM_siteHeader ('menu'$LANG_LINKS_ADMIN[11]);
  568.     if (isset ($_REQUEST['msg'])) {
  569.         $msg COM_applyFilter ($_REQUEST['msg']true);
  570.         if ($msg 0{
  571.             $display .= COM_showMessage ($msg'links');
  572.         }
  573.     }
  574.     $display .= links_list_categories($root);
  575.     $display .= COM_siteFooter();
  576. }
  577.  
  578. COM_output($display);
  579.  
  580. ?>

Documentation generated on Fri, 25 May 2012 02:08:11 -0400 by phpDocumentor 1.4.3