phpBB

Code Changes

File: phpbb/notification/type/post.php

  Unmodified   Added   Modified   Removed
Line 50Line 50
	* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id', 'lang', and 'group')
*/

	* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id', 'lang', and 'group')
*/

	public static $notification_option = array(

	static public $notification_option = array(

		'lang'	=> 'NOTIFICATION_TYPE_POST',
'group' => 'NOTIFICATION_GROUP_POSTING',
);

		'lang'	=> 'NOTIFICATION_TYPE_POST',
'group' => 'NOTIFICATION_GROUP_POSTING',
);

 

/** @var \phpbb\user_loader */
protected $user_loader;

/** @var \phpbb\config\config */
protected $config;

public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}

public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}


/**
* Is available


/**
* Is available

Line 67Line 83
	* Get the id of the item
*
* @param array $post The data from the post

	* Get the id of the item
*
* @param array $post The data from the post

 
	* @return int The post id

	*/

	*/

	public static function get_item_id($post)

	static public function get_item_id($post)

	{
return (int) $post['post_id'];
}

	{
return (int) $post['post_id'];
}

Line 77Line 94
	* Get the id of the parent
*
* @param array $post The data from the post

	* Get the id of the parent
*
* @param array $post The data from the post

 
	* @return int The topic id

	*/

	*/

	public static function get_item_parent_id($post)

	static public function get_item_parent_id($post)

	{
return (int) $post['topic_id'];
}

	{
return (int) $post['topic_id'];
}

Line 131Line 149
		}

// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications

		}

// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications

		$update_notifications = array();
$sql = 'SELECT n.*
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))

		$notified_users = $this->notification_manager->get_notified_users($this->get_type(), array(
'item_parent_id' => static::get_item_parent_id($post),
'read' => 0,
));

foreach ($notified_users as $user => $notification_data)





		{

		{

			// Do not create a new notification
unset($notify_users[$row['user_id']]);

			unset($notify_users[$user]);






			$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);


			/** @var post $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);

			$update_responders = $notification->add_responders($post);
if (!empty($update_responders))
{

			$update_responders = $notification->add_responders($post);
if (!empty($update_responders))
{

				$sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
WHERE notification_id = ' . $row['notification_id'];
$this->db->sql_query($sql);


				$this->notification_manager->update_notification($notification, $update_responders, array(
'item_parent_id' => self::get_item_parent_id($post),
'read' => 0,
'user_id' => $user,
));

			}
}

			}
}

		$this->db->sql_freeresult($result);

 

return $notify_users;
}


return $notify_users;
}

Line 165Line 179
	*/
public function get_avatar()
{

	*/
public function get_avatar()
{

		return $this->user_loader->get_avatar($this->get_data('poster_id'));

		return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true);

	}

/**

	}

/**

Line 206Line 220

if ($trimmed_responders_cnt > 20)
{


if ($trimmed_responders_cnt > 20)
{

			$usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS');

			$usernames[] = $this->language->lang('NOTIFICATION_MANY_OTHERS');

		}
else if ($trimmed_responders_cnt)
{

		}
else if ($trimmed_responders_cnt)
{

			$usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt);

			$usernames[] = $this->language->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt);

		}


		}


		return $this->user->lang(

		return $this->language->lang(

			$this->language_key,
phpbb_generate_string_list($usernames, $this->user),
$responders_cnt

			$this->language_key,
phpbb_generate_string_list($usernames, $this->user),
$responders_cnt

Line 227Line 241
	*/
public function get_reference()
{

	*/
public function get_reference()
{

		return $this->user->lang(

		return $this->language->lang(

			'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);

			'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);

Line 357Line 371
		{
$tracking_data[$row['user_id']] = $row['mark_time'];
}

		{
$tracking_data[$row['user_id']] = $row['mark_time'];
}

 
		$this->db->sql_freeresult($result);


return $tracking_data;
}

/**


return $tracking_data;
}

/**

	* Function for preparing the data for insertion in an SQL query
* (The service handles insertion)
*
* @param array $post Data from submit_post
* @param array $pre_create_data Data from pre_create_insert_array()
*
* @return array Array of data ready to be inserted into the database

	* {@inheritdoc}







	*/
public function create_insert_array($post, $pre_create_data = array())
{

	*/
public function create_insert_array($post, $pre_create_data = array())
{

Line 393Line 402
			$this->notification_read = true;
}


			$this->notification_read = true;
}


		return parent::create_insert_array($post, $pre_create_data);

		parent::create_insert_array($post, $pre_create_data);

	}

/**
* Add responders to the notification
*
* @param mixed $post

	}

/**
* Add responders to the notification
*
* @param mixed $post

 
	* @return array Array of responder data

	*/
public function add_responders($post)
{

	*/
public function add_responders($post)
{

Line 446Line 456
			return array();
}


			return array();
}


		return array('notification_data' => $serialized_data);







		$data_array = array_merge(array(
'post_time' => $post['post_time'],
'post_id' => $post['post_id'],
'topic_id' => $post['topic_id']
), $this->get_data(false));

return $data_array;

	}
}


	}
}