0

私はどこでも、IPBフォーラム、グーグル、どこでも検索しました。

IPB / IP.Nexusフォーラムにはドキュメントがないため、ドキュメントが見つかりませんでした。Zendで暗号化されています。

私がやろうとしていたのは、渡された関数内のプライベートオブジェクト配列からアイテム「数量」を取得することでした。

これはphpファイルです。

<?php 
class custom_actions_ibeconomy
{
        /**
         * Item Purchased (run before onPurchaseGenerated)
         *
         * @param       array   The member purchasing
         * @param       array   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice Invoice Model
         * @return      void
         */
        public function onPaid( $member, $package, $invoice )
        {

        }

        /**
         * Purchase record generated (run after onPaid)
         *
         * @param       array   The member purchasing
         * @param       array   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice Invoice Model
         * @param       array   Row from nexus_purchases [since Nexus 1.5]
         * @return      void
         */
        public function onPurchaseGenerated( $member, $package, $invoice, $purchase )
        {
        #What package have we purchased here?
        switch($package['p_id']) {
                        case 3: // 500 HLcoins
                                $value = 500;
                                break;
                        case 4: // 1000 HLcoins
                                $value = 1000;
                                break;

                        default: //Neither? 0 HLcoins.
                                $value = 0;
                                break;;
                }       
        #Find current members HLcoins?           
        $amount = $this->$invoice->quantity * $value;

        #execute points
        ipsRegistry::DB()->update( 'pfields_content', 'eco_points=eco_points+'.$amount, 'member_id=' . $member['member_id'] , true, true );   
        }

        /**
         * Purchase Renewed, but was still active anyway
         *
         * @param       array   The member renewing
         * @param       array   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice Invoice Model
         * @param       array   The row from nexus_purchases [since Nexus 1.5]
         * @return      void
         */
        public function onRenew( $member, $package, $invoice, $purchase )
        {

        }        

        /**
         * Purchase Renewed after had expired
         *
         * @param       array                   The member renewing
         * @param       array                   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice|null    Invoice Model [May not be set if manually reactivating]
         * @param       array                   The row from nexus_purchases [since Nexus 1.5]
         * @return      void
         */
        public function onReactivate( $member, $package, $invoice, $purchase )
        {

        }

        /**
         * Purchase Expired
         *
         * @param       array                   The member the purchase belongs to
         * @param       array                   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice|null    Will usually be null. If the purchase is expiring because the invoice which previously renewed it is now being marked unpaid, the invoice object will be passed.
         * @param       array                   The row from nexus_purchases [since Nexus 1.5]
         * @return      void
         */
        public function onExpire( $member, $package, $invoice, $purchase )
        {

        }

        /**
         * Purchase Cancelled or Deleted
         *
         * @param       array                   The member the purchase belongs to
         * @param       array                   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       invoice|null    Will usually be null. If the purchase is being cancelled because the invoice which was used to purchase it it is now being marked unpaid, the invoice object will be passed.
         * @param       array                   The row from nexus_purchases [since Nexus 1.5]
         * @return      void
         */
        public function onCancel( $member, $package, $invoice, $purchase )
        {

        }

        /**
         * Purchase is transferred to another member
         *
         * @param       array           Old owner
         * @param       array           Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       array           The row from nexus_purchases
         * @param       customer        New owner
         * @return      void
         */
        public function onTransfer( $oldOwner, $package, $purchase, $newOwner )
        {

        }

        /**
         * Purchase is upgraded/downgraded
         *
         * @param       array           The member the purchase belongs to
         * @param       array           Old package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       array           The row from nexus_purchases
         * @param       package         New package object
         * @return      void
         */
        public function onchange( $member, $oldPackage, $purchase, $newPackage )
        {

        }

        /**
         * Purchases' parent purchase is changed
         *
         * @param       array                   The member the purchase belongs to
         * @param       array                   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
         * @param       array                   The row from nexus_purchases
         * @param       array|null        The previous parent (may be null if had no parent previously)
         * @param       array|null        The new parent (may be null if was previously associated and now not)
         * @return      void
         */
        public function onAssociate( $member, $package, $purchase, $oldParent, $newParent )
        {

        }

}
?>

