Repository URL to install this package:
|
Version:
3.3.1 ▾
|
<?php
namespace Evsmash\Widgets\Http;
use Evsmash\Core\Http\Base;
use Evsmash\Core\Helpers\Redirect;
use Evsmash\Core\Input\Post;
use Evsmash\Core\Input\Server;
use Evsmash\Core\Services\Mail;
use Evsmash\Core\Services\Recaptcha;
use Evsmash\Core\System\Auth;
use Evsmash\Widgets\Review;
class Reviews extends Base {
// add
public function add() {
// recaptcha
Recaptcha::check();
// validate
Post::validate(new Review);
// add
$item = new Review;
$item->rel = Post::get('rel');
$item->ip = Server::ip();
if(!Auth::check()) {
$item->author = Post::get('author');
}
$item->rate = Post::get('rate');
$item->content = Post::get('content', 'cleanlines');
$item->user_id = Auth::userID();
$item->smash_id = Auth::smashID();
$item->save();
// notify
if(cfg('evsmash-widgets-reviews-notify')) {
// mail
$mail = new Mail;
$mail->template = false;
$mail->title = 'New review';
$mail->title_domain = true;
$mail->msg = t('New review to moderate');
$mail->send(cfg('evsmash-widgets-reviews-notify'));
}
// redirect
Redirect::msg('Review added. I will be visible in a short time.');
Redirect::back();
}
}