示例#1
0
 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
0
 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
0
 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
0
    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
0
 public function notifiy(SystemEvent $e)
 {
     if ($e->severity >= $this->minSeverity) {
         return $this->wrapped->notifiy($e);
     }
     return false;
 }
示例#6
0
 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.';
     }
 }
示例#7
0
 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();
     }
 }
示例#8
0
 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'));
 }
示例#9
0
 /**
  * PHP shutdown handler that notifies Airbrake about shutdown. Should be
  * used with register_shutdown_function.
  */
 public function onShutdown()
 {
     $error = error_get_last();
     if ($error === null) {
         return;
     }
     if ($error['type'] & error_reporting() === 0) {
         return;
     }
     $exc = new Errors\Fatal($error['message'], debug_backtrace());
     $this->notifier->notify($exc);
 }
 /**
  * @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;
     }
 }
示例#11
0
 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);
 }
示例#12
0
 /**
  * Run notification process through a chain
  * @param string $message
  * @param array $sentEmails
  * @return array
  */
 public function handle($message, $sentEmails = [])
 {
     $emailsToSend = $this->getEmailsToSend();
     $sent = [];
     foreach ($emailsToSend as $email) {
         if (!in_array($email, $sentEmails, true)) {
             $this->notify($email, $message);
             $sent[] = $email;
         }
     }
     $sentEmails = array_merge($sentEmails, $sent);
     if (!is_null($this->successor)) {
         return $this->successor->handle($message, $sentEmails);
     }
     return $sentEmails;
 }
示例#13
0
 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));
 }
示例#14
0
文件: Base.php 项目: ultractiv/lean
 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();
         }
     }
 }
