Beispiel #1
0
function xt_get_multicashback($user, $rate, $sharerate, &$multi = array())
{
    if ($user->exists()) {
        $parents = get_user_meta($user->ID, XT_USER_PARENT, true);
        if (!empty($parents)) {
            $parent = new WP_User($parents['id']);
            if ($parent->exists()) {
                //当前推广人的推广人存在
                $adrate = xt_get_adrate($parent);
                $_temp = $rate + $sharerate + $adrate;
                foreach ($multi as $_m) {
                    $_temp += $_m['adrate'];
                }
                if (!empty($multi)) {
                    //多级
                    if (xt_is_role_multicashback($parent->roles)) {
                        $multi[] = array('id' => $parent->ID, 'name' => $parent->user_login, 'sub_id' => $user->ID, 'sub_name' => $user->user_login, 'adrate' => $adrate);
                    }
                } else {
                    //一级
                    $multi[] = array('id' => $parent->ID, 'name' => $parent->user_login, 'sub_id' => $user->ID, 'sub_name' => $user->user_login, 'adrate' => $adrate);
                }
                if ($adrate > 0 && xt_fanxian_is_multi()) {
                    if (xt_is_role_multicashback($parent->roles)) {
                        xt_get_multicashback($parent, $rate, $sharerate, $multi);
                    }
                }
            }
        }
    }
    return $multi;
}
function xt_row_role($key, $role, $count)
{
    global $wp_roles;
    $_title = isset($wp_roles->role_names[$role->name]) ? translate_user_role($wp_roles->role_names[$role->name]) : '未知';
    $_rate = xt_get_role_rate(array($key));
    $_adrate = xt_get_role_adrate(array($key));
    $_sharerate = xt_get_role_sharerate(array($key));
    $_ismulti = xt_is_role_multicashback(array($key));
    $_isSys = in_array($key, xt_roles());
    ?>
    <tr id="role-<?php 
    echo $key;
    ?>
" <?php 
    echo $count % 2 == 0 ? 'class = "alternate"' : '';
    ?>
>
        <td><span><?php 
    echo $_isSys ? '内置' : '自定义';
    ?>
</span></td>
        <td><span><?php 
    echo $key;
    ?>
</span></td>
        <td>
            <span><?php 
    echo $_title;
    ?>
</span>
            <?php 
    if (!$_isSys) {
        ?>
                <br>
                <div class="row-actions">
                        <!--<span class="edit"><a href="">编辑</a> | </span>-->
                    <span class="inline hide-if-no-js"><a href="#" class="editinline">快速编辑</a> | </span>
                    <span class="delete"><a class="delete-role" href="javascript:;" data-value="<?php 
        echo $key;
        ?>
">删除</a></span>
                </div>
                <div class="hidden" id="inline_<?php 
        echo $key;
        ?>
">
                    <div class="title"><?php 
        echo $_title;
        ?>
</div>
                    <div class="rate"><?php 
        echo $_rate;
        ?>
</div>
                    <div class="sharerate"><?php 
        echo $_sharerate;
        ?>
</div>
                    <div class="adrate"><?php 
        echo $_adrate;
        ?>
</div>
                </div>
            <?php 
    }
    ?>
        </td>
        <td><?php 
    echo $_rate;
    ?>
%</td>
        <td><?php 
    echo $_sharerate;
    ?>
%</td>
        <td><?php 
    echo $_adrate;
    ?>
%</td>
    </tr>
    <?php 
}