| | 1736 | function ws_categories_setInfo($params, &$service) |
| | 1737 | { |
| | 1738 | global $conf; |
| | 1739 | if (!is_admin() || is_adviser() ) |
| | 1740 | { |
| | 1741 | return new PwgError(401, 'Access denied'); |
| | 1742 | } |
| | 1743 | |
| | 1744 | // category_id |
| | 1745 | // name |
| | 1746 | // comment |
| | 1747 | |
| | 1748 | $params['category_id'] = (int)$params['category_id']; |
| | 1749 | if ($params['category_id'] <= 0) |
| | 1750 | { |
| | 1751 | return new PwgError(WS_ERR_INVALID_PARAM, "Invalid category_id"); |
| | 1752 | } |
| | 1753 | |
| | 1754 | // database registration |
| | 1755 | $update = array( |
| | 1756 | 'id' => $params['category_id'], |
| | 1757 | ); |
| | 1758 | |
| | 1759 | $info_columns = array( |
| | 1760 | 'name', |
| | 1761 | 'comment', |
| | 1762 | ); |
| | 1763 | |
| | 1764 | $perform_update = false; |
| | 1765 | foreach ($info_columns as $key) |
| | 1766 | { |
| | 1767 | if (isset($params[$key])) |
| | 1768 | { |
| | 1769 | $perform_update = true; |
| | 1770 | $update[$key] = $params[$key]; |
| | 1771 | } |
| | 1772 | } |
| | 1773 | |
| | 1774 | if ($perform_update) |
| | 1775 | { |
| | 1776 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
| | 1777 | mass_updates( |
| | 1778 | CATEGORIES_TABLE, |
| | 1779 | array( |
| | 1780 | 'primary' => array('id'), |
| | 1781 | 'update' => array_diff(array_keys($update), array('id')) |
| | 1782 | ), |
| | 1783 | array($update) |
| | 1784 | ); |
| | 1785 | } |
| | 1786 | |
| | 1787 | } |
| | 1788 | |