当前位置: 首页>>代码示例>>PHP>>正文


PHP xoonips_getormcompohandler函数代码示例

本文整理汇总了PHP中xoonips_getormcompohandler函数的典型用法代码示例。如果您正苦于以下问题:PHP xoonips_getormcompohandler函数的具体用法?PHP xoonips_getormcompohandler怎么用?PHP xoonips_getormcompohandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xoonips_getormcompohandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * execute getIndex
  *
  * @param[in]  $vars[0] session ID
  * @param[in]  $vars[1] index ID
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error  error information
  * @param[out] $response->success XooNIpsIndexCompo index information
  */
 function execute(&$vars, &$response)
 {
     // parameter check
     $error =& $response->getError();
     if (count($vars) > 2) {
         $error->add(XNPERR_EXTRA_PARAM);
     } else {
         if (count($vars) < 2) {
             $error->add(XNPERR_MISSING_PARAM);
         } else {
             if (isset($vars[0]) && strlen($vars[0]) > 32) {
                 $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
             }
             if (!is_int($vars[1]) && !ctype_digit($vars[1])) {
                 $error->add(XNPERR_INVALID_PARAM, 'not integer parameter 2');
             }
         }
     }
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return;
     } else {
         $sessionid = $vars[0];
         $index_id = $vars[1];
     }
     list($result, $uid, $session) = $this->restoreSession($sessionid);
     if (!$result) {
         $response->setResult(false);
         $error->add(XNPERR_INVALID_SESSION);
         return false;
     }
     // get index from index_id
     $index_compo_handler =& xoonips_getormcompohandler('xoonips', 'index');
     $index = $index_compo_handler->get($index_id);
     if ($index == false) {
         $response->setResult(false);
         $response->error->add(XNPERR_NOT_FOUND, "cannot get index");
         return false;
     }
     // check permission
     $index_handler =& xoonips_getormhandler('xoonips', 'index');
     if (!$index_handler->getPerm($index_id, $uid, 'read')) {
         $response->setResult(false);
         $response->error->add(XNPERR_ACCESS_FORBIDDEN, "no permission");
         return false;
     }
     $response->setSuccess($index);
     $response->setResult(true);
     return true;
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:60,代码来源:getindex.class.php

示例2: execute

 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);
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:44,代码来源:importimport.class.php

示例3: onDelete

 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.');
         }
     }
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:39,代码来源:item_event_listener.class.php

