當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subscription類代碼示例

本文整理匯總了PHP中Subscription的典型用法代碼示例。如果您正苦於以下問題:PHP Subscription類的具體用法?PHP Subscription怎麽用?PHP Subscription使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Subscription類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareSubscription

 protected function prepareSubscription()
 {
     if (!isset($_POST['Subscription'])) {
         new \Error(4, 'Subscription');
     }
     $subs = json_decode($_POST['Subscription'], true);
     //var_dump($subs);
     if ($subs['DepartCity'] == NULL || $subs['ArriveCity'] == NULL || $subs['StartDate'] == NULL || $subs['EndDate'] == NULL) {
         new \Error(4, array('DepartCity', 'ArriveCity', 'StartDate', 'EndDate'));
     }
     $tiSubs = new \Subscription();
     $tiSubs->attributes = $subs;
     $subs_adp = $tiSubs->search();
     if ($subs_adp->itemCount) {
         $this->_subs = $subs_adp->getData()[0];
         $this->_subs->Count = $this->_subs->Count + 1;
     } else {
         /*
         			$lowestPrice = new \D_LowestPrice;
         			$tiSubs->CurrentPrice = (int)$lowestPrice->searchFlight($tiSubs);
         */
         $this->_subs = $tiSubs;
     }
     try {
         if (!$this->_subs->save()) {
             new \Error(5, null, json_encode($this->_subs->getErrors()));
         }
     } catch (Exception $e) {
         new \Error(5, NULL, $e->getMessage());
     }
 }
開發者ID:Yougmark,項目名稱:TiCheck_Server,代碼行數:31,代碼來源:DefaultController.php

示例2: displaySubscriptions

 public function displaySubscriptions($tab, $user, $ui)
 {
     $db = JFactory::getDBO();
     include_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $dateFormat = $this->params->get('dateFormat', "m/d/Y");
     $meta_user = new metaUser($user->id);
     $html_return = '' . '<table class="aeceventlog_table" style="border-collapse: collapse">' . '<tr class="aeceventlog_row_header">' . '<th width="30%" class="text-center">Plan</th>' . '<th width="10%" class="text-center">Primary</th>' . '<th width="10%" class="text-center">Status</th>' . '<th width="10%" class="text-center">Started</th>' . '<th width="20%" class="text-center">Ends</th>' . '</tr>';
     $subscriptions = $meta_user->getAllSubscriptions();
     $subscr_info = $this->getAllCurrentSubscriptionsInfoComplete($user->id);
     foreach ($subscriptions as $i => $subscriptionid) {
         $subscription = new Subscription();
         $subscription->load($subscriptionid);
         $plan_name = $subscr_info[$i]->name == '' ? "Excluded" : $subscr_info[$i]->name;
         $html_return .= '<tr>' . '<td width="30%" class="text-center">' . $plan_name . '</td>' . '<td width="10%" class="text-center">' . ($subscription->primary ? "Yes" : "No") . '</td>' . '<td width="10%" class="text-center">' . $this->getIconHtml($subscription->status) . ' ' . $subscription->status . '</td>' . '<td width="10%" class="text-center">' . date($dateFormat, strtotime($subscription->signup_date)) . '</td>';
         $html_return .= '<td width="10%" class="text-center">';
         if (!empty($subscription->lifetime)) {
             $html_return .= JText::_('AEC_ISLIFETIME');
         } else {
             if ($subscription->recurring && in_array($subscription->status, array('Active', 'Trial'))) {
                 $html_return .= JText::_('AEC_WILLRENEW') . ': ' . date($dateFormat, strtotime($subscription->expiration));
             } else {
                 $html_return .= date($dateFormat, strtotime($subscription->expiration));
             }
         }
         $html_return .= '</td></tr>';
     }
     $html_return .= '</table>';
     return $html_return;
 }
開發者ID:Ibrahim1,項目名稱:aec,代碼行數:29,代碼來源:cbaecmembershiptab.php

