コード例 #1
0
/**
 * find all item ids in the index of $index_id.
 * if $recursive_item is given.
 * @param integer $index_id index id to export
 * @param integer $index_id user id to export
 * @param boolean $recursive_item true(recursive) or false(not recursive)
 * @return array integer item id(s)
 */
function xoonips_get_all_item_ids_to_export($index_id, $uid, $recursive_item = false)
{
    $ids = array();
    $tmp_idx = array($index_id);
    while (count($tmp_idx) > 0) {
        $i = array_shift($tmp_idx);
        $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
        $index_item_links = $index_item_link_handler->getByIndexId($i, $uid);
        foreach ($index_item_links as $link) {
            $ids[] = $link->get('item_id');
        }
        if (!$recursive_item) {
            return $ids;
        }
        $child = array();
        $res = xnp_get_indexes($_SESSION['XNPSID'], $i, array(), $child);
        if ($res == RES_OK) {
            foreach ($child as $c) {
                array_push($tmp_idx, $c['item_id']);
            }
        }
    }
    return $ids;
}
コード例 #2
0
function xoonipsGetTopIndex($xid)
{
    global $xnpsid;
    $index = array();
    $result = xnp_get_index($xnpsid, $xid, $index);
    if ($result != RES_OK) {
        return 0;
    }
    $indexes = array();
    $criteria = array();
    $result = xnp_get_indexes($xnpsid, IID_ROOT, $criteria, $indexes);
    if ($result != RES_OK) {
        return 0;
    }
    foreach ($indexes as $key => $val) {
        if ($index['open_level'] == $val['open_level']) {
            if ($index['open_level'] == OL_PUBLIC || $index['open_level'] == OL_GROUP_ONLY && $index['owner_gid'] == $val['owner_gid'] || $index['open_level'] == OL_PRIVATE && $index['owner_uid'] == $val['owner_uid']) {
                return $val['item_id'];
            }
        }
    }
    return 0;
}
コード例 #3
0
/**
 * Importing indexes to a index that is specified by $parent_index_id.
 * Associations of pseudo ID and Real index ID are sotred to $id_table.
 *
 * @param parent_index_id index_id that indexes is imported to.
 * @param $indexes array of index information to be imported.
 * $indexes = array(
 *                   array( 'titles' => array( TITLE1, TITLE2, ... )
 *                          'parent_id' => pseudo id of parent index
 *                          'item_id' => pseudo id of own index
 *                          'child' => array( [0] => array( 'titles' => ..., 'parent_id' => ..., 'child' => ....)
 *                                            [1] => array( same above ),
 *                                            ....
 *                           )
 *                         ),
 *                   array( 'titles' => array( TITLE1, TITLE2, ... )
 *                          same above ... ),
 *                   ...
 *                   );
 * @param id_table reference of associative array for output( [pseudo id] => [real index id] )
 * @return no return value.
 */
function _xoonips_import_index($parent_index_id, &$indexes, &$id_table)
{
    $xnpsid = $_SESSION['XNPSID'];
    $lengths = xnpGetColumnLengths('xoonips_item_title');
    $unicode =& xoonips_getutility('unicode');
    foreach ($indexes as $index) {
        foreach ($index['titles'] as $k => $title) {
            list($index['titles'][$k], $dummy) = xnpTrimString($unicode->decode_utf8($title, xoonips_get_server_charset(), 'h'), $lengths['title'], 'UTF-8');
        }
        $child = array();
        // numbers of same index name
        $cnt = 0;
        $index_id = 0;
        if (xnp_get_indexes($xnpsid, $parent_index_id, array(), $child) == RES_OK) {
            foreach ($child as $i) {
                $diff = array_diff($i['titles'], $index['titles']);
                if (empty($diff)) {
                    // true if $index have only same names of $i ( $i['titles'] == $index['titles'] )
                    $cnt++;
                    $index_id = $i['item_id'];
                }
            }
        }
        if ($cnt == 1) {
            $id_table[$index['index_id']] = $index_id;
        } else {
            $insert_index = array();
            $insert_index['titles'] = $index['titles'];
            $insert_index['parent_index_id'] = $parent_index_id;
            $result = xnp_insert_index($xnpsid, $insert_index, $index_id);
            if ($result != RES_OK) {
                break;
            }
            $id_table[$index['index_id']] = $index_id;
            // record event log
            $mydirname = basename(dirname(__DIR__));
            $event_handler =& xoonips_getormhandler('xoonips', 'event_log');
            $event_handler->recordInsertIndexEvent($index_id);
        }
        if (array_key_exists('child', $index)) {
            _xoonips_import_index($index_id, $index['child'], $id_table);
        }
    }
}