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


PHP Alert::find方法代碼示例

本文整理匯總了PHP中Alert::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Alert::find方法的具體用法?PHP Alert::find怎麽用?PHP Alert::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Alert的用法示例。


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

示例1: alerts_list

function alerts_list()
{
    //Go through all the hosts and determine if any alerts should be created
    global $hosts;
    $h = new Host();
    $hosts = $h->find();
    $alerts = new Alert();
    foreach ($hosts as $host) {
        foreach ($host->ports() as $port) {
            $status = $host->get_port_status($port, true);
            if ($status == 0) {
                if ($alert = $alerts->find("WHERE host_id = " . $host->id . " AND port = " . $port)) {
                    //There is already an alert for this, go through each user and see what their preference for this port is
                    send_user_alerts($host->id, $port, $alert->id, 'all');
                } else {
                    $alert = new alert();
                    $alert->message = "HOST: " . $host->name . "PORT: " . $port . "";
                    $alert->user_id = 1;
                    $alert->host_id = $host->id;
                    $alert->port = $port;
                    $alert->sent_on = time();
                    $alert->save();
                    send_user_alerts($host->id, $port, $alert->id, 'single');
                    //Go through each user and determine what their preference for this port is.
                }
            } else {
                //The port is up, but we need to set up reports if there is an existing one!
                if ($alert = $alerts->find("WHERE host_id = " . $host->id . " AND port = " . $port)) {
                    //There is already an alert for this, go through each user and see what their preference for this port is
                    send_user_alerts($host->id, $port, $alert->id, 'single');
                }
            }
        }
    }
    render();
}
開發者ID:bjcpgd,項目名稱:palserve,代碼行數:36,代碼來源:alerts.php

示例2: __sendAlert

 private static function __sendAlert($alertsId, $message)
 {
     $alert = Alert::find($alertsId);
     if (!is_null($alert)) {
         $alerts_to = $alert->users;
         foreach ($alerts_to as $current) {
             if ($current->pivot->to_facebook) {
                 static::__sendFacebook($current->facebook_id, $message);
             }
             if ($current->pivot->to_sms) {
                 static::__sendSms($current->mobile, $message);
             }
             if ($current->pivot->to_email) {
                 static::__sendEmail(array($current->email, $current->display_name), $message);
             }
         }
     }
 }
開發者ID:frankpaul142,項目名稱:cloudinventory,代碼行數:18,代碼來源:globals.php


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