TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 343
  • Total: 343

[bugtracker] User cannot edit own article.

Started by freddy888, May 28, 2009, 12:29:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Freddy

I have set up a user with permissions to submit and edit
articles.

The user types in some text and heading etc for their article,
then clicks SAVE.  All well and good.

Then as admin I approve the article and put it in a category.

Then the user goes to their profile and trys to edit the article
but all they get is what looks like an incorrectly formated
form.

Link to my site: offline work using Abyss webserver
SMF version: 1.1.9
TP version: v1.0 beta 4
Theme name and version: Default
Browser Name and Version: Firefox 3, Chrome
Mods installed: None
Related Error messages: n/a

Freddy


G6Cad

When you submit a bug or what you think is a bug, you MUSt follow the posting guidelines.

Setup, forum version, tp version, theme, other mods , language etc...

Freddy

Sorry G6, I did enter the details into Bugtracker - I assumed they would be related here too.  I have ammended my post.

G6Cad


Freddy

#5
Well I spent most of the afternoon on this and found out where I think the problem is.

I monitored the way the database gets updated when admins and normal users submit articles.  By 'normal user' I mean a user that has permission to submit articles but NOT to manage articles.

Both these actions means the article and details get saved in the table called tp_articles:


  • When an admin submits HTML articles the field type is set to undefined/empty.

  • When a normal user submits HTML articles the field type is set to 'html'

So you can see there are two conflicting methods here of identifying an article type and that is what is causing the problem.

All of the code I have examined that deal with article submission and editing assume that if the field type is empty then it must be an HTML article.  This is how it seems to me that the whole thing is currently set up to work.

But because when a normal user submits an article and the field type gets set to 'html' it means it gets ignored by the system.  So this means the user cannot edit the html article and the admin cannot edit the article fully either.

The only bit of code I can find that explicitly checks for the field type to be 'html' is in:

Themes\default\TPmodules.template.php on line 78 :

if($context['TPortal']['allow_wysiwyg'] && $mg['articletype']=='html')

All that does is allow the normal user to turn on and off the WYSIWYG editor - which you can do anyway in Profile->Articles->settings tab. So not much use for that really I suppose.  I mention this because my fix will mean that option will not show up when you are editing the article.  Not a problem for me because the whole form wasn't working anyway.

But yeah, there's a few ways I can see to fix this , but I decided on one with less changes to the actual code. Edit : See my post after this one for a better fix...

So anyway, in this file :

Sources\TPmodules.php

There is the code that handles submitted articles by normal users.  The code in question starts around line 594.

What I have done is to detect if the article is type 'html', then if it is I empty the variable that holds it so that when the database gets set the type field will be empty.  This in turn will mean that the article will now get recognised globally as being HTML by the existing code.

Sooo...after line 603 I did this :

      $arttype = isset($_POST['submittedarticle']) ? $_POST['submittedarticle'] : '';
      if ($arttype == 'html') {$arttype = '';}
      $arts=strip_tags($_POST['tp_article_title']);

The bold bit is the bit you need to add in there.  This works for me.  Note that $arrtype='' is TWO single quotes not one double quote...

Freddy

#6
Just found a better fix and probably more elegant is to look in :

Themes\default\TPmodules.template.php

Find line 408:

<input name="submittedarticle" type="hidden" value="', isset($context['TPortal']['submitbbc']) ? 'bbc' : 'html' , '">

Replace with :

<input name="submittedarticle" type="hidden" value="', isset($context['TPortal']['submitbbc']) ? 'bbc' : '' , '">

ie, remove html from within the quotes at the end.

Same effect but this just intercepts it earlier and sends the 'correct' data from there.

Note: you only need one of these fixes, I think this one is better really.

This also fixes this bug which was stopping the admin editing a submission in full:

http://www.tinyportal.net/index.php/topic,29779.0.html

Hopefully this will make sense to someone.

IchBin

I just tested this in the latest beta. I didn't have a problem with a user being able to edit their own article. I'm betting we can mark this one solved?

bloc

Actually, it is now yes. ;D I've just gone through today the whole process and fixed whats non-logical and what had actual errors.

For example:
- if a user isn't allowed to edit their own article, the image quicklist will not appear(since it depends on the quicklist to be populated byt he upload, but the user get just the "thanks" screen.)
- if a user CAN edit their own article, they can do so even before its approved, but NOT when the article is locked or their "edit own article" permission is revoked. This also now saves any image quicklist uploads, so the user can use that feature. Still the approved state will decide if its shown or not.
- BBC editor too is now working in SMF2.0 RC2 version.

Freddy

Cool  :)  I remember having a lot of fun with that one  ;D

This website is proudly hosted on Crocweb Cloud Website Hosting.