ただし、何も返しません。

配列を印刷してプライベートとしてリストしましたが、関数内にあるので取得できるはずです。方法がわからないので、あなたの助けが必要です。

invoice Object
(
    [data:private] => Array
    (
    [i_status] => pend
    [i_title] => 500 HLCoins , 500 HLCoins x8
    [i_member] => 1
    [i_items] => Array
        (
            [0] => Array
            (
    [act] => new
    [app] => nexus
    [type] => product
    [cost] => 0
    [tax] => 0
    [renew_term] => 0
    [renew_units] =>
    [renew_cost] => 0
    [quantity] => 1
    [physical] =>
    [shipping] => Array
        (
            )
        [weight] => 0
        [itemName] => 500 HLCoins
        [itemID] => 3
        [cfields] => Array
(
)
[extra] =>
[opt_id] => 0
[associated] =>
[assocBought] =>
[groupRenewals] => 0
[methods] => Array
(
)
[k] => 0
[_tax] => 0
)
[1] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 8
[physical] =>
[shipping] => Array
(
)
[weight] => 0
[itemName] => 500 HLCoins
[itemID] => 3
[cfields] => Array
(
)
[opt_id] => 0
[groupRenewals] => 0
[methods] => Array
(
)
[_tax] => 0
)
)
[i_total] => 0
[i_date] => 1347217384
[i_return_uri] =>
[i_paid] => 0
[i_status_extra] => a:1:{s:4:"type";s:4:"zero";}
[i_discount] => 0
[i_temp] =>
[i_ordersteps] => 0
[i_noreminder] => 1
[i_renewal_ids] => Array
(
)
[i_po] =>
[i_notes] =>
[i_shipaddress] =>
[i_id] => 229
)
[customer:private] => customer Object
(
[data] => Array
(
[member_id] => 1
[name] => Administrator
[member_group_id] => 4
[email] => honlegends@gmail.com
[joined] => 1346519183
[ip_address] => 108.251.14.208
[posts] => 19
[title] => Administrator
[allow_admin_mails] => 0
[time_offset] => -8
[skin] => 5
[warn_level] => 0
[warn_lastwarn] => 0
[language] => 1
[last_post] => 1347048210
[restrict_post] =>
[view_sigs] => 1
[view_img] => 1
[bday_day] => 0
[bday_month] => 0
[bday_year] => 0
[msg_count_new] => 0
[msg_count_total] => 1
[msg_count_reset] => 0
[msg_show_notification] => 1
[misc] =>
[last_visit] => 1347174074
[last_activity] => 1347217377
[dst_in_use] => 1
[coppa_user] => 0
[mod_posts] =>
[auto_track] =>
[temp_ban] => 0
[login_anonymous] => 0&1
[ignored_users] => a:0:{}
[mgroup_others] => 7
[org_perm_id] => ,,,,,8,
[member_login_key] => 341ebfc939f1c5acb5dbe8b9a6819b21
[member_login_key_expire] => 1347820877
[has_blog] =>
[blogs_recache] =>
[has_gallery] => 0
[members_auto_dst] => 1
[members_display_name] => PAPA_bert
[members_seo_name] => papa-bert
[members_created_remote] => 0
[members_cache] => a:7:{s:11:"report_temp";a:0:{}s:19:"report_last_updated";i:1347139096;s:10:"report_num";s:1:"0";s:13:"msgAlertReset";i:1346520781;s:13:"notifications";a:19:{s:13:"report_center";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:11:"new_comment";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:11:"post_quoted";a:1:{s:8:"selected";a:0:{}}s:9:"new_likes";a:1:{s:8:"selected";a:1:{i:0;s:6:"inline";}}s:15:"followed_topics";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:15:"followed_forums";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:22:"followed_topics_digest";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:22:"followed_forums_digest";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:15:"profile_comment";a:1:{s:8:"selected";a:1:{i:0;s:6:"inline";}}s:14:"friend_request";a:1:{s:8:"selected";a:1:{i:0;s:6:"inline";}}s:22:"friend_request_approve";a:1:{s:8:"selected";a:1:{i:0;s:6:"inline";}}s:19:"new_private_message";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:21:"reply_private_message";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:22:"invite_private_message";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:17:"reply_your_status";a:1:{s:8:"selected";a:0:{}}s:16:"reply_any_status";a:1:{s:8:"selected";a:0:{}}s:20:"friend_status_update";a:1:{s:8:"selected";a:0:{}}s:7:"warning";a:1:{s:8:"selected";a:1:{i:0;s:5:"email";}}s:12:"warning_mods";a:1:{s:8:"selected";a:1:{i:0;s:6:"inline";}}}s:23:"show_notification_popup";i:0;s:7:"friends";a:1:{i:11;s:1:"1";}}
[members_disable_pm] => 0
[members_l_display_name] => papa_bert
[members_l_username] => administrator
[failed_logins] =>
[failed_login_count] => 0
[members_profile_views] => 575
[members_pass_hash] => cf407e695cc8d14e0a7079c8e0e1f4b4
[members_pass_salt] => ]s:%5
[member_banned] => 0
[member_uploader] => flash
[members_bitoptions] => 0
[fb_uid] => 0
[fb_emailhash] =>
[fb_lastsync] => 0
[members_day_posts] => 0,0
[live_id] =>
[twitter_id] =>
[twitter_token] =>
[twitter_secret] =>
[notification_cnt] => 0
[tc_lastsync] => 0
[fb_session] =>
[fb_token] =>
[ips_mobile_token] =>
[unacknowledged_warnings] =>
[feedb_percent] => -1
[feedb_pos] => 0
[feedb_neg] => 0
[feedb_neu] => 0
[sospromote_vip] => 0
[sospromote_vip_eterno] => 0
[sospromote_vip_g_origem] => 0
                    [sospromote_vip_dias] => 0
                    [sospromote_vip_secondary] => 0
                    [sospromote_vip_removesecondary] => 0
                    [sub_end] => 0
                    [subs_pkg_chosen] => 0
                    [cm_credits] => 0
                    [cm_reg] => 0
                    [referred_by] => 0
                    [cm_no_sev] => 0
                    [cim_profile_id] => 
                    [cim_payment_id] => 0
                    [cim_method] => 0
                    [cm_return_group] => 0
                    [my_member_id] => 1
                    [pp_member_id] => 1
                    [pp_last_visitors] => a:2:{i:1346978590;i:7;i:1346536186;i:2;}
                    [pp_rating_hits] => 0
                    [pp_rating_value] => 0
                    [pp_rating_real] => 0
                    [pp_main_photo] => http://www.honlegends.com/community/uploads/profile/photo-1.jpg?_r=1347002709
                    [pp_main_width] => 170
                    [pp_main_height] => 125
                    [pp_thumb_photo] => http://www.honlegends.com/community/uploads/profile/photo-thumb-1.jpg?_r=1347002709
                    [pp_thumb_width] => 100
                    [pp_thumb_height] => 100
                    [pp_setting_moderate_comments] => 0
                    [pp_setting_moderate_friends] => 0
                    [pp_setting_count_friends] => 1
                    [pp_setting_count_comments] => 1
                    [pp_setting_count_visitors] => 1
                    [pp_about_me] => 
                    [pp_reputation_points] => 1
                    [pp_gravatar] => 
                    [pp_photo_type] => custom
                    [signature] => [center][img]http://tomeisopa.files.wordpress.com/2009/11/snooze-snorlax.png[/img][/center]
                    [avatar_location] => 
                    [avatar_size] => 0
                    [avatar_type] => 
                    [pconversation_filters] => 
                    [fb_photo] => 
                    [fb_photo_thumb] => 
                    [fb_bwoptions] => 0
                    [tc_last_sid_import] => 0
                    [tc_photo] => 
                    [tc_bwoptions] => 0
                    [pp_customization] => 
                    [pp_profile_update] => 1347002709
                    [cache_content] => <p class='bbc_center'><span rel='lightbox'><img src='http://tomeisopa.files.wordpress.com/2009/11/snooze-snorlax.png' alt='Posted Image' class='bbc_img' /></span></p>
                    [full] => 1
                    [_canBeIgnored] => 
                    [bw_is_spammer] => 0
                    [bw_from_sfs] => 0
                    [bw_vnc_type] => 0
                    [bw_forum_result_type] => 0
                    [bw_no_status_update] => 0
                    [bw_status_email_mine] => 0
                    [bw_status_email_all] => 0
                    [bw_disable_customization] => 0
                    [bw_local_password_set] => 0
                    [bw_disable_tagging] => 0
                    [bw_disable_prefixes] => 0
                    [bw_using_skin_gen] => 0
                    [bw_disable_gravatar] => 0
                    [_group_formatted] => <span style="color: #46c843; font-weight: bold; text-shadow: 0 0 .7em #59ff55;">Administrators</span>
                    [member_rank_img] => http://www.honlegends.com/community/public/style_extra/team_icons/admin.png
                    [member_rank_img_i] => img
                    [show_warn] => 1
                    [custom_fields] => 
                    [_has_photo] => 1
                    [pp_small_photo] => http://www.honlegends.com/community/uploads/profile/photo-thumb-1.jpg?_r=1347002709
                    [pp_small_width] => 50
                    [pp_small_height] => 50
                    [pp_mini_photo] => http://www.honlegends.com/community/uploads/profile/photo-thumb-1.jpg?_r=1347002709
                    [pp_mini_width] => 25
                    [pp_mini_height] => 25
                    [_online] => 1
                    [_last_active] => Today, 12:02 PM
                    [_pp_rating_real] => 0
                    [members_display_name_formatted] => <span style="color: #46c843; font-weight: bold; text-shadow: 0 0 .7em #59ff55;">PAPA_bert</span>
                    [members_display_name_short] => PAPA_bert
                    [author_reputation] => Array
                        (
                            [text] => Neutral
                            [image] => 
                        )

                    [member_title] => Administrator
                    [cm_first_name] => Albert
                    [cm_last_name] => Yang
                    [cm_address_1] => 2919 Warwick Ave
                    [cm_address_2] => 
                    [cm_city] => Los Angeles
                    [cm_state] => CA
                    [cm_zip] => 90032
                    [cm_country] => US
                    [cm_phone] => 3233160892
                    [_name] => Albert Yang
                )

            [cardhandler:private] => 
        )

    [takeAction] => 1
)
4

