/**
  * @covers ::get
  */
 public function testGet()
 {
     $mockdb = new \TMT\MockDB();
     $mockdb->expectPrepare("SELECT * FROM notifications WHERE guid=:guid");
     $mockdb->expectExecute(array(':guid' => "guid1"));
     $mockdb->setReturnData(array((object) array("guid" => "guid1", "timestamp" => "2000-01-01 00:00:00", "message" => "message", "area" => "areaguid", "type" => "type1")));
     $expected = new \TMT\model\Notification(array("guid" => "guid1", "timestamp" => "2000-01-01 00:00:00", "message" => "message", "area" => "areaguid", "type" => "type1"));
     $accessor = new Notification($mockdb);
     $actual = $accessor->get("guid1");
     $this->assertEquals($expected, $actual);
     $mockdb->verify();
 }
Esempio n. 2
0
 public function testNotification()
 {
     $event = new WelcomeEvent("Welcome!", $this->player);
     $this->notification = Notification::newNotification($this->player->getId(), Events::WELCOME, $event);
     $this->assertEquals($event, $this->notification->getEvent());
     $this->assertEquals(Events::WELCOME, $this->notification->getCategory());
     $this->assertEquals($this->player->getId(), $this->notification->getReceiver()->getId());
     $this->assertFalse($this->notification->isRead());
     $this->notification->markAsRead();
     $this->assertTrue($this->notification->isRead());
     // Refresh the notification from the database
     $this->notification = Notification::get($this->notification->getId());
     $this->assertTrue($this->notification->isRead());
 }
Esempio n. 3
0
 /**
  * Replace the default $this->load->view() method
  * with our own, so we can use Smarty!
  *
  * This method works identically to CI's default method,
  * in that you should pass parameters to it in the same way.
  *
  * @access  public
  * @param   string  The template path name.
  * @param   array   An array of data to convert to variables.
  * @param   bool    Set to TRUE to return the loaded template as a string.
  * @return  mixed   If $return is TRUE, returns string. If not, returns void.
  */
 public function view($template, $data = array(), $return = false)
 {
     //Assign notifications to view data aswell
     $data["notification"] = Notification::get();
     // Get the CI super object, load related library.
     $CI =& get_instance();
     $CI->load->library('smartytpl');
     // Add extension to the filename if it's not there.
     $ext = '.' . $CI->config->item('smarty_template_ext');
     if (substr($template, -strlen($ext)) !== $ext) {
         $template .= $ext;
     }
     // Make sure the file exists first.
     if (!$CI->smartytpl->templateExists($template)) {
         show_error('Unable to load the template file: ' . $template);
     }
     // Assign any variables from the $data array.
     $CI->smartytpl->assign_variables($data);
     // Assign CI instance to be available in templates as $ci
     $CI->smartytpl->assignByRef('ci', $CI);
     /*
         Smarty has two built-in functions to rendering templates: display()
         and fetch(). We're going to use only fetch(), since we want to take
         the template contents and either return them or add them to
         CodeIgniter's output class. This lets us optionally take advantage
         of some of CI's built-in output features.
     */
     $output = $CI->smartytpl->fetch($template);
     /*
         Reset notification class
     */
     Notification::reset();
     // Return the output if the return value is TRUE.
     if ($return === true) {
         return $output;
     }
     // Otherwise append to output just like a view.
     $CI->output->append_output($output);
 }
Esempio n. 4
0
?tag=<?php 
        echo Notification::get('tag');
    }
    ?>
"><?php 
    echo $parent_page['title'];
    ?>
</a>&nbsp;<span>&rarr;</span>&nbsp;<a href="<?php 
    echo Site::url() . $page['parent'] . '/' . $page['slug'];
    ?>
"><?php 
    echo $page['title'];
    ?>
</a>
<?php 
} else {
    ?>
    <a href="<?php 
    echo Site::url() . "/" . $page['slug'];
    if (Notification::get('tag')) {
        ?>
?tag=<?php 
        echo Notification::get('tag');
    }
    ?>
"><?php 
    echo $page['title'];
    ?>
</a>
<?php 
}
Esempio n. 5
0
        </div>

        <div class="install-block <?php 
if (Request::get('action') && Request::get('action') == 'install') {
} else {
    ?>
 hide <?php 
}
?>
">

            <ul class="list-unstyled">
            <?php 
// Monstra Notifications
if (Notification::get('errors') && count(Notification::get('errors') > 0)) {
    foreach (Notification::get('errors') as $error) {
        ?>
                 <li class="error alert alert-danger"><?php 
        echo $error;
        ?>
</li>
            <?php 
    }
}
?>
            </ul>

        <div class="well">
            <form action="install.php?action=install" method="post">
                <input type="hidden" name="php" value="<?php 
