HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


"Close Topic"

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#77862 (In Topic #15998)
Avatar

Community saint

At least in my 'for sale' section, I want users to be able to close their own topics.   I found the global permission for 'allow user to close their own topics'…   set that for everyone.   Reset all the caches.

I don't see an option (when logged on as a test user account)…  guessing it would be in the drop down box below the message like it is when I am on as admin.   But it's not there.

I checked the site tree editor and forum editor, and don't see that as something available, so wondering if I am just missing something, or if perhaps it just wasn't implemented.

Thanks
Paul

Paul
Back to the top
 
Posted
Rating:
#77870
Avatar

Community saint

I have looked in viewtopic.php, and found the code that looks like it should allow the 'close topic' option for users around like 600.    

That looked ok, so I worked backwards and found ocf_read_in_topic where it get's the information used in the stuff I mentioned above.

That function is in ocf_topicview.php … and it looks ok there as well:

Code

if (($topic_info['t_cache_first_member_id']==get_member()) && (has_specific_permission(get_member(),'close_own_topics')) && ($topic_info['t_is_open']==0))
         {
            $out['may_close_topic']=1;
         }

so if the id of the poster of the first message equals the current users ID, and they have permission to close own topics, and the topic is open, then 'may_close_topic' should be set right and show up.

So not sure why the option is not showing up for my test user.

So I dug in further and found has_specific_permission in permissions.php.   That looks ok, it searches *_gsp database… it appears it searches for 'close_own_topics' which is in the database as enabled (a 1) for all usergroups.    Though that code is a bit abstract (maybe because it's late) to me.

So I pounded my head on the desk a bit, then I went back to the code section from ocf_topicview that I posted above…. I took out one part at a time, and found that if the :

Code

($topic_info['t_is_open']==0)

was removed, then it did show up.    Then my too late at night brain realized that the above didn't make sense.   if is_open is false?  That means it's already closed.   So I changed that to an is_open==1 and the option to close the topic shows up.

Issue fixed/solved.   

New issue.

Selecting 'close thread' and pressing proceed, and the thread does not get closed….  AAAAAAAAAAAARRRRRRRRRRRRGHHHHHHHH!

I'll have to pick this up tomorrow.


Paul
Back to the top
 
Posted
Rating:
#77871
Avatar

Community saint

Ok, I could not leave it be, so I found that all this stuff get's passed o the ofc_topic_wrap template…  it shows up there fine…   

So what happens to the 'close_topic' option when it is passed back from that select form?

In topics php you find the close_topic function… but that doesn't seem to be it.   argh again.

I must go to sleep.

Paul
Back to the top
 
Posted
Rating:
#77879
Avatar

Community saint

And test user originated the thread correct?

I am assuming so, but sometimes our sleeping brains skip the obvious. I am also guessing you set the Close own topics for all levels of topics (low, mid, and high level), believing that forum posts are mid level.

I know, I am likely shooting out things you are already aware of and check out, but just in case you accidently overlooked these things….

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#77883
Avatar

Community saint

Yes, testuser originated the thread, close own topics is only one item in global permissions, it is not attached to the low,mid and high level…  though your comment made me go back and check, but yeah, that's right, only one place to set it yes/no for each group.

Paul
Back to the top
 
Posted
Rating:
#77886
Avatar

Community saint

Well, it appears that form where you select 'close topic' returns to topics.php, and that has the close_topic function.

that function calls ofc_edit_topic, which has:

Code

if (!ocf_may_moderate_forum($forum_id))
   {
      $pinned=0;
      $sunk=0;
      $open=1;
      $cascading=0;
   }

In it, so if any user is not a moderator then the topic is never closed.

well may_moderate_forum seems to include edit_own_mid_range as part of it, so I turned that on… still no go.  hmm…


Paul
Back to the top
 
Posted
Rating:
#77887
Avatar

Community saint

Hmm…  so edit_own_mid_range is set, and edit_own_topic is set.   Very strange.

Paul
Back to the top
 
Posted
Rating:
#77888
Avatar

Community saint

Ok, it seems it should work with the permissions that are set.   But I modified ocf_edit_topic and it does work.

Code

function ocf_edit_topic($topic_id,$description=NULL,$emoticon=NULL,$validated=NULL,$open=NULL,$pinned=NULL,$sunk=NULL,$cascading=NULL,$reason='',$title=NULL)
{
    $info=$GLOBALS['FORUM_DB']->query_select('f_topics',array('t_pt_from','t_pt_to','t_cache_first_member_id','t_cache_first_title','t_forum_id','t_cache_first_post_id','t_is_open'),array('id'=>$topic_id),'',1);
    if (!array_key_exists(0,$info)) warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    $name=$info[0]['t_cache_first_title'];
    $forum_id=$info[0]['t_forum_id'];

    if (!is_null($title))
    {
        require_code('urls2');
        suggest_new_idmoniker_for('topicview','misc',strval($topic_id),$title);
    }

    if (!ocf_may_moderate_forum($forum_id))
    {
        $pinned=0;
        $sunk=0;
        if (!(($info[0]['t_cache_first_member_id']==get_member()) && (has_specific_permission(get_member(),'close_own_topics')) && ($info[0]['t_is_open']==1))) {
            $open=1;
          }
        $cascading=0;
    }

 

Modified : added t_is_open as a return in the array, then if they are not moderator,
it checks they posted the first message, it is open and they have permission to close their own topics.  if not, then $open is forced to 1 to keep it open.   If so, open stays whatever was passed to it.  In the case of closing a topic, 0 is passed to it.

Works like a charm.

Paul
Back to the top
 
Posted
Rating:
#77897
Avatar

Well done! 2 bugs from something supposed to work but too obscure for anyone to properly try until now.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#77898
Avatar

Community saint

I figured the ==0 was a 'bug'  but wasn't sure about the rest.  The privledges and permissions can get a bit confusing.  But it does appear I have them all set right and may_moderate_forum doesn't take close_own_topic into consideration.

Paul
Back to the top
 
Posted
Rating:
#77899
Avatar

Your fixes were spot on.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#77902
Avatar

Community saint

Thanks.  Good to know I'm doing it right.

Paul
Back to the top
 
Posted
Rating:
#77914
Avatar

Community saint

It's so good to see more coding discussions in the forums. I'm certain this will only strengthen ocPortal as a product.

Bob
Back to the top
 
Posted
Rating:
#89923
Avatar

Community saint

Chris, out of curiosity, without going into v9 code to look, were all the different fixes people found like this included in the new version?

Paul
Back to the top
 
Posted
Rating:
#89924
Avatar

yes


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#89925
Avatar

Community saint

Ah, I figured, but thought I'd ask before I started killing braincells digging into the new code.  ;)

Paul
Back to the top
 
Posted
Rating:
#89955
Avatar

Well-settled

Will these fixes get put into the appropriate files in the bug tracker so that I can just download them rather than trying to find and fix all of this myself when I try the v9 upgrade this weekend?

I'm hoping that any significant issues will have been found by then and updates files made available so that hopefully there are fewer issues for me to deal with.   :cool:
Back to the top
 
Posted
Rating:
#89973
Avatar

19 December 2011

All found issues affecting v9 are in the bugs database, this was fixed many versions back.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: