function _get_item_log()
 {
     $log = '';
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     foreach ($this->_params['import_items'] as $item) {
         //skip this item if don't import as new and update
         if (!$item->getImportAsNewFlag() && !$item->getUpdateFlag()) {
             continue;
         }
         $basic =& $item->getVar('basic');
         $itemtype =& $item_type_handler->get($basic->get('item_type_id'));
         $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
         $log .= "\n\n[item]\n" . $handler->getImportLog($item);
         foreach ($item->getErrors() as $e) {
             $log .= "\nerror {$e}";
         }
         if ($item->getDoiConflictFlag()) {
             $log .= "\nerror doi conflict with following items" . " in exitsing item.";
         }
         foreach (array_merge($item->getDuplicateUnupdatableItemId(), $item->getDuplicateUpdatableItemId(), $item->getDuplicateLockedItemId()) as $item_id) {
             $log .= "\nwarning conflict with " . xnpGetItemDetailURL($item_id);
         }
     }
     return $log;
 }
 function preAction()
 {
     global $xoopsUser;
     xoonips_allow_post_method();
     xoonips_deny_guest_access();
     $page = $this->_formdata->getValue('post', 'page', 'i', false);
     xoonips_validate_request($page > 0);
     $resolve_flag = $this->_formdata->getValue('post', 'resolve_conflict_flag', 'i', false);
     xoonips_validate_request(1 == $resolve_flag || 0 == $resolve_flag);
     $itemtype_handler =& xoonips_getormhandler('xoonips', 'item_type');
     foreach ($itemtype_handler->getObjects() as $itemtype) {
         if ('xoonips_index' == $itemtype->get('name')) {
             continue;
         }
         $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
         $handler->create();
     }
     $sess_hander =& xoonips_getormhandler('xoonips', 'session');
     $sess =& $sess_hander->get(session_id());
     $session = unserialize($sess->get('sess_data'));
     $this->_collection = unserialize(gzuncompress(base64_decode($session['xoonips_import_items'])));
     xoonips_validate_request($this->_collection);
     $this->_collection->setImportAsNewOption(!is_null($this->_formdata->getValue('post', 'import_as_new', 'i', false)));
     $items =& $this->_collection->getItems();
     foreach (array_keys($items) as $key) {
         if (in_array($items[$key]->getPseudoId(), $this->getUpdatablePseudoId())) {
             // set update flag of displayed item
             $items[$key]->setUpdateFlag(in_array($items[$key]->getPseudoId(), $this->getUpdatePseudoId()));
         }
     }
     $this->_params[] = $this->_collection->getItems();
     $this->_params[] = $xoopsUser->getVar('uid');
     $this->_params[] = $this->_collection->getImportAsNewOption();
 }
function download_create_zipfile($file_id, $item_id, $file_name, $metadata)
{
    $file_handler =& xoonips_gethandler('xoonips', 'file');
    $file_path = $file_handler->getFilePath($file_id);
    if (!file_exists($file_path)) {
        // file not found
        return false;
    }
    // open metafile
    $dirutil =& xoonips_getutility('directory');
    $metafile_path = $dirutil->get_template('XooNIpsDownloadMetaFile');
    $metafile_fp = $dirutil->mkstemp($metafile_path);
    if ($metafile_fp === false) {
        // failed to create temporary file for metadata
        return false;
    }
    register_shutdown_function('download_unlink', $metafile_path);
    // write metafile
    $unicode =& xoonips_getutility('unicode');
    $metafile_body = '';
    foreach ($metadata as $key => $val) {
        $metafile_body .= $key;
        // convert dos and mac new line code to unix
        $val = str_replace("\r", "\n", str_replace("\r\n", "\n", $val));
        $ar = explode("\n", $val);
        $metafile_body .= ': ';
        if (count($ar) <= 1) {
            $metafile_body .= $val;
        } else {
            $metafile_body .= "\r\n  " . implode("\r\n  ", $ar);
        }
        $metafile_body .= "\r\n";
    }
    $metafile_body .= _MD_XOONIPS_ITEM_DETAIL_URL . ': ' . xnpGetItemDetailURL($item_id) . "\r\n";
    $metafile_body = $unicode->encode_utf8($metafile_body);
    fwrite($metafile_fp, $metafile_body);
    // close metafile
    fclose($metafile_fp);
    // open zipfile
    $zipfile_path = $dirutil->get_template('XooNIpsDownloadZipFile');
    $zipfile_fp = $dirutil->mkstemp($zipfile_path);
    if ($zipfile_fp === false) {
        // failed to create temporary file for zip
        return false;
    }
    register_shutdown_function('download_unlink', $zipfile_path);
    fclose($zipfile_fp);
    $ziputil =& xoonips_getutility('zip');
    if ($ziputil->open($zipfile_path) == false) {
        // failed to open zip file
        return false;
    }
    // write zipfile
    $ziputil->add($file_path, $file_name);
    $ziputil->add($metafile_path, 'metainfo.txt');
    // close zipfile
    $ziputil->close();
    return $zipfile_path;
}
 function execute(&$vars, &$response)
 {
     $this->_import_items = $vars[0];
     $handler =& xoonips_gethandler('xoonips', 'import_item');
     $handler->findDuplicateItems($this->_import_items);
     $success = array('import_items' => $this->_import_items, 'is_conflict' => $this->_is_conflict($this->_import_items));
     $response->setResult(true);
     $response->setSuccess($success);
 }