示例3: run

 /**
  * Check stripe data.
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
     if ($paymentGateway->exists()) {
         \Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
         $subscriptions = new Subscription();
         $allSubscriptions = $subscriptions->where('status', Subscription::STATUS_ACTIVE)->get();
         /* @var Subscription $_subscription */
         foreach ($allSubscriptions as $_subscription) {
             $end = DateTime::createFromFormat('Y-m-d', $_subscription->end_date);
             if ($end->getTimestamp() > strtotime('now')) {
                 $paymentTransaction = $_subscription->payment_transaction->get();
                 if ($paymentTransaction->system == 'stripe') {
                     $user = new User($_subscription->user_id);
                     try {
                         $customer = \Stripe\Customer::retrieve($user->stripe_id);
                         $subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
                     } catch (Exception $e) {
                         log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
                     }
                     if (!isset($subscription) || $subscription->status != 'active') {
                         $_subscription->deactivate();
                         $_subscription->save();
                     }
                 }
             }
         }
         log_message('CRON_SUCCESS', __FUNCTION__);
     }
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:36,代碼來源:check_subscriptions_cron.php

示例4: get_blocked_subs

/**
 * Fetch subscriptions that should be disallowed by a block
 */
function get_blocked_subs()
{
    $query = "SELECT subscription.* " . "FROM subscription " . "INNER JOIN profile_block " . "ON blocker=subscribed " . "AND blocked=subscriber";
    $subscription = new Subscription();
    $subscription->query($query);
    return $subscription;
}
開發者ID:microcosmx,項目名稱:experiments,代碼行數:10,代碼來源:fixup_blocks.php

示例5: body

 protected function body()
 {
     if (!$this->userHasPrivileges(User::groupsJoinPrivate, User::groupsJoinPublic, User::groupsRequest)) {
         return false;
     }
     if (!$this->isInputValid(array('id' => 'isIndex'))) {
         return false;
     }
     $groupId = $this->getParams('id');
     /**
      * @var $group \Group
      */
     $group = Repositories::findEntity(Repositories::Group, $groupId);
     // Calculate privileges of the user
     $user = User::instance();
     $canJoinPrivate = User::instance()->hasPrivileges(User::groupsJoinPrivate);
     $groupIsPrivate = $group->getType() == \Group::TYPE_PRIVATE;
     $hasSufficientPrivileges = $groupIsPrivate && ($canJoinPrivate || $user->hasPrivileges(User::groupsRequest)) || !$groupIsPrivate && $user->hasPrivileges(User::groupsJoinPublic);
     if (!$hasSufficientPrivileges) {
         return $this->death(StringID::InsufficientPrivileges);
     }
     $status = $canJoinPrivate || !$groupIsPrivate ? \Subscription::STATUS_SUBSCRIBED : \Subscription::STATUS_REQUESTED;
     // Put into database
     $subscription = new \Subscription();
     $subscription->setGroup($group);
     $subscription->setUser(User::instance()->getEntity());
     $subscription->setStatus($status);
     Repositories::persistAndFlush($subscription);
     return true;
 }
開發者ID:pombredanne,項目名稱:xmlcheck-public,代碼行數:30,代碼來源:AddSubscription.php

示例6: send

 /**
  * The function sends emails with new articles to subscribers.
  * 
  * @access public
  */
 public function send()
 {
     $Subscription = new Subscription();
     foreach ($Subscription->findList() as $Subscription) {
         $Sent = new Article_Sent();
         $Sent->MailerId = $this->Id;
         $Sent->Email = $Subscription->Email;
         $Email = new Email_Article($Subscription);
         $Email->setArticles($this->getArticles());
         if ($Email->send()) {
             $Sent->Result = 1;
         } else {
             $Sent->Result = 0;
         }
         $Sent->saveNew();
     }
     foreach ($this->getArticles() as $Article) {
         $Article = $Article->findItem(array('Id = ' . $Article->Id));
         if ($Article) {
             $Article->InSubscription = 0;
             $Article->save();
         }
     }
     $this->SentAt = time();
     $this->save();
 }
開發者ID:vosaan,項目名稱:ankor.local,代碼行數:31,代碼來源:mailer.php

