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

Source for file pnadminapi.php

Documentation is available at pnadminapi.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2002, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: pnadminapi.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Value_Addons
  10.  * @subpackage Feeds
  11.  */
  12.  
  13. /**
  14.  * create a new RSS item
  15.  * @param $args['feedname'] name of the item
  16.  * @param $args['number'] number of the item
  17.  * @return mixed RSS item ID on success, false on failure
  18.  */
  19. function feeds_adminapi_create($args)
  20. {
  21.     // Argument check
  22.     if (!isset($args['name']||
  23.         !isset($args['url'])) {
  24.         return LogUtil::registerError (_MODARGSERROR);
  25.     }
  26.  
  27.     // Security check
  28.     if (!SecurityUtil::checkPermission'Feeds::Item'"$args[name]::"ACCESS_ADD)) {
  29.         return LogUtil::registerError (_MODULENOAUTH);
  30.     }
  31.  
  32.     // check for maximum length to avoid cutting off URLs
  33.     if (strlen($args['url'255)) {
  34.         return LogUtil::registerError (_FEEDS_URLTOOLONG);
  35.     }
  36.  
  37.     // Check for a protocol Magpie RSS (more exactly Snoopy) can handle.
  38.     $url_parts parse_url($args['url']);
  39.     if (!isset($url_parts['scheme']|| ($url_parts['scheme'!= 'http' && $url_parts['scheme'!= 'https')) {
  40.         return LogUtil::registerError (_FEEDS_INVALIDPROTOCOL);
  41.     }
  42.  
  43.     // define the permalink title if not present
  44.     if (!isset($args['urltitle']|| empty($args['urltitle'])) {
  45.         $args['urltitle'DataUtil::formatPermalink($args['name']);
  46.     }
  47.  
  48.     if (!DBUtil::insertObject($args'feeds''fid')) {
  49.         return LogUtil::registerError (_CREATEFAILED);
  50.     }
  51.  
  52.     // Let any hooks know that we have created a new item.
  53.     pnModCallHooks('item''create'$args['fid']array('module' => 'Feeds'));
  54.  
  55.     // Return the id of the newly created item to the calling process
  56.     return $args['fid'];
  57. }
  58.  
  59. /**
  60.  * delete a RSS item
  61.  * @param $args['fid'] ID of the item
  62.  * @return bool true on success, false on failure
  63.  */
  64. function feeds_adminapi_delete($args)
  65. {
  66.     // Argument check
  67.     if (!isset($args['fid']|| !is_numeric($args['fid'])) {
  68.         return LogUtil::registerError (_MODARGSERROR);
  69.     }
  70.  
  71.     // Get the feed
  72.     $item pnModAPIFunc('Feeds''user''get'array('fid' => $args['fid']));
  73.  
  74.     if ($item == false{
  75.         return LogUtil::registerError (_NOSUCHITEM);
  76.     }
  77.  
  78.     // Security check
  79.     if (!SecurityUtil::checkPermission'Feeds::Item'"$item[name]::$args[fid]"ACCESS_DELETE)) {
  80.         return LogUtil::registerError (_MODULENOAUTH);
  81.     }
  82.  
  83.     if (!DBUtil::deleteObjectByID('feeds'$args['fid']'fid')) {
  84.         return LogUtil::registerError (_DELETEFAILED);
  85.     }
  86.  
  87.     // Let any hooks know that we have deleted an item
  88.     pnModCallHooks('item''delete'$args['fid']array('module' => 'Feeds'));
  89.  
  90.     // Let the calling process know that we have finished successfully
  91.     return true;
  92. }
  93.  
  94. /**
  95.  * update a RSS item
  96.  * @param $args['fid'] the ID of the item
  97.  * @param $args['feedname'] the new name of the item
  98.  * @param $args['number'] the new number of the item
  99.  */
  100. function feeds_adminapi_update($args)
  101. {
  102.     // Argument check
  103.     if (!isset($args['fid']||
  104.         !isset($args['name']||
  105.         !isset($args['url'])) {
  106.         return LogUtil::registerError (_MODARGSERROR);
  107.     }
  108.  
  109.     // Get the existing feed
  110.     $item pnModAPIFunc('Feeds''user''get'array('fid' => $args['fid']));
  111.  
  112.     if ($item == false{
  113.         return LogUtil::registerError (_NOSUCHITEM);
  114.     }
  115.  
  116.     // Security check
  117.     if (!SecurityUtil::checkPermission'Feeds::Item'"$item[name]::$args[fid]"ACCESS_EDIT)) {
  118.         return LogUtil::registerError (_MODULENOAUTH);
  119.     }
  120.     if (!SecurityUtil::checkPermission'Feeds::Item'"$args[name]::$args[fid]"ACCESS_EDIT)) {
  121.         return LogUtil::registerError (_MODULENOAUTH);
  122.     }
  123.  
  124.     // check for maximum length to avoid cutting off URLs
  125.     if (strlen($args['url'200)) {
  126.         return LogUtil::registerError (_FEEDS_URLTOOLONG);
  127.     }
  128.  
  129.     // Check for a protocol Magpie RSS (more exactly Snoopy) can handle.
  130.     $url_parts parse_url($args['url']);
  131.     if ($url_parts['scheme'!= 'http' && $url_parts['scheme'!= 'https'{
  132.         return LogUtil::registerError (_FEEDS_INVALIDPROTOCOL);
  133.     }
  134.  
  135.     // define the permalink title if not present
  136.     if (!isset($args['urltitle']|| empty($args['urltitle'])) {
  137.         $args['urltitle'DataUtil::formatPermalink($args['name']);
  138.     }
  139.  
  140.     if (!DBUtil::updateObject($args'feeds''''fid')) {
  141.         return LogUtil::registerError (_UPDATEFAILED);
  142.     }
  143.  
  144.     // Let any hooks know that we have updated an item.
  145.     pnModCallHooks('item''update'$args['fid']array('module' => 'Feeds'));
  146.  
  147.     // Let the calling process know that we have finished successfully
  148.     return true;
  149. }
  150.  
  151. /**
  152.  * get available admin panel links
  153.  *
  154.  * @author Mark West
  155.  * @return array array of admin links
  156.  */
  157. {
  158.     $links array();
  159.  
  160.     pnModLangLoad('Feeds''admin');
  161.  
  162.     if (SecurityUtil::checkPermission('Feeds::''::'ACCESS_READ)) {
  163.         $links[array('url' => pnModURL('Feeds''admin''view')'text' => _FEEDS_VIEW);
  164.     }
  165.     if (SecurityUtil::checkPermission('Feeds::''::'ACCESS_ADD)) {
  166.         $links[array('url' => pnModURL('Feeds''admin''new')'text' => _FEEDS_CREATE);
  167.     }
  168.     if (SecurityUtil::checkPermission('Feeds::''::'ACCESS_ADMIN)) {
  169.         $links[array('url' => pnModURL('Feeds''admin''modifyconfig')'text' => _MODIFYCONFIG);
  170.     }
  171.  
  172.     return $links;
  173. }

Documentation generated on Fri, 18 Jul 2008 21:52:08 +0200 by phpDocumentor 1.4.1