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


PHP Subscription::Exist方法代码示例

本文整理汇总了PHP中Subscription::Exist方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::Exist方法的具体用法?PHP Subscription::Exist怎么用?PHP Subscription::Exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


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

示例1: array

        $data = array('member' => $member->user_id, 'user_id' => $user->user_id);
        if (!Subscription::Exist($data)) {
            $subscribed = Subscription::Create($data);
            Plugin::Trigger('subscribe.ajax.subscribe');
            echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_subscribed', array('username' => $member->username)), 'other' => (string) Language::GetText('unsubscribe')));
            exit;
        } else {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_duplicate')));
            exit;
        }
        ### Handle unsubscribe user from a member
    ### Handle unsubscribe user from a member
    case 'unsubscribe':
        // Verify user is logged in
        if (!$logged_in) {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_login')));
            exit;
        }
        // Delete subscription if one exists
        $subscription_id = Subscription::Exist(array('user_id' => $user->user_id, 'member' => $member->user_id));
        if ($subscription_id) {
            Subscription::Delete($subscription_id);
            Plugin::Trigger('subscribe.ajax.unsubscribe');
            echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_unsubscribed', array('username' => $member->username)), 'other' => (string) Language::GetText('subscribe')));
            exit;
        } else {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_noexist')));
            exit;
        }
}
// END action switch
开发者ID:KmServer,项目名称:CumulusClips,代码行数:31,代码来源:subscribe.ajax.php

示例2: User

    $user_id = User::Exist($data);
} else {
    App::Throw404();
}
// Verify Member exists
if ($user_id) {
    View::$vars->member = new User($user_id);
    View::$vars->meta->title = Functions::Replace(View::$vars->meta->title, array('member' => View::$vars->member->username));
    Plugin::Trigger('profile.load_member');
} else {
    App::Throw404();
}
### Check if user is subscribed
if (View::$vars->logged_in) {
    $data = array('user_id' => View::$vars->user->user_id, 'member' => View::$vars->member->user_id);
    View::$vars->subscribe_text = Subscription::Exist($data) ? 'unsubscribe' : 'subscribe';
} else {
    View::$vars->subscribe_text = 'subscribe';
}
### Count subscription
$query = "SELECT COUNT(sub_id) FROM " . DB_PREFIX . "subscriptions WHERE member = " . View::$vars->member->user_id;
$result = $db->Query($query);
View::$vars->sub_count = $db->FetchRow($result);
### Retrieve video list
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE user_id = " . View::$vars->member->user_id . " AND status = 'approved' AND private = '0' LIMIT 3";
Plugin::Trigger('profile.load_recent_videos');
View::$vars->result_videos = $db->Query($query);
### Update Member view count
$data = array('views' => View::$vars->member->views + 1);
View::$vars->member->Update($data);
### Retrieve latest status updates
开发者ID:KmServer,项目名称:CumulusClips,代码行数:31,代码来源:profile.php

示例3: User

App::LoadClass('Subscription');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('subscriptions');
Plugin::Trigger('subscriptions.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/subscriptions';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $data = array('user_id' => View::$vars->user->user_id, 'member' => $_GET['id']);
    $id = Subscription::Exist($data);
    if ($id) {
        $subscribed_user = new User($_GET['id']);
        Subscription::Delete($id);
        View::$vars->message = Language::GetText('success_unsubscribed', array('username' => $subscribed_user->username));
        View::$vars->message_type = 'success';
        Plugin::Trigger('subscriptions.unsubscribe');
    }
}
/******************
Prepare page to run
******************/
// Retrieve total count
$query = "SELECT sub_id FROM " . DB_PREFIX . "subscriptions WHERE user_id = " . View::$vars->user->user_id;
$result_count = $db->Query($query);
$total = $db->Count($result_count);
开发者ID:KmServer,项目名称:CumulusClips,代码行数:31,代码来源:subscriptions.php


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