function b_xoonips_moderator_show()
{
    global $xoopsUser;
    // hide block if user is guest
    if (!is_object($xoopsUser)) {
        return false;
    }
    $uid = $xoopsUser->getVar('uid', 'n');
    // hide block if user is invalid xoonips user
    $xsession_handler =& xoonips_getormhandler('xoonips', 'session');
    if (!$xsession_handler->validateUser($uid, false)) {
        return false;
    }
    // check moderator user
    $xmember_handler =& xoonips_gethandler('xoonips', 'member');
    if (!$xmember_handler->isModerator($uid)) {
        // user is not moderator
        return false;
    }
    // count certification requested users
    $xu_ohandler =& xoonips_getormhandler('xoonips', 'users');
    $join = new XooNIpsJoinCriteria('users', 'uid', 'uid', 'INNER', 'u');
    $criteria = new CriteriaCompo(new Criteria('activate', 0));
    $criteria->add(new Criteria('level', 0, '>', 'u'));
    $cu_count = $xu_ohandler->getCount($criteria, $join);
    // count certification requested items
    $xil_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
    $join = new XooNIpsJoinCriteria('xoonips_index', 'index_id', 'index_id', 'INNER', 'x');
    $criteria = new CriteriaCompo(new Criteria('certify_state', CERTIFY_REQUIRED));
    $criteria->add(new Criteria('open_level', OL_PUBLIC, '=', 'x'));
    $ci_count = $xil_handler->getCount($criteria, $join);
    // count group items open to public certification requested indexes
    if (xoonips_get_version() >= 340) {
        $xgxl_handler =& xoonips_getormhandler('xoonips', 'index_group_index_link');
        $gi_count = $xgxl_handler->getCount();
    } else {
        $gi_count = 0;
    }
    // assign block template variables
    $block = array();
    $block['lang_edit_group'] = _MB_XOONIPS_MODERATOR_EDIT_GROUPS;
    $block['lang_certify_users'] = _MB_XOONIPS_MODERATOR_CERTIFY_USERS;
    $block['lang_certify_users_count'] = $cu_count;
    $block['lang_certify_items'] = _MB_XOONIPS_MODERATOR_CERTIFY_PUBLIC_ITEMS;
    $block['lang_certify_items_count'] = $ci_count;
    $block['lang_groupcertify_items'] = _MB_XOONIPS_MODERATOR_GROUP_CERTIFY_PUBLIC_ITEMS;
    $block['lang_groupcertify_items_count'] = $gi_count;
    $block['lang_edit_public_index'] = _MB_XOONIPS_MODERATOR_EDIT_PUBLIC_INDEX;
    $block['lang_event_log'] = _MB_XOONIPS_MODERATOR_EVENT_LOG;
    $block['xid'] = IID_PUBLIC;
    return $block;
}
 function get_gids_to_subscribe($uid, $item_ids)
 {
     $item_group_ids = xoonips_transfer_get_group_ids_of_items($item_ids);
     $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
     $gids = $xgroup_handler->getGroupIds($uid);
     // return array_diff( $item_group_ids, $gids );
     $result = array();
     foreach ($item_group_ids as $gid) {
         if (!in_array($gid, $gids)) {
             $result[] = $gid;
         }
     }
     return $result;
 }
 function _get_item_log()
 {
     $log = '';
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     foreach ($this->_params['import_items'] as $item) {
         $basic =& $item->getVar('basic');
         $itemtype =& $item_type_handler->get($basic->get('item_type_id'));
         $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
         $log .= "\n\n[item]\n" . $handler->getImportLog($item);
         foreach ($item->getErrors() as $e) {
             $log .= "\nerror {$e}";
         }
         foreach (array_merge($item->getDuplicateUnupdatableItemId(), $item->getDuplicateUpdatableItemId(), $item->getDuplicateLockedItemId()) as $item_id) {
             $log .= "\nwarning conflict with " . xnpGetItemDetailURL($item_id);
         }
     }
     return $log;
 }
 function execute(&$vars, &$response)
 {
     global $xoopsUser;
     $success = array();
     $error = false;
     $transaction = XooNIpsTransaction::getInstance();
     $transaction->start();
     $itemtype_handler =& xoonips_getormhandler('xoonips', 'item_type');
     foreach (array_keys($vars[0]) as $key) {
         assert(!($vars[0][$key]->getImportAsNewFlag() && $vars[0][$key]->getUpdateFlag()));
         //skip this item if don't import as new and update
         if (!$vars[0][$key]->getImportAsNewFlag() && !$vars[0][$key]->getUpdateFlag()) {
             continue;
         }
         $item_handler =& xoonips_getormcompohandler('xoonips', 'item');
         if ($vars[0][$key]->getUpdateFlag() && !$item_handler->getPerm($vars[0][$key]->getUpdateItemId(), $xoopsUser->getVar('uid'), 'write')) {
             //no write permission to updating exist item -> error
             $vars[0][$key]->setErrors(E_XOONIPS_UPDATE_CERTIFY_REQUEST_LOCKED, "can't update locked item(" . $vars[0][$key]->getUpdateItemId() . ")");
             $error = true;
             break;
         }
         $basic =& $vars[0][$key]->getVar('basic');
         $itemtype =& $itemtype_handler->get($basic->get('item_type_id'));
         $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
         $handler->import($vars[0][$key]);
         $error = $error || count($vars[0][$key]->getErrors()) > 0;
     }
     if ($error) {
         $transaction->rollback();
     } else {
         foreach (array_keys($vars[0]) as $key) {
             $basic =& $vars[0][$key]->getVar('basic');
             $itemtype =& $itemtype_handler->get($basic->get('item_type_id'));
             $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
             $handler->onImportFinished($vars[0][$key], $vars[0]);
             $error = $error || count($vars[0][$key]->getErrors()) > 0;
         }
         $transaction->commit();
         $this->_remove_files();
     }
     $success['import_items'] =& $vars[0];
     $response->setResult(!$error);
     $response->setSuccess($success);
 }
function b_xoonips_group_show()
{
    global $xoopsUser;
    // hide block if user is guest
    if (!is_object($xoopsUser)) {
        return false;
    }
    $uid = $xoopsUser->getVar('uid', 'n');
    // hide block if user is invalid xoonips user
    $xsession_handler =& xoonips_getormhandler('xoonips', 'session');
    if (!$xsession_handler->validateUser($uid, false)) {
        return false;
    }
    // get administrable group ids
    $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
    $admin_gids = $xgroup_handler->getGroupIds($uid, true);
    if (empty($admin_gids)) {
        // user is not group admin
        return false;
    }
    // get index id of primary group
    $gid = $admin_gids[0];
    // primary gid
    $group_index_id = $xgroup_handler->getGroupRootIndexId($gid);
    // count certification requested items
    $xil_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
    $join = new XooNIpsJoinCriteria('xoonips_index', 'index_id', 'index_id', 'INNER', 'x');
    $criteria = new CriteriaCompo(new Criteria('certify_state', CERTIFY_REQUIRED));
    $criteria->add(new Criteria('open_level', OL_GROUP_ONLY, '=', 'x'));
    $criteria->add(new Criteria('gid', '(' . implode(',', $admin_gids) . ')', 'IN', 'x'));
    $ci_count = $xil_handler->getCount($criteria, $join);
    // assign block template variables
    $block = array();
    $block['lang_edit_group'] = _MB_XOONIPS_GROUP_EDIT_GROUP_MEMBERS;
    $block['lang_certify_group_items'] = _MB_XOONIPS_GROUP_CERTIFY_GROUP_ITEMS;
    $block['lang_certify_group_items_count'] = $ci_count;
    $block['lang_edit_group_index'] = _MB_XOONIPS_GROUP_EDIT_GROUP_INDEX;
    $block['xid'] = $group_index_id;
    return $block;
}
 function onDelete($item_id)
 {
     //trigger_error( "Binder onDelete( $item_id )" );
     $bilink_handler =& xoonips_getormhandler('xnpbinder', 'binder_item_link');
     $criteria = new Criteria('item_id', $item_id);
     $bilinks =& $bilink_handler->getObjects($criteria);
     if (!$bilinks) {
         return;
     }
     foreach ($bilinks as $bilink) {
         $child_items =& $bilink_handler->getObjects(new Criteria('binder_id', $bilink->get('binder_id')));
         if (!$child_items) {
             continue;
         }
         $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
         $join = new XooNIpsJoinCriteria('xoonips_index', 'index_id', 'index_id');
         $criteria = new CriteriaCompo(new Criteria('open_level', OL_PUBLIC));
         $criteria->add(new Criteria('certify_state', CERTIFIED));
         $criteria->add(new Criteria('item_id', $bilink->get('binder_id')));
         $index_item_links =& $index_item_link_handler->getObjects($criteria, false, '', false, $join);
         if (empty($index_item_links)) {
             continue;
         }
         if (count($child_items) == 1) {
             $item_handler =& xoonips_getormcompohandler('xnpbinder', 'item');
             $binder = $item_handler->get($bilink->get('binder_id'));
             $basic = $binder->getVar('basic');
             // define tags here for notification message
             $tags = xoonips_notification_get_item_tags($basic->get('item_id'));
             $mhandler =& xoops_gethandler('module');
             $module = $mhandler->getByDirName('xnpbinder');
             $nhandler =& xoonips_gethandler('xoonips', 'notification');
             $nhandler->triggerEvent2('user', 0, 'item_updated', _MD_XNPBINDER_USER_CONTENT_EMPTY_NOTIFYSBJ, $nhandler->getTemplateDirByMid($module->mid()), 'user_content_empty_notify', $tags, array($basic->get('uid')));
         }
         if (!$bilink_handler->delete($bilink)) {
             die('cannnot remove a deleted item from a binder.');
         }
     }
 }
 function preAction()
 {
     xoonips_deny_guest_access();
     xoonips_allow_post_method();
     if (!$GLOBALS['xoopsGTicket']->check(true, 'import', false)) {
         die('ticket error');
     }
     $itemtype_handler =& xoonips_getormhandler('xoonips', 'item_type');
     foreach ($itemtype_handler->getObjects() as $itemtype) {
         if ('xoonips_index' == $itemtype->get('name')) {
             continue;
         }
         $handler =& xoonips_gethandler($itemtype->get('name'), 'import_item');
         $handler->create();
     }
     $sess_handler =& xoonips_getormhandler('xoonips', 'session');
     $sess =& $sess_handler->get(session_id());
     $session = unserialize($sess->get('sess_data'));
     $this->_collection = unserialize(gzuncompress(base64_decode($session['xoonips_import_items'])));
     xoonips_validate_request($this->_collection);
     $this->_make_clone_of_update_item($this->_collection);
     $this->_begin_time = time();
     $this->_params[] =& $this->_collection->getItems();
 }