示例7: run

 /**
  * Check stripe data.
  *
  * @access public
  * @return void
  */
 public function run()
 {
     try {
         $paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
         if ($paymentGateway->exists()) {
             \Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
             $subscriptions = new Subscription();
             $allSubscriptions = $subscriptions->get();
             /* @var Subscription $_subscription */
             foreach ($allSubscriptions as $_subscription) {
                 if ($_subscription->end_date <= strtotime('now')) {
                     $paymentTransaction = $_subscription->payment_transaction->get();
                     if ($paymentTransaction->system == 'stripe') {
                         $user = new User($_subscription->user_id);
                         $customer = \Stripe\Customer::retrieve($user->stripe_id);
                         $subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
                         if ($subscription->status == 'active') {
                             $date = new DateTime();
                             $date->setTimestamp($subscription->current_period_end);
                             $_subscription->end_date = $date->format('Y-m-d');
                             $_subscription->activate();
                             $_subscription->save();
                         }
                     }
                 }
             }
             log_message('CRON_SUCCESS', __FUNCTION__);
         } else {
             log_message('CRON_ERROR', __FUNCTION__ . ' > ' . 'No Stripe Api key.');
         }
     } catch (Exception $e) {
         log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
     }
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:40,代碼來源:stripe_subscriptions_cron.php

示例8: destroy

 function destroy($args, $apidata)
 {
     parent::handle($args);
     if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
         $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
         return;
     }
     $id = $apidata['api_arg'];
     # We can't subscribe to a remote person, but we can unsub
     $other = $this->get_profile($id);
     $user = $apidata['user'];
     $sub = new Subscription();
     $sub->subscriber = $user->id;
     $sub->subscribed = $other->id;
     if ($sub->find(true)) {
         $sub->query('BEGIN');
         $sub->delete();
         $sub->query('COMMIT');
     } else {
         $this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
         return;
     }
     $type = $apidata['content-type'];
     $this->init_document($type);
     $this->show_profile($other, $type);
     $this->end_document($type);
 }
開發者ID:Br3nda,項目名稱:laconica,代碼行數:27,代碼來源:twitapifriendships.php

示例9: executeSubscription

 public function executeSubscription(sfWebRequest $request)
 {
     $params = $request->getParameter('email');
     $form = new SubscriptionForm();
     if ($request->isMethod('post')) {
         $email = $params;
         try {
             if (empty($obj)) {
                 $obj = new Subscription();
                 $obj->setEmail($email)->save();
             }
         } catch (Exception $e) {
         }
         $contacts = UserPeer::getAllContact();
         $backEmail = $contacts->getEmail();
         $message = "E-mail: " . $email . "<br/>";
         // почта, на которую придет письмо
         $mail_to = $backEmail;
         // тема письма
         $subject = "Новый подписчик";
         // заголовок письма
         $headers = "Content-type: text/html; charset=utf-8\r\n";
         // кодировка письма
         // отправляем письмо
         mail($mail_to, $subject, $message, $headers);
     }
     $this->form = $form;
 }
開發者ID:alexspark21,項目名稱:symfony_bisM,代碼行數:28,代碼來源:components.class.php

示例10: create

 public function create($data, $save = true)
 {
     $sbc = new Subscription($this, $data);
     if ($save) {
         $sbc->save();
     }
     return $sbc;
 }
開發者ID:bandwidthcom,項目名稱:php-bandwidth-iris,代碼行數:8,代碼來源:SubscriptionsModel.php

