/**
 * 
 * how many items can be registered more to private index?
 * 
 * @return available space for register item( in a number of items )
 * 
 */
function available_space_of_private_item()
{
    $xnpsid = $_SESSION['XNPSID'];
    $uid = $_SESSION['xoopsUserId'];
    $account = array();
    if (xnp_get_account($xnpsid, $uid, $account) == RES_OK) {
        $iids = array();
        if (xnp_get_private_item_id($xnpsid, $uid, $iids) == RES_OK) {
            return max(0, $account['item_number_limit'] - count($iids));
        }
    }
    return 0;
}
 /**
  * Get array of item id of private items.
  * Its returns private items except public and group shared items.
  * @param $uid integer user id
  * @param array of integer of item id(s)
  */
 function getAllPrivateOnlyItemId($uid)
 {
     // for xnp_get_private_item_id
     include_once XOOPS_ROOT_PATH . '/modules/xoonips/include/AL.php';
     $iids = array();
     if (RES_OK == xnp_get_private_item_id($_SESSION['XNPSID'], $uid, $iids)) {
         return $iids;
     }
     return array();
 }
$body = $func();
$xoopsTpl->assign('body', $body);
if (isset($system_message)) {
    $xoopsTpl->assign("system_message", $system_message);
}
$xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false);
if (isset($xoonipsCheckedXID)) {
    $xoopsTpl->assign("index_checked_id", $xoonipsCheckedXID);
}
$xoopsTpl->assign('scrollX', $scrollX);
$xoopsTpl->assign('scrollY', $scrollY);
$xoopsTpl->assign("invalid_doi_message", sprintf(_MD_XOONIPS_ITEM_DOI_INVALID_ID, XNP_CONFIG_DOI_FIELD_PARAM_MAXLEN));
$account = array();
if (xnp_get_account($xnpsid, $uid, $account) == RES_OK) {
    $iids = array();
    if (xnp_get_private_item_id($xnpsid, $uid, $iids) == RES_OK) {
        $xoopsTpl->assign('num_of_items_current', count($iids));
    } else {
        $xoopsTpl->assign('num_of_items_current', 0);
    }
    $xoopsTpl->assign('num_of_items_max', $account['item_number_limit']);
    $xoopsTpl->assign('storage_of_items_max', sprintf("%.02lf", $account['item_storage_limit'] / 1000 / 1000));
    $xoopsTpl->assign('storage_of_items_current', sprintf("%.02lf", filesize_private() / 1000 / 1000));
}
// If the page is made by POST, $_POST is made to save somewhere and page redirects.
// rfc2616 10.3.4 303 See Other
if ($_SERVER["REQUEST_METHOD"] == 'POST') {
    $post_id = uniqid('postid');
    $_SESSION['post_id'] = array($post_id => serialize($_POST));
    header("HTTP/1.0 303 See Other");
    header("Location: " . XOOPS_URL . "/modules/xoonips/register.php?post_id={$post_id}");
 function _filesize_private()
 {
     $iids = array();
     if (xnp_get_private_item_id($_SESSION['XNPSID'], $_SESSION['xoopsUserId'], $iids) != RES_OK) {
         return 0;
     }
     return $this->_filesize_by_item_id($iids);
 }