/** * * @return WpWikiplace */ public function getWikiPlace() { if (is_null($this->wikiplace)) { $this->wikiplace = WpWikiplace::getById($this->wpm_wpw_id); } return $this->wikiplace; }
private function getInfos($wpw_id = null, $wpname = null) { $output = $this->getOutput(); $output->addWikiText("=== Infos (wpw_id || wikiplace) ==="); // WIKIPLACE $wikiplace = null; if ($wpw_id != null) { $wpw_id = intval($wpw_id); $output->addWikiText("Search by wikiplace id <code><nowiki>{$wpw_id}</nowiki></code>"); $wikiplace = WpWikiplace::getById($wpw_id); } elseif ($wpname != null) { $output->addWikiText("Search by wikiplace name <code><nowiki>{$wpname}</nowiki></code>"); $wikiplace = WpWikiplace::newFromName($wpname); } if ($wikiplace == null) { $output->addWikiText("=== No Wikiplace ==="); return; } $id = $wikiplace->getId(); $name = $wikiplace->getName(); $report_expires = $wikiplace->getDateExpires(); $report_updated = $wikiplace->getReportUpdated(); $output->addWikiText("=== Wikiplace ==="); $output->addWikiText("id = <code><nowiki>{$id}</nowiki></code>"); $output->addWikiText("name = <code><nowiki>{$name}</nowiki></code>"); $output->addWikiText("report expires = <code><nowiki>{$report_expires}</nowiki></code>"); $output->addWikiText("report updated = <code><nowiki>{$report_updated}</nowiki></code>"); // OWNER $owner = User::newFromId($wikiplace->getOwnerUserId()); if ($owner == null || !$owner->getId()) { $output->addWikiText("=== No Owner ==="); return; } $id = $owner->getId(); $username = $owner->getName(); $email = $owner->getEmail(); $output->addWikiText("=== Owner ==="); $output->addWikiText("id = <code><nowiki>{$id}</nowiki></code>"); $output->addWikiText("username = <code><nowiki>{$username}</nowiki></code>"); $output->addWikiText("email = <code><nowiki>{$email}</nowiki></code>"); // SUBSCRIPTION $subscription = WpSubscription::newFromId($wikiplace->getSubscriptionId()); if ($subscription == null) { $output->addWikiText("=== No Subscription ==="); return; } $output->addWikiText("=== Subscription ==="); $output->addWikiText("wps_id = " . $subscription->getId()); $output->addWikiText("wps_start_date = " . $subscription->getStart()); $output->addWikiText("wps_end_date = " . $subscription->getEnd()); $output->addWikiText("wps_active = " . ($subscription->isActive() ? "true" : "false")); $output->addWikiText("wps_renewal_notified = " . ($subscription->isRenewalNotified() ? "true" : "false")); $plan = WpPlan::newFromId($subscription->getPlanId()); $rplanid = $subscription->getRenewalPlanId(); $rplan = $rplanid == 0 ? null : WpPlan::newFromId($rplanid); $output->addWikiText("==== Plan ===="); $output->addWikiText("wpp_id = " . $plan->getId()); $output->addWikiText("wpp_name = " . $plan->getName()); $output->addWikiText("renew_wpp_id = " . ($rplan == null ? '<i>NONE</i>' : $rplan->getId())); $output->addWikiText("renew_wpp_name = " . ($rplan == null ? '<i>NONE</i>' : $rplan->getName())); $tmr = TMRecord::getById($subscription->getTmrId()); $output->addWikiText("==== TMR ===="); $output->addWikiText("tmr_id = " . $tmr->getId()); $output->addWikiText("tmr_status = " . $tmr->getStatus()); $tmb = TMBill::newFromId($tmr->getTMBId()); if ($tmb == null) { $output->addWikiText("==== No Bill ===="); return; } $output->addWikiText("==== TMB ===="); $output->addWikiText("tmb_id = " . $tmb->getId()); $output->addWikiText("tmb_date_created = " . $tmb->getDateCreated()); }
public function processAddMember($formData) { if (!isset($formData['WpId']) || !isset($formData['UserName'])) { throw new MWException('Cannot add member, no data.'); } $wikiplace = WpWikiplace::getById(intval($formData['WpId'])); $user = User::newFromName($formData['UserName']); if (is_null($member = WpMember::Create($wikiplace, $user))) { return wfMessage('internalerror'); } $user->invalidateCache(); // necessary to update menus and link of the user $this->logActionMember('add', $wikiplace->getTitle(), $user); $this->name = $wikiplace->getName(); return true; }
/** * Checks subscription is active, page creation quota is not exceeded and * diskpace quota is not exceeded. * @param int $current_user_id The current user identifier (used to select i18n message) * @param int|WpWikiplace $wikiplace An instance of WpWikiplace (faster) or the wikiplace id (int), checks the * subscriptions associated to the wikiplace and the quotas of the subscription buyer. * @return boolean/string True if user can, or string message explaining why she can't * <ul> * <li><b>wp-no-active-sub</b> you have no active subscription</li> * <li><b>wp-wikiplace-no-active-sub</b> wikiplace has no active subscription associated</li> * <li><b>wp-page-quota-exceeded</b> your page quota exceeded</li> * <li><b>wp-wikiplace-page-quota-exceeded</b> the subscriber page quota exceeded</li> * <li><b>wp-diskspace-quota-exceeded</b> your diskspace quota exceeded</li> * <li><b>wp-wikiplace-diskspace-quota-exceeded</b> the subscriber diskspace quota exceeded</li> * </ul> */ public static function userCanUploadNewFile($current_user_id, $wikiplace) { if (is_int($wikiplace)) { $wikiplace = WpWikiplace::getById($wikiplace); } if (!$wikiplace instanceof WpWikiplace) { throw new MWException('Invalid $wikiplace argument.'); } $subscription = self::newFromId($wikiplace->getSubscriptionId()); if (!$subscription instanceof WpSubscription) { return 'wp-wikiplace-no-active-sub'; // "THE OWNER subscription ..." } else { if (!$subscription->isActive()) { if ($wikiplace->isOwner($current_user_id)) { return 'wp-no-active-sub'; // "YOUR subscription ..." } else { return 'wp-wikiplace-no-active-sub'; // "THE OWNER subscription ..." } } } if (!$wikiplace->isOwner($current_user_id) && !WpMember::IsMember($wikiplace, $current_user_id)) { return 'wp-not-owner-or-member'; } $plan = $subscription->getPlan(); $max_pages = $plan->getNbWikiplacePages(); $owner_pages_nb = WpPage::countPagesOwnedByUser($wikiplace->getOwnerUserId()); if ($owner_pages_nb >= $max_pages) { if ($wikiplace->isOwner($current_user_id)) { return 'wp-page-quota-exceeded'; // "YOUR quota..." } else { return 'wp-wikiplace-page-quota-exceeded'; // "THE OWNER quota ..." } } $max_diskspace = $plan->getDiskspace(); $owner_diskspace_usage = WpPage::countDiskspaceUsageByUser($wikiplace->getOwnerUserId()); if ($owner_diskspace_usage >= $max_diskspace) { if ($wikiplace->isOwner($current_user_id)) { return 'wp-diskspace-quota-exceeded'; // "YOUR quota..." } else { return 'wp-wikiplace-diskspace-quota-exceeded'; // "THE OWNER quota ..." } } return true; }