示例#15
0
 function register(Lesson $lesson)
 {
     // do something with this Lesson
     // now tell someone
     $notifier = Notifier::getNotifier();
     $notifier->inform("new lesson: cost ({$lesson->cost()})");
 }
 /**
  * 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;
 }
示例#17
0
 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'));
     }
 }
示例#18
0
 public function register(Lesson $lesson)
 {
     // marking registration
     // ...
     // notify
     $notifier = Notifier::getNotifier();
     $notifier->inform("new lesson. cost = {$lesson->cost()}");
 }
示例#19
0
 public function __construct($url, $token, $room, $prefix = null, $spamTimeout = 60, $icons = [])
 {
     parent::__construct($spamTimeout);
     self::$url = $url;
     self::$token = $token;
     self::$room = $room;
     self::$prefix = $prefix;
     self::$icons = $icons + ['sad' => ':thumbsdown:', 'smile' => ':thumbsup::sparkles:', 'error' => ':thumbsdown::shit:'];
 }
示例#20
0
 /**
  * Handle on add comment event
  *
  * @param Comment $comment
  * @return null
  */
 function onAddComment(Comment $comment)
 {
     try {
         Notifier::newMessageComment($comment);
     } catch (Exception $e) {
         // nothing here, just suppress error...
     }
     // try
 }
 /**
  * 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 ApplicationLog
  */
 static function createLog($object, $action = null, $is_private = false, $is_silent = null, $save = true, $log_data = '')
 {
     $args = array('action' => &$action, 'is_private' => &$is_private, 'is_silent' => &$is_silent, 'save' => &$save, 'log_data' => &$log_data);
     /**
      * Modify log and notification parameters before creating the application log registry
      */
     Hook::fire('application_logs_create', $object, $args);
     if (is_null($action)) {
         $action = self::ACTION_ADD;
     }
     // if
     if (!self::isValidAction($action)) {
         throw new Error("'{$action}' is not valid log action");
     }
     // if
     if ($object instanceof TemplateTask || $object instanceof TemplateMilestone) {
         $is_silent = true;
     }
     if (is_null($is_silent)) {
         $is_silent = $action == self::ACTION_DELETE;
     } else {
         $is_silent = (bool) $is_silent;
     }
     // if
     if (!$is_silent) {
         try {
             Notifier::notifyAction($object, $action, $log_data);
         } catch (Exception $ex) {
             Logger::log($ex->getMessage());
         }
     }
     $log = new ApplicationLog();
     if (logged_user() instanceof Contact) {
         $log->setTakenById(logged_user()->getId());
     } else {
         $log->setTakenById(0);
     }
     if ($object instanceof ContentDataObject) {
         $log->setRelObjectId($object->getObjectId());
         $log->setObjectName($object->getObjectName());
     }
     if ($object instanceof Member) {
         $log->setMemberId($object->getId());
         $log->setRelObjectId($object->getObjectId());
         $log->setObjectName($object->getName());
     }
     $log->setAction($action);
     $log->setIsPrivate($is_private);
     $log->setIsSilent($is_silent);
     $log->setLogData($log_data);
     if ($save) {
         $log->save();
     }
     // if
     return $log;
 }
 /**
  * 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, $is_private = false, $is_silent = 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 User) {
         $log->setTakenById(logged_user()->getId());
     } else {
         $log->setTakenById(0);
     }
     $log->setRelObjectId($object->getObjectId());
     $log->setRelObjectManager(get_class($manager));
     $log->setAction($action);
     if ($save) {
         $log->save();
     }
     // if
     if ($save) {
         if ($workspaces instanceof Project) {
             $wo = new WorkspaceObject();
             $wo->setObject($log);
             $wo->setWorkspace($workspaces);
             $wo->save();
         } else {
             if (is_array($workspaces)) {
                 foreach ($workspaces as $w) {
                     if ($w instanceof Project) {
                         $wo = new WorkspaceObject();
                         $wo->setObject($log);
                         $wo->setWorkspace($w);
                         $wo->save();
                     }
                 }
             }
         }
     }
     return $log;
 }
示例#23
0
 public function __construct($url, $settings = [], $prefix = null, $attachment = [], $spamTimeout = 60)
 {
     if (!class_exists('\\Maknz\\Slack\\Client')) {
         $message = 'Class \\Maknz\\Slack\\Client does not exist. Are you sure you have installed it? i.e. composer require "maknz/slack"';
         throw new \Exception($message);
     }
     parent::__construct($spamTimeout);
     self::$url = $url;
     self::$prefix = $prefix;
     self::$settings = $settings + ['username' => 'Behat', 'channel' => '#general', 'link_names' => true, 'icon' => ':fire:'];
     self::$attachment = $attachment + ['fallback' => 'Behat test failed', 'text' => '', 'pretext' => '', 'color' => 'danger', 'fields' => array()];
 }
示例#24
0
 public function actionMainform($isFancy = 0)
 {
     $model = new SimpleformModel();
     $model->scenario = 'forrent';
     if (isset($_POST['SimpleformModel']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
         $request = Yii::app()->request;
         $isForBuy = $request->getPost('isForBuy', 0);
         $model->attributes = $_POST['SimpleformModel'];
         if ($isForBuy) {
             $model->scenario = 'forbuy';
         }
         if ($model->validate()) {
             if (!$isForBuy) {
                 $model->time_inVal = $this->getI18nTimeIn($model->time_in);
                 $model->time_outVal = $this->getI18nTimeOut($model->time_out);
             }
             $types = Apartment::getI18nTypesArray();
             $model->type = $types[$model->type];
             $notifier = new Notifier();
             if (!$isForBuy) {
                 $notifier->raiseEvent('onNewSimpleBookingForRent', $model);
             } else {
                 $notifier->raiseEvent('onNewSimpleBookingForBuy', $model);
             }
             Yii::app()->user->setFlash('success', tt('Operation successfully complete. Your order will be reviewed by administrator.'));
         }
     }
     $user = null;
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
     }
     $type = Apartment::getTypesWantArray();
     if ($isFancy) {
         $this->excludeJs();
         $this->renderPartial('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => true), false, true);
     } else {
         $this->render('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => false));
     }
 }
示例#25
0
 public function run()
 {
     Yii::import('application.modules.contactform.models.ContactForm');
     $model = new ContactForm();
     $model->scenario = 'insert';
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if (!Yii::app()->user->isGuest) {
             $model->email = Yii::app()->user->email;
             $model->username = Yii::app()->user->username;
         }
         if ($model->validate()) {
             $notifier = new Notifier();
             $notifier->raiseEvent('onNewContactform', $model);
             Yii::app()->user->setFlash('success', tt('Thanks_for_message', 'contactform'));
             $model = new ContactForm();
             // clear fields
         } else {
             $model->unsetAttributes(array('verifyCode'));
             Yii::app()->user->setFlash('error', tt('Error_send', 'contactform'));
         }
     }
     $this->render('widgetContactform', array('model' => $model));
 }
	/**
	 * 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 ApplicationLog
	 */
	static function createLog($object, $action = null, $is_private = false, $is_silent = null, $save = true, $log_data = '') {
		if(is_null($action)) {
			$action = self::ACTION_ADD;
		} // if
		if(!self::isValidAction($action)) {
			throw new Error("'$action' is not valid log action");
		} // if

		if(is_null($is_silent)) {
			$is_silent = $action == self::ACTION_DELETE;
		} else {
			$is_silent = (boolean) $is_silent;
		} // if

		if (!$is_silent) {
			try {
				Notifier::notifyAction($object, $action, $log_data);
			} catch (Exception $ex) {
				Logger::log($ex->getMessage());
			}
		}
		
		$log = new ApplicationLog();
		if (logged_user() instanceof Contact) {
			$log->setTakenById(logged_user()->getId());
		} else {
			$log->setTakenById(0);
		}
		if ($object instanceof ContentDataObject) {
			$log->setRelObjectId($object->getObjectId());
			$log->setObjectName($object->getObjectName());
		}
		if ($object instanceof Member) {
			$log->setRelObjectId($object->getId());
			$log->setObjectName($object->getName());
		}
		
		$log->setAction($action);
		$log->setIsPrivate($is_private);
		$log->setIsSilent($is_silent);
		$log->setLogData($log_data);
		
		if($save) {
			$log->save();
		} // if
		
		return $log;
	} // createLog
示例#27
0
 function handleLogin($user, $pass, $ip)
 {
     switch (rand(1, 3)) {
         case 1:
             $this->setStatus(self::LOGIN_ACCESS, $user, $ip);
             $ret = true;
             break;
         case 2:
             $this->setStatus(self::LOGIN_WRONG_PASS, $user, $ip);
             $ret = false;
             break;
         case 3:
             $this->setStatus(self::LOGIN_USER_UNKNOWN, $user, $ip);
             $ret = false;
             break;
     }
     Logger::logIP($user, $ip, $this->getStatus());
     if (!$ret) {
         Notifier::mailWarning($user, $ip, $this->getStatus());
     }
     return $ret;
 }
 public function getTwilio($number, $message)
 {
     return Notifier::sendTwilio($number, $message);
 }
示例#29
0
function send_notifications_through_cron()
{
    _log("Sending notifications...");
    $count = Notifier::sendQueuedEmails();
    _log("{$count} notifications sent.");
}
 public function __construct()
 {
     parent::__construct();
     $this->subCommands = array();
     $this->initializeMacroCommand();
 }