示例4: doAction

 function doAction()
 {
     global $xoopsUser;
     // get item_id
     $item_id = $this->_formdata->getValue('get', 'item_id', 'i', false);
     // permission check
     $item_compo_handler =& xoonips_getormcompohandler('xoonips', 'item');
     if (!$item_compo_handler->getPerm($item_id, $xoopsUser->getVar('uid'), 'read')) {
         $this->show_no_permission_error_page();
     }
     // get item_info_compo of $item_id
     $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
     $item_basic = $item_basic_handler->get($item_id);
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     $item_type = $item_type_handler->get($item_basic->get('item_type_id'));
     $info_compo_handler =& xoonips_getormcompohandler($item_type->get('name'), 'item');
     $info_compo = $info_compo_handler->get($item_id);
     // read language file of item
     $langman =& xoonips_getutility('languagemanager');
     $langman->read('main.php', $item_type->get('name'));
     // set params
     $this->_view_params['template_file_name'] = $info_compo_handler->getTemplateFileName(XOONIPS_TEMPLATE_TYPE_TRANSFER_ITEM_DETAIL);
     $this->_view_params['template_vars'] = $info_compo_handler->getTemplateVar(XOONIPS_TEMPLATE_TYPE_TRANSFER_ITEM_DETAIL, $item_id, $xoopsUser->getVar('uid'));
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:24,代码来源:transfer_user_detail_item.class.php

示例5: get_item_template_vars

 /**
  * get array of item for template vars
  * @param integer $item_id
  */
 function get_item_template_vars($item_id)
 {
     $item_handler =& xoonips_getormcompohandler('xoonips', 'item');
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     $item =& $item_handler->get($item_id);
     $basic =& $item->getVar('basic');
     $itemtype =& $item_type_handler->get($basic->get('item_type_id'));
     return array('item_id' => $item_id, 'item_type_name' => $itemtype->getVar('display_name', 's'), 'title' => $this->concatenate_titles($item->getVar('titles')));
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:13,代码来源:transfer_user_item_list.class.php

示例6: xnp_get_items

/**
 *
 * アイテム情報取得.
 *
 * @param sid セッションID
 * @param iids 取得したいアイテムのIDの配列
 * @param criteria 結果の範囲指定,ソート条件指定
 * @param items 検索結果のを書き込む配列
 * @return RES_OK
 * @return RES_DB_NOT_INITIALIZED
 * @return RES_NO_SUCH_SESSION
 * @return RES_DB_QUERY_ERROR
 *
 */
function xnp_get_items($sess_id, $iids, $criteria, &$items)
{
    global $xoopsDB;
    $items = array();
    if (!xnp_is_valid_session_id($sess_id)) {
        return RES_NO_SUCH_SESSION;
    }
    $ret = _xnpal_sessionID2UID($sess_id, $uid);
    if ($ret != RES_OK) {
        return $ret;
    }
    $items = array();
    if (!isset($iids) || count($iids) == 0) {
        return RES_OK;
    }
    $sql = "SELECT DISTINCT ti.item_id as item_id, item_type_id, tt.title as title, description, doi, ti.uid as uid, creation_date, last_update_date, publication_year, publication_month, publication_mday, lang ";
    $sql .= " FROM ";
    $sql .= $xoopsDB->prefix("xoonips_index_item_link") . " AS tlink";
    $sql .= " LEFT JOIN " . $xoopsDB->prefix("xoonips_index") . " AS tx ON tlink.index_id = tx.index_id";
    $sql .= " LEFT JOIN " . $xoopsDB->prefix("xoonips_item_basic") . " AS ti ON tlink.item_id = ti.item_id";
    $sql .= " LEFT JOIN " . $xoopsDB->prefix("xoonips_item_title") . " AS tt ON tt.item_id=ti.item_id";
    $sql .= " LEFT JOIN " . $xoopsDB->prefix("xoonips_groups_users_link") . " as tgulink ON tx.gid=tgulink.gid";
    $sql .= " WHERE tlink.item_id IN ( " . _xnpal_getCsvStr($iids) . " )";
    $sql .= " AND title_id=" . DEFAULT_ORDER_TITLE_OFFSET;
    $sql .= xnp_criteria2str($criteria);
    $result = $xoopsDB->query($sql);
    if (!$result) {
        _xnpal_setLastErrorString("error in xnp_get_items " . $xoopsDB->error());
        return RES_DB_QUERY_ERROR;
    }
    $items_buf = array();
    $ordered_ids = array();
    //array of sorted item_id(s) to sort $items_buf in the end of this function
    $item_compo_handler =& xoonips_getormcompohandler('xoonips', 'item');
    while ($row = $xoopsDB->fetchArray($result)) {
        if (!$item_compo_handler->getPerm($row['item_id'], $uid, 'read')) {
            continue;
        }
        $items_buf[$row['item_id']] = $row;
        $items_buf[$row['item_id']]['titles'] = array();
        $items_buf[$row['item_id']]['keywords'] = array();
        $ordered_ids[] = $row['item_id'];
    }
    //get titles of selected item
    if (count($items_buf) > 0) {
        $sql = "SELECT item_id, title FROM " . $xoopsDB->prefix("xoonips_item_title") . " WHERE item_id IN ( " . implode(",", array_keys($items_buf)) . " ) ORDER BY item_id ASC, title_id ASC";
        $result = $xoopsDB->query($sql);
        if (!$result) {
            _xnpal_setLastErrorString("error in xnp_get_items " . $xoopsDB->error() . " sql={$sql}" . " at " . __LINE__ . " in " . __FILE__ . "\n" . xnp_get_last_error_string());
            return RES_DB_QUERY_ERROR;
        }
        while ($row = $xoopsDB->fetchArray($result)) {
            $items_buf[$row['item_id']]['titles'][] = $row['title'];
        }
        //get keywords of selected item
        $sql = "SELECT item_id, keyword FROM " . $xoopsDB->prefix("xoonips_item_keyword") . " WHERE item_id IN ( " . implode(",", array_keys($items_buf)) . " ) ORDER BY item_id ASC, keyword_id ASC";
        $result = $xoopsDB->query($sql);
        if (!$result) {
            _xnpal_setLastErrorString("error in xnp_get_items " . $xoopsDB->error() . " sql={$sql}" . " at " . __LINE__ . " in " . __FILE__ . "\n" . xnp_get_last_error_string());
            return RES_DB_QUERY_ERROR;
        }
        while ($row = $xoopsDB->fetchArray($result)) {
            $items_buf[$row['item_id']]['keywords'][] = $row['keyword'];
        }
    }
    // convert the associative array(index_buf) to the array(indexes) (keep order specified by criteriaString)
    foreach ($ordered_ids as $id) {
        $items[] = $items_buf[$id];
    }
    _xnpal_setLastErrorString("");
    return RES_OK;
}
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:86,代码来源:AL.php

示例7: execute

 /**
  * execute getItemPermission
  *
  * @param[in] $vars[0] sessionid
  * @param[in] $vars[1] id
  * @param[in] $vars[2] id_type
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error  error information
  * @param[out] $response->success array item permission structure
  * @return false if fault
  */
 function execute(&$vars, &$response)
 {
     // parameter check
     $error =& $response->getError();
     if (count($vars) > 3) {
         $error->add(XNPERR_EXTRA_PARAM);
     } else {
         if (count($vars) < 3) {
             $error->add(XNPERR_MISSING_PARAM);
         } else {
             if (isset($vars[0]) && strlen($vars[0]) > 32) {
                 $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
             }
             if ($vars[2] != 'item_id' && $vars[2] != 'ext_id') {
                 $error->add(XNPERR_INVALID_PARAM, 'invalid parameter 3');
             }
             if ($vars[2] == 'item_id') {
                 if (!is_int($vars[1]) && !ctype_digit($vars[1])) {
                     $error->add(XNPERR_INVALID_PARAM, 'not integer parameter 2');
                 }
                 if (strlen($vars[1]) > 10) {
                     $error->add(XNPERR_INVALID_PARAM, 'too long parameter 2');
                 }
             }
         }
     }
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return false;
     } else {
         $sessionid = $vars[0];
         $id = $vars[1];
         $id_type = $vars[2];
         if ($id_type == 'item_id') {
             $id = intval($id);
         }
     }
     // validate session
     list($result, $uid, $session) = $this->restoreSession($sessionid);
     if (!$result) {
         // error invalid session
         $error->add(XNPERR_INVALID_SESSION);
         $response->setResult(false);
         return false;
     }
     // ext_id to item_id
     $item_compo_handler =& xoonips_getormcompohandler('xoonips', 'item');
     if ($id_type == 'ext_id') {
         $item_compo = $item_compo_handler->getByExtId($id);
     } else {
         if ($id_type == 'item_id') {
             $item_compo = $item_compo_handler->get($id);
         } else {
             $error->add(XNPERR_INVALID_PARAM, "invalid id_type({$id_type})");
             $response->setResult(false);
             return false;
         }
     }
     if ($item_compo == false) {
         $error->add(XNPERR_NOT_FOUND);
         $response->setResult(false);
         return false;
     }
     $item_basic = $item_compo->getVar('basic');
     $item_id = $item_basic->get('item_id');
     // get permission
     $result = array('read' => $item_compo_handler->getPerm($item_id, $uid, 'read'), 'write' => $item_compo_handler->getPerm($item_id, $uid, 'write'), 'delete' => $item_compo_handler->getPerm($item_id, $uid, 'delete'));
     $response->setSuccess($result);
     $response->setResult(true);
     return true;
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:83,代码来源:getitempermission.class.php

示例8: xnpmodelGetMetaInformation

function xnpmodelGetMetaInformation($item_id)
{
    $ret = array();
    $creator_array = array();
    $basic = xnpGetBasicInformationArray($item_id);
    $detail = xnpmodelGetDetailInformation($item_id);
    if (!empty($basic)) {
        $ret[_MD_XOONIPS_ITEM_TITLE_LABEL] = implode("\n", $basic['titles']);
        $ret[_MD_XOONIPS_ITEM_CONTRIBUTOR_LABEL] = $basic['contributor'];
        $ret[_MD_XOONIPS_ITEM_KEYWORDS_LABEL] = implode("\n", $basic['keywords']);
        $ret[_MD_XOONIPS_ITEM_DESCRIPTION_LABEL] = $basic['description'];
        $ret[_MD_XOONIPS_ITEM_DOI_LABEL] = $basic['doi'];
        $ret[_MD_XOONIPS_ITEM_LAST_UPDATE_DATE_LABEL] = $basic['last_update_date'];
        $ret[_MD_XOONIPS_ITEM_CREATION_DATE_LABEL] = $basic['creation_date'];
    }
    if (!empty($detail)) {
        $ret[_MD_XNPMODEL_MODEL_TYPE_LABEL] = $detail['model_type']['display_value'];
    }
    $xnpmodel_handler =& xoonips_getormcompohandler('xnpmodel', 'item');
    $xnpmodel =& $xnpmodel_handler->get($item_id);
    foreach ($xnpmodel->getVar('creator') as $creator) {
        $creator_array[] = $creator->getVar('creator', 'n');
    }
    $ret[_MD_XNPMODEL_CREATOR_LABEL] = implode("\n", $creator_array);
    return $ret;
}
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:26,代码来源:view.php

示例9: xoonips_transfer_get_index_tree_for_dropdown

function xoonips_transfer_get_index_tree_for_dropdown($index_id, &$result, $depth)
{
    $index_compo_handler =& xoonips_getormcompohandler('xoonips', 'index');
    $index_compo = $index_compo_handler->get($index_id);
    if ($index_compo === false) {
        return;
        // bad index_id
    }
    $titles = $index_compo->getVar('titles');
    $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
    $result[] = array('index_id' => $index_id, 'title' => $titles[DEFAULT_INDEX_TITLE_OFFSET]->get('title'), 'depth' => $depth, 'item_count' => $index_item_link_handler->getCount(new Criteria('index_id', $index_id)));
    $index_handler =& xoonips_getormhandler('xoonips', 'index');
    $index = $index_compo->getVar('index');
    $criteria = new Criteria('parent_index_id', $index_id);
    $criteria->setOrder('asc');
    $criteria->setSort('sort_number');
    $indexes =& $index_handler->getObjects($criteria);
    if ($indexes !== false) {
        foreach ($indexes as $index) {
            xoonips_transfer_get_index_tree_for_dropdown($index->get('index_id'), $result, $depth + 1);
        }
    }
}
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:23,代码来源:transfer.inc.php

示例10: count

            break;
        }
        $dirArrayR[] = $index;
    }
    $ct = count($dirArrayR);
    $dirArray = array();
    for ($i = 0; $i < $ct; $i++) {
        $dirArray[] = $dirArrayR[$ct - $i - 1];
    }
    return $dirArray;
}
$dirArray = xoonipsGetPathArray($xnpsid, $xid);
// get Children
// -> childIndexes
$childIndexes = array();
$index_compo_handler =& xoonips_getormcompohandler('xoonips', 'index');
$join = new XooNIpsJoinCriteria('xoonips_index', 'item_id', 'index_id');
$criteria2 =& new Criteria('parent_index_id', $xid);
$criteria2->setSort('sort_number');
foreach ($index_compo_handler->getObjects($criteria2, true, '', false, $join) as $index_id => $childindex) {
    $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock');
    $index_group_index_link_handler =& xoonips_getormhandler('xoonips', 'index_group_index_link');
    $titles =& $childindex->getVar('titles');
    $childIndexes[$index_id] = array('isLocked' => $item_lock_handler->isLocked($index_id), 'titles' => array($titles[0]->getVar('title', 's')), 'item_id' => $index_id, 'lockTypeString' => $textutil->html_special_chars(get_lock_type_string($index_id)), 'write_permission' => $index_handler->getPerm($index_id, @$_SESSION['xoopsUserId'], 'write'), 'public_index_string' => '', 'public_index_pending_string' => '');
    foreach ($index_group_index_link_handler->getByGroupIndexId($index_id, @$_SESSION['xoopsUserId']) as $link) {
        $childIndexes[$index_id]['public_index_string'] .= xnpGetIndexPathString($xnpsid, $link->get('index_id')) . "<br />";
        $childIndexes[$index_id]['public_index_pending_string'] .= _MD_XOONIPS_ITEM_PENDING_NOW . "<br />";
    }
}
// prev_idnex_id, next_index_id are set
reset($childIndexes);
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:31,代码来源:editindex.php

