Перейти к публикации
View in the app

A better way to browse. Learn more.

Дизайн и модификация Invision Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Запрет на редактирование старых постов

Опубликовано:

Задача такая: оджидается приход двух "фаерволов" на форум, тех, кто набрал много постов и будет обижен. Нужна защита от редактирования пользователями их постов, если эти посты были написаны 30 и более дней назад. Для начала делал без проверки условием - модератор это или нет. Все равно возникли проблемы. 60 секунд - это мало, но тем не менее система даже через несколько секунд выдавала ошибку из too_old_post_for_edit. Не говоря уже про 600, 60000 и т.д. Что я сделал не так?

 

lang_error.php

Добавил

too_old_post_for_edit					=>	"Ваше сообщение устарело и автоматически заблокированно от несанкционированного редактирования. Это вынужденая мера, введенная с целью безопасности.",

post_edit_post.php

Нашел

 // Is the topic locked?

 if ( $this->topic['state'] != 'open' )
 {
	  if ( !$ibforums->member['id'] or !( $ibforums->member['g_post_closed'] and ( $ibforums->member['g_is_supmod'] or $class->moderator['mid'] ) ) )
  {
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
  }
 }

добавил после

		if (time() - $this->orig_post['start_date'] > 60)
	{
		$std->Error( array( LEVEL => 1, MSG => 'too_old_post_for_edit') );
	}

 

П.С. Все это 1.3 <_<

Рекомендованные сообщения

Опубликовано:

В 2.0 вроде уже можно выставить время, в течении которого пользователю разрешено редактировать пост <_>

Опубликовано:
  • Автор

Спасибо. Сейчас посмотрю как там это реализованно <_< Если пойму...

  • 3 недели спустя...
Опубликовано:
В 2.0 вроде уже можно выставить время

не замечал. Как называется переменная?

 

С учётом 2.2 переделал функцию.

 

function check_for_edit( $topic=array() )
{

	//-----------------------------------------
	// Is the topic locked?
	//-----------------------------------------

	if ( ( $topic['state'] != 'open' ) and ( ! $this->ipsclass->member['g_is_supmod'] ) )
	{
		if ( $this->ipsclass->member['g_post_closed'] != 1 )
		{
			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'locked_topic' ) );
		}
	}

	//-----------------------------------------
	// Return OK if we're an admin or mod
	//-----------------------------------------

	if ( $this->ipsclass->member['g_is_supmod'] OR $this->moderator['edit_post'] )
	{
		return TRUE;
	}
	else{
		if($this->orig_post['post_date'] + (30 * 84600) < time()){

			$this->ipsclass->Error( array( 'LEVEL' => '1', 'MSG' => 'too_old_post_for_edit') );
		}
	}
	//-----------------------------------------
	// Continue.
	//-----------------------------------------
	//AND
	if ($this->ipsclass->check_perms( $this->forum['reply_perms'] ) == FALSE)
	{
		$_ok = 0;

		//-----------------------------------------
		// Are we a member who started this topic
		// and are editing the topic's first post?
		//-----------------------------------------

		if ( $this->ipsclass->member['id'] )
		{
			if ( $topic['topic_firstpost'] )
			{
				$_post = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'pid, author_id, topic_id',
				'from'   => 'posts',
				'where'  => 'pid=' . intval( $topic['topic_firstpost'] ) ) );

				if ( $_post['pid'] AND $_post['topic_id'] == $topic['tid'] AND $_post['author_id'] == $this->ipsclass->member['id'] )
				{
					$_ok = 1;
				}
			}
		}

		if ( ! $_ok )
		{
			$this->ipsclass->Error( array( 'LEVEL' => '1', 'MSG' => 'not_op') );
		}
	}
	/*else
	{
	//echo $this->topic['start_date'] + (14 * 84600) ." = ". time();
	//echo "start ".date("F j, Y, g:i a", $this->topic['start_date'] + (14 * 84600))." date= ".date("F j, Y, g:i a",time());

	$this->ipsclass->Error( array( 'LEVEL' => '1', 'MSG' => 'too_old_post_for_edit') );
	}
	*/
}

Опубликовано:

Я вас непонимаю, зачем заново изобретать велосипед? В ipb это уже реализовано начиная с версий 2.0.х, если я не ошибаюсь. Просто надо лучше изучать админцентр.

Идите в управление группами. Далее выберите нужную вам группу и нажмите редактировать. Там вы увидите "В течении скольких минут пользователь может редактировать свои сообщения", или что-то наподобие этого.

Гость
Эта тема закрыта для дальнейших сообщений.

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.