echo $errors['php'];
 */
require_once "init.inc.php";
if (defined("NOTIFICATIONS_ACTIVE") && NOTIFICATIONS_ACTIVE) {
    require_once "Models/notifications/NotificationUser.class.php";
    require_once "Models/notifications/Notification.class.php";
    $query = "SELECT `nuser_id` FROM `notification_users` \n\t\t\t\tWHERE `next_notification_date` <> 0 \n\t\t\t\tAND `next_notification_date` < " . $db->qstr(time()) . "\n\t\t\t\tAND `notify_active` = 1";
    $nuser_ids = $db->GetAll($query);
    if ($nuser_ids) {
        foreach ($nuser_ids as $nuser_id) {
            $nuser_id = $nuser_id["nuser_id"];
            $notification_user = NotificationUser::getByID($nuser_id);
            if ($notification_user) {
                $query = "SELECT `notification_id` FROM `notifications` \n\t\t\t\t\t\t\tWHERE `nuser_id` = " . $db->qstr($nuser_id) . "\n\t\t\t\t\t\t\tAND `sent` = 0";
                $notification_ids = $db->GetAll($query);
                if ($notification_ids) {
                    if ($notification_user->getDigestMode()) {
                        $notification = Notification::addDigest($nuser_id);
                        $notification->send();
                    } else {
                        foreach ($notification_ids as $notification_id) {
                            $notification_id = $notification_id["notification_id"];
                            $notification = Notification::get($notification_id);
                            $notification->send();
                        }
                    }
                }
                $notification_user->clearNextNotificationDate();
            }
        }
    }
}
Esempio n. 7
0
 /**
  * Pushes or emails a new notification to the user
  *
  * @param array $event The event data we received from the web server
  */
 private function onNotificationServerEvent($event)
 {
     $notification = \Notification::get($event->data->notification);
     // Whether we've notified that player in real time - if he isn't online
     // at the moment, we'll send an e-mail to him
     $active = false;
     foreach ($this->clients as $client) {
         if ($client->Player->getId() == $event->data->receiver) {
             $this->send($client, $event);
             $active = true;
         }
     }
     if (!$active) {
         $player = $notification->getReceiver();
         $this->log("<fg=green>E-mailing player {$player->getId()} ({$player->getUsername()})</>");
         $this->subscriber->emailNotification($notification);
     }
 }
echo Form::label('page_keywords', __('Keywords', 'pages')) . Form::input('page_keywords', $keywords_to_edit, array('class' => 'form-control'));
?>
        </div>
        <div class="form-group">
        <?php 
echo Form::label('page_description', __('Description', 'pages')) . Form::textarea('page_description', $description_to_edit, array('class' => 'form-control'));
?>
        </div>
        <div class="form-group">
        <?php 
echo Form::label('robots', __('Search Engines Robots', 'pages')) . Html::br(1) . 'no Index' . Html::nbsp() . Form::checkbox('robots_index', 'index', $post_robots_index) . Html::nbsp(2) . 'no Follow' . Html::nbsp() . Form::checkbox('robots_follow', 'follow', $post_robots_follow);
?>
        </div>
    </div>
    <div class="tab-pane <?php 
if (Notification::get('settings')) {
    ?>
active<?php 
}
?>
" id="settings">        
            <?php 