示例11: xoonips_get_item_count_from_search_cache

/**
 * return number of items of the item search cache
 * 
 * @param $search_cache_id integer cache id
 * @return integer number of items
 */
function xoonips_get_item_count_from_search_cache($search_cache_id)
{
    global $xoopsDB, $xoopsUser;
    $search_cache_item_handler =& xoonips_getormhandler('xoonips', 'search_cache_item');
    $join = new XooNIpsJoinCriteria('xoonips_item_basic', 'item_id', 'item_id', 'INNER', 'tb');
    $search_cache_item =& $search_cache_item_handler->getObjects(new Criteria('search_cache_id', $search_cache_id), false, '', false, $join);
    if (count($search_cache_item) == 0) {
        return 0;
    }
    $c = 0;
    $item_handler =& xoonips_getormcompohandler('xoonips', 'item');
    foreach ($search_cache_item as $item) {
        if ($item_handler->getPerm($item->get('item_id'), $xoopsUser ? $xoopsUser->getVar('uid') : UID_GUEST, 'read')) {
            $c++;
        }
    }
    return $c;
    /*
        $search_cache_item =& $search_cache_item_handler->getObjects( new Criteria( 'search_cache_id', $search_cache_id ), false, 'count(tb.item_id)', false, $join );
        if( count( $search_cache_item ) == 0 ) return 0;
        var_dump( $search_cache_item[0] -> getExtraVar( 'count(tb.item_id)' ) );
        return $search_cache_item[0] -> getExtraVar( 'count(tb.item_id)' );
    */
}
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:30,代码来源:itemselect.inc.php