3 に答える 3

0

プライベート プロパティにはアクセスできません。のようなデバッグ ツールだけvar_dump()がそれらを見ることができます。

クラスの定義を見つけてinvoice、新しい関数を追加してプロパティを編集するか (まだプロパティがない場合)、単に public に変更する必要があります。

于 2012-09-09T19:50:53.733 に答える
0

理論的には:

ob_start();
var_dump($object);
$objectStr = ob_get_clean();

次に、文字列関数を使用して値を取得します - 次のように:

$qPos = strpos($objectStr,"quantity",0);
$value = substring($objectStr$qPos+SOMEVALUE,$qPOS+SOMEVALUE+LENGTH);

これは完璧な答えではなく、微調整する必要があります。

ただし、@ abhi-beckert が言ったように、それを行うのは悪い形式であり、パフォーマンスにとって恐ろしい可能性があります。ドキュメントを確認して、別の方法があるかどうかを確認してください。

クラスを拡張してそれを行うことはできません-プライベートは継承されません。

于 2012-09-09T20:00:03.473 に答える
0

クラスを拡張し、アクセサ メソッド (または「getter」) を作成して値を取得できます。

<?php
class YourClassName extends custom_actions_ibeconomy
{
    public function getQuantity()
    {
        return $this->quantity;
    }
}
于 2012-09-09T19:53:52.093 に答える