/**
 * xoonips uninstall function
 *
 * @param object $xoopsMod module instance
 * @return bool false if failure
 */
function xoops_module_uninstall_xoonips($xoopsMod)
{
    $mydirname = basename(__DIR__);
    $uid = $GLOBALS['xoopsUser']->getVar('uid', 'n');
    $mid = $xoopsMod->getVar('mid', 'n');
    // get xoops administration handler
    $admin_xoops_handler =& xoonips_gethandler('xoonips', 'admin_xoops');
    // show original 'user' and 'login' blocks
    $sys_blocks = array('user' => array(), 'login' => array());
    if (defined('XOOPS_CUBE_LEGACY')) {
        // for XOOPS Cube Legacy 2.1
        $sys_blocks['user'][] = array('legacy', 'b_legacy_usermenu_show');
        $sys_blocks['login'][] = array('user', 'b_user_login_show');
    }
    $sys_blocks['user'][] = array('system', 'b_system_user_show');
    $sys_blocks['login'][] = array('system', 'b_system_login_show');
    foreach ($sys_blocks as $type => $sys_type_blocks) {
        foreach ($sys_type_blocks as $sys_block) {
            list($dirname, $show_func) = $sys_block;
            $sysmid = $admin_xoops_handler->getModuleId($dirname);
            if ($sysmid === false) {
                continue;
                // module not found
            }
            $bids = $admin_xoops_handler->getBlockIds($sysmid, $show_func);
            foreach ($bids as $bid) {
                $admin_xoops_handler->setBlockPosition($bid, true, 0, 0);
            }
            if (count($bids) != 0) {
                break;
                // found this type's block
            }
        }
    }
    return true;
}
/**
 * get group list
 *
 * @return array group list
 */
function xoonips_group_get_groups($uid, $gids = null)
{
    $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
    $xmember_handler =& xoonips_gethandler('xoonips', 'member');
    $u_handler =& xoonips_getormhandler('xoonips', 'xoops_users');
    $is_admin = $xmember_handler->isAdmin($uid);
    $xg_objs =& $xgroup_handler->getGroupObjects($gids);
    $groups = array();
    foreach ($xg_objs as $xg_obj) {
        $gid = $xg_obj->get('gid');
        $gadmin_uids = $xgroup_handler->getUserIds($gid, true);
        $is_gadmin = in_array($uid, $gadmin_uids);
        $gadmins = array();
        foreach ($gadmin_uids as $gadmin_uid) {
            $u_obj =& $u_handler->get($gadmin_uid);
            if (!is_object($u_obj)) {
                continue;
            }
            $gadmins[] = array('uid' => $gadmin_uid, 'uname' => $u_obj->getVar('uname', 's'));
        }
        $groups[] = array('gid' => $gid, 'gname' => $xg_obj->get('gname', 's'), 'gdesc' => $xg_obj->get('gdesc', 's'), 'locked' => !xoonips_group_check_perm($gid), 'gadmins' => $gadmins, 'is_admin' => $is_admin || $is_gadmin);
    }
    return $groups;
}
    $xoopsTpl->assign('download_file_id', $download_file_id);
}
$xoonips_module_header = '<link rel="stylesheet" type="text/css" href="style.css" />';
$func = $modname . 'GetHeadMeta';
if (function_exists($func)) {
    eval('$xoonips_module_header .= "\\n".' . $func . '($item_id);');
}
$xoonips_module_header .= "\n" . $xoopsTpl->get_template_vars('xoops_module_header');
$xoopsTpl->assign('xoops_module_header', $xoonips_module_header);
// Record events(view item)
$eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log');
$eventlog_handler->recordViewItemEvent($item_id);
$basic = xnpGetBasicInformationArray($item_id);
$xoopsTpl->assign('xoops_pagetitle', $textutil->html_special_chars($basic['titles'][0]));
// get item viewed count
$ranking_handler =& xoonips_gethandler('xoonips', 'ranking');
$ranking_handler->update();
$viewed_count = $ranking_handler->get_count_viewed_item($item_id);
$xoopsTpl->assign('viewed_count', $viewed_count);
//start of item comment function
$comconfig_handler =& xoonips_getormhandler('xoonips', 'config');
$com_dir_name = $comconfig_handler->getValue('item_comment_dirname');
$com_forum_id = $comconfig_handler->getValue('item_comment_forum_id');
$xoopsTpl->assign('dir_name', $com_dir_name);
$xoopsTpl->assign('forum_id', $com_forum_id);
//end of item comment function
include XOOPS_ROOT_PATH . '/footer.php';
function xoonips_delete_item($item_id)
{
    $params = array(session_id(), $item_id, 'item_id');
    $response = new XooNIpsResponse();
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) {
    exit;
}
// check token ticket
require_once '../class/base/gtickets.php';
$ticket_area = 'xoonips_admin_maintenance_ranking';
if (!$xoopsGTicket->check(true, $ticket_area, false)) {
    redirect_header($xoonips_admin['mypage_url'], 3, $xoopsGTicket->getErrors());
    exit;
}
$admin_ranking_handler =& xoonips_gethandler('xoonips', 'admin_ranking');
if (!$admin_ranking_handler->clear_sum_data()) {
    redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MAINTENANCE_RANKING_LOCKED);
    exit;
}
redirect_header($xoonips_admin['mypage_url'], 1, _AM_XOONIPS_MSG_DBUPDATED);
function xnpbookGetMetadata($prefix, $item_id)
{
    $mydirpath = dirname(dirname(__FILE__));
    $mydirname = basename($mydirpath);
    if (!in_array($prefix, array('oai_dc', 'junii2'))) {
        return false;
    }
    // detail information
    $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail');
    $author_handler =& xoonips_getormhandler($mydirname, 'author');
    $detail_obj =& $detail_handler->get($item_id);
    if (empty($detail_obj)) {
        return false;
    }
    $detail = $detail_obj->getArray();
    $criteria = new Criteria('book_id', $item_id);
    $criteria->setSort('author_order');
    $author_objs =& $author_handler->getObjects($criteria);
    $detail['authors'] = array();
    foreach ($author_objs as $author_obj) {
        $detail['authors'][] = $author_obj->get('author');
    }
    // basic information
    $basic = xnpGetBasicInformationArray($item_id);
    $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']);
    // indexes
    $indexes = array();
    if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) {
        foreach ($xids as $xid) {
            if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) {
                $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid);
            }
        }
    }
    // files
    $files = array();
    $mimetypes = array();
    if ($detail['attachment_dl_limit'] == 0) {
        $file_handler =& xoonips_gethandler('xoonips', 'file');
        $files = $file_handler->getFilesInfo($item_id, 'book_pdf');
        foreach ($files as $file) {
            if (!in_array($file['mime_type'], $mimetypes)) {
                $mimetypes[] = $file['mime_type'];
            }
        }
    }
    // related to
    $related_to_handler =& xoonips_getormhandler('xoonips', 'related_to');
    $related_to_ids = $related_to_handler->getChildItemIds($item_id);
    $related_tos = array();
    foreach ($related_to_ids as $related_to_id) {
        $related_tos[] = array('item_id' => $related_to_id, 'item_url' => XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $related_to_id);
    }
    // repository configs
    $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
    $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER);
    $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']);
    // assign template
    global $xoopsTpl;
    $tpl = new XoopsTpl();
    $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins';
    $tpl->assign($xoopsTpl->get_template_vars());
    $tpl->assign('basic', $basic);
    $tpl->assign('detail', $detail);
    $tpl->assign('indexes', $indexes);
    $tpl->assign('files', $files);
    $tpl->assign('mimetypes', $mimetypes);
    $tpl->assign('related_tos', $related_tos);
    $tpl->assign('repository', $repository);
    $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml');
    return $xml;
}
 /**
  * create group root index
  *
  * @access public
  * @param int gid group id
  * @return int created index id, false if failure
  */
 function createGroupRootIndex($gid)
 {
     // check existing group index
     $criteria = new CriteriaCompo(new Criteria('gid', $gid));
     $criteria->add(new Criteria('parent_index_id', IID_ROOT));
     if ($this->getCount($criteria) != 0) {
         // already exists
         return false;
     }
     // get group id (gname)
     $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
     $xgroup_obj =& $xgroup_handler->getGroupObject($gid);
     if (!is_object($xgroup_obj)) {
         // group not found
         return false;
     }
     $gname = $xgroup_obj->getVar('gname', 'n');
     return $this->_createRootIndex($gname, false, $gid);
 }
