The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
|||
|
|||
I am working on the possibility of saving with the actual userId, but I see a couple of problems:
Now I see that all of those features would need to take the new table into account. |
#12
|
||||
|
||||
Quote:
I've been thinking about this and maybe updating the node table with the anonymous user info is the way to go. Adding logic to the template to determine whether or not the post belongs to a specific user shouldn't be too difficult for editing purposes. There will also need to be an undo script added to the uninstall procedure to revert the changes made by the mod. EDIT:Ya, after thinking about it, I don't like this idea. If something in the mod or uninstall script were to go awry, the anonymous posts would be irreversible, unowned and I still think it's a bad idea to modify the node table directly. Also the future vbulletin upgrade scripts are not going to take the changes into account and could cause issues there as well. |
#13
|
|||
|
|||
Quote:
Once we, the moderators, have their identities saved in a special table to avoid eventual problems, I would be fine with that. Quote:
Quote:
To perform any update, one would need to uninstall the plugin (and undo changes to the hook), then update vB and install the plugin adapted for the new version. I foresee hard time testing the feature, but I don't see another way to avoid multiple hacks (for the post counter, for the topic creator, for the last poster in the topic, for the user information in the topic itself, for the search and maybe more). So, we have two options: change the data vB stores in the table node or multiple hacks to override fetchUserInfo. |
#14
|
|||
|
|||
Here it is a functional code to replace the user with "Guest".
Instead of userid (an integer), the table node will save 0. Instead of username for authorname, the table node will save Guest. I picked those values, because old posts as anonymous from my old system were migrated with those values. PS: I tried to not change any existing logic, expect of the userid and authorname, to avoid a higher possibility of including bugs. ------------------- Notes: page.php manages whether the checkbox should be displayed or not. Currently, it always returns true. However, page.php is only called when there is a submission of the whole page. That means for ajax calls (case 1: when the user clicks to edit the post; case 2: when the user posts something in a thread), the anonymous checkbox won't appear. The case 2 (or simply the whole thing to show the checkbox) should be fixed. ------------------- 1) Installing the plugin: 1.1) Download the file product_anonymous.xml attached to this post; 1.2) Install the product: go to "Products & Hooks" -> "Manage Products" -> "Add/Import Product" and install the .xml file; 2) Copying the page.php file with the function to enable the checkbox: 2.1) Create the structure /anonymous/api/ inside of /core/packages/, so you will have /core/packages/anonymous/api/; 2.2) Download the file page.php attached to this post; 2.3) Copy it to the directory /core/packages/anonymous/api/; 3) Create a new template: Go to "Style & Themes" -> "Style Manager" , then pick "Add New Tamplate" for "Default vB5 Style" 3.1) For this new template, set "anonymous_cb" as the title. Then add the following code: HTML Code:
<vb:if condition="$page['hasCheckbox'] == true"> <div class="b-content-entry-panel__content b-content-entry-panel__content--smiley h-clearfix"> <label class="js-collapse__link h-align-middle text-bold b-link js-link" for="checkbox_anonymous">Post as anonymous</label> <input type="checkbox" id="checkbox_anonymous" name="anonymous_post" value="1"> </div> </vb:if> 4.1) Look for the if statement (line 242-258): HTML Code:
// ************************************* // * Fill some default data if missing * // ************************************* if (empty($data['userid'])) { $user = vB::getCurrentSession()->fetch_userinfo(); $data['authorname'] = $user['username']; $userid = $data['userid'] = $user['userid']; } else { $userid = $data['userid']; if (empty($data['authorname'])) { $data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid); } } HTML Code:
if ($_POST['anonymous_post'] === "1") { $data['authorname'] = "Guest"; $userid = $data['userid'] = 0; } HTML Code:
if (empty($nodevals['userid'])) HTML Code:
$isPostAnonymous = $_POST['anonymous_post'] === "1" && $nodevals['userid'] === 0; if (empty($nodevals['userid']) && !$isPostAnonymous) 5.1) Look for the if statement (line 492-506): HTML Code:
if (empty($data['userid'])) { $user = vB::getCurrentSession()->fetch_userinfo(); $data['authorname'] = $user['username']; $userid = $data['userid'] = $user['userid']; } else { $userid = $data['userid']; if (empty($data['authorname'])) { $data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid); } $user = vB_Api::instance('user')->fetchUserinfo($userid); } HTML Code:
if ($_POST['anonymous_post'] === "1") { $data['authorname'] = "Guest"; $userid = $data['userid'] = 0; } |
#15
|
|||
|
|||
There are two major issues in the code:
1) User information still not saved in the table anonymous_log. I didn't find any example in vb5 of a plugin which saves info in a new table. Does anyone know one? 2) Condition to display the checkbox needs to be treated in a proper way. I added the hook to "editor_additional_panels". So how can I know whether it is a new post, a new topic or edition of an existing post? |
#16
|
||||
|
||||
Create the following directory structure in your product directory
Code:
db/mysql Code:
<?php if (!defined('VB_ENTRY')) die('Access denied.'); class Anonymous_dB_MYSQL_QueryDefs extends vB_dB_QueryDefs { protected $db_type = 'MYSQL'; protected $saveDbCacheErrorState = false; protected $table_data = array( 'anonymous_log' => array('key' => array('logid' , 'userid' , 'parentid' , 'nodeid')) ); protected $query_data = array(); } Code:
$userinfo = vB_Api::instance('user')->fetchUserInfo(); vB::getDbAssertor()->insert('Replinonymous:anonymous_log', array( 'userid' => $userinfo['userid'], 'logid' => '', 'parentid' => $input['parentid'], 'nodeid' => $nodeId )); |
#17
|
|||
|
|||
Hello Replicant, sorry for the long time with no reply, but I've tried it and it works fine!
Thank you for the help! Soon I will edit the initial post and add the last state of all files. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|