Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OUGC Mark PM As Unread

Please note that this is pretty much a negative criticism post, rather than a balanced review as mentioned in this thread. Also be aware that stuff posted here may be highly subjective.
Please feel free to criticise this post, however.

Plugin Reviewed: OUGC Mark PM As Unread
Plugin Version: 1.0
Plugin Author: Omar Gonzalez
Author Message
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #1
OUGC Mark PM As Unread
Okay, I'm tired and in a weird mood.  This means that I will do a half dazed skim over and blurt out anything that catches my attention.
  • Code:
     * 1.- You may edit whatever you want to fit your needs without permission.
     * 3.- You MUST NOT remove any license comments in any file that comes with this plugin pack.

    Can I make #1 override #3?

  • PHP Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    		$mark = ougc_markpmasunread_markunread($mybb->input['markunread']);
    		if($mark !== true)
    		{
    			global $lang;
    			$lang->load('ougc_markpmasunread');
    
    			switch((int)$mark)
    			{
    				case 1:
    					$message = $lang->ougc_markpmasunread_error_invalidpm;
    					break;
    				case 2:
    					$message = $lang->ougc_markpmasunread_error_alreadyunread;
    					break;
    				case 3:
    					$message = $lang->ougc_markpmasunread_error_userupdate;
    					break;
    				default:
    					$message = $lang->ougc_markpmasunread_error_unkown;
    					break;
    			}
    			error($message);
    		}

    Okay, that seemed awkward...  Maybe skip the magic numbers and pass back better references?

  • I honestly would just chuck the entire contents of the ougc_markpmasunread template into the private_messagebit template - saves a shit-tonne of work, but whatever makes you happy I guess
  • PHP Code:
    1
    2
    3
    4
    5
    6
    7
    8
    	$return = false;
    	(isset($pmid) && ($pmid = (int)$pmid)) or ($return = true);
    	($pmid && $pmid > 0) or ($return = true);
    
    	if($return)
    	{
    		return 1;
    	}

    Seems the same as

    PHP Code:
    if(($pmid = (int)@$pmid) > 0) return 1;

    Okay, yeah, I'm being pedantic...

  • When marking unread, the pmid isn't validated against a user - eg it's possibly to mark someone else's PMs as unread, if you want to be a bored twat with nothing better to do, that is
  • Also marking unread doesn't have/check postkeys, but I honestly wouldn't care for it myself

Okay, there's absolutely nothing wrong with the plugin, I just need some negative points to stick up for my own enjoyment.
I'm going to bed.

My Blog
08-18-2012 11:10 PM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 476
Joined: May 2011
Post: #2
RE: OUGC Mark PM As Unread
Quote:Okay, I'm tired and in a weird mood.  This means that I will do a half dazed skim over and blurt out anything that catches my attention.
  • Code:
     * 1.- You may edit whatever you want to fit your needs without permission.
     * 3.- You MUST NOT remove any license comments in any file that comes with this plugin pack.

    Can I make #1 override #3?


You can, but you are no suppose to Tongue

Quote:
  • PHP Code:
    1
    2
    3
    4
    5
    6
    7
    8
    	$return = false;
    	(isset($pmid) && ($pmid = (int)$pmid)) or ($return = true);
    	($pmid && $pmid > 0) or ($return = true);
    
    	if($return)
    	{
    		return 1;
    	}

    Seems the same as

    PHP Code:
    if(($pmid = (int)@$pmid) > 0) return 1;


Didn't know we could use @ to hide variable errors too (just functions). This should probably save code in future.

Quote:
  • I honestly would just chuck the entire contents of the ougc_markpmasunread template into the private_messagebit template - saves a shit-tonne of work, but whatever makes you happy I guess

It is done that way so that the text is only show when necessary, I know nothing about regex, so I will be even more work to hide it using a different way (I like nice details too).

Quote:
  • When marking unread, the pmid isn't validated against a user - eg it's possibly to mark someone else's PMs as unread, if you want to be a bored twat with nothing better to do, that is
  • Also marking unread doesn't have/check postkeys, but I honestly wouldn't care for it myself

Didn't think about that.

Quote:
  • PHP Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    		$mark = ougc_markpmasunread_markunread($mybb->input['markunread']);
    		if($mark !== true)
    		{
    			global $lang;
    			$lang->load('ougc_markpmasunread');
    
    			switch((int)$mark)
    			{
    				case 1:
    					$message = $lang->ougc_markpmasunread_error_invalidpm;
    					break;
    				case 2:
    					$message = $lang->ougc_markpmasunread_error_alreadyunread;
    					break;
    				case 3:
    					$message = $lang->ougc_markpmasunread_error_userupdate;
    					break;
    				default:
    					$message = $lang->ougc_markpmasunread_error_unkown;
    					break;
    			}
    			error($message);
    		}

    Okay, that seemed awkward...  Maybe skip the magic numbers and pass back better references?


Probably can reduce the code there, but what exactly do you mean?

Tank you for the review Zinga Burga.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
(This post was last modified: 08-21-2012 05:12 AM by Sama34.)
08-21-2012 05:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #3
RE: OUGC Mark PM As Unread
(08-21-2012 05:12 AM)Sama34 Wrote:  Didn't know we could use @ to hide variable errors too (just functions). This should probably save code in future.
It's actually unnecessary because MyBB ignores notice errors, but I just chucked it there for the sake of doing so.

(08-21-2012 05:12 AM)Sama34 Wrote:  It is done that way so that the text is only show when necessary, I know nothing about regex, so I will be even more work to hide it using a different way (I like nice details too).
Okay, I missed that - my bad.
Still doable with a CSS hack, but I guess it's less elegant.

(08-21-2012 05:12 AM)Sama34 Wrote:  Probably can reduce the code there, but what exactly do you mean?

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
if($mark = ougc_markpmasunread_markunread($mybb->input['markunread'])) {
	global $lang;
	$lang->load('ougc_markpmasunread');
	error($lang->$mark);
}

function ougc_markpmasunread_markunread(...) {
if(you_suck)
	return 'ougc_markpmasunread_error_invalidpm';
...
return false;
}


Doesn't handle the default case, but all return values from the function are controlled, right?


My Blog
08-21-2012 11:17 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 476
Joined: May 2011
Post: #4
RE: OUGC Mark PM As Unread
Yes, they are. Thank you Zinga Burga, I had applied the improvements you highlighted.

I suppose this will be good enough for the license as well:
Quote:* 1.- You MUST NOT remove any license comments in any file that comes within this package.
* 2.- You MUST NOT redistribute this or any modified version of this plugin by any means without the author written permission.
* 3.- You MAY edit whatever you want to fit your needs without permission (EXCEPT FOR THAT MENTIONED IN #1).

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
(This post was last modified: 08-21-2012 01:57 PM by Sama34.)
08-21-2012 01:57 PM
Visit this user's website Find all posts by this user Quote this message in a reply


Forum Jump: