Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Forcing Discussions to be Whispered

edited August 2006 in Vanilla 1.0 Help
I would like to know if it is possible to force all discussions created by a user to be whispered to themselves. Would it be as simple as: a) Using JavaScript to fill the whisper field with the users name b) Having the users name pre-filled in the whisper-to field. Or would there be a better way with an extension of some sort. I am not sure how to go about this, so if anyone could lend a hand, it would be greatly appreciated. -- Nathan.
«13

Comments

  • I would suggest some type of SQL script to update the database. Or do you want to do this every time that person posts? Then possibly a extension attached to some delegate. Is this some kind of punishment/banishment?
  • I would like it to occur EVERY time the user posts. -- Is this some kind of punishment/banishment? -- It is actually for a personal notes system based on Vanilla. I don't want any forum aspect at all, instead, I want the commenst whispered to the user who created them, so all the notes are private.
  • Interesting idea.

    I would suggest creating a new theme with the themes/discussion_form.php file. Change this block: if ($this->Context->Configuration['ENABLE_WHISPERS'] && $Discussion->DiscussionID == 0) { echo '<li> <label for="WhisperUsername">'.$this->Context->GetDefinition('WhisperYourCommentsTo').'</label> <input id="WhisperUsername" name="WhisperUsername" type="text" value="'.FormatStringForDisplay($Discussion->WhisperUsername, 0).'" class="Whisper AutoCompleteInput" maxlength="20" /> <script type="text/javascript"> var WhisperAutoComplete = new AutoComplete("WhisperUsername", false); WhisperAutoComplete.TableID = "WhisperAutoCompleteResults"; WhisperAutoComplete.KeywordSourceUrl = "'.$this->Context->Configuration['WEB_ROOT'].'ajax/getusers.php?Search="; </script> </li> '; }To: <input id="WhisperUsername" name="WhisperUsername" type="hidden" value="'. $this->Context->Session->UserID .'" />And that should work for you. You might still ned that IF statement, but I suspect it is OK to replace it completely. Test editing the messages to make sure.
  • edited August 2006
    It didn't work.

    I did the new theme thing (I had a new one already), and I used the following code (you still need to echo the code, you can't just replace it entirely).

    if ($this->Context->Configuration['ENABLE_WHISPERS'] && $Discussion->DiscussionID == 0) { echo '<input id="WhisperUsername" name="WhisperUsername" type="hidden" value="'. $this->Context->Session->UserID .'" /> '; }

    I get this error when I try and make a post:
    The username entered as the whisper recipient could not be found.

    I assume that UserID will return a number, i.e. 1, or 43 which is not a valid User Name. Is there a way to insert a UserName?

    Thanks though. Very nearly there.

    Unless there is an extension that does this... that is.
  • edited August 2006
    $this->User->Name

    I can't use that. It doesn't work.
  • edited August 2006
    $this->Context->Session->Name? or UserName?
  • No go mini. It did't work.
  • Oh my bad. It needs to use the UserManager object i think. Try $AccountUser->Name.
  • Unfortunately, still no go. BTW, I am doing as WallPhone suggested while making your changes. Just to let you know what I am doing.
  • Sorry I haven't checked up on this in a bit... one of these objects has to store the text user name... maybe try to figure out where it comes from to build the 'Signed in as x' link in the top-right?

    Maybe I will be able to poke through the code more later today and find it.
  • Here we go. Try this:
    if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager");
    $AccountUserID = ForceIncomingInt("u", $Context->Session->UserID);
    $AccountUser = $UserManager->GetUserById($AccountUserID);
    $name = $AccountUser->Name;
  • that's the one ^^
  • Forgive me, but where am I supposed to put that? I really have no idea.
  • Well just put that code somewhere in your file above where you need to use $name then just stick $name in where you need it (i.e. as the value of the hidden input to give it the whisper-to username). I'm wondering if an extension rather than a theme file would really be the best way to achieve this. Either should work though.
  • -- Fatal error: Call to a member function on a non-object in /home/virtual/site482/fst/var/www/html/korkbord.com/themes/korkbord/discussion_form.php on line 26 -- It didn't work again. I am thinking an extension might be better also, but sadly, my understanding of the extension system is less and the theme system.
  • This is actually a reall awesome idea. I've been using one of my loads as a client management tool where they can upload photos, etc to use for website updates, and just creating an exclusive category and user/role for each client. But, once we start getting bigger, that's a lot of categories. Using one category for work orders and forcing the users to only be able to whisper to themselves and then the other admins and i could check the permission that we can see all whispers. However, what would be cool is this: the "members" role can only whisper, as set in their permission, while the master admin can post freely, and can then whisper to each client, therefor, communicating with them in their exclusive post. That would definitely be pimp and would allow me to keep the db size down, as far as category and user/roles go.
  • Yeah, garvins idea sounds better and I'm pretty sure it shouldn't be that difficult. I'll give it a shot tomorrow if you guys dont mind waiting and i can make myself start the job.
  • No, that's fine by me. Thanks mini. I appreciate it.
  • Snap, man. I'd use this today if it were availalbe. I'd have to reconstructure mysetup a bit, but its Sunday, so that's all cool. Yah, whenever you get it up and working, Mini. We'll be patient.
  • edited August 2006
    comment_form.php is part of the GetCommentForm methode of the DiscussionForm class,
    so replace $context by $this->Context:$this->Context->Session->User->Name
This discussion has been closed.