本文整理汇总了PHP中Application::FireEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::FireEvent方法的具体用法?PHP Application::FireEvent怎么用?PHP Application::FireEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::FireEvent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnStartForking
public function OnStartForking()
{
global $TLDs, $modules_config;
Log::Log("Starting 'Renew' cronjob...", E_USER_NOTICE);
$db = Core::GetDBInstance();
$RegFactory = RegistryModuleFactory::GetInstance();
$DbDomain = DBDomain::GetInstance();
$this->ThreadArgs = array();
// For each client send notice about expiring domains
$sql = "SELECT id FROM users";
foreach ($db->GetAll($sql) as $client_data)
{
try
{
$Client = Client::Load($client_data["id"]);
$sql = "
SELECT
d.id, d.name, d.TLD, d.end_date,
IF(dd.`key` IS NOT NULL, FROM_UNIXTIME(dd.`value`), DATE_SUB(end_date, INTERVAL 1 DAY)) AS last_renew_date
FROM domains d
LEFT JOIN domains_data dd ON (dd.domainid = d.id AND dd.`key` = 'RenewalDate')
WHERE d.status = '".DOMAIN_STATUS::DELEGATED."' AND d.userid = ? AND (TO_DAYS(end_date) - TO_DAYS(NOW()) BETWEEN 0 AND ?) AND renew_disabled != 1
ORDER BY d.end_date ASC";
$start_days = $Client->GetSettingValue(ClientSettings::EXPIRE_NOTIFY_START_DAYS);
$domains_data = $db->GetAll($sql, array($Client->ID, $start_days ? $start_days : 60));
// Send email to client
if ($domains_data)
{
$eml_args = array(
"client_name" => $Client->Name,
"domains" => array()
);
foreach ($domains_data as $domain_data)
{
$eml_args["domains"][] = array(
"name" => "{$domain_data["name"]}.{$domain_data["TLD"]}",
"expire_date" => date("Y-m-d", strtotime($domain_data["end_date"])),
"last_renew_date" => date("Y-m-d", strtotime($domain_data["last_renew_date"]))
);
}
mailer_send("bulk_renew_notice.eml", $eml_args, $Client->Email, $Client->Name);
}
foreach ($domains_data as $domain_data)
{
$Domain = $DbDomain->Load($domain_data['id']);
// Find more then 60 days invoice
// Legacy from old notification system.
// FIXME: Need to create a better solution to finding unpaid invoices for upgoing renew
$dtNearest = date("Y-m-d", $Domain->ExpireDate - 60*24*60*60);
$invoiceid = $db->GetOne("SELECT id FROM invoices
WHERE userid=? AND itemid=? AND purpose=? AND dtcreated >= ?",
array($Domain->UserID, $Domain->ID, INVOICE_PURPOSE::DOMAIN_RENEW, $dtNearest)
);
// Generate invoice
if (!$invoiceid && !$Domain->RenewDisabled)
{
$Registry = $RegFactory->GetRegistryByExtension($Domain->Extension);
$config = $Registry->GetManifest()->GetSectionConfig();
$period = (int)$config->domain->renewal->min_period;
$Domain->Period = $period;
$DbDomain->Save($Domain);
try
{
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $Domain->ID, $Domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $Domain->GetHostName(), $period);
$Invoice->Cancellable = 1;
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING)
{
$diff_days = ceil(($Domain->ExpireDate - time())/(60*60*24));
Application::FireEvent('DomainAboutToExpire', $Domain, $diff_days);
}
}
catch(Exception $e)
{
Log::Log("Cannot create renew invoice. Caught: {$e->getMessage()}", E_USER_ERROR);
}
}
}
}
catch (Exception $e)
{
Log::Log("Caught: {$e->getMessage()}", E_USER_ERROR);
}
}
/*
//.........这里部分代码省略.........
示例2: HandleImpendingExpiration
public function HandleImpendingExpiration(Domain $domain)
{
// http://bugzilla.webta.net/show_bug.cgi?id=210
// Prevent domain expiration
$Config = $this->GetManifest()->GetSectionConfig();
$days = $Config->domain->xpath("//renewal/notifications/period");
$last_notification_period = (int) end($days);
$last_renewal_date = $domain->RenewalDate ? $domain->RenewalDate : $domain->ExpireDate;
$days_before_expire = (int) ceil(($last_renewal_date - time()) / 86400);
if ($days_before_expire <= $last_notification_period) {
if ($days_before_expire < 0) {
// Today will expire... OMG!
$days_before_expire = 0;
}
// Set renew period
$period = (int) $Config->domain->renewal->min_period;
$domain->Period = $period;
// Copypasta from class.RenewProcess.php
// Issue invoice for renew and send notification to client.
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $domain->GetHostName(), $period);
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING) {
$userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID));
$args = array("domain_name" => $domain->Name, "extension" => $domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $domain->RenewalDate);
mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
Application::FireEvent('DomainAboutToExpire', $domain, $days_before_expire);
}
}
}
示例3: ApplicationException
{
foreach ((array)$_SESSION['wizard']['newclient']["add"] as $k=>$v)
$Client->{$k} = $v;
}
catch(Exception $e){}
try
{
$_SESSION["userid"] = $Client->Save()->ID;
}
catch(Exception $e)
{
throw new ApplicationException($e->getMessage(), $e->getCode());
}
Application::FireEvent('ClientCreated', $Client);
if (CONFIG::$CLIENT_MANUAL_APPROVAL == 1)
{
$Client->SetSettingValue("pwd", $password);
mailer_send("signup_pending.eml", $args, $_SESSION['wizard']['newclient']["email"], $_SESSION['wizard']['newclient']["name"]);
}
else
{
mailer_send("signup.eml", $args, $_SESSION['wizard']['newclient']["email"], $_SESSION['wizard']['newclient']["name"]);
$Client->SetSettingValue("welcome_send", 1);
}
if ($_SESSION['userid'] && $_SESSION['c_login'] && $_SESSION['c_password'])
{
示例4: array
foreach ((array)$_POST["add"] as $k=>$v)
$Client->{$k} = $v;
try
{
$Client->Save();
}
catch(Exception $e)
{
$errmsg = $e->getMessage();
}
if (!$errmsg)
{
Application::FireEvent('ClientUpdated', $oldClient, $Client);
// CoreUtils::Redirect to users view page
$okmsg = _("Profile successfully updated");
CoreUtils::Redirect("index.php");
}
}
}
if (!$_POST)
$display["attr"] = $db->GetRow("SELECT * FROM users WHERE id = ?", array($_SESSION['userid']));
else
$display["attr"] = $_POST;
$display["countries"] = $db->GetAll("SELECT * FROM countries");
示例5: _
$mess = _("Client with specified login not found in database");
CoreUtils::Redirect("login.php");
}
if ($Crypto->Hash($post_pass) == $Client->Password)
{
if ($Client->Status == 1)
{
$sault = $Crypto->Sault();
$_SESSION["sault"] = $sault;
$_SESSION["userid"] = $Client->ID;
$_SESSION["login"] = $Client->Login;
$_SESSION["hash"] = $Crypto->Hash("{$Client->Login}:{$Client->Password}:{$sault}");
Application::FireEvent('LoginSuccess', $post_login, $post_pass);
if (!$_SESSION["REQUEST_URI"])
CoreUtils::Redirect ("/client/domains_view.php");
else
CoreUtils::Redirect($_SESSION["REQUEST_URI"]);
}
else
{
$mess = _("Client account is inactive");
CoreUtils::Redirect("login.php");
}
}
else
{
示例6: Invoice
// Today will expire... OMG!
$days_before_expire = 0;
}
// Set renew period
$period = (int) $Config->domain->renewal->min_period;
$Domain->Period = $period;
// Copypasta from class.RenewProcess.php
// Issue invoice for renew and send notification to client.
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $Domain, $Domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $Domain->GetHostName(), $period);
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING) {
$userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
$args = array("domain_name" => $Domain->Name, "extension" => $Domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $Domain->RenewalDate);
mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
Application::FireEvent('DomainAboutToExpire', $Domain, $days_before_expire);
}
}
} catch (Exception $e) {
$err[] = sprintf("%s: %s", $Domain->GetHostName(), $e->getMessage());
}
}
} else {
$err[] = sprintf(_("'%s' cannot be imported because it does not belong to the current registar."), $Domain->GetHostName());
}
} else {
$err[] = sprintf(_("'%s' has no RemoteCLID, we cannot check that domain belongs to current registrar."), $Domain->GetHostName());
}
} else {
$err[] = sprintf(_("Domain '%s' already exists in our database."), $Domain->GetHostName());
}
示例7:
// Delete users
$i = 0;
foreach ((array)$post_id as $k=>$v)
{
$i++;
try
{
$Client = Client::Load($v);
$Client->Delete();
}
catch(Exception $e)
{
$err[] = $e;
}
Application::FireEvent('ClientDeleted', $Client);
}
if (!$err)
{
$okmsg = "{$i} users deleted";
CoreUtils::Redirect("users_view.php");
}
}
elseif($post_action == "mail")
{
// Resend registration email
$i = 0;
foreach ((array)$post_id as $k=>$v)
{
$info = $db->GetRow("SELECT * FROM users WHERE id='{$v}'");