Warning: The author of this contribution does not provide support for it anymore.

User's notes

I created a module and moved this to UCP (Updated, works!) - User's notes

I created a module and moved this to UCP (Updated, works!)

by PiperB » Sat Apr 01, 2017 9:59 pm

Update: Complete! You may now proceed with the edits! It is fully working, and all changes to the below edits are totally completed. Note: If you previously downloaded the template files I created for this from this particular version of this mod, you will need to re-download them as I left out the form name last time by accident out of being tired. I can assure with 100% certainty, all works as it should now with zero errors. :)

I do like this mod quite a bit but really felt it didn't belong in the overall header and decided it needed to be in the User control panel with all of the other personal user stuff, since it is personal notes.

Now the link says what it is too, personal notes. Just a few file edits, a language addition, template changes and such and we are ready to boogie.

If you already have this mod installed, you will be deleting the files "notes.html", notes.php (from the root folder)(full details in delete and file copy instructions further down) and also removing the edit for the link display from the overall header plus the edits for the /includes/functions.php. I made these changes for prosilver, and subsilver2 based styles.

Let's begin shall we, now you too will create this module on your board per my instructions.

Open: /includes/ucp/info/ucp_main.php

Find:

Code: Select all

				'drafts'		=> array('title' => 'UCP_MAIN_DRAFTS', 'auth' => '', 'cat' => array('UCP_MAIN')),
Add After: (On a new blank line)

Code: Select all

				'notes'	=> array('title' => 'UCP_MAIN_NOTES', 'auth' => '', 'cat' => array('UCP_MAIN')),
Save the file.

Open: /includes/ucp/ucp_main.php

Find:

Code: Select all

				if (!$edit)
				{
					$template->assign_var('S_DRAFT_ROWS', $row_count);
				}

			break;
Add After: (On a new blank line)

Code: Select all

						case 'notes':

			$user->add_lang('mods/notes');
			add_form_key('users_notes');

if ( isset($_POST['snote']) )
{
  
  $note = utf8_normalize_nfc( request_var('note', '', true) );
  $note_ready = $db->sql_escape($note);
  
  // and finaly adding new notes into database
  $db->sql_query("UPDATE " . USERS_TABLE . " SET user_note = '" . $note_ready . "' WHERE user_id = " . $user->data['user_id']);

  trigger_error( sprintf($user->lang['NOTES_SAVED'], append_sid("{$phpbb_root_path}ucp.$phpEx" , 'i=main&mode=notes')) );
}

// create a template variables
$template->assign_vars(array(
      'NOTE'               => $user->data['user_note'],
)); 

page_header($user->lang['NOTES']);

$template->set_filenames(array(
    'body' => 'ucp_main_notes.html',
));

;

			break;
Save the file.

Open: /language/en/ucp.php

Find:

Code: Select all

	'UCP_MAIN_SUBSCRIBED'		=> 'Manage subscriptions',
Add after: (On a new blank line)

Code: Select all

	'UCP_MAIN_NOTES'			=> 'Personal Notes',
Save the file.

Remove or delete the file "notes.php" from your phpbb root directory.
Path: root/notes.php
Note: (We remove this because all of the needed code is in the new includes/ucp_main.php file edits. We no longer need to check for bots in the notes because bots are not going to be inside ucp of personal users, and also no log in check is required because users already have to be logged in to see their ucp panel.)

Remove or delete the file "notes.html" from your styles templates directory if you already have this mod installed.
Path: /styles/prosilver/templates/notes.html
or /styles/subsilver2/templates/notes.html

Remove the "overall_header.html" edits from this mod if you have previously added them.
Path: /styles/prosilver/templates/overall_header.html
or /styles/subsilver2/templates/overall_header.html

Remove the "includes/functions.php" edits from this mod if you have previously added them.
Path: /includes/functions.php

Here are my newly created template files for this along with css file for both prosilver, subsilver2, and in the contrib folder I've provided the files for X-Treme Purple. I've included the newly edited language file as well for those who don't have it already.
User_Notes_UCP_Templates&css.zip
(6.83 KiB) Downloaded 57 times

File Copy *I said prosilver or subsilver2 in the file paths as to not have to explain the same thing twice.

1. Copy: /styles/prosilver or subsilver2/template/ucp_main_notes.html
To: /styles/prosilver or subsilver2/template/ucp_main_notes.html

2. Copy: /styles/prosilver or subsilver2/theme/notes.css
To: /styles/prosilver or subsilver2/theme/notes.css

// If you don't already have this new version of the language file, or don't have this mod at all.
3. Copy: /language/en/mods/notes.php
To: /language/en/mods/notes.php

The same file copies for X-Treme purple if you are doing that, and those again are in the contrib folder.

No other files are included with this version of the mod.

Clear your cache.

These next steps are the most important ones for the completion, as it's how you obtain the view and activation of the module.

1. Go to your admin control panel.

2. Click on the "System" tab.

