function preAction() { xoonips_allow_post_method(); if (!$GLOBALS['xoopsGTicket']->check(true, 'xoonips_transfer_admin_list_item', false)) { die('ticket error'); } global $xoopsUser; $from_uid = $this->_formdata->getValue('post', 'from_uid', 'i', true); $to_uid = $this->_formdata->getValue('post', 'to_uid', 'i', true); $to_index_id = $this->_formdata->getValue('post', 'to_index_id', 'i', true); $transfer_item_ids = array_merge($this->get_item_ids_to_transfer(), $this->get_child_item_ids_to_transfer()); if (!xoonips_transfer_is_transferrable($from_uid, $to_uid, $transfer_item_ids)) { redirect_header(XOOPS_URL . '/modules/xoonips/admin/maintenance.php?' . 'page=item&action=transfer_admin_initialize', 3, _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR); } if (xoonips_transfer_is_private_item_number_exceeds_if_transfer($to_uid, $transfer_item_ids)) { redirect_header(XOOPS_URL . '/modules/xoonips/admin/maintenance.php?' . 'page=item&action=transfer_admin_initialize', 3, _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_ITEM_NUMBER_EXCEEDS); } if (xoonips_transfer_is_private_item_storage_exceeds_if_transfer($to_uid, $transfer_item_ids)) { redirect_header(XOOPS_URL . '/modules/xoonips/admin/maintenance.php?' . 'page=item&action=transfer_admin_initialize', 3, _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_ITEM_STORAGE_EXCEEDS); } if (!$this->is_equals_group_ids(xoonips_transfer_get_group_ids_of_items($transfer_item_ids), $this->_formdata->getValueArray('post', 'group_ids_to_subscribe', 'i', false))) { redirect_header(XOOPS_URL . '/modules/xoonips/admin/maintenance.php' . '?page=item', 3, _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_BAD_SUBSCRIBE_GROUP); } $this->_params[] = $transfer_item_ids; $this->_params[] = $from_uid; $this->_params[] = $to_uid; $this->_params[] = $to_index_id; $this->_params[] = xoonips_transfer_get_group_ids_of_items($transfer_item_ids); }
function doAction() { global $xoopsUser; $this->_view_params['from_uid'] = $this->_formdata->getValue('post', 'from_uid', 'i', true); $this->_view_params['from_index_id'] = $this->_formdata->getValue('post', 'from_index_id', 'i', true); $this->_view_params['to_uid'] = $this->_formdata->getValue('post', 'to_uid', 'i', true); $this->_view_params['to_index_id'] = $this->_formdata->getValue('post', 'to_index_id', 'i', true); $error_message = false; if (!$this->is_valid_uid($this->_view_params['from_uid'])) { $error_message = _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_NO_FROM_UID_SELECTED; } else { if (!$this->is_valid_uid($this->_view_params['to_uid'])) { $error_message = _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_NO_TO_UID_SELECTED; } else { if (!$this->is_private_index_id_of($this->_view_params['from_index_id'], $this->_view_params['from_uid'])) { $error_message = _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_NO_FROM_INDEX_ID_SELECTED; } else { if (!$this->is_private_index_id_of($this->_view_params['to_index_id'], $this->_view_params['to_uid'])) { $error_message = _AM_XOONIPS_MAINTENANCE_TRANSFER_ITEM_ERROR_NO_TO_INDEX_ID_SELECTED; } } } } if ($error_message) { redirect_header(XOOPS_URL . '/modules/xoonips/admin/maintenance.php?page=item', 3, $error_message); } $this->_view_params['item_ids_to_transfer'] = $this->sort_item_ids_by_title($this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); $this->_view_params['child_items'] = $this->get_child_items($this->_formdata->getValue('post', 'from_uid', 'i', true), $this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); $this->_view_params['limit_check_result'] = $this->get_limit_check_result($this->_formdata->getValue('post', 'to_uid', 'i', true), $this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); $this->_view_params['group_ids_to_subscribe'] = xoonips_transfer_get_group_ids_of_items($this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); $this->_view_params['item_ids_transfer_disabled'] = $this->get_transfer_disabled_item_ids($this->_formdata->getValue('post', 'from_uid', 'i', true), $this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); $this->_view_params['can_not_transfer_items'] = $this->get_untransferrable_reasons_and_items($this->_formdata->getValue('post', 'from_uid', 'i', true), $this->_formdata->getValueArray('post', 'checked_item_ids', 'i', false)); }
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; }
/** * 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; }