本文整理汇总了PHP中notifications::notify_admins方法的典型用法代码示例。如果您正苦于以下问题:PHP notifications::notify_admins方法的具体用法?PHP notifications::notify_admins怎么用?PHP notifications::notify_admins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifications
的用法示例。
在下文中一共展示了notifications::notify_admins方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
if (isset($_GET['key'])) {
$frontlinesms_key = $_GET['key'];
}
if (isset($_GET['s'])) {
$message_from = $_GET['s'];
// Remove non-numeric characters from string
$message_from = ereg_replace("[^0-9]", "", $message_from);
}
if (isset($_GET['m'])) {
$message_description = $_GET['m'];
}
if (!empty($frontlinesms_key) && !empty($message_from) && !empty($message_description)) {
// Is this a valid FrontlineSMS Key?
$keycheck = ORM::factory('settings', 1)->where('frontlinesms_key', $frontlinesms_key)->find();
if ($keycheck->loaded == TRUE) {
$services = new Service_Model();
$service = $services->where('service_name', 'SMS')->find();
if (!$service) {
return;
}
$reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message_from)->find();
if (!$reporter->loaded == TRUE) {
// get default reporter level (Untrusted)
$level = ORM::factory('level')->where('level_weight', 0)->find();
$reporter->service_id = $service->id;
$reporter->level_id = $level->id;
$reporter->service_userid = null;
$reporter->service_account = $message_from;
$reporter->reporter_first = null;
$reporter->reporter_last = null;
$reporter->reporter_email = null;
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
}
// Save Message
$message = new Message_Model();
$message->parent_id = 0;
$message->incident_id = 0;
$message->user_id = 0;
$message->reporter_id = $reporter->id;
$message->message_from = $message_from;
$message->message_to = null;
$message->message = $message_description;
$message->message_type = 1;
// Inbox
$message->message_date = date("Y-m-d H:i:s", time());
$message->service_messageid = null;
$message->save();
// Notify Admin Of New Email Message
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_sms.subject'), Kohana::lang('notifications.admin_new_sms.message'));
}
}
}
示例2: view
/**
* Displays a report.
* @param boolean $id If id is supplied, a report with that id will be
* retrieved.
*/
public function view($id = false)
{
$this->template->header->this_page = 'reports';
$this->template->content = new View('reports_view');
// Load Akismet API Key (Spam Blocker)
$api_akismet = Kohana::config('settings.api_akismet');
if (!$id) {
url::redirect('main');
} else {
$incident = ORM::factory('incident', $id);
if ($incident->id == 0) {
url::redirect('main');
}
// Comment Post?
// Setup and initialize form field names
$form = array('comment_author' => '', 'comment_description' => '', 'comment_email' => '', 'comment_ip' => '', 'captcha' => '');
$captcha = Captcha::factory();
$errors = $form;
$form_error = FALSE;
// Check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = Validation::factory($_POST);
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('comment_author', 'required', 'length[3,100]');
$post->add_rules('comment_description', 'required');
$post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
$post->add_rules('captcha', 'required', 'Captcha::valid');
// Test to see if things passed the rule checks
if ($post->validate()) {
// Yes! everything is valid
if ($api_akismet != "") {
// Run Akismet Spam Checker
$akismet = new Akismet();
// comment data
$comment = array('author' => $post->comment_author, 'email' => $post->comment_email, 'website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
$config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
$akismet->init($config);
if ($akismet->errors_exist()) {
if ($akismet->is_error('AKISMET_INVALID_KEY')) {
// throw new Kohana_Exception('akismet.api_key');
} elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
// throw new Kohana_Exception('akismet.server_failed');
} elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
// throw new Kohana_Exception('akismet.server_not_found');
}
// If the server is down, we have to post
// the comment :(
// $this->_post_comment($comment);
$comment_spam = 0;
} else {
if ($akismet->is_spam()) {
$comment_spam = 1;
} else {
$comment_spam = 0;
}
}
} else {
// No API Key!!
$comment_spam = 0;
}
$comment = new Comment_Model();
$comment->incident_id = $id;
$comment->comment_author = strip_tags($post->comment_author);
$comment->comment_description = strip_tags($post->comment_description);
$comment->comment_email = strip_tags($post->comment_email);
$comment->comment_ip = $_SERVER['REMOTE_ADDR'];
$comment->comment_date = date("Y-m-d H:i:s", time());
// Activate comment for now
if ($comment_spam == 1) {
$comment->comment_spam = 1;
$comment->comment_active = 0;
} else {
$comment->comment_spam = 0;
$comment->comment_active = 1;
}
$comment->save();
// Notify Admin Of New Comment
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/view/' . $id);
// Redirect
url::redirect('reports/view/' . $id);
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('comments'));
$form_error = TRUE;
}
}
$this->template->content->incident_id = $incident->id;
$this->template->content->incident_title = $incident->incident_title;
$this->template->content->incident_description = nl2br($incident->incident_description);
$this->template->content->incident_location = $incident->location->location_name;
//.........这里部分代码省略.........
示例3: _add_comment
/**
* Submit comments
*
* @return int
*/
private function _add_comment()
{
$api_akismet = Kohana::config('settings.api_akismet');
// Comment Post?
// Setup and initialize form field names
$form = array('incident_id' => '', 'comment_author' => '', 'comment_description' => '', 'comment_email' => '');
$captcha = Captcha::factory();
$errors = $form;
$form_error = FALSE;
$ret_value = 0;
// Check, has the form been submitted, if so, setup validation
if ($_POST and Kohana::config('settings.allow_comments')) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = Validation::factory($_POST);
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('incident_id', 'required');
$post->add_rules('comment_author', 'required', 'length[3,100]');
$post->add_rules('comment_description', 'required');
$post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
// Test to see if things passed the rule checks
if ($post->validate()) {
// Yes! everything is valid
$incident = ORM::factory('incident')->where('id', $post->incident_id)->where('incident_active', 1)->find();
if ($incident->id == 0) {
return $this->response(1, "No incidents with that ID");
}
if ($api_akismet != "") {
// Run Akismet Spam Checker
$akismet = new Akismet();
// Comment data
$comment = array('author' => $post->comment_author, 'email' => $post->comment_email, 'website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
$config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
$akismet->init($config);
if ($akismet->errors_exist()) {
if ($akismet->is_error('AKISMET_INVALID_KEY')) {
// throw new Kohana_Exception('akismet.api_key');
} elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
// throw new Kohana_Exception('akismet.server_failed');
} elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
// throw new Kohana_Exception('akismet.server_not_found');
}
// If the server is down, we have to post
// the comment :(
// $this->_post_comment($comment);
$comment_spam = 0;
} else {
if ($akismet->is_spam()) {
$comment_spam = 1;
} else {
$comment_spam = 0;
}
}
} else {
// No API Key!!
$comment_spam = 0;
}
$comment = new Comment_Model();
$comment->incident_id = strip_tags($post->incident_id);
$comment->comment_author = strip_tags($post->comment_author);
$comment->comment_description = strip_tags($post->comment_description);
$comment->comment_email = strip_tags($post->comment_email);
$comment->comment_ip = $_SERVER['REMOTE_ADDR'];
$comment->comment_date = date("Y-m-d H:i:s", time());
// Activate comment for now
if ($comment_spam == 1) {
$comment->comment_spam = 1;
$comment->comment_active = 0;
} else {
$comment->comment_spam = 0;
if (Kohana::config('settings.allow_comments') == 1) {
// Auto Approve
$comment->comment_active = 1;
} else {
// Manually Approve
$comment->comment_active = 0;
}
}
$comment->save();
// Notify Admin Of New Comment
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/view/' . $post->incident_id);
} else {
// No! We have validation errors, we need to show the form again, with the errors
// Repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// Populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('comments'));
foreach ($errors as $error_item => $error_description) {
if (!is_array($error_description)) {
$this->error_messages .= $error_description;
if ($error_description != end($errors)) {
$this->error_messages .= " - ";
}
}
//.........这里部分代码省略.........
示例4: add_email
/**
* Adds email to the database and saves the sender as a new
* Reporter if they don't already exist
* @param string $messages
*/
private function add_email($messages)
{
$services = new Service_Model();
$service = $services->where('service_name', 'Email')->find();
if (!$service) {
return;
}
if (empty($messages) || !is_array($messages)) {
return;
}
foreach ($messages as $message) {
$reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message['email'])->find();
if (!$reporter->loaded == true) {
// Add new reporter
$names = explode(' ', $message['from'], 2);
$last_name = '';
if (count($names) == 2) {
$last_name = $names[1];
}
// get default reporter level (Untrusted)
$level = ORM::factory('level')->where('level_weight', 0)->find();
$reporter->service_id = $service->id;
$reporter->level_id = $level->id;
$reporter->service_userid = null;
$reporter->service_account = $message['email'];
$reporter->reporter_first = $names[0];
$reporter->reporter_last = $last_name;
$reporter->reporter_email = $message['email'];
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
}
if ($reporter->level_id > 1 && count(ORM::factory('message')->where('service_messageid', $message['message_id'])->find_all()) == 0) {
// Save Email as Message
$email = new Message_Model();
$email->parent_id = 0;
$email->incident_id = 0;
$email->user_id = 0;
$email->reporter_id = $reporter->id;
$email->message_from = $message['from'];
$email->message_to = null;
$email->message = $message['subject'];
$email->message_detail = $message['body'];
$email->message_type = 1;
// Inbox
$email->message_date = $message['date'];
$email->service_messageid = $message['message_id'];
$email->save();
// Notify Admin Of New Email Message
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_email.subject'), Kohana::lang('notifications.admin_new_email.message'));
}
}
}
示例5: view
//.........这里部分代码省略.........
// No API Key!!
$comment_spam = 0;
}
$comment = new Comment_Model();
$comment->incident_id = 0;
if ($this->user) {
$comment->user_id = $this->user->id;
$comment->comment_author = $this->user->name;
$comment->comment_email = $this->user->email;
} else {
$comment->comment_author = strip_tags($post->comment_author);
$comment->comment_email = strip_tags($post->comment_email);
}
$comment->comment_description = strip_tags($post->comment_description);
$comment->comment_ip = $_SERVER['REMOTE_ADDR'];
$comment->comment_date = date("Y-m-d H:i:s", time());
// Activate comment for now
if ($comment_spam == 1) {
$comment->comment_spam = 1;
$comment->comment_active = 0;
} else {
$comment->comment_spam = 0;
$comment->comment_active = Kohana::config('settings.allow_comments') == 1 ? 1 : 0;
}
$comment->save();
// link comment to sharing_incident
$incident_comment = ORM::factory('sharing_incident_comment');
$incident_comment->comment_id = $comment->id;
$incident_comment->sharing_incident_id = $incident->id;
$incident_comment->save();
// Event::comment_add - Added a New Comment
Event::run('ushahidi_action.comment_add', $comment);
// Notify Admin Of New Comment
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . utf8::strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/sharing/view/' . $id);
// Redirect
url::redirect('reports/sharing/view/' . $id);
} else {
// No! We have validation errors, we need to show the form again, with the errors
// Repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// Populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('comments'));
$form_error = TRUE;
}
}
// Filters
$incident_title = $incident->incident_title;
$incident_description = $incident->incident_description;
Event::run('ushahidi_filter.report_title', $incident_title);
Event::run('ushahidi_filter.report_description', $incident_description);
$this->template->header->page_title .= $incident_title . Kohana::config('settings.title_delimiter');
// Add Features
// hardcode geometries to empty
$this->template->content->features_count = 0;
$this->template->content->features = array();
$this->template->content->incident_id = $incident->id;
$this->template->content->incident_title = $incident_title;
$this->template->content->incident_description = $incident_description;
$this->template->content->incident_location = $incident->location->location_name;
$this->template->content->incident_latitude = $incident->location->latitude;
$this->template->content->incident_longitude = $incident->location->longitude;
$this->template->content->incident_date = date('M j Y', strtotime($incident->incident_date));
$this->template->content->incident_time = date('H:i', strtotime($incident->incident_date));
$this->template->content->incident_category = ORM::factory('sharing_incident_category')->where('sharing_incident_id', $incident->id)->find_all();
// Incident rating
$rating = ORM::factory('rating')->join('incident', 'incident.id', 'rating.incident_id', 'INNER')->where('rating.incident_id', $incident->id)->find();
示例6: add_email
//.........这里部分代码省略.........
return;
}
if (empty($messages) or !is_array($messages)) {
return;
}
foreach ($messages as $message) {
$reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message['email'])->find();
if (!$reporter->loaded == true) {
// Add new reporter
$names = explode(' ', $message['from'], 2);
$last_name = '';
if (count($names) == 2) {
$last_name = $names[1];
}
// get default reporter level (Untrusted)
$level = ORM::factory('level')->where('level_weight', 0)->find();
$reporter->service_id = $service->id;
$reporter->level_id = $level->id;
$reporter->service_account = $message['email'];
$reporter->reporter_first = $names[0];
$reporter->reporter_last = $last_name;
$reporter->reporter_email = $message['email'];
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
}
if ($reporter->level_id > 1 && count(ORM::factory('message')->where('service_messageid', $message['message_id'])->find_all()) == 0) {
// Save Email as Message
$email = new Message_Model();
$email->parent_id = 0;
$email->incident_id = 0;
$email->user_id = 0;
$email->reporter_id = $reporter->id;
$email->message_from = $message['from'];
$email->message_to = null;
$email->message = $message['subject'];
$email->message_detail = $message['body'];
$email->message_type = 1;
// Inbox
$email->message_date = $message['date'];
$email->service_messageid = $message['message_id'];
$email->save();
// Attachments?
foreach ($message['attachments'] as $attachments) {
foreach ($attachments as $attachment) {
$media = new Media_Model();
$media->location_id = 0;
$media->incident_id = 0;
$media->message_id = $email->id;
$media->media_type = 1;
// Images
$media->media_link = $attachment[0];
$media->media_medium = $attachment[1];
$media->media_thumb = $attachment[2];
$media->media_date = date("Y-m-d H:i:s", time());
$media->save();
}
}
// Auto-Create A Report if Reporter is Trusted
$reporter_weight = $reporter->level->level_weight;
$reporter_location = $reporter->location;
if ($reporter_weight > 0 and $reporter_location) {
// Create Incident
$incident = new Incident_Model();
$incident->location_id = $reporter_location->id;
$incident->incident_title = $message['subject'];
$incident->incident_description = $message['body'];
$incident->incident_date = $message['date'];
$incident->incident_dateadd = date("Y-m-d H:i:s", time());
$incident->incident_active = 1;
if ($reporter_weight == 2) {
$incident->incident_verified = 1;
}
$incident->save();
// Update Message with Incident ID
$email->incident_id = $incident->id;
$email->save();
// Save Incident Category
$trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find();
if ($trusted_categories->loaded) {
$incident_category = new Incident_Category_Model();
$incident_category->incident_id = $incident->id;
$incident_category->category_id = $trusted_categories->id;
$incident_category->save();
}
// Add Attachments
$attachments = ORM::factory("media")->where("message_id", $email->id)->find_all();
foreach ($attachments as $attachment) {
$attachment->incident_id = $incident->id;
$attachment->save();
}
}
// Notify Admin Of New Email Message
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_email.subject'), Kohana::lang('notifications.admin_new_email.message'));
// Action::message_email_add - Email Received!
Event::run('ushahidi_action.message_email_add', $email);
}
}
}
示例7: add
/**
* Send The SMS Message Using Default Provider
* @param from mixed The source/sender address
* @param message mixed The text content of the message
* @param to mixed Optional... 'which number the message was sent to'
*/
public static function add($from = NULL, $message = NULL, $to = NULL)
{
$from = preg_replace("#[^0-9]#", "", $from);
$to = preg_replace("#[^0-9]#", "", $to);
if (!$from or !$message) {
return "Missing Sender and/or Message";
}
//Filters to allow modification of the values from the SMS gateway
Event::run('ushahidi_filter.message_sms_from', $from);
Event::run('ushahidi_filter.message_sms', $message);
$services = new Service_Model();
$service = $services->where('service_name', 'SMS')->find();
if (!$service) {
return false;
}
$reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $from)->find();
if (!$reporter->loaded == TRUE) {
// get default reporter level (Untrusted)
$level = ORM::factory('level')->where('level_weight', 0)->find();
$reporter->service_id = $service->id;
$reporter->level_id = $level->id;
$reporter->service_userid = null;
$reporter->service_account = $from;
$reporter->reporter_first = null;
$reporter->reporter_last = null;
$reporter->reporter_email = null;
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
}
// Save Message
$sms = new Message_Model();
$sms->parent_id = 0;
$sms->incident_id = 0;
$sms->user_id = 0;
$sms->reporter_id = $reporter->id;
$sms->message_from = $from;
$sms->message_to = $to;
$sms->message = $message;
$sms->message_type = 1;
// Inbox
$sms->message_date = date("Y-m-d H:i:s", time());
$sms->service_messageid = null;
$sms->save();
// Notify Admin Of New Email Message
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_sms.subject'), Kohana::lang('notifications.admin_new_sms.message'));
// Action::message_sms_add - SMS Received!
Event::run('ushahidi_action.message_sms_add', $sms);
// Auto-Create A Report if Reporter is Trusted
$reporter_weight = $reporter->level->level_weight;
$reporter_location = $reporter->location;
if ($reporter_weight > 0 and $reporter_location) {
$incident_title = text::limit_chars($message, 50, "...", false);
// Create Incident
$incident = new Incident_Model();
$incident->location_id = $reporter_location->id;
$incident->incident_title = $incident_title;
$incident->incident_description = $message;
$incident->incident_date = $sms->message_date;
$incident->incident_dateadd = date("Y-m-d H:i:s", time());
$incident->incident_active = 1;
if ($reporter_weight == 2) {
$incident->incident_verified = 1;
}
$incident->save();
// Update Message with Incident ID
$sms->incident_id = $incident->id;
$sms->save();
// Save Incident Category
$trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find();
if ($trusted_categories->loaded) {
$incident_category = new Incident_Category_Model();
$incident_category->incident_id = $incident->id;
$incident_category->category_id = $trusted_categories->id;
$incident_category->save();
}
}
return TRUE;
}
示例8: add
/**
Function for the administrator to add feeds.
*/
public function add($feedtype = 'rss2')
{
//$this->template->header->this_page = 'feed_add';
$this->template->content = new View('feed_add');
// setup and initialize form field names
$form = array('feed_name' => '', 'feed_url' => '', 'feed_active' => 1, 'feed_category' => 0);
//copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$errors = $form;
$form_error = FALSE;
// check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = Validation::factory(array_merge($_POST, $_FILES));
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('feed_name', 'required', 'length[3,200]');
$post->add_rules('feed_url', 'required');
//$post->add_rules('feed_active', 'required');
$post->add_rules('feed_category', 'required');
// echo " post->feed_active ".(isset($post->feed_active))?"True","FALSE" ;
// exit(0);
// Test to see if things passed the rule checks
if ($post->validate()) {
// STEP 2: SAVE INCIDENT
$feed = new Feed_Model();
$feed->feed_name = $post->feed_name;
$feed->feed_url = $post->feed_url;
$feed->feed_active = isset($post->feed_active) ? 1 : 0;
$feed->category_id = $post->feed_category;
if (ORM::factory('feed')->where('feed_url', $post->feed_url)->count_all() == 0) {
$feed->save();
} else {
$errors['feed_url'] = 'This url is already in the database';
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('report'));
$form_error = TRUE;
}
// Notify Admin Of New Report
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_report.subject'), Kohana::lang('notifications.admin_new_report.message') . "\n\n'" . strtoupper($feed->feed_name) . "'" . "\n" . $feed->feed_url);
// url::redirect('reports/thanks');
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('report'));
$form_error = TRUE;
}
}
$this->template->content->form = $form;
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->categories = $this->_get_categories($form['feed_category']);
$this->template->header->render(TRUE);
$this->template->content->render(TRUE);
$this->template->Render();
}
示例9: add
/**
* ADD The SMS Message Using Default Provider
* @param from mixed The source/sender address
* @param message mixed The text content of the message
* @param to mixed Optional... 'which number the message was sent to'
*/
public static function add($from = NULL, $message = NULL, $to = NULL)
{
$from = preg_replace("#[^0-9]#", "", $from);
$to = preg_replace("#[^0-9]#", "", $to);
if (!$from or !$message) {
return "Missing Sender and/or Message";
}
//Filters to allow modification of the values from the SMS gateway
Event::run('ushahidi_filter.message_sms_from', $from);
Event::run('ushahidi_filter.message_sms', $message);
$services = new Service_Model();
$service = $services->where('service_name', 'SMS')->find();
if (!$service) {
return false;
}
$reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $from)->find();
if (!$reporter->loaded == TRUE) {
// get default reporter level (Untrusted)
$level = ORM::factory('level')->where('level_weight', 0)->find();
$reporter->service_id = $service->id;
$reporter->level_id = $level->id;
$reporter->service_userid = null;
$reporter->service_account = $from;
$reporter->reporter_first = null;
$reporter->reporter_last = null;
$reporter->reporter_email = null;
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
}
// Save Message
$sms = new Message_Model();
$sms->parent_id = 0;
$sms->incident_id = 0;
$sms->user_id = 0;
$sms->reporter_id = $reporter->id;
$sms->message_from = $from;
$sms->message_to = $to;
$sms->message = $message;
$sms->message_type = 1;
// Inbox
$sms->message_date = date("Y-m-d H:i:s", time());
$sms->service_messageid = null;
$sms->save();
// Notify Admin Of New Email Message
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_sms.subject'), Kohana::lang('notifications.admin_new_sms.message'));
// Action::message_sms_add - SMS Received!
Event::run('ushahidi_action.message_sms_add', $sms);
// Auto-Create A Report if Reporter is Trusted
$reporter_weight = $reporter->level->level_weight;
$reporter_location = $reporter->location;
if ($reporter_weight > 0 and $reporter_location) {
$incident_title = text::limit_chars($message, 50, "...", false);
// Create Incident
$incident = new Incident_Model();
$incident->location_id = $reporter_location->id;
$incident->incident_title = $incident_title;
$incident->incident_description = $message;
$incident->incident_date = $sms->message_date;
$incident->incident_dateadd = date("Y-m-d H:i:s", time());
$incident->incident_active = 1;
if ($reporter_weight == 2) {
$incident->incident_verified = 1;
}
$incident->save();
// Update Message with Incident ID
$sms->incident_id = $incident->id;
$sms->save();
// Save Incident Category
$trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find();
if ($trusted_categories->loaded) {
$incident_category = new Incident_Category_Model();
$incident_category->incident_id = $incident->id;
$incident_category->category_id = $trusted_categories->id;
$incident_category->save();
}
}
// Add clickable report back feature.
// Change delimiter to whatever is needed for sending the text aka #
$delimiter = "#";
$token = strtok($message, $delimiter);
$i = 0;
while ($token !== false) {
$str[$i] = $token;
$token = strtok($delimiter);
$i++;
}
// Redirection for mysql server
$php_db = "ranjoat_Ushahidi_Web";
$myphp_db = 'ranjoat_Ushahidi_Web';
// Change these variables to the working database
$addr = "127.0.0.1";
$login = "root";
//.........这里部分代码省略.........
示例10: _save_feed
private function _save_feed($feed_id, $feed_url, $feed_category, $feed_name = "none", $weight)
{
$feedname = $feed_name == "none" ? $feed_url : $feed_name;
if (isset($feed_url) && !empty($feed_url) && $feed_url != '' && $feed_category > 0) {
$feed = new Feed_Model();
//if unique url then create new else update old.
$numItems = ORM::factory('feed')->where('feed_url', $feed_url)->count_all();
if ($numItems == 0 && $feed_id == 0) {
$feed->feed_name = $feedname;
$feed->feed_url = $feed_url;
$feed->weight = $weight;
$feed->category_id = $feed_category;
$feed->save();
} else {
if ($feed_id != 0) {
$db = new Database();
$sql = " UPDATE feed SET feed_url = '" . $feed_url . "' , feed_name = '" . $feedname . "' , weight= " . $weight . "\t";
$sql .= " WHERE id = " . $feed_id;
// echo $sql."<br/>";
$Result = $db->query($sql);
}
}
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_report.subject'), Kohana::lang('notifications.admin_new_report.message') . "\n\n'" . strtoupper($feed->feed_name) . "'" . "\n" . $feed->feed_url);
}
}