當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。