if (Request::get('name') == 'error404') {
    echo Form::hidden('pages', $parent_page);
} else {
    ?>
            <div class="form-group">
            <?php 
    echo Form::label('pages', __('Parent', 'pages')) . Form::select('pages', $pages_array, $parent_page, array('class' => 'form-control'));
    ?>
            </div>
Action::run('admin_header');
?>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
      <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
    <![endif]-->
    </head>
    <body class="login-body">

        <?php 
// Monstra Notifications
Notification::get('success') and Alert::success(Notification::get('success'));
Notification::get('warning') and Alert::warning(Notification::get('warning'));
Notification::get('error') and Alert::error(Notification::get('error'));
?>

        <div class="container form-signin">

            <div class="text-center"><a class="brand" href="<?php 
echo Option::get('siteurl');
?>
/admin"><img src="<?php 
echo Option::get('siteurl');
?>
/public/assets/img/monstra-logo-256px.png" alt="monstra" /></a></div>
            <div class="administration-area well">
                <div>
                    <form method="post">
                        <div class="form-group">
Esempio n. 10
0
<?php

require_once "../initialize.php";
$html = "";
if ($session->is_logged_in()) {
    if (isset($_GET['touserid'])) {
        $notifications = Notification::get($session->user_id);
        if (count($notifications) > 0) {
            foreach ($notifications as $notification) {
                $user = User::get_by_id($notification->fromuserid);
                if ($user) {
                    $html .= "<tr>";
                    $html .= "  <td style='width:50px;'>";
                    $html .= "  \t<img style='height:50px;' src='data:image/jpeg;base64, " . $user->picture . "' />";
                    $html .= "  </td>";
                    $html .= "  <td>";
                    $title = "";
                    $done = false;
                    if ($notification->itemtype == "friend") {
                        $title = "Friend Request";
                        $friendobject = Friend::get_by_id($notification->itemid);
                        if (!$friendobject) {
                            $notification->delete();
                            continue;
                        } else {
                            if ($friendobject->pending == 0) {
                                $done = true;
                            }
                        }
                    } else {
                        if ($notification->itemtype == "schooluser" && $notification->pending == 1) {
Esempio n. 11
0
				<div id="sidebar" class="left">
					<ul>
						<li class="selected-option"><a href="./">Recent Activity</a></li>
						<li><a href="friend-requests.php">Friend Requests</a></li>
						<li><a href="my-friends.php">Friends</a></li>
						<li><a href="search.php">Search</a></li>
					</ul>
				</div>
				<div id="main-container" class="page">
					<h2 class="title">Recent Activity</h2>
					<?php 
    include 'includes/alerts.php';
    ?>
					<?php 
    $activity = new Notification();
    if ($activity->get($user->data()->id)) {
        $notifications = $activity->notifications();
        ?>
						<?php 
        foreach ($notifications as $notification) {
            ?>
							<div class="notification">
								<div class="picture">
									<a href="profile.php?user=<?php 
            echo $notification['username'];
            ?>
"><img src="<?php 
            echo $notification['profilePicture'];
            ?>
"></a>
								</div>
<div class="row">	
	<div class="col-md-12">		
	    <?php 
// Monstra Notifications
$error = Notification::get('error') ?: '';
$error != '' and print '<div class="error margin-bottom-1">' . $error . '</div>';
?>
    </div>
</div>
<div class="row">	
	<div class="col-md-3">
		<form method="post">
		    <?php 
echo Form::hidden('csrf', Security::token());
?>
		    <div class="form-group">
		    	<label><?php 
echo __('Username', 'users');
?>
</label>
		    	<input name="username" type="text" class="form-control">
		    </div>    
		    <div class="form-group">
			    <label><?php 
echo __('Password', 'users');
?>
</label>
			    <input name="password" type="password" class="form-control">
			</div>
			<div class="form-group">
				<input name="login_submit" class="btn btn-primary" type="submit" value="<?php 
<div class="row">	
	<div class="col-md-12">		
	    <?php 
// Monstra Notifications
$success = Notification::get('success') ?: '';
$success != '' and print '<div class="success margin-bottom-1">' . $success . '</div>';
?>
    </div>
</div>
<div class="row">
	<div class="col-md-3">
		<form method="post">

		<?php 
echo Form::hidden('csrf', Security::token());
?>

		<div class="form-group">
			<label><?php 
echo __('Username', 'users');
?>
</label>
			<input type="text" value="<?php 
echo $user_login;
?>
" name="login" class="form-control">
			<?php 
if (isset($errors['users_user_doesnt_exists'])) {
    echo Html::nbsp(3) . '<span class="error">' . $errors['users_user_doesnt_exists'] . '</span>';
}
if (isset($errors['users_empty_field'])) {
Esempio n. 14
0
			if(empty($error_msg)){
				goBack();
			}

		}else{
			$error_msg .= "Error adding Notification!\n";
			debug_message($notification->getLastError());
		}
	}
}else if($_REQUEST['mode'] == 'edit'){
	$title = "Edit Notification";
	if(empty($_REQUEST['id'])){
		$error_msg .= "Error: No ID specified!\n";
	}else{
		if(!$notification->get($_REQUEST['id'])){
			$error_msg .= "Error retrieving notification information!\n";
			debug_message($notification->getLastError());
		}
	}

	if($_POST['save']){
		$notification->updateFromAssocArray($_POST);
		if($notification->update()){
			if(!empty($_POST['new_address'])){
				if($notification->addAddress($_POST['new_address']) === FALSE){
					$error_msg .= "Error adding new address to notification!";
					debug_message($notification->getLastError());
				}
			}