示例12: execute

 /**
  * execute updateFile
  *
  * @param[in]  $vars[0] session ID
  * @param[in]  $vars[1] item ID
  * @param[in]  $vars[2] identifier type of $vars[1] parameter('item_id'|'ext_id')
  * @param[in]  $vars[3] field name to add/update file
  * @param[in]  $vars[4] XooNIpsFile file information
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error  error information
  * @param[out] $response->success new file id
  */
 function execute(&$vars, &$response)
 {
     /*
     check permission
     check field name
     check filesize <= upload_max_filesize
     get XooNIpsFile if file_id exist ($oldfile)
     create XooNIpsFile from item_id and file information ($newfile)
     start transaction
     insert $newfile
     create search_text and update xoonips_file table
     if oldfile exists, set is_deleted of oldfile to 1
     update certify_state, notify certify_required, auto_certify, update item_status, udpate RSS
     commit
     delete oldfile
     */
     // parameter check
     $error =& $response->getError();
     if (count($vars) > 5) {
         $error->add(XNPERR_EXTRA_PARAM);
     } else {
         if (count($vars) < 5) {
             $error->add(XNPERR_MISSING_PARAM);
         } else {
             if (isset($vars[0]) && strlen($vars[0]) > 32) {
                 $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
             }
             if ($vars[2] != 'item_id' && $vars[2] != 'ext_id') {
                 $error->add(XNPERR_INVALID_PARAM, 'invalid parameter 3');
             }
             if ($vars[2] == 'item_id' && !is_int($vars[1]) && !ctype_digit($vars[1])) {
                 $error->add(XNPERR_INVALID_PARAM, 'not integer parameter 2');
             }
             if ($vars[2] == 'item_id' && strlen($vars[1]) > 10) {
                 $error->add(XNPERR_INVALID_PARAM, 'too long parameter 2');
             }
             // file size check
             $upload_max_filesize = $this->returnBytes(ini_get('upload_max_filesize'));
             if (filesize($vars[4]->getFilepath()) > $upload_max_filesize) {
                 $error->add(XNPERR_INVALID_PARAM, 'too large file');
             }
             $vars[4]->set('file_size', filesize($vars[4]->getFilepath()));
         }
     }
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return false;
     } else {
         $sessionid = $vars[0];
         $id = $vars[1];
         $id_type = $vars[2];
         $field_name = $vars[3];
         $file = $vars[4];
     }
     list($result, $uid, $session) = $this->restoreSession($sessionid);
     if (!$result) {
         $response->setResult(false);
         $error->add(XNPERR_INVALID_SESSION);
         return false;
     }
     // get item and item_id
     $item_handler =& xoonips_getormcompohandler('xoonips', 'item');
     $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
     if ($id_type == 'item_id') {
         $item = $item_handler->get($id);
     } else {
         if ($id_type == 'ext_id') {
             if (strlen($id) == 0) {
                 $response->setResult(false);
                 $error->add(XNPERR_INVALID_PARAM, "ext_id is empty");
                 return false;
             } else {
                 $basics =& $item_basic_handler->getObjects(new Criteria('doi', addslashes($id)));
                 if (false === $basics) {
                     $response->setResult(false);
                     $error->add(XNPERR_SERVER_ERROR, "cannot get basic information");
                     return false;
                 } else {
                     if (count($basics) >= 2) {
                         $response->setResult(false);
                         $error->add(XNPERR_SERVER_ERROR, "ext_id is duplicated");
                         return false;
                     } else {
                         if (count($basics) == 1) {
                             $item = $item_handler->get($basics[0]->get('item_id'));
                         } else {
                             $item = false;
//.........这里部分代码省略.........
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:101,代码来源:updatefile.class.php

示例13: execute


//.........这里部分代码省略.........
     if (!$add_to_private) {
         $error->add(XNPERR_INVALID_PARAM, "select at least 1 private index");
         // test e5
     }
     // item_type_id -> item_type_name, detail_item_type_handler, detail_item_type, detail_item_handler
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     $basic = $item->getVar('basic');
     $item_type_id = $basic->get('item_type_id');
     $item_type = $item_type_handler->get($item_type_id);
     if (!$item_type) {
         $response->setResult(false);
         $transaction->rollback();
         $error->add(XNPERR_INVALID_PARAM, "bad itemtype(item_type_id={$item_type_id})");
         // test E6*
         return false;
     }
     $item_type_name = $item_type->get('name');
     $detail_item_type_handler =& xoonips_getormhandler($item_type_name, 'item_type');
     if (!$detail_item_type_handler) {
         $response->setResult(false);
         $transaction->rollback();
         $error->add(XNPERR_SERVER_ERROR, "cannot get item type handler(item_type_id={$item_type_id})");
         // test E7*
         return false;
     }
     $detail_item_type = $detail_item_type_handler->get($item_type_id);
     if (!$detail_item_type) {
         $response->setResult(false);
         $transaction->rollback();
         $error->add(XNPERR_SERVER_ERROR, "cannot get item type(item_type_id={$item_type_id})");
         // test E8*
         return false;
     }
     $detail_item_handler =& xoonips_getormcompohandler($item_type_name, 'item');
     // can access that related_tos?
     $related_tos = $item->getVar('related_tos');
     foreach ($related_tos as $related_to) {
         $item_id = $related_to->get('item_id');
         $item_basic = $item_basic_handler->get($item_id);
         if (!$item_basic) {
             $error->add(XNPERR_INVALID_PARAM, "no such related_to(item_id={$item_id})");
             // test e5
         } else {
             if (!$detail_item_handler->getPerm($item_id, $uid, 'read')) {
                 $error->add(XNPERR_ACCESS_FORBIDDEN, "cannot access related_tos(item_id={$item_id})");
                 // test e5
             }
         }
     }
     if ($error->get()) {
         $transaction->rollback();
         $response->setResult(false);
         return false;
     }
     // error if add to public/group and no rights/readme input
     if ($add_to_public || count($add_to_gids)) {
         if (!$detail_item_handler->isValidForPubicOrGroupShared($item)) {
             $response->setResult(false);
             $error->add(XNPERR_INCOMPLETE_PARAM, "item cannot be public nor group-shared");
             return false;
         }
     }
     if (!$this->isPublicationDateValid($response, $basic->get('publication_year'), $basic->get('publication_month'), $basic->get('publication_mday'), $detail_item_type->getRequired('publication_year'), $detail_item_type->getRequired('publication_month'), $detail_item_type->getRequired('publication_mday'))) {
         $response->setResult(false);
         return false;
     }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:67,代码来源:putitem.class.php

示例14: execute

 /**
  * execute getSimpleItems
  *
  * @param[in] $vars[0] sessionid
  * @param[in] $vars[1] array of id
  * @param[in] $vars[2] id_type
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error  error information
  * @param[out] $response->success XooNIpsItem retrieved item object
  * @return false if fault
  */
 function execute(&$vars, &$response)
 {
     $error =& $response->getError();
     $response->setResult(false);
     //
     // parameter check
     if (count($vars) > 3) {
         $error->add(XNPERR_EXTRA_PARAM);
     } else {
         if (count($vars) < 3) {
             $error->add(XNPERR_MISSING_PARAM);
         } else {
             if (isset($vars[0]) && strlen($vars[0]) > 32) {
                 $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
             }
             if ($vars[2] != 'item_id' && $vars[2] != 'ext_id') {
                 $error->add(XNPERR_INVALID_PARAM, 'invalid parameter 3');
             }
         }
     }
     //
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return false;
     } else {
         $sessionid = $vars[0];
         $ids = $vars[1];
         $id_type = $vars[2];
     }
     //
     // validate session
     list($result, $uid, $session) = $this->restoreSession($sessionid);
     if (!$result) {
         $error->add(XNPERR_INVALID_SESSION);
     }
     //
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return;
     } else {
         $response->setResult(false);
         $sessionid = $vars[0];
         $item = $vars[1];
         $files = $vars[2];
     }
     //
     // escape each id
     $esc_ids = array();
     foreach ($ids as $id) {
         if ($id_type == 'item_id') {
             $esc_ids[] = intval($id);
         } else {
             if ($id_type == 'ext_id') {
                 $esc_ids[] = $GLOBALS['xoopsDB']->quoteString($id);
             }
         }
     }
     //
     //
     if ($id_type == 'item_id') {
         $criteria = new Criteria('item_id', '(' . implode(', ', $esc_ids) . ')', 'IN');
     } else {
         if ($id_type == 'ext_id') {
             $criteria = new Criteria('doi', '(' . implode(', ', $esc_ids) . ')', 'IN');
         }
     }
     // retrieve each item
     $xoonipsitem_handler =& xoonips_getormcompohandler('xoonips', 'item');
     $items =& $xoonipsitem_handler->getObjects($criteria);
     //
     $ret = array();
     // return array of items
     if ($items) {
         //
         // creat mapping of ext_id or item_id => item object
         $map = array();
         for ($i = 0; $i < count($items); $i++) {
             $basic = $items[$i]->getVar('basic');
             if ($id_type == 'item_id') {
                 $map[$basic->get('item_id')] = $items[$i];
             } else {
                 if ($id_type == 'ext_id') {
                     $map[$basic->get('doi')] = $items[$i];
                 }
             }
         }
         //
//.........这里部分代码省略.........
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:101,代码来源:getsimpleitems.class.php

示例15: execute

 /**
  * execute getFile
  *
  * @param[in]  $vars[0] session ID
  * @param[in]  $vars[1] file ID
  * @param[out] $response->result true:success, false:failed
  * @param[out] $response->error  error information
  * @param[out] $response->success file metadata
  */
 function execute(&$vars, &$response)
 {
     // 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]) > 32) {
         $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1');
     }
     if (!is_int($vars[1]) && !ctype_digit($vars[1])) {
         $error->add(XNPERR_INVALID_PARAM, 'not integer parameter 2');
     }
     //
     if ($error->get(0)) {
         // return if parameter error
         $response->setResult(false);
         return false;
     } else {
         $sessionid = $vars[0];
         $file_id = intval($vars[1]);
     }
     list($result, $uid, $session) = $this->restoreSession($sessionid);
     if (!$result) {
         $response->setResult(false);
         $error->add(XNPERR_INVALID_SESSION);
         return false;
     }
     // file_id -> file, item_id
     $file_handler =& xoonips_getormhandler('xoonips', 'file');
     $file = $file_handler->get($file_id);
     if (!$file) {
         $response->setResult(false);
         $error->add(XNPERR_NOT_FOUND);
         return false;
     }
     $item_id = $file->get('item_id');
     if (empty($item_id)) {
         $response->setResult(false);
         $error->add(XNPERR_NOT_FOUND);
         // maybe belong to other session
         return false;
     }
     // can user access that item?
     $item_handler =& xoonips_getormcompohandler('xoonips', 'item');
     if (!$item_handler->getPerm($item_id, $uid, 'read')) {
         $response->setResult(false);
         $error->add(XNPERR_ACCESS_FORBIDDEN);
         return false;
     }
     // already deleted?
     if ($file->get('is_deleted')) {
         $response->setResult(false);
         $error->add(XNPERR_NOT_FOUND, "already deleted or replaced");
         return false;
     }
     // item_id -> item, itemtype
     $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
     $basic = $item_basic_handler->get($item_id);
     if (!$basic) {
         $response->setResult(false);
         $error->add(XNPERR_SERVER_ERROR, "cannot get item_basic");
         return false;
     }
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     $item_type = $item_type_handler->get($basic->get('item_type_id'));
     if (!$item_type) {
         $response->setResult(false);
         $error->add(XNPERR_SERVER_ERROR, "cannot get itemtype of that item");
         return false;
     }
     // item_type, item_id -> detail
     $detail_item_handler =& xoonips_getormcompohandler($item_type->get('name'), 'item');
     $detail_item = $detail_item_handler->get($item_id);
     if (!$detail_item) {
         $response->setResult(false);
         $error->add(XNPERR_SERVER_ERROR, "cannot get item");
         return false;
     }
     if (!$detail_item_handler->hasDownloadPermission($uid, $file_id)) {
         $response->setResult(false);
         $error->add(XNPERR_ACCESS_FORBIDDEN);
         return false;
     }
     $file_type_handler =& xoonips_getormhandler('xoonips', 'file_type');
     $file_type = $file_type_handler->get($file->get('file_type_id'));
     if ($file_type === false) {
//.........这里部分代码省略.........
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:101,代码来源:getfilemetadata.class.php


注:本文中的xoonips_getormcompohandler函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。