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 Ephemerids
  11.  */
  12.  
  13. /**
  14.  * Create a new Ephemerids item
  15.  * @author Mark West
  16.  * @param 'did' the day of the emphererid
  17.  * @param 'mid' the month of the emphererid
  18.  * @param 'yid' the year of the emphererid
  19.  * @param 'content' the ephmerid description
  20.  * @param 'language' the language of the ephemerid
  21.  * @return mixed Ephemerids item ID on success, false on failure
  22.  */
  23. {
  24.     // Argument check
  25.     if ((!isset($args['did'])) ||
  26.         (!isset($args['mid'])) ||
  27.         (!isset($args['yid'])) ||
  28.         (!isset($args['content'])) ||
  29.         (!isset($args['language']))) {
  30.         return LogUtil::registerError (_MODARGSERROR);
  31.     }
  32.  
  33.     // Security check
  34.     if (!SecurityUtil::checkPermission('Ephemerids::''::'ACCESS_ADD)) {
  35.         return LogUtil::registerPermissionError();
  36.     }
  37.  
  38.     $item array('did' => $args['did'],
  39.                   'mid' => $args['mid'],
  40.                   'yid' => $args['yid'],
  41.                   'content' => $args['content'],
  42.                   'language' => $args['language']);
  43.  
  44.     if (!DBUtil::insertObject($item'ephem''eid')) {
  45.         return LogUtil::registerError (_CREATEFAILED);
  46.     }
  47.  
  48.     // Let any hooks know that we have created a new item.
  49.     pnModCallHooks('item''create'$item['eid']array('module' => 'Ephemerids'));
  50.  
  51.     // Return the id of the newly created item to the calling process
  52.     return $item['eid'];
  53. }
  54.  
  55. /**
  56.  * Delete a Ephemerids item
  57.  * @author Mark West
  58.  * @param 'eid' the id of the ephemerid
  59.  * @return bool true on success, false on failure
  60.  */
  61. {
  62.     // Argument check
  63.     if (!isset($args['eid']|| !is_numeric($args['eid'])) {
  64.         return LogUtil::registerError (_MODARGSERROR);
  65.     }
  66.  
  67.     // The user API function is called.
  68.     $item pnModAPIFunc('Ephemerids''user''get'array('eid' => $args['eid']));
  69.  
  70.     if ($item == false{
  71.         return LogUtil::registerError (_EPHEMERIDSNOSUCHITEM);
  72.     }
  73.  
  74.     // Security check
  75.     if (!SecurityUtil::checkPermission('Ephemerids::'"$item[content]::$args[eid]"ACCESS_DELETE)) {
  76.         return LogUtil::registerPermissionError();
  77.     }
  78.  
  79.     if (!DBUtil::deleteObjectByID('ephem'$args['eid']'eid')) {
  80.         return LogUtil::registerError (_DELETEFAILED);
  81.     }
  82.  
  83.     // Let any hooks know that we have deleted an item.
  84.     pnModCallHooks('item''delete'$args['eid']array('module' => 'Ephemerids'));
  85.  
  86.     // Let the calling process know that we have finished successfully
  87.     return true;
  88. }
  89.  
  90. /**
  91.  * Update a Ephemerids item
  92.  * @author Mark West
  93.  * @param $args['eid'] the ID of the item
  94.  * @param $args['did'] the day of the ephemerid
  95.  * @param $args['mid'] the month of the ephemerid
  96.  * @param $args['yid'] the year of the ephemerid
  97.  * @param $args['content'] the event description
  98.  * @param $args['language'] the language of the item
  99.  * @return bool true on update success, false on failiure
  100.  */
  101. {
  102.     // Argument check
  103.     if ((!isset($args['eid'])) ||
  104.         (!isset($args['did'])) ||
  105.         (!isset($args['mid'])) ||
  106.         (!isset($args['yid'])) ||
  107.         (!isset($args['content'])) ||
  108.         (!isset($args['language']))) {
  109.         return LogUtil::registerError (_MODARGSERROR);
  110.     }
  111.  
  112.     // The user API function is called.
  113.     $item pnModAPIFunc('Ephemerids''user''get'array('eid' => $args['eid']));
  114.  
  115.     if ($item == false{
  116.         return LogUtil::registerError (_EPHEMERIDSNOSUCHITEM);
  117.     }
  118.  
  119.     if (!SecurityUtil::checkPermission('Ephemerids::'"$item[content]::$args[eid]"ACCESS_EDIT)) {
  120.         return LogUtil::registerPermissionError();
  121.     }
  122.     if (!SecurityUtil::checkPermission('Ephemerids::'"$args[content]::$args[eid]"ACCESS_EDIT)) {
  123.         return LogUtil::registerPermissionError();
  124.     }
  125.  
  126.     $item array('eid' => $args['eid'],
  127.                   'did' => $args['did'],
  128.                   'mid' => $args['mid'],
  129.                   'yid' => $args['yid'],
  130.                   'content' => $args['content'],
  131.                   'language' => $args['language']);
  132.  
  133.     if (!DBUtil::updateObject($item'ephem''''eid')) {
  134.         return LogUtil::registerError (_UPDATEFAILED);
  135.     }
  136.  
  137.     // Let any hooks know that we have updated an item.
  138.     pnModCallHooks('item''update'$args['eid']array('module' => 'Ephemerids'));
  139.  
  140.     // Let the calling process know that we have finished successfully
  141.     return true;
  142. }
  143.  
  144. /**
  145.  * get available admin panel links
  146.  *
  147.  * @author Mark West
  148.  * @return array array of admin links
  149.  */
  150. {
  151.     $links array();
  152.  
  153.     pnModLangLoad('Ephemerids''admin');
  154.  
  155.     if (SecurityUtil::checkPermission('Ephemerids::''::'ACCESS_READ)) {
  156.         $links[array('url' => pnModURL('Ephemerids''admin''view')'text' => _EPHEMERIDS_VIEW);
  157.     }
  158.     if (SecurityUtil::checkPermission('Ephemerids::''::'ACCESS_ADD)) {
  159.         $links[array('url' => pnModURL('Ephemerids''admin''new')'text' => _EPHEMERIDS_CREATE);
  160.     }
  161.     if (SecurityUtil::checkPermission('Ephemerids::''::'ACCESS_ADMIN)) {
  162.         $links[array('url' => pnModURL('Ephemerids''admin''modifyconfig')'text' => _MODIFYCONFIG);
  163.     }
  164.  
  165.     return $links;
  166. }

Documentation generated on Fri, 18 Jul 2008 21:51:39 +0200 by phpDocumentor 1.4.1