Example #18
0
/**
 * check ownerUID, ownerGID and openLevel indexes writable privileges
 *
 * @param string $sess_id session id
 * @param int $uid user id
 * @param int $ownerUID index owner user
 * @param int $ownerGID index owner group
 * @param int $openLevel open level of index
 * @return bool
 *
 */
function _xnpal_isWritableInternal2($sess_id, $uid, $ownerUID, $ownerGID, $openLevel)
{
    if ($openLevel == OL_PUBLIC) {
    } else {
        if ($openLevel == OL_GROUP_ONLY) {
            $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
            if ($xgroup_handler->isGroupAdmin($uid, $ownerGID)) {
                return true;
            }
        } else {
            if ($openLevel == OL_PRIVATE) {
                if ($uid == $ownerUID) {
                    return true;
                }
            }
        }
    }
    if (xnp_is_moderator($sess_id, $uid)) {
        return true;
    }
    return false;
}
function xoonips_notification_user_file_downloaded($file_id, $downloader_uid)
{
    $file_handler =& xoonips_getormhandler('xoonips', 'file');
    $file = $file_handler->get($file_id);
    $user_handler =& xoops_gethandler('user');
    $user = $user_handler->get($downloader_uid);
    $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
    $item_basic = $item_basic_handler->get($file->get('item_id'));
    $tags = xoonips_notification_get_item_tags($file->get('item_id'));
    $tags['DOWNLOAD_TIMESTAMP'] = date('Y/m/d H:i:s');
    $tags['ORIGINAL_FILE_NAME'] = $file->get('original_file_name');
    $tags['UNAME'] = $user->getVar('uname');
    $nhandler =& xoonips_gethandler('xoonips', 'notification');
    $nhandler->triggerEvent2('user', 0, 'file_downloaded', _MD_XOONIPS_USER_FILE_DOWNLOADED_NOTIFYSBJ, $nhandler->getTemplateDirByMid(), 'user_file_downloaded_notify', $tags, array($item_basic->get('uid')));
}
function xoops_module_update_xoonips($xoopsMod, $oldversion)
{
    $mydirname = basename(__DIR__);
    $uid = $GLOBALS['xoopsUser']->getVar('uid', 'n');
    $mid = $xoopsMod->getVar('mid', 'n');
    global $xoopsDB;
    if ($oldversion < 324) {
        echo '<code>The update does not supported before ver 3.24.</code><br />';
        return false;
    }
    echo '<code>Updating modules...</code><br />';
    switch ($oldversion) {
        case 324:
            xoonips_insert_default_configs(330);
            $sqls = <<<SQL
-- xoonips_changelog
ALTER TABLE `xoonips_changelog`
  ENGINE=INNODB;
-- xoonips_file
ALTER TABLE `xoonips_file`
  MODIFY `file_size` int(10) unsigned NOT NULL default '0',
  MODIFY `file_type_id` int(10) unsigned NOT NULL default '0',
  ADD `is_deleted` tinyint(1) unsigned NOT NULL default '0',
  ADD `download_count` int(10) unsigned NOT NULL default '0';
-- xoonips_file_type
ALTER TABLE `xoonips_file_type`
  MODIFY `name` varchar(30) NOT NULL default '';
-- xoonips_item_basic
ALTER TABLE `xoonips_item_basic`
  DROP `title`,
  DROP `keywords`;
-- xoonips_item_keyword
ALTER TABLE `xoonips_item_keyword`
  DROP PRIMARY KEY,
  ADD `seq_id` int(10) unsigned NOT NULL auto_increment PRIMARY KEY FIRST,
  MODIFY `keyword` varchar(255) NOT NULL default '',
  ADD UNIQUE (`item_id`,`keyword_id`);
-- xoonips_item_title
ALTER TABLE `xoonips_item_title`
  DROP PRIMARY KEY,
  ADD `seq_id` int(10) unsigned NOT NULL auto_increment PRIMARY KEY FIRST,
  MODIFY `title` varchar(255) NOT NULL default '',
  ADD UNIQUE (`item_id`,`title_id`);
-- xoonips_position
ALTER TABLE `xoonips_positions`
  ADD UNIQUE (`posi_title`);
-- xoonips_ranking_active_group
ALTER TABLE `xoonips_ranking_active_group`
  MODIFY `gid` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_contributing_user
ALTER TABLE `xoonips_ranking_contributing_user`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `uid` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_downloaded_item
ALTER TABLE `xoonips_ranking_downloaded_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_new_group
ALTER TABLE `xoonips_ranking_new_group`
  MODIFY `gid` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_new_item
ALTER TABLE `xoonips_ranking_new_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_searched_keyword
ALTER TABLE `xoonips_ranking_searched_keyword`
  MODIFY `keyword` varchar(255) binary NOT NULL default '',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_active_group
ALTER TABLE `xoonips_ranking_sum_active_group`
  MODIFY `gid` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_contributing_user
ALTER TABLE `xoonips_ranking_sum_contributing_user`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `uid` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_downloaded_item
ALTER TABLE `xoonips_ranking_sum_downloaded_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_new_group
ALTER TABLE `xoonips_ranking_sum_new_group`
  MODIFY `gid` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_new_item
ALTER TABLE `xoonips_ranking_sum_new_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_searched_keyword
ALTER TABLE `xoonips_ranking_sum_searched_keyword`
  MODIFY `keyword` varchar(255) binary NOT NULL default '',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_sum_viewed_item
ALTER TABLE `xoonips_ranking_sum_viewed_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_ranking_viewed_item
ALTER TABLE `xoonips_ranking_viewed_item`
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  MODIFY `count` int(10) unsigned NOT NULL default '0';
-- xoonips_related_to
ALTER TABLE `xoonips_related_to`
  DROP PRIMARY KEY,
  ADD `related_to_id` int(10) unsigned NOT NULL auto_increment PRIMARY KEY FIRST,
  MODIFY `parent_id` int(10) unsigned NOT NULL default '0',
  MODIFY `item_id` int(10) unsigned NOT NULL default '0',
  ADD UNIQUE `related_to` (`parent_id`,`item_id`);
-- xoonips_search_cache
ALTER TABLE `xoonips_search_cache`
  MODIFY `sess_id` varchar(32) NOT NULL default '';
-- xoonips_search_cache_file
ALTER TABLE `xoonips_search_cache_file`
  MODIFY `search_cache_id` int(10) unsigned NOT NULL default '0';
-- xoonips_search_cache_item
ALTER TABLE `xoonips_search_cache_item`
  DROP PRIMARY KEY,
  ADD `search_cache_item_id` int(10) NOT NULL auto_increment PRIMARY KEY FIRST,
  MODIFY `search_cache_id` int(10) unsigned NOT NULL default '0',
  ADD `matchfor_index` tinyint(1) NOT NULL default '0',
  ADD `matchfor_item` tinyint(1) NOT NULL default '0',
  ADD `matchfor_file` tinyint(1) NOT NULL default '0',
  ADD UNIQUE `search_cache_id` (`search_cache_id`,`item_id`);
ALTER TABLE `xoonips_search_cache_metadata`
  MODIFY `search_cache_id` int(10) unsigned NOT NULL default '0',
  MODIFY `identifier` varchar(255) NOT NULL default '';
ALTER TABLE `xoonips_search_text`
  MODIFY `file_id` int(10) unsigned NOT NULL default '0';
-- xoonips_session
ALTER TABLE `xoonips_session`
  MODIFY uid int(10) unsigned NOT NULL default '0';
SQL;
            // queries
            if (!xoonips_sql_queries($sqls)) {
                return false;
            }
            // fixed unlinked item bug.
            $sql = sprintf('DELETE FROM `%s` WHERE `item_id`=0', $xoopsDB->prefix('xoonips_related_to'));
            $xoopsDB->query($sql);
            $sql = sprintf('DELETE FROM `%s` WHERE `item_id`=0', $xoopsDB->prefix('xoonips_index_item_link'));
            $xoopsDB->query($sql);
            xoonips_delete_obsolete_configs(330);
        case 330:
        case 331:
            // fixed default xoonips group bug.
            // if xoonips was installed before 3.24, then the administrator have
            // joined to group id 0. this group id have to be GID_DEFAULT(1).
            $sql = sprintf('UPDATE `%s` SET `gid`=1 WHERE `gid`=0', $xoopsDB->prefix('xoonips_groups_users_link'));
            $xoopsDB->query($sql);
            $sqls = <<<SQL
-- xoonips_config
ALTER TABLE `xoonips_config`
  ENGINE=INNODB;
-- xoonips_ranking_active_group
ALTER TABLE `xoonips_ranking_active_group`
  ENGINE=INNODB;
-- xoonips_ranking_contributing_user
ALTER TABLE `xoonips_ranking_contributing_user`
  ENGINE=INNODB;
-- xoonips_ranking_downloaded_item
ALTER TABLE `xoonips_ranking_downloaded_item`
  ENGINE=INNODB;
-- xoonips_ranking_new_group
ALTER TABLE `xoonips_ranking_new_group`
  ENGINE=INNODB;
-- xoonips_ranking_new_item
ALTER TABLE `xoonips_ranking_new_item`
  ENGINE=INNODB;
-- xoonips_ranking_searched_keyword
ALTER TABLE `xoonips_ranking_searched_keyword`
  ENGINE=INNODB;
-- xoonips_ranking_sum_active_group
ALTER TABLE `xoonips_ranking_sum_active_group`
  ENGINE=INNODB;
-- xoonips_ranking_sum_contributing_user
ALTER TABLE `xoonips_ranking_sum_contributing_user`
  ENGINE=INNODB;
-- xoonips_ranking_sum_downloaded_item
ALTER TABLE `xoonips_ranking_sum_downloaded_item`
  ENGINE=INNODB;
-- xoonips_ranking_sum_new_group
ALTER TABLE `xoonips_ranking_sum_new_group`
  ENGINE=INNODB;
-- xoonips_ranking_sum_new_item
ALTER TABLE `xoonips_ranking_sum_new_item`
  ENGINE=INNODB;
-- xoonips_ranking_sum_searched_keyword
ALTER TABLE `xoonips_ranking_sum_searched_keyword`
  ENGINE=INNODB;
-- xoonips_ranking_sum_viewed_item
ALTER TABLE `xoonips_ranking_sum_viewed_item`
  ENGINE=INNODB;
ALTER TABLE `xoonips_ranking_viewed_item`
  ENGINE=INNODB;
SQL;
            // queries
            if (!xoonips_sql_queries($sqls)) {
                return false;
            }
        case 332:
            // Notice:
            //   version 333-339 are reserved number for future releases of
            //   RELENG_3_3 branch. don't change database structure after
            //   3.40 released.
        // Notice:
        //   version 333-339 are reserved number for future releases of
        //   RELENG_3_3 branch. don't change database structure after
        //   3.40 released.
        case 333:
        case 334:
        case 335:
        case 336:
        case 337:
        case 338:
        case 339:
            xoonips_insert_default_configs(340);
            // delete all harvested metadata, because table design has been changed.
            $sql = sprintf('DELETE FROM `%s`', $xoopsDB->prefix('xoonips_oaipmh_metadata'));
            $xoopsDB->query($sql);
            $sqls = <<<SQL
-- xoonips_search_cache_metadata
ALTER TABLE xoonips_search_cache_metadata
    DROP PRIMARY KEY,
    ADD `search_cache_metadata_id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
    ADD UNIQUE ( `search_cache_id`, `identifier` );
-- xoonips_config
ALTER TABLE xoonips_config
    MODIFY `value` text NOT NULL;
-- xoonips_session
ALTER TABLE xoonips_session
    ADD `sess_data` longtext NOT NULL;
-- xoonips_groups_users_link
ALTER TABLE xoonips_groups_users_link
    DROP PRIMARY KEY,
    ADD groups_users_link_id int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
    ADD UNIQUE ( gid, uid );
-- xoonips_item_show
ALTER TABLE xoonips_item_show
    DROP PRIMARY KEY,
    ADD item_show_id int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
    ADD UNIQUE ( item_id, uid );
-- xoonips_item_lock
CREATE TABLE xoonips_item_lock (
    item_id int(10) unsigned NOT NULL,
    lock_count int(10) unsigned NOT NULL default '0',
    PRIMARY KEY  (`item_id`)
    ) TYPE=InnoDB;
-- xoonips_transfer_request
CREATE TABLE xoonips_transfer_request (
    item_id int(10) unsigned NOT NULL,
    to_uid int(10) unsigned NOT NULL,
    PRIMARY KEY  (`item_id`)
    ) TYPE=InnoDB;
-- xoonips_item_show
ALTER TABLE xoonips_item_show
    TYPE=innodb;
-- xoonips_groups_users_link
ALTER TABLE xoonips_groups_users_link
    TYPE=innodb;
-- xoonips_oaipmh_repositories
ALTER TABLE xoonips_oaipmh_repositories
    ADD repository_name text,
    ADD metadata_count int(10) unsigned NOT NULL default '0';
UPDATE xoonips_oaipmh_repositories
    SET last_access_date=NULL,
    last_success_date=NULL,
    last_access_result=NULL;
-- xoonips_oaipmh_metadata
ALTER TABLE xoonips_oaipmh_metadata
    DROP PRIMARY KEY,
    DROP metadata,
    ADD metadata_id int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
    ADD last_update_date varchar(255) NOT NULL default '',
    ADD creation_date varchar(255) NOT NULL default '',
    ADD `date` varchar(255) NOT NULL default '',
    ADD creator varchar(255) NOT NULL default '',
    ADD link text,
    ADD last_update_date_for_sort datetime NOT NULL default '1970-01-01 00:00:00',
    ADD creation_date_for_sort datetime NOT NULL default '1970-01-01 00:00:00',
    ADD date_for_sort datetime NOT NULL default '1970-01-01 00:00:00',
    ADD UNIQUE (identifier);
-- xoonips_oaipmh_metadata_field
CREATE TABLE `xoonips_oaipmh_metadata_field` (
  `metadata_field_id` int(10) unsigned NOT NULL auto_increment,
  `metadata_id` int(10) unsigned NOT NULL,
  `format` varchar(100) NOT NULL,
  `name` varchar(255) NOT NULL,
  `ordernum` int(10) unsigned NOT NULL,
  `category_name` varchar(255) NOT NULL default '',
  `value` text,
  `namespace` varchar(255) NOT NULL default '',
  `namespace_uri` text,
  PRIMARY KEY  (`metadata_field_id`),
  KEY `metadata_id` (`metadata_id`)
) TYPE=MyISAM;
-- xoonips_index
ALTER TABLE `xoonips_index`
  MODIFY `index_id` int(10) unsigned NOT NULL;
-- xoonips_index_group_index_link
CREATE TABLE `xoonips_index_group_index_link` (
  `index_group_index_link_id` int(10) unsigned NOT NULL auto_increment,
  `index_id` int(10) unsigned NOT NULL default '0',
  `group_index_id` int(10) unsigned NOT NULL default '0',
  `gid` int(10) NOT NULL default '0',
  `uid` int(10) NOT NULL default '0',
  PRIMARY KEY  (`index_group_index_link_id`),
  UNIQUE KEY `index_id_2` (`index_id`,`group_index_id`),
  KEY `index_id` (`index_id`),
  KEY `item_id` (`group_index_id`)
) TYPE=InnoDB;
SQL;
            // queries
            if (!xoonips_sql_queries($sqls)) {
                return false;
            }
            // fixed old update script bugs.
            // from too old to 324
            if (xoonips_sql_has_index('xoonips_file', 'sid')) {
                $sql = sprintf('ALTER TABLE `%s` DROP INDEX `sid`, ADD INDEX (`sess_id`)', $xoopsDB->prefix('xoonips_file'));
                $xoopsDB->query($sql);
            }
            if (xoonips_sql_has_index('xoonips_search_cache', 'sess_id')) {
                $sql = sprintf('ALTER TABLE `%s` DROP INDEX `sess_id`', $xoopsDB->prefix('xoonips_search_cache'));
                $xoopsDB->query($sql);
            }
            if (xoonips_sql_has_index('xoonips_search_text', 'search')) {
                $sql = sprintf('ALTER TABLE `%s` DROP INDEX `search`, ADD FULLTEXT `search_text`', $xoopsDB->prefix('xoonips_search_text'));
                $xoopsDB->query($sql);
            }
            // from 324 to 330
            $sqls = <<<SQL
-- xoonips_changelog
ALTER TABLE `xoonips_changelog`
  ENGINE=INNODB;
-- xoonips_ranking_searched_keyword
ALTER TABLE `xoonips_ranking_searched_keyword`
  MODIFY `keyword` varchar(255) binary NOT NULL default '';
-- xoonips_ranking_sum_searched_keyword
ALTER TABLE `xoonips_ranking_sum_searched_keyword`
  MODIFY `keyword` varchar(255) binary NOT NULL default '';
SQL;
            // queries
            if (!xoonips_sql_queries($sqls)) {
                return false;
            }
            // remove obsolete configs
            xoonips_delete_obsolete_configs(340);
        case 340:
        case 341:
        case 342:
        case 343:
        case 344:
        case 345:
            // remove zombie related_to entries
            xoonips_remove_zombie_related_to_ids();
            // remove duplicated private item ids
            xoonips_remove_duplicated_private_item_ids();
        default:
            break;
    }
    // enable available notifications
    $admin_xoops_handler =& xoonips_gethandler('xoonips', 'admin_xoops');
    $member_handler =& xoops_gethandler('member');
    $uids = array_keys($member_handler->getUsers(null, true));
    // php-indent: disable
    $notifications = array('administrator' => array('subscribe' => array('item_transfer', 'account_certify', 'item_certify', 'group_item_certify_request'), 'unsubscribe' => array('binder_content_empty', 'item_certify_request')), 'user' => array('subscribe' => array('item_transfer', 'item_updated', 'item_certified', 'item_rejected', 'file_downloaded', 'group_item_certified', 'group_item_rejected'), 'unsubscribe' => array('index_renamed', 'index_moved', 'index_deleted')));
    // php-indent: enable
    foreach ($notifications as $category => $events) {
        // enable module event
        foreach ($events['subscribe'] as $event) {
            $admin_xoops_handler->enableNotification($mid, $category, $event);
        }
    }
    // subscribe all notifications to all users
    foreach ($uids as $uid) {
        foreach ($notifications as $category => $events) {
            foreach ($events['subscribe'] as $event) {
                $admin_xoops_handler->subscribeNotification($mid, $uid, $category, $event);
            }
        }
    }
    // unsubscribe obsolete notifications from all users
    foreach ($notifications as $category => $events) {
        foreach ($events['unsubscribe'] as $event) {
            $admin_xoops_handler->unsubscribeNotification($mid, 0, $category, $event);
        }
    }
    return true;
}
function xnpconferenceGetMetadata($prefix, $item_id)
{
    $mydirpath = dirname(dirname(__FILE__));
    $mydirname = basename($mydirpath);
    if (!in_array($prefix, array('oai_dc', 'junii2'))) {
        return false;
    }
    // detail information
    $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail');
    $author_handler =& xoonips_getormhandler($mydirname, 'author');
    $detail_obj =& $detail_handler->get($item_id);
    if (empty($detail_obj)) {
        return false;
    }
    $detail = $detail_obj->getArray();
    $criteria = new Criteria('conference_id', $item_id);
    $criteria->setSort('author_order');
    $author_objs =& $author_handler->getObjects($criteria);
    $detail['authors'] = array();
    foreach ($author_objs as $author_obj) {
        $detail['authors'][] = $author_obj->get('author');
    }
    $detail['conference_from_iso8601'] = xnpISO8601($detail['conference_from_year'], $detail['conference_from_month'], $detail['conference_from_mday']);
    $detail['conference_to_iso8601'] = xnpISO8601($detail['conference_to_year'], $detail['conference_to_month'], $detail['conference_to_mday']);
    $types = xnpconferenceGetTypes();
    $detail['presentation_type_display'] = $types[$detail['presentation_type']];
    // basic information
    $basic = xnpGetBasicInformationArray($item_id);
    $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']);
    // indexes
    $indexes = array();
    if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) {
        foreach ($xids as $xid) {
            if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) {
                $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid);
            }
        }
    }
    // files
    $files = array();
    $mimetypes = array();
    $file_handler =& xoonips_gethandler('xoonips', 'file');
    if ($detail['attachment_dl_limit'] == 0) {
        $files = $file_handler->getFilesInfo($item_id, 'conference_file');
        foreach ($files as $file) {
            if (!in_array($file['mime_type'], $mimetypes)) {
                $mimetypes[] = $file['mime_type'];
            }
        }
    }
    // related to
    $related_to_handler =& xoonips_getormhandler('xoonips', 'related_to');
    $related_to_ids = $related_to_handler->getChildItemIds($item_id);
    $related_tos = array();
    foreach ($related_to_ids as $related_to_id) {
        $related_tos[] = array('item_id' => $related_to_id, 'item_url' => XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $related_to_id);
    }
    // repository configs
    $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
    $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER);
    $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']);
    // conference date
    if ($detail['conference_from_year'] == $detail['conference_to_year']) {
        if ($detail['conference_from_month'] == $detail['conference_to_month']) {
            if ($detail['conference_from_mday'] == $detail['conference_to_mday']) {
                if ($basic['lang'] == 'jpn') {
                    $fmt = "%1\$d年%2\$d月%3\$d日";
                } else {
                    $fmt = '%7$s %3$d, %1$d';
                }
            } else {
                if ($basic['lang'] == 'jpn') {
                    $fmt = "%1\$d年%2\$d月%3\$d〜%6\$d日";
                } else {
                    $fmt = '%7$s %3$d-%6$d, %1$d';
                }
            }
        } else {
            if ($basic['lang'] == 'jpn') {
                $fmt = "%1\$d年%2\$d月%3\$d日〜%5\$d月%6\$d日";
            } else {
                $fmt = '%7$s %3$d-%8$s %6$d, %1$d';
            }
        }
    } else {
        if ($basic['lang'] == 'jpn') {
            $fmt = "%1\$d年%2\$d月%3\$d日〜%4\$d年%5\$d月%6\$d日";
        } else {
            $fmt = '%7$s %3$d %1$d-%8$s %6$d %4$d';
        }
    }
    $month_str = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec');
    $detail['conference_date'] = sprintf($fmt, $detail['conference_from_year'], $detail['conference_from_month'], $detail['conference_from_mday'], $detail['conference_to_year'], $detail['conference_to_month'], $detail['conference_to_mday'], $month_str[$detail['conference_from_month']], $month_str[$detail['conference_to_month']]);
    if (_CHARSET != 'UTF-8' && ($basic['lang'] = 'jpn')) {
        $detail['conference_date'] = mb_convert_encoding($detail['conference_date'], _CHARSET, 'UTF-8');
    }
    // assign template
    global $xoopsTpl;
    $tpl = new XoopsTpl();
    $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins';
    $tpl->assign($xoopsTpl->get_template_vars());
    $tpl->assign('basic', $basic);
    $tpl->assign('detail', $detail);
    $tpl->assign('indexes', $indexes);
    $tpl->assign('files', $files);
    $tpl->assign('mimetypes', $mimetypes);
    $tpl->assign('related_tos', $related_tos);
    $tpl->assign('repository', $repository);
    $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml');
    return $xml;
}
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------- //
include 'include/common.inc.php';
include_once 'include/lib.php';
include_once 'include/AL.php';
include_once 'include/notification.inc.php';
include 'class/base/gtickets.php';
$xnpsid = $_SESSION['XNPSID'];
xoonips_deny_guest_access('user.php');
$uid = $_SESSION['xoopsUserId'];
$xgroup_handler =& xoonips_gethandler('xoonips', 'group');
$is_moderator = xnp_is_moderator($xnpsid, $uid);
$admin_gids = $xgroup_handler->getGroupIds($uid, true);
$is_groupadmin = count($admin_gids) != 0;
// Only Moderator and Group administrator can access this page.
if (!$is_moderator) {
    if (!xnp_is_activated($xnpsid, $uid)) {
        redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_MODERATOR_NOT_ACTIVATED);
        exit;
    }
    if (!$is_groupadmin) {
        redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ITEM_FORBIDDEN);
        exit;
    }
}
// get requests
 function get_gname_csv()
 {
     $result = array();
     $gids = array();
     foreach ($this->_params['gids_to_subscribe'] as $gid) {
         $gids[] = intval($gid);
     }
     if (count($gids) == 0) {
         return '';
     }
     $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
     $xgroup_objs =& $xgroup_handler->getGroupObjects($gids);
     if (empty($xgroup_objs)) {
         return '';
     }
     foreach ($xgroup_objs as $xgroup_obj) {
         $result[] = $xgroup_obj->getVar('gname', 's');
     }
     return implode(',', $result);
 }
    die('illegal request');
}
if ($to_index_obj->get('uid') != $to_uid || $to_index_obj->get('open_level') != OL_PRIVATE) {
    die('illegal request');
}
// get rescue and delete item ids
$index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
$item_ids = $index_item_link_handler->getNonPrivateItemIds($uid);
// merge group and public item ids
$item_ids = array_unique($item_ids);
if (count($item_ids) == 0) {
    die('illegal request');
}
// handover of items
$item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
$admin_xgroup_handler =& xoonips_gethandler('xoonips', 'admin_group');
$event_handler =& xoonips_getormhandler('xoonips', 'event_log');
foreach ($item_ids as $item_id) {
    $item_basic_obj =& $item_basic_handler->get($item_id);
    $index_item_link_objs =& $index_item_link_handler->getByItemId($item_id);
    foreach ($index_item_link_objs as $index_item_link_obj) {
        $xid = $index_item_link_obj->get('index_id');
        $index_obj =& $index_handler->get($xid);
        $open_level = $index_obj->get('open_level');
        switch ($open_level) {
            case OL_PRIVATE:
                // delete index item link
                $index_item_link_handler->delete($index_item_link_obj);
                break;
            case OL_GROUP_ONLY:
                // join old user joined group
 /**
  * return array of group name that user is not subscribed.
  * 
  * @param integer $uid user id
  * @param array $item_ids array of integer of item id
  * @return array of group name string
  * 
  */
 function get_unsubscribed_group_names($uid, $item_ids)
 {
     $item_group_ids = xoonips_transfer_get_group_ids_of_items($item_ids);
     $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
     $gids = $xgroup_handler->getGroupIds($uid);
     $result = array();
     foreach ($item_group_ids as $gid) {
         if (!in_array($gid, $gids)) {
             $xg_obj =& $xgroup_handler->getGroupObject($gid);
             $result[] = $xg_obj->get('gname');
         }
     }
     return $result;
 }
 function setAllDoiConflictFlag(&$import_items)
 {
     $handler =& xoonips_gethandler('xoonips', 'import_item');
     foreach (array_keys($import_items) as $key) {
         $doi_conflict_id = $handler->_findDoiConflictItemIds($import_items[$key]);
         $import_items[$key]->setDoiConflictFlag(count($doi_conflict_id) > 0);
     }
 }
 /**
  * execute login
  *
  * @param[in] $vars[0] id (use '' if guest login)
  * @param[in] $vars[1] pass (use '' if guest login)
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error error information
  * @param[out] $response->success session id
  * @return false if error
  */
 function execute(&$vars, &$response)
 {
     $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF);
     // parameter check
     $error =& $response->getError();
     if (count($vars) > 2) {
         $error->add(XNPERR_EXTRA_PARAM);
     }
     if (count($vars) < 2) {
         $error->add(XNPERR_MISSING_PARAM);
     }
     //
     if (isset($vars[0]) && strlen($vars[0]) > 25) {
         $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
     }
     //
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return;
     } else {
         $id = $vars[0];
         $pass = $vars[1];
     }
     $member_handler =& xoonips_gethandler('xoonips', 'member');
     $user_handler =& xoonips_getormhandler('xoonips', 'users');
     $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log');
     $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
     $transaction = XooNIpsTransaction::getInstance();
     $transaction->start();
     if ($id == '') {
         $target_user = $xconfig_handler->getValue(XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY);
         if ($pass != '' || $target_user != XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL) {
             $transaction->rollback();
             $response->error->add(XNPERR_AUTH_FAILURE);
             $response->setResult(false);
             return false;
         }
         $user = false;
         $uid = UID_GUEST;
         $groups = array();
     } else {
         $user =& $member_handler->loginUser($id, $pass);
         if (!$user) {
             $transaction->rollback();
             // insert login failure event
             if (!$eventlog_handler->recordLoginFailureEvent($id)) {
                 $response->error->add(XNPERR_SERVER_ERROR, "cannot insert event");
             }
             // return error
             $response->error->add(XNPERR_AUTH_FAILURE);
             $response->setResult(false);
             return false;
         }
         $xoonips_user = $user->getVar('xoonips_user');
         $uid = $xoonips_user->get('uid');
         $xoops_user_handler =& xoops_gethandler('user');
         $xoops_user = $xoops_user_handler->get($uid);
         if (0 == $xoops_user->getVar('level', 'n') || !$xoonips_user->get('activate')) {
             // not activated, not certified
             // return error
             $transaction->rollback();
             $response->error->add(XNPERR_AUTH_FAILURE);
             $response->setResult(false);
             return false;
         }
         $groups = $xoops_user->getGroups();
     }
     if ($myxoopsConfig['closesite'] == 1) {
         $allowed = false;
         if ($user) {
             foreach ($groups as $group) {
                 if (in_array($group, $myxoopsConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) {
                     $allowed = true;
                     break;
                 }
             }
         }
         if (!$allowed) {
             // site closed
             $transaction->rollback();
             $response->error->add(XNPERR_AUTH_FAILURE);
             $response->setResult(false);
             return false;
         }
     }
     // remove expired xoonips sessions
     $session_handler =& xoonips_getormhandler('xoonips', 'session');
     if (!$session_handler->gcSession()) {
         $transaction->rollback();
         $response->error->add(XNPERR_SERVER_ERROR, "failed to gc session");
         $response->setResult(false);
         return false;
     }
     // record $uid
     $_SESSION = array();
     $_SESSION['xoopsUserId'] = $uid;
     $_SESSION['xoopsUserGroups'] = $groups;
     // set XNPSID(for old routines)
     $_SESSION['XNPSID'] = $uid == UID_GUEST ? SID_GUEST : session_id();
     if ($user) {
         // update last_login
         $xoops_user->setVar('last_login', time());
         if (!$xoops_user_handler->insert($xoops_user)) {
         }
         // init xoonips_session
         $session_handler->initSession($uid);
         // insert login event
         $eventlog_handler->recordLoginSuccessEvent($uid);
     }
     $transaction->commit();
     $response->setSuccess(session_id());
     $response->setResult(true);
     return true;
 }
    $posi_handler =& xoonips_getormhandler('xoonips', 'positions');
    $criteria = new CriteriaElement();
    $criteria->setSort('posi_order');
    $criteria->setOrder(ASC);
    $posi_objs =& $posi_handler->getObjects($criteria, false, 'posi_id, posi_title');
    $ret = array();
    foreach ($posi_objs as $posi_obj) {
        $posi_id = $posi_obj->getVar('posi_id', 's');
        $posi_title = $posi_obj->getVar('posi_title', 'e');
        $ret[$posi_id] = $posi_title;
    }
    return $ret;
}
// initialize variable
$op = $formdata->getValue('both', 'op', 's', false, 'editprofile');
$xmember_handler =& xoonips_gethandler('xoonips', 'member');
$is_admin = $xmember_handler->isAdmin($myuid);
$is_moderator = $xmember_handler->isModerator($myuid);
if (!$is_admin && !$is_moderator && $myuid != $uid) {
    redirect_header(XOOPS_URL . '/', 3, _US_NOEDITRIGHT);
    exit;
}
$myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF);
$myxoopsConfigUser =& xoonips_get_xoops_configs(XOOPS_CONF_USER);
$xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
$xconfig_keys = array('realname' => _US_REALNAME, 'address' => _MD_XOONIPS_ACCOUNT_ADDRESS, 'company_name' => _MD_XOONIPS_ACCOUNT_COMPANY_NAME, 'division' => _MD_XOONIPS_ACCOUNT_DIVISION, 'tel' => _MD_XOONIPS_ACCOUNT_TEL, 'country' => _MD_XOONIPS_ACCOUNT_COUNTRY, 'zipcode' => _MD_XOONIPS_ACCOUNT_ZIPCODE, 'fax' => _MD_XOONIPS_ACCOUNT_FAX);
$xconfig_vars = array();
foreach ($xconfig_keys as $key => $label) {
    $xconfig_vars[$key] = $xconfig_handler->getValue('account_' . $key . '_optional');
}
$u_handler =& xoonips_getormhandler('xoonips', 'xoops_users');
/**
 * 
 * groupde_item_storage_limit <= file size of all attachment files registered in group area
 * : return false
 * @param gid id of group to be checked
 * @return true if available space is enough. 
 *
 */