3. Scroll down to the left hand side where it says "Module management" and then click on "User Control Panel".

4. After the ucp module settings page loads, look (ONLY LOOK) towards the right hand bottom for the drop down menu NEXT TO the button that says "add module" and open the drop down menu after which scroll until you see the entries for "Overview [ucp_main]", then within that list populated under it you select "Personal Notes".

5. then click the "Add Module" button directly next to the drop down from which you just made your selection.

6. Once your module has been added, you will see it within the main modules list, and from there you will click the word "enable" to enable your module.
Note: You can enable or disable it from showing on the ucp from any time from within these settings.

7. You may move the new module up or down to the position in which you wish for it to show in your ucp.

Clear your cache for fun.

Here is an illustration with the areas squared out in red so you can see the spots you need to be working with for the above steps numbered 1-7.
Note: Click the image or open in a new tab/window to view full size.
3.png

Now for some screenies!

Prosilver
0.png

Subsilver2
1.png

X-Treme Purple
2.png

__________________________________________________________________________________
Note: If you don't have this mod installed previously, you can still install this by following all of the above steps and ignoring the part about removing edits and deleting mod files for this mod, lol duh. You would then need to execute the sql query for this mod (Only if you don't have this mod already, making this clear as to not confuse anyone.)

Here is the query (Remember, don't execute this query unless you have NOT installed the mod ever, if you have the previous version of the mod, then you don't need this query)

Code: Select all

ALTER TABLE phpbb_users ADD user_note TEXT NOT NULL;
Also if you don't have this mod installed you would add the language edits from this to the /language/en/common.php

Find:

Code: Select all

	'NOTIFY_ADMIN_EMAIL'		=> 'Please notify the board administrator or webmaster: <a href="mailto:%1$s">%1$s</a>',
Add After: (On a new blank line)

Code: Select all

	'NOTES'		=> 'Notes',
Clear your cache.
__________________________________________________________________________________

That's it!!!

If you don't like my custom css that I recently created for subsilver based styles, then you can follow the instructions here and apply the changes to the file "ucp_main_notes.html", instead of the "notes.html".
https://www.phpbb.com/customise/db/mod/ ... 86#p551286

then in "ucp_main_notes.html" you'd need to change the table width in the main table for the template to "100%" instead of what it is now which is "98%". Again, that's only if you don't like the custom css I added, so if you like it, just follow the instructions to install.

Enjoy! ;) :D
Last edited by PiperB on Wed Oct 18, 2017 6:58 pm
<!-- IF U_LOVE_NOTEPAD++ -->
[td class=statement]I Notepad++ ![/td]
<!-- ENDNEVER --> <!-- tee hee --> :P
Whoa ooo whoa ooo whoa I'm a Lady!
User avatar
PiperB
Registered User
Posts: 173
Joined: Mon Nov 07, 2016 6:54 pm

Re: I created a module and moved this to UCP (Updated, works

by PiperB » Sun Apr 02, 2017 11:53 pm

Updated, and it works great, bump! :)

I'm more partial to the outer glowy bits...may the force be with you! (Star Wars reference, pretty sure everyone knows that but just in case.) :)
<!-- IF U_LOVE_NOTEPAD++ -->
[td class=statement]I Notepad++ ![/td]
<!-- ENDNEVER --> <!-- tee hee --> :P
Whoa ooo whoa ooo whoa I'm a Lady!
User avatar
PiperB
Registered User
Posts: 173
Joined: Mon Nov 07, 2016 6:54 pm

Re: I created a module and moved this to UCP (Updated, works

by Vogelek23 » Sat Apr 30, 2022 2:24 pm

Code: Select all

case 'notes':

			$user->add_lang('mods/notes');
			add_form_key('users_notes');

if ( isset($_POST['snote']) )
{
  
  $note = utf8_normalize_nfc( request_var('note', '', true) );
  $note_ready = $db->sql_escape($note);
  
  // and finaly adding new notes into database
  $db->sql_query("UPDATE " . USERS_TABLE . " SET user_note = '" . $note_ready . "' WHERE user_id = " . $user->data['user_id']);

  trigger_error( sprintf($user->lang['NOTES_SAVED'], append_sid("{$phpbb_root_path}ucp.$phpEx" , 'i=main&mode=notes')) );
}

// create a template variables
$template->assign_vars(array(
      'NOTE'               => $user->data['user_note'],
)); 

page_header($user->lang['NOTES']);

$template->set_filenames(array(
    'body' => 'ucp_main_notes.html',
));

;

			break;
Unnecessary semicolon in line 29. Apart from that, very good job!
Professional computer repair forum.
The largest documentation database in Europe.
FREE and professional advice from over 70k users.
Earn money for activity!
https://www.elvikom.pl
User avatar
Vogelek23
Registered User
Posts: 64
Joined: Tue Aug 17, 2010 7:30 pm
Location: West Midlands, UK
Name: Lukas