function get_xoonips_item_template_vars() { $basic =& $this->_params['item']->getVar('basic'); $result = array('basic' => array('item_id' => $basic->get('item_id'), 'description' => $basic->getVar('description', 's'), 'doi' => $basic->get('doi'), 'creation_date' => $basic->get('creation_date'), 'last_update_date' => $basic->get('last_update_date'), 'publication_year' => $basic->get('publication_year'), 'publication_month' => $basic->get('publication_month'), 'publication_mday' => $basic->get('publication_mday'), 'lang' => $this->get_lang_label()), 'title' => array(), 'keyword' => array(), 'changelog' => array(), 'index_item_link' => array(), 'related_tos' => array()); foreach ($this->_params['item']->getVar('titles') as $title) { $result['title'][] = array('title' => $title->getVar('title', 's')); } foreach ($this->_params['item']->getVar('keywords') as $keyword) { $result['keyword'][] = array('keyword' => $keyword->getVar('keyword', 's')); } foreach ($this->_params['item']->getVar('changelogs') as $changelog) { $result['changelog'][] = array('log_date' => $changelog->get('log_date'), 'log' => $changelog->getVar('log', 's')); } foreach ($this->_params['item']->getVar('indexes') as $link) { $result['index_item_link'][] = array('path' => $this->get_index_path_by_index_id($link->get('index_id')), 's'); } $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); $basic_handler =& xoonips_getormhandler('xoonips', 'item_basic'); foreach ($this->_params['item']->getVar('related_tos') as $related_to) { $related_basic =& $basic_handler->get($related_to->get('item_id')); $related_item_type =& $item_type_handler->get($related_basic->get('item_type_id')); $item_compo_handler =& xoonips_getormcompohandler($related_item_type->get('name'), 'item'); $result['related_tos'][] = array('filename' => 'db:' . $item_compo_handler->getTemplateFileName(XOONIPS_TEMPLATE_TYPE_TRANSFER_ITEM_LIST), 'var' => $item_compo_handler->getTemplateVar(XOONIPS_TEMPLATE_TYPE_TRANSFER_ITEM_LIST, $related_basic->get('item_id'))); } return $result; }
function postAction() { global $xoopsUser; if (!$this->_response->getResult()) { foreach ($this->_collection->getItems() as $item) { foreach ($item->getErrorCodes() as $code) { if ($code != E_XOONIPS_UPDATE_CERTIFY_REQUEST_LOCKED) { continue; } $titles =& $item->getVar('titles'); $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock'); redirect_header(XOOPS_URL . '/modules/xoonips/import.php?action=default', 5, sprintf(_MD_XOONIPS_ERROR_CANNOT_OVERWRITE_LOCKED_ITEM, $titles[0]->get('title'), xoonips_get_lock_type_string($item_lock_handler->getLockType($item->getUpdateItemId())))); } } } $this->_finish_time = time(); $success =& $this->_response->getSuccess(); $this->_view_params['result'] = $this->_response->getResult(); $this->_view_params['import_items'] = $success['import_items']; $this->_view_params['begin_time'] = $this->_begin_time; $this->_view_params['finish_time'] = $this->_finish_time; $this->_view_params['filename'] = $this->_collection->getImportFileName(); $this->_view_params['uname'] = $xoopsUser->getVar('uname'); $this->_view_params['errors'] = array(); foreach ($success['import_items'] as $item) { foreach (array_unique($item->getErrorCodes()) as $code) { $this->_view_params['errors'][] = array('code' => $code, 'extra' => $item->getPseudoId()); } } }
/** * * @brief unlock item * * @param[in] $item_id item id */ function xoonips_admin_maintenance_item_unlock_item($item_id) { // unlock item $index_handler =& xoonips_getormhandler('xoonips', 'index'); $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock'); $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic'); $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link'); $event_log_handler =& xoonips_getormhandler('xoonips', 'event_log'); if ($item_lock_handler->isLocked($item_id)) { $lock_type = $item_lock_handler->getLockType($item_id); if ($lock_type == XOONIPS_LOCK_TYPE_CERTIFY_REQUEST) { $index_item_links =& $index_item_link_handler->getObjects(new Criteria('item_id', $item_id)); foreach ($index_item_links as $index_item_link) { if ($index_item_link->get('certify_state') == CERTIFY_REQUIRED) { $index_id = $index_item_link->get('index_id'); $index = $index_handler->get($index_id); if ($index->getVar('open_level', 'n') == OL_PUBLIC || $index->getVar('open_level', 'n') == OL_GROUP_ONLY) { $item_basic_handler->unlockItemAndIndexes($item_id, $index_id); $event_log_handler->recordRejectItemEvent($item_id, $index_id); $index_item_link_handler->delete($index_item_link); xoonips_notification_item_rejected($item_id, $index_id); } } } } else { // TODO: unlock if transfer request } } }
/** * return XooNIpsXmlRpcItemView corresponding to $logic and $item(itemtype) * * @param string $logic logic name * @param XooNIpsItemCompo item object * @retval XooNIpsXmlRpcItemViewElement corresponding to $logic * @retval false unknown logic or unknown item */ function &create($logic, &$item) { static $falseVar = false; $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); $basic =& $item->getVar('basic'); $itemtype =& $item_type_handler->get($basic->get('item_type_id')); if (!$itemtype) { return $falseVar; } // $name = $itemtype->get('name'); // $include_file = XOOPS_ROOT_PATH . "/modules/{$name}/class/xmlrpc/view/" . strtolower($logic) . ".class.php"; if (file_exists($include_file)) { include_once $include_file; } else { return $falseVar; } // if (strncmp('xnp', $name, 3) == 0) { $tok = substr($name, 3); $class = 'XNP' . ucfirst($tok) . 'XmlRpcItemView' . ucfirst($logic); $ret = new $class($item); return $ret; } return $falseVar; }
function item_get_userlist($upage) { global $xoopsDB; global $xoopsUser; // myuid $myuid = $xoopsUser->getVar('uid', 'n'); $xusers_handler =& xoonips_getormhandler('xoonips', 'users'); $tables['users'] = $xoopsDB->prefix('users'); $tables['xusers'] = $xoopsDB->prefix('xoonips_users'); $join_criteria = new XooNIpsJoinCriteria('users', 'uid', 'uid'); $criteria = new Criteria($tables['users'] . '.level', 0, '>'); $criteria->setSort($tables['users'] . '.uname'); $fields = array(); $fields[] = $tables['xusers'] . '.uid'; $fields[] = $tables['users'] . '.uname'; $xusers_objs =& $xusers_handler->getObjects($criteria, false, implode(',', $fields), false, $join_criteria); $textutil =& xoonips_getutility('text'); $users = array(); $users[] = array('uid' => 0, 'uname' => $textutil->html_special_chars(_AM_XOONIPS_MAINTENANCE_ITEM_LABEL_ALLUSERS), 'selected' => 'selected="selected"'); foreach ($xusers_objs as $xusers_obj) { $uid = $xusers_obj->getVar('uid', 'e'); $uname = $textutil->html_special_chars($xusers_obj->getExtraVar('uname')); $users[] = array('uid' => $uid, 'uname' => $uname, 'selected' => ''); } return $users; }
/** * transfer request * * @param[in] $vars[0] array of item_id * @param[in] $vars[1] uid of old item owner * @param[in] $vars[2] uid of new item owner * @param[out] XooNIpsError error * @return bool true if succeeded */ function execute_without_transaction(&$vars, &$error) { $item_ids = $vars[0]; $from_uid = $vars[1]; $to_uid = $vars[2]; if (false == xoonips_transfer_is_transferrable($from_uid, $to_uid, $item_ids)) { $error->add(XNPERR_SERVER_ERROR, "not transferrable"); return false; } foreach ($item_ids as $item_id) { $transfer_request_handler =& xoonips_getormhandler('xoonips', 'transfer_request'); $transfer_request = $transfer_request_handler->create(); $transfer_request->set('item_id', $item_id); $transfer_request->set('to_uid', $to_uid); if (false == $transfer_request_handler->insert($transfer_request)) { $error->add(XNPERR_SERVER_ERROR, "cannot insert tranfer_request"); return false; } $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock'); if (false == $item_lock_handler->lock($item_id)) { $error->add(XNPERR_SERVER_ERROR, "cannot lock item"); return false; } $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log'); if (false == $eventlog_handler->recordRequestTransferItemEvent($item_id, $to_uid)) { $error->add(XNPERR_SERVER_ERROR, "cannot insert evnet log"); return false; } } return true; }
function userCheck($uname, $email, $pass, $vpass) { global $myxoopsConfigUser; $xoopsDB =& Database::getInstance(); $stop = ''; if (!checkEmail($email)) { $stop .= _US_INVALIDMAIL . '<br />'; } foreach ($myxoopsConfigUser['bad_emails'] as $be) { if (!empty($be) && preg_match('/' . $be . '/i', $email)) { $stop .= _US_INVALIDMAIL . '<br />'; break; } } if (strrpos($email, ' ') > 0) { $stop .= _US_EMAILNOSPACES . '<br />'; } $uname = xoops_trim($uname); $restrictions = array(0 => '/[^a-zA-Z0-9\\_\\-]/', 1 => '/[^a-zA-Z0-9\\_\\-\\<\\>\\,\\.\\$\\%\\#\\@\\!\\\'\\"]/', 2 => '/[\\000-\\040]/'); $restriction = $restrictions[$myxoopsConfigUser['uname_test_level']]; if (empty($uname) || preg_match($restriction, $uname)) { $stop .= _US_INVALIDNICKNAME . '<br />'; } if (strlen($uname) > $myxoopsConfigUser['maxuname']) { $stop .= sprintf(_US_NICKNAMETOOLONG, $myxoopsConfigUser['maxuname']) . '<br />'; } if (strlen($uname) < $myxoopsConfigUser['minuname']) { $stop .= sprintf(_US_NICKNAMETOOSHORT, $myxoopsConfigUser['minuname']) . '<br />'; } foreach ($myxoopsConfigUser['bad_unames'] as $bu) { if (!empty($bu) && preg_match('/' . $bu . '/i', $uname)) { $stop .= _US_NAMERESERVED . '<br />'; break; } } if (strrpos($uname, ' ') > 0) { $stop .= _US_NICKNAMENOSPACES . '<br />'; } $u_handler =& xoonips_getormhandler('xoonips', 'xoops_users'); $criteria = new Criteria('uname', addslashes($uname)); if ($u_handler->getCount($criteria) > 0) { $stop .= _US_NICKNAMETAKEN . "<br />"; } if ($email) { $criteria = new Criteria('email', addslashes($email)); if ($u_handler->getCount($criteria) > 0) { $stop .= _US_EMAILTAKEN . "<br />"; } } if (!isset($pass) || $pass == '' || !isset($vpass) || $vpass == '') { $stop .= _US_ENTERPWD . '<br />'; } if (isset($pass) && $pass != $vpass) { $stop .= _US_PASSNOTSAME . '<br />'; } elseif ($pass != '' && strlen($pass) < $myxoopsConfigUser['minpass']) { $stop .= sprintf(_US_PWDTOOSHORT, $myxoopsConfigUser['minpass']) . '<br />'; } return $stop; }
/** * constructor * * @access public */ function XooNIpsUtilityFile() { $this->setSingleton(); $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $this->magic_file_path = $xconfig_handler->getValue('magic_file_path'); // append additional mimetype mapping $this->mimetype_map['application/zip'] = $this->mimetype_map['application/x-zip']; }
/** * constractor * * @access public */ function XooNIpsFileHandler() { $this->xf_handler =& xoonips_getormhandler('xoonips', 'file'); $this->xst_handler =& xoonips_getormhandler('xoonips', 'search_text'); $xc_handler =& xoonips_getormhandler('xoonips', 'config'); $this->upload_dir = $xc_handler->getValue('upload_dir'); if (strlen($this->upload_dir) > 1 && substr($this->upload_dir, -1) == '/') { $this->upload_dir = substr($this->upload_dir, 0, strlen($this->upload_dir) - 1); } }
function _getItemTitle($item_id, $fmt) { $it_handler =& xoonips_getormhandler('xoonips', 'title'); $title = ''; $tobjs = $it_handler->getTitles($item_id); foreach ($tobjs as $tobj) { $title .= $tobj->get('title', $fmt); } return $title; }
/** * get creator objects of this item * @return XNPConferenceOrmCreator[] */ function getCreators() { $handler =& xoonips_getormhandler('xnpmodel', 'creator'); $criteria = new Criteria('model_id', $this->get('model_id')); $criteria->setSort('creator_order'); $result =& $handler->getObjects($criteria); if ($result) { return $result; } return array(); }
/** * remove all deleted(is_deleted=1) files from file system */ function _remove_files() { $handler =& xoonips_getormhandler('xoonips', 'file'); $criteria = new Criteria('is_deleted', 1); $delete_files =& $handler->getObjects($criteria); if ($delete_files) { foreach ($delete_files as $file) { $handler->deleteFile($file); } } }
/** * get author objects of this item * @return XNPPaperOrmAuthor[] */ function getAuthors() { $handler =& xoonips_getormhandler('xnppaper', 'author'); $criteria = new Criteria('paper_id', $this->get('paper_id')); $criteria->setSort('author_order'); $result =& $handler->getObjects($criteria); if ($result) { return $result; } return array(); }
function _get_result_log() { $log = ''; $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); foreach ($this->_params['import_items'] as $item) { foreach (array_unique($item->getErrorCodes()) as $code) { $log .= "\nerror " . $code . " " . $item->getVar('pseudo_id'); } } return $log; }
/** * get developer objects of this item * @return XnpstimulusOrmDeveloper[] */ function getDevelopers() { $handler =& xoonips_getormhandler('xnpstimulus', 'developer'); $criteria = new Criteria('stimulus_id', $this->get('stimulus_id')); $criteria->setSort('developer_order'); $result =& $handler->getObjects($criteria); if ($result) { return $result; } return array(); }
/** * execute getItemtypes * * @param[in] $vars[0] session ID * @param[out] $response->result true:success, false:failed * @param[out] $response->error error information * @param[out] $response->success array of item type structure */ function execute(&$vars, &$response) { // parameter check $error =& $response->getError(); if (count($vars) > 1) { $error->add(XNPERR_EXTRA_PARAM); } if (count($vars) < 1) { $error->add(XNPERR_MISSING_PARAM); } // if (isset($vars[0]) && strlen($vars[0]) > 32) { $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1'); } // if ($error->get(0)) { // return if parameter error $response->setResult(false); return; } else { $response->setResult(false); $sessionid = $vars[0]; } list($result, $uid, $session) = $this->restoreSession($sessionid); if (!$result) { $response->setResult(false); $error->add(XNPERR_INVALID_SESSION); return false; } // $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); $item_types =& $item_type_handler->getObjects(); if (!$item_types) { $response->setResult(false); $error->add(XNPERR_SERVER_ERROR, "cannot get itemtypes"); return false; } $result = array(); foreach ($item_types as $item_type) { $item_type_name = $item_type->get('name'); $detail_item_type_handler =& xoonips_getormhandler($item_type_name, 'item_type'); if (!$detail_item_type_handler) { continue; } $detail_item_type = $detail_item_type_handler->get($item_type->get('item_type_id')); if (!$detail_item_type) { continue; } $result[] = $detail_item_type; } $response->setSuccess($result); $response->setResult(true); return true; }
/** * get experimenter objects of this item * @return XNPDataOrmExperimenter[] */ function getExperimenters() { $handler =& xoonips_getormhandler('xnpdata', 'experimenter'); $criteria = new Criteria('data_id', $this->get('data_id')); $criteria->setSort('experimenter_order'); $result =& $handler->getObjects($criteria); if ($result) { return $result; } return array(); }
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; }
/** * * get array of item id to transfer to user($uid) * * @param integer $uid transferee's uid * @return array integer array of item id to be transfered */ function get_transfer_request_item_ids($uid) { $transfer_handler =& xoonips_getormhandler('xoonips', 'transfer_request'); $transfers =& $transfer_handler->getObjects(new Criteria('to_uid', $uid)); if (false === $transfers) { return array(); } $result = array(); foreach ($transfers as $t) { $result[] = $t->get('item_id'); } return $result; }
/** * 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; }
function b_xoonips_userlist_show() { global $xoopsDB; $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid', 'n') : UID_GUEST; // hide block if user is invalid xoonips user $xsession_handler =& xoonips_getormhandler('xoonips', 'session'); if (!$xsession_handler->validateUser($uid, false)) { return false; } $tables['users'] = $xoopsDB->prefix('users'); $tables['xusers'] = $xoopsDB->prefix('xoonips_users'); $user_handler =& xoonips_getormhandler('xoonips', 'xoops_users'); $positions_handler =& xoonips_getormhandler('xoonips', 'positions'); // get visible positions $criteria = new Criteria('posi_order', 0, '>'); $criteria->setSort('posi_order'); $criteria->setOrder('ASC'); $position_objs =& $positions_handler->getObjects($criteria); $positions = array(); foreach ($position_objs as $position_obj) { $posi_id = $position_obj->getVar('posi_id', 'n'); $posi_title = $position_obj->getVar('posi_title', 's'); // get visible users, who set position to $posi_id $join_criteria = new XooNIpsJoinCriteria('xoonips_users', 'uid', 'uid'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria($tables['users'] . '.level', '0', '>')); $criteria->add(new Criteria($tables['xusers'] . '.activate', '1')); $criteria->add(new Criteria($tables['xusers'] . '.posi', $posi_id)); $sort = array($tables['users'] . '.uid', $tables['xusers'] . '.user_order'); $criteria->setSort($sort); $criteria->setOrder('ASC'); $fields = array($tables['users'] . '.uid', $tables['users'] . '.uname', $tables['users'] . '.name'); $user_objs =& $user_handler->getObjects($criteria, false, implode(',', $fields), false, $join_criteria); if (!empty($user_objs)) { $position['title'] = $posi_title; $position['users'] = array(); foreach ($user_objs as $user_obj) { $position['users'][] = array('uid' => $user_obj->getVar('uid', 'e'), 'name' => $user_obj->getVar('name', 's'), 'uname' => $user_obj->getVar('uname', 's')); } $positions[] = $position; } } if (empty($positions)) { return false; // visible users not found } // assign block template variables $block = array(); $block['positions'] = $positions; return $block; }
/** * constractor * * @access public */ function XooNIpsRankingHandler() { // set base name of ranking tables $this->basenames = array('viewed_item', 'downloaded_item', 'contributing_user', 'searched_keyword', 'active_group', 'new_item', 'new_group'); // load object handlers foreach ($this->basenames as $basename) { $name = $basename; $this->handlers[$name] =& xoonips_getormhandler('xoonips', 'ranking_' . $name); $name = 'sum_' . $basename; $this->handlers[$name] =& xoonips_getormhandler('xoonips', 'ranking_' . $name); } $this->handlers['event_log'] =& xoonips_getormhandler('xoonips', 'event_log'); $this->handlers['config'] =& xoonips_getormhandler('xoonips', 'config'); }
function XooNIpsAdminFileHandler() { parent::XooNIpsFileHandler(); $xc_handler =& xoonips_getormhandler('xoonips', 'config'); $this->_load_file_search_plugins(); $xft_handler =& xoonips_getormhandler('xoonips', 'file_type'); // get preview file type id $criteria = new Criteria('name', 'preview'); $xft_objs =& $xft_handler->getObjects($criteria); if (count($xft_objs) != 1) { die('Fatal Error : Preview File Type not found'); } $this->preview_ftid = $xft_objs[0]->get('file_type_id'); }
function getUserPosiList() { $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; }
function &get_harvester_repositories() { $repositories_handler =& xoonips_getormhandler('xoonips', 'oaipmh_repositories'); $urls =& $repositories_handler->getRepositories('e'); $ret = ''; $is_first = true; foreach ($urls as $url) { if ($is_first) { $ret = $url['URL']; $is_first = false; } else { $ret .= "\n" . $url['URL']; } } return $ret; }
function doAction() { global $xoopsUser; $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); if ($item_type_handler->getCount() <= 1) { redirect_header(XOOPS_URL . '/modules/xoonips/', 3, _MD_XOONIPS_TRANSFER_USER_REQUEST_ERROR_NO_ITEMTYPE); } $this->_view_params['to_uid'] = $this->_formdata->getValue('post', 'to_uid', 'i', false); $item_ids_to_transfer = $this->_formdata->getValueArray('post', 'item_ids_to_transfer', 'i', false); $this->_view_params['items_to_transfer'] = xoonips_transfer_get_transferrable_item_information($xoopsUser->getVar('uid'), $item_ids_to_transfer); $this->_view_params['to_user_options'] = xoonips_transfer_get_users_for_dropdown($xoopsUser->getVar('uid')); if (empty($this->_view_params['to_user_options'])) { redirect_header(XOOPS_URL . '/modules/xoonips/', 3, _MD_XOONIPS_TRANSFER_USER_REQUEST_ERROR_NO_TRANSFEREE_USER); } $this->_view_params['transfer_enable'] = $this->is_all_transferrable_items($xoopsUser->getVar('uid'), $item_ids_to_transfer); }
function b_xoonips_itemtypes_show() { global $xoopsUser; // hide block if user is guest and public index viewing policy is 'platform' if (!is_object($xoopsUser)) { $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $target_user = $xconfig_handler->getValue('public_item_target_user'); if ($target_user != 'all') { // 'platform' return false; } } $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid', 'n') : UID_GUEST; // hide block if user is invalid xoonips user $xsession_handler =& xoonips_getormhandler('xoonips', 'session'); if (!$xsession_handler->validateUser($uid, false)) { return false; } require_once XOOPS_ROOT_PATH . '/modules/xoonips/include/lib.php'; // get installed itemtypes $block = array(); $block['explain'] = array(); $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type'); $item_type_objs =& $item_type_handler->getObjectsSortByWeight(); foreach ($item_type_objs as $item_type_obj) { $name = $item_type_obj->get('name'); $file = XOOPS_ROOT_PATH . '/modules/' . $item_type_obj->get('viewphp'); if (file_exists($file)) { require_once $file; } $fname = $name . 'GetTopBlock'; if (function_exists($fname)) { // call xxxGetTopBlock function in view.php $itemtype = $item_type_obj->getVarArray('s'); $html = $fname($itemtype); if (!empty($html)) { $block['explain'][] = $html; } } } if (empty($block['explain'])) { // visible itemtype not found return false; } return $block; }
function deleteById($id) { // check existing id $posi_criteria = new Criteria('posi_id', $id); if ($this->getCount($posi_criteria) == 0) { return false; } // if deleting position has used in existing users, // change position to neutral. $xusers_handler =& xoonips_getormhandler('xoonips', 'users'); $xusers_criteria = new Criteria('posi', $id); $xusers_objs =& $xusers_handler->getObjects($xusers_criteria); foreach ($xusers_objs as $xusers_obj) { $xusers_obj->set('posi', 0); $xusers_handler->insert($xusers_obj); } // delete return $this->deleteAll($posi_criteria); }
function user_reactivate($uid) { global $xoonips_admin; // get user information $u_handler =& xoonips_getormhandler('xoonips', 'xoops_users'); $xu_handler =& xoonips_getormhandler('xoonips', 'users'); $u_obj =& $u_handler->get($uid); $xu_obj =& $xu_handler->get($uid); if (!is_object($u_obj) || !is_object($xu_obj)) { redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MSG_ILLACCESS); exit; } // update db values $u_obj->set('level', 1); if (!$u_handler->insert($u_obj)) { redirect_header($xoonips_admin['mypage_url'], 1, _AM_XOONIPS_MSG_UNEXPECTED_ERROR); exit; } }
/** * execute logout * * @param[in] $vars[0] sessionid * @param[out] $response->result true:success, false:failed * @param[out] $response->error error information * @return true logged out * @return false if error */ function execute(&$vars, &$response) { // parameter check $error =& $response->getError(); if (count($vars) > 1) { $error->add(XNPERR_EXTRA_PARAM); } if (count($vars) < 1) { $error->add(XNPERR_MISSING_PARAM); } // if (isset($vars[0]) && strlen($vars[0]) > 32) { $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1'); } // if ($error->get(0)) { // return if parameter error $response->setResult(false); return; } else { $sessionid = $vars[0]; } list($result, $uid, $session) = $this->restoreSession($sessionid); if (!$result) { $response->setResult(false); $error->add(XNPERR_INVALID_SESSION); return false; } if ($uid != UID_GUEST) { // insert logout event $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log'); $eventlog_handler->recordLogoutEvent($uid); // delete XooNIps session $session_handler =& xoonips_getormhandler('xoonips', 'session'); $session_handler->delete($session); } // delete XOOPS session and forbid future session.write() $_SESSION = array(); session_destroy(); $response->setResult(true); return true; }