示例11: index

 /**
  * Display subscriptions of user
  */
 public function index()
 {
     $subscription = new Subscription();
     $subscriptions = $subscription->getUserSubscriptions($this->c_user->id, true);
     CssJs::getInst()->add_css('dev/admin.css')->c_js('settings/subscriptions', 'index');
     $this->template->set('subscriptions', $subscriptions);
     $this->template->set('active_subscription', $this->c_user->getLastSubscription());
     $this->template->render();
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:12,代碼來源:subscriptions.php

示例12: sendAll

 protected function sendAll($IDs)
 {
     $sub = new Subscription();
     foreach ($IDs as $ID) {
         if (!$ID) {
             continue;
         }
         echo "{$ID} sent to " . $sub->send_bulk($ID) . " email(s)\n";
     }
 }
開發者ID:abiliojr,項目名稱:digesttrigger,代碼行數:10,代碼來源:digest.php

示例13: onSuccess

 public function onSuccess(Course $course)
 {
     $this->em->persist($course);
     $subscription = new Subscription();
     $user = $this->container->get('security.context')->getToken()->getUser();
     $subscription->setUser($user);
     $subscription->setCourse($course);
     $this->em->persist($subscription);
     $this->em->flush();
     $this->get('session')->setFlash('notice', 'Your Course is created! & Subscription OK !');
 }
開發者ID:nonoscred,項目名稱:Run4Fun,代碼行數:11,代碼來源:CourseHandler.php

示例14: subscriptionDetailsFromRow

 private function subscriptionDetailsFromRow($row)
 {
     $subscription = new Subscription();
     $subscription->storeId = $row['storeId'];
     $subscription->pss_sp_id = $row['pss_sp_id'];
     $subscription->sp_plan_name = $row['sp_plan_name'];
     $subscription->sp_caption = $row['sp_caption'];
     $subscription->sp_description = $row['sp_description'];
     $subscription->sp_jed_id = $row['sp_jed_id'];
     $subscription->unsetValues(array('storeId', 'created_on', 'updated_on', 'created_by', 'updated_by'));
     return $subscription;
 }
開發者ID:sujata-patne,項目名稱:icon_api,代碼行數:12,代碼來源:SubscriptionDao.php

示例15: takeAction

 /**
  * Performs the action; returns true on success, false on error.
  *
  * @param $p_context - the current context object
  * @return bool
  */
 public function takeAction(CampContext &$p_context)
 {
     $p_context->default_url->reset_parameter('f_' . $this->m_name);
     $p_context->url->reset_parameter('f_' . $this->m_name);
     if (PEAR::isError($this->m_error)) {
         return false;
     }
     $auth = Zend_Auth::getInstance();
     $user = new User($p_context->user->identifier);
     if ($user->getUserId() != $auth->getIdentity() || $user->getUserId() == 0) {
         $this->m_error = new PEAR_Error('You must be logged in to create or edit your subscription.', ACTION_EDIT_SUBSCRIPTION_ERR_NO_USER);
         return false;
     }
     $subscriptions = Subscription::GetSubscriptions($p_context->publication->identifier, $user->getUserId());
     if (count($subscriptions) == 0) {
         $subscription = new Subscription();
         $created = $subscription->create(array('IdUser' => $user->getUserId(), 'IdPublication' => $p_context->publication->identifier, 'Active' => 'Y', 'Type' => $this->m_subscriptionType == 'trial' ? 'T' : 'P'));
         if (!$created) {
             $this->m_error = new PEAR_Error('Internal error (code 1)', ACTION_EDIT_SUBSCRIPTION_ERR_INTERNAL);
             exit(1);
         }
     } else {
         $subscription = $subscriptions[0];
     }
     $publication = new Publication($p_context->publication->identifier);
     $subscriptionDays = $this->computeSubscriptionDays($publication, $p_context->publication->subscription_time);
     $startDate = new Date();
     $columns = array('StartDate' => $startDate->getDate(), 'Days' => $subscriptionDays, 'PaidDays' => $this->m_subscriptionType == 'trial' ? $subscriptionDays : 0, 'NoticeSent' => 'N');
     if ($this->m_properties['subs_by_type'] == 'publication') {
         $sectionsList = Section::GetUniqueSections($p_context->publication->identifier);
         foreach ($sectionsList as $section) {
             $this->m_sections[] = $section['id'];
         }
     }
     foreach ($this->m_languages as $languageId) {
         foreach ($this->m_sections as $sectionNumber) {
             $subsSection = new SubscriptionSection($subscription->getSubscriptionId(), $sectionNumber, $languageId);
             $subsSection->create($columns);
         }
     }
     $fields = array('SubsType', 'tx_subs', 'nos', 'unitcost', 'unitcostalllang', 'f_substype', 'cb_subs', 'subs_all_languages', 'suma', 'tpl', 'subscription_language');
     foreach (CampRequest::GetInput() as $field => $value) {
         if (strncmp('tx_subs', $field, strlen('tx_subs')) == 0) {
             $fields[] = $field;
         }
     }
     foreach ($fields as $fieldName) {
         $p_context->default_url->reset_parameter($fieldName);
         $p_context->url->reset_parameter($fieldName);
     }
     $this->m_error = ACTION_OK;
     return true;
 }
開發者ID:nidzix,項目名稱:Newscoop,代碼行數:59,代碼來源:MetaActionEdit_Subscription.php


注:本文中的Subscription類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。