function check_group_item_storage_limit($gid)
{
    $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
    $xgroup_obj =& $xgroup_handler->getGroupObject($gid);
    if (!is_object($xgroup_obj)) {
        return false;
    }
    $item_storage_limit = $xgroup_obj->getVar('group_item_storage_limit', 'n');
    if (filesize_group($gid) >= $item_storage_limit) {
        return false;
    }
    return true;
}
function xoonipsGetIndexCountInfo($xnpsid, $xid)
{
    $index = array();
    $result = xnp_get_index($xnpsid, $xid, $index);
    if ($result != RES_OK) {
        redirect_header(XOOPS_URL . '/index.php', 3, "ERROR");
        break;
    }
    $openLevel = $index['open_level'];
    $indexes = array();
    $result = xnp_get_all_indexes($xnpsid, array(), $indexes);
    if ($result != RES_OK) {
        redirect_header(XOOPS_URL . '/index.php', 3, "ERROR");
        break;
    }
    $indexesLen = count($indexes);
    if ($openLevel == OL_PRIVATE) {
        $indexUID = $index['owner_uid'];
        $indexCount = 0;
        for ($i = 0; $i < $indexesLen; $i++) {
            if ($indexes[$i]['owner_uid'] == $indexUID) {
                $indexCount++;
            }
        }
        global $account;
        $indexNumberLimit = $account['index_number_limit'];
        $limitLabel = _MD_XOONIPS_INDEX_NUMBER_OF_PRIVATE_INDEX_LABEL;
    } else {
        if ($openLevel == OL_GROUP_ONLY) {
            $xgroup_handler =& xoonips_gethandler('xoonips', 'group');
            $indexGID = $index['owner_gid'];
            $xg_obj =& $xgroup_handler->getGroupObject($indexGID);
            if (!is_object($xg_obj)) {
                redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ERROR_GROUP_SELECT);
                exit;
            }
            $indexCount = 0;
            for ($i = 0; $i < $indexesLen; $i++) {
                if ($indexes[$i]['owner_gid'] == $indexGID) {
                    $indexCount++;
                }
            }
            $indexNumberLimit = $xg_obj->get('group_index_number_limit');
            $limitLabel = _MD_XOONIPS_INDEX_NUMBER_OF_GROUP_INDEX_LABEL;
        } else {
            return array(false, false, false);
        }
    }
    return array($limitLabel, $indexCount, $indexNumberLimit);
}