本文整理汇总了PHP中Notifier类的典型用法代码示例。如果您正苦于以下问题:PHP Notifier类的具体用法?PHP Notifier怎么用?PHP Notifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdd
public function actionAdd($isFancy = 0)
{
$model = new Reviews();
if (isset($_POST[$this->modelName])) {
$model->attributes = $_POST[$this->modelName];
if ($model->validate()) {
if ($model->save(false)) {
$model->name = CHtml::encode($model->name);
$model->body = CHtml::encode($model->body);
$notifier = new Notifier();
$notifier->raiseEvent('onNewReview', $model);
if (Yii::app()->user->getState('isAdmin')) {
Yii::app()->user->setFlash('success', tt('success_send_not_moderation'));
} else {
Yii::app()->user->setFlash('success', tt('success_send'));
}
$this->redirect(array('index'));
}
$model->unsetAttributes(array('name', 'body', 'verifyCode'));
} else {
Yii::app()->user->setFlash('error', tt('failed_send'));
}
$model->unsetAttributes(array('verifyCode'));
}
if ($isFancy) {
$this->excludeJs();
$this->renderPartial('add', array('model' => $model), false, true);
} else {
$this->render('add', array('model' => $model));
}
}
示例2: actionAdd
public function actionAdd($isFancy = 0)
{
$model = new Vacancy();
if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
$model->attributes = $_POST[$this->modelName];
if ($model->validate()) {
$model->user_ip = Yii::app()->controller->currentUserIp;
$model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
if ($model->save(false)) {
$model->name = CHtml::encode($model->name);
$model->body = CHtml::encode($model->body);
$notifier = new Notifier();
$notifier->raiseEvent('onNewReview', $model);
if (Yii::app()->user->checkAccess('vacancy_admin')) {
Yii::app()->user->setFlash('success', tt('success_send_not_moderation'));
} else {
Yii::app()->user->setFlash('success', tt('success_send'));
}
$this->redirect(array('index'));
}
$model->unsetAttributes(array('name', 'body', 'verifyCode'));
} else {
Yii::app()->user->setFlash('error', tt('failed_send'));
}
$model->unsetAttributes(array('verifyCode'));
}
if ($isFancy) {
$this->excludeJs();
$this->renderPartial('add', array('model' => $model), false, true);
} else {
$this->render('add', array('model' => $model));
}
}
示例3: getForm
public static function getForm($errors = array())
{
global $cfg;
if (LOGGED) {
redirect(REFERER);
}
$note = new Notifier();
$err = new Error();
if ($errors) {
$note->error($errors);
}
if ($_POST['login'] && $_POST['module']) {
$form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : '');
$err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('The logname you used isn't registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
$err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray());
}
$tpl = new PHPTAL('modules/login/form.html');
$tpl->form = $form;
$tpl->err = $err->toArray();
$tpl->note = $note;
echo $tpl->execute();
}
示例4: getContent
public function getContent()
{
global $sql;
//Lang::load('blocks/shoutbox/lang.*.php');
$err = new Error();
$note = new Notifier('note-shoutbox');
$form['author'] = LOGGED ? User::$nickname : '';
$form['message'] = '';
if (isset($_POST['reply-shoutbox'])) {
$form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
$form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
$err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
$err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
$err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
VALUES (
' . TIMESTAMP . ',
"' . $form['author'] . '",
"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
' . UID . ',
"' . IP . '")');
$sql->clearCache('shoutbox');
$note->success(t('Entry was added successfully.'));
redirect(HREF . PATH . '#shoutbox');
} else {
$note->error($err->toArray());
}
}
// If cache for shoutbox doesn't exists
if (!($entries = $sql->getCache('shoutbox'))) {
$query = $sql->query('
SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
FROM ' . DB_PREFIX . 'shoutbox s
LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
ORDER BY s.id DESC
LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
while ($row = $query->fetch()) {
if ($row['author_id']) {
$row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
$row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
}
$entries[] = $row;
}
$sql->putCacheContent('shoutbox', $entries);
}
try {
$tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
$tpl->entries = $entries;
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
//echo Note::error($e->getMessage());
}
}
示例5: recruitment
public function recruitment()
{
$this->rec_form = new WaxForm();
$this->rec_form->add_element("age", "TextInput");
$this->rec_form->add_element("english_level", "TextInput", array('label' => 'How well do you speak english'));
$this->rec_form->add_element("name", "TextInput", array("label" => "Character Name"));
$this->rec_form->add_element("class", "TextInput", array('label' => "Character Class"));
$this->rec_form->add_element("level", "TextInput", array('label' => "Character Level"));
$this->rec_form->add_element("gear", "TextInput", array("label" => "Average gear level (heroic/naxx10/25/uld10/25)"));
$this->rec_form->add_element("attendance", "TextInput", array("label" => "Can you attend 2 of our weekly planned raids every week"));
$this->rec_form->add_element("talents", "TextareaInput", array("label" => "Your chosen raid talents and why you chose them"));
$this->rec_form->add_element("previous_guild", "TextareaInput", array("label" => "Reason for leaving your previous guild"));
$this->rec_form->add_element("raid_experience", "TextareaInput", array("label" => "Previous raiding experience (which classes have you played in raids, and to what level of raid)"));
$this->rec_form->add_element("internet", "TextareaInput", array("label" => "What kind of internet connection do you have. (Please mention anything about regular lags here)"));
$this->rec_form->add_element("other_members", "TextareaInput", array("label" => "Do you know any other members in Deja Vu and what is your replationship to them"));
$this->rec_form->add_element("about", "TextareaInput", array("label" => "About Yourself"));
$this->rec_form->submit_text = "Apply to Guild";
if ($this->rec_form->save()) {
$notifier = new Notifier();
$notifier->send_recruitment($this->rec_form);
$forum_data_row = array("user_id" => "1", "status" => "0", "forum_id" => "7", "thread" => "0", "parent_id" => "0", "thread_count" => "0", "author" => "Paracetamol", "ip" => "127.0.0.1", "status" => "2", "modifystamp" => time(), "subject" => "Application from " . $this->rec_form->handler->elements['name']->value, "body" => "");
foreach ($this->rec_form as $name => $element) {
$forum_data_row['body'] .= "[b][size=large]" . $element->label . " :[/size][/b]\n" . $element->value . "\n\n";
}
$forum_model = new WaxModel();
$forum_model->table = "phorum_messages";
$forum_model->row = $forum_data_row;
$forum_model->primary_key = "message_id";
$forum_model->save();
$forum_model->thread = $forum_model->message_id;
$forum_model->save();
$this->recruitment_message = 'Thanks for your application, we\'ll get back to your shortly. Please check our <a href="/forum/list.php?7">recruitment forum</a> for an assessment from our members.';
}
}
示例6: getContent
public function getContent()
{
// User is logged in
if (LOGGED) {
$this->subcodename = 'logged';
$tpl = new PHPTAL('blocks/user_panel/logged.html');
$tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
$pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
$tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
return $tpl->execute();
} else {
$err = new Error();
$note = new Notifier('note-user_panel');
$this->subcodename = 'not_logged';
$form = array('logname' => null, 'password' => null);
if ($_POST['login'] && $_POST['user_panel']) {
$form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
$form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
$err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
if ($err->noErrors()) {
redirect('./');
} else {
$note->error($err->toArray());
}
}
$tpl = new PHPTAL('blocks/user_panel/not_logged.html');
$tpl->note = $note;
$tpl->form = $form;
$tpl->err = $err->toArray();
return $tpl->execute();
}
}
示例7: processPayment
public function processPayment(Payments $payment)
{
$payment->status = Payments::STATUS_WAITOFFLINE;
$payment->update(array('status'));
try {
$notifier = new Notifier();
$notifier->raiseEvent('onOfflinePayment', $payment);
} catch (CHttpException $e) {
}
return array('status' => Paysystem::RESULT_OK, 'message' => tt('Thank you! Notification of your payment sent to the administrator.', 'payment'));
}
示例8: registerShutdownHandler
/**
* @param Notifier $notifier
*/
public function registerShutdownHandler(Notifier $notifier)
{
$self = $this;
if (!self::$registerShutdownFlag) {
register_shutdown_function(function () use($notifier, $self) {
if (false != ($lastError = $self->catchLastError())) {
$notifier->reportPhpError($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']);
}
$notifier->flush();
});
self::$registerShutdownFlag = true;
}
}
示例9: testUseTransportToSendMessage
public function testUseTransportToSendMessage()
{
$application = new Application("Test application");
$type = new NotificationType("TEST1");
$n1 = new Notification($type, "Title1", "Message1");
$n2 = new Notification($type, "Title2", "Message2");
$transport = $this->getMock('\\Growler\\Transport');
$transport->expects($this->exactly(2))->method('send');
$transport->expects($this->at(1))->method('send')->with($application, $n1);
$transport->expects($this->at(2))->method('send')->with($application, $n2);
$n = new Notifier($application, $transport);
$n->registerNotification($type);
$n->sendNotification($n1);
$n->sendNotification($n2);
}
示例10: actionData
public function actionData()
{
$this->setActiveMenu('my_data');
$model = $this->loadModel(Yii::app()->user->id);
$agencyUserIdOld = '';
if ($model->type == User::TYPE_AGENT) {
$agencyUserIdOld = $model->agency_user_id;
}
if (preg_match("/null\\.io/i", $model->email)) {
Yii::app()->user->setFlash('error', tt('Please change your email and password!', 'socialauth'));
}
if (isset($_POST[$this->modelName])) {
$model->scenario = 'usercpanel';
$model->attributes = $_POST[$this->modelName];
if ($agencyUserIdOld != $model->agency_user_id) {
if ($model->agency_user_id) {
$agency = User::model()->findByPk($model->agency_user_id);
if ($agency) {
$notifier = new Notifier();
$notifier->raiseEvent('onNewAgent', $model, array('forceEmail' => $agency->email));
} else {
$model->addError('agency_user_id', 'There is no Agency with such ID');
}
}
$model->agent_status = User::AGENT_STATUS_AWAIT_VERIFY;
}
if ($model->save()) {
if ($model->scenario == 'usercpanel') {
Yii::app()->user->setFlash('success', tt('Your details successfully changed.'));
}
$this->redirect(array('index'));
}
}
$this->render('data', array('model' => $model));
}
示例11: __construct
protected function __construct($attrs = null)
{
if (!$this->no_backend) {
if (!$this->table) {
$this->table = strtolower(Inflector::get()->pluralize(get_class($this)));
}
$this->db = DB::instance();
}
if (!$this->no_cache) {
$this->cache = Cache::instance();
}
if (class_exists('\\Notifier')) {
$this->notifier = \Notifier::instance();
}
if (defined('AWS_CONSUMER_KEY') && defined('AWS_CONSUMER_SECRET') && defined('AWS_BUCKET')) {
if (!class_exists('\\Aws\\S3\\S3Client')) {
throw new Exception("AWS S3 packaged is required");
}
$this->s3 = \Aws\S3\S3Client::factory(array('key' => AWS_CONSUMER_KEY, 'secret' => AWS_CONSUMER_SECRET));
}
$this->validator = ValidatorBase::instance();
if ($attrs && is_numeric($attrs)) {
// assume $attrs is id
$this->findOne(array($this->primary_key => $attrs));
} else {
if ($attrs && is_array($attrs)) {
if (!array_key_exists($this->primary_key, $attrs)) {
$this->validate($attrs);
}
// set the attrs
$this->attrs = $attrs;
$this->protectAttrs();
}
}
}
示例12: register
function register(Lesson $lesson)
{
// do something with this Lesson
// now tell someone
$notifier = Notifier::getNotifier();
$notifier->inform("new lesson: cost ({$lesson->cost()})");
}
示例13: createLog
/**
* Create new log entry and return it
*
* Delete actions are automatically marked as silent if $is_silent value is not provided (not NULL)
*
* @param ApplicationDataObject $object
* @param Project $project
* @param DataManager $manager
* @param boolean $save Save log object before you save it
* @return ApplicationReadLog
*/
static function createLog(ApplicationDataObject $object, $workspaces, $action = null, $save = true, $log_data = '')
{
if (is_null($action)) {
$action = self::ACTION_READ;
}
// if
if (!self::isValidAction($action)) {
throw new Error("'{$action}' is not valid log action");
}
// if
try {
Notifier::notifyAction($object, $action, $log_data);
} catch (Exception $ex) {
}
$manager = $object->manager();
if (!$manager instanceof DataManager) {
throw new Error('Invalid object manager');
}
// if
$log = new ApplicationReadLog();
if (logged_user() instanceof Contact) {
$log->setTakenById(logged_user()->getId());
} else {
$log->setTakenById(0);
}
$log->setRelObjectId($object->getObjectId());
$log->setAction($action);
if ($save) {
$log->save();
}
// if
return $log;
}
示例14: actionComplain
public function actionComplain($isFancy = 0)
{
$id = Yii::app()->request->getParam('id', 0);
if (!$id) {
throw404();
}
$model = new $this->modelName();
$modelApartment = Apartment::model()->findByPk($id);
if (!$modelApartment) {
throw404();
}
if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
$model->attributes = $_POST[$this->modelName];
$model->apartment_id = $id;
$model->session_id = Yii::app()->session->sessionId;
$model->user_id = 0;
$model->user_ip = Yii::app()->controller->currentUserIp;
$model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
if (!Yii::app()->user->isGuest) {
$model->email = Yii::app()->user->email;
$model->name = Yii::app()->user->username;
$model->user_id = Yii::app()->user->id;
}
if ($model->validate()) {
if ($this->checkAlreadyComplain($model->apartment_id, $model->user_id, $model->session_id)) {
if ($model->save(false)) {
$notifier = new Notifier();
$notifier->raiseEvent('onNewComplain', $model);
Yii::app()->user->setFlash('success', tt('Thanks_for_complain', 'apartmentsComplain'));
$model = new $this->modelName();
// clear fields
}
} else {
Yii::app()->user->setFlash('notice', tt('your_already_post_complain', 'apartmentsComplain'));
}
}
}
if ($isFancy) {
Yii::app()->clientscript->scriptMap['jquery.js'] = false;
Yii::app()->clientscript->scriptMap['jquery.min.js'] = false;
Yii::app()->clientscript->scriptMap['jquery-ui.min.js'] = false;
$this->renderPartial('complain_form', array('model' => $model, 'apId' => $id, 'isFancy' => true, 'modelApartment' => $modelApartment), false, true);
} else {
$this->render('complain_form', array('model' => $model, 'apId' => $id, 'modelApartment' => $modelApartment, 'wtf' => 'huilo'));
}
}
示例15: register
public function register(Lesson $lesson)
{
// marking registration
// ...
// notify
$notifier = Notifier::getNotifier();
$notifier->inform("new lesson. cost = {$lesson->cost()}");
}