Thread Rating:
  • 15 Vote(s) - 4.13 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.8] OUGC Awards
#71
This user has been denied support. This user has been denied support.
Yeah, I've yet to make it go live, as I'm still testing various functions as I've ported db from My Awards.

But, oh no, I would like a manual fix to what ever you make. I will just deactivate and reactivate the plugin, as I did a ton of numerous edits to suit my needs, if possible.
Reply
#72
What edits did you applied? There are actually 1 to 3 edits to solve the HTML thing (reasons will be sanitized, always, you can use MyCode there anyways). Activation/deactivation of the plugin just applies the templates edits, I use upgrade scripts that are to be deleted after you run them.
Reply
#73
This user has been denied support. This user has been denied support.
I know that, I guess I could use up BB code for now for reasons, do let me know what edits you make, because I prefer not to run upgrade script, too much edits.

Also, I'm now facing a new problem.

As I've ported MyAwards db into yours, in profile, you're using a query to order awards by ascending or descending, so I switched it to ascending order as it was weird.

But on postbit, you're using cache to read awards I see and using that later, you're using $award['users'] to display user's awards on postbit. But the thing now is, the awards in postbit appear in a random order and not by date given, so I am not sure how would I order the queried data using the cache function, somewhere near this:

function ougc_awards_postbit(&$post)
{
	global $mybb;

	$post['ougc_awards'] = '';
	$max_postbit = intval($mybb->settings['ougc_awards_postbit']);
	if($mybb->settings['ougc_awards_power'] == 1 && ($max_postbit > 0 || $max_postbit == -1))
	{
		global $cache, $templates;

		$awards = $cache->read('ougc_awards'); // Get all awards.

I'm not very sure about how would I go on solving the postbit order issue.

And one more thing I cannot find is, there is a spacing, perhaps a padding between awards, which I cannot find in any of the code edits, I prefer not to keep space as it looks bad, any idea where would I find the code edit for it?

Thanks for your time.
Reply
#74
That is the reason I'm asking you the core edits you made, because I dropped the cache system in the next version and replaced it with queries instead (calm down, it is just one extra query by page).

There are no template edits, just a bunch of code that was removed, and some was updated for performance reasons.

If your edits are suitable for the plugin I can rather implement them as well. I have been updating the plugin since long ago and there are too many changes that a full list is not possible now.
Reply
#75
This user has been denied support. This user has been denied support.
Well, I made my system very complex. I disabled completely mod cp awards page, using htmlspecialchars_decode function at couple of places to enable HTML, removing the award linking to it's award id on postbit, and many or some others.

If you're interested, LMK, I'll send you the edited files, how that sounds?

And yeah, fetching user's/awards through cache won't be a good solution there, because it makes very complex for me to work out on expanding the plugin. I even tried myself with a query but that fails and doesn't output all awards.

Anyway, it would only increase one query when not using cache, so that should be fine.

Also if possible, please could you write down what changes you made regarding query or something and possibly all others? That would be a lot convenient for me.

edit: Also, the awards has space between each, which I dislike. When I view source, each award is in the newline, which is causing that extra space. If it was adjacent and not in the newline, the space won't be there. I even edited the template with numerous hacks, and still don't work. Unsure how each award is inserted into new line, any hack possible for that? lol.
Reply
#76
Quote:I disabled completely mod cp awards page

Just curious, why? You can set which groups can edit those awards from the ModCP, so what can be the reason to completely disable it? Maybe adding a setting will suit everybody, I see no problem.

Quote:using htmlspecialchars_decode function at couple of places to enable HTML

I currently enabled HTML for award names and descriptions, only administrators can create those from the ACP so maybe there is not a real issue enabling it.

Quote:removing the award linking to it's award id on postbit
Those are template edits , right? The upgrade script will update the master templates, you will need to use the "Find Updated Templates" feature to update your templates as you like.

I will test all this my self to make sure it works as expected, I wouldn't like my custom edits to be reverted as well, no matter which plugin it is.

Quote:If you're interested, LMK, I'll send you the edited files, how that sounds?

No really... useful. The new update requires a full update of all files, the plugin was almost completely rewritten for better user experience and my own code standards. This is the reason I'm asking about all the changes you did so that I can implement them (if they fit everybody) so you don't need to redone it all.

I have to admit it, the plugin is nice, but the code is a mess, completely ugly, IMO. An update is necessary.

Quote:And yeah, fetching user's/awards through cache won't be a good solution there, because it makes very complex for me to work out on expanding the plugin. I even tried myself with a query but that fails and doesn't output all awards.

Anyway, it would only increase one query when not using cache, so that should be fine.

Yes, the cache system resulted to be worse that querying the DB, that is way I dropped the idea.

Quote:Also if possible, please could you write down what changes you made regarding query or something and possibly all others? That would be a lot convenient for me.

No really possible, as I already mentioned there are way too many changes. It would be easiest to you to comment all your suggestions, honestly.

Quote:edit: Also, the awards has space between each, which I dislike. When I view source, each award is in the newline, which is causing that extra space. If it was adjacent and not in the newline, the space won't be there. I even edited the template with numerous hacks, and still don't work. Unsure how each award is inserted into new line, any hack possible for that? lol.

I think I know what the problem is, if you disable HTML comments from the ACP settings it should be fixed. I will update that as well so that templates don't output the HTML comments when it is really no necessary as I had done with other plugins already.

You suggestions are appreciated!
Reply
#77
This user has been denied support. This user has been denied support.
Quote:Just curious, why? You can set which groups can edit those awards from the ModCP, so what can be the reason to completely disable it? Maybe adding a setting will suit everybody, I see no problem.
For safety, because I myself won't be using that feature anytime as well. Hence, I just asked to send the edited file so as to you can see what changes I made.

Quote:I currently enabled HTML for award names and descriptions, only administrators can create those from the ACP so maybe there is not a real issue enabling it.
Yeah, also make sure the HTML for award reason is enabled as well.

Quote:removing the award linking to it's award id on postbit
Quote:Those are template edits , right? The upgrade script will update the master templates, you will need to use the "Find Updated Templates" feature to update your templates as you like.
No, I actually made that to plugin, so every time I activate/deactivate plugin, or uninstall/re-install, they don't get lost.


Quote:No really... useful. The new update requires a full update of all files, the plugin was almost completely rewritten for better user experience and my own code standards. This is the reason I'm asking about all the changes you did so that I can implement them (if they fit everybody) so you don't need to redone it all.

Quote:I have to admit it, the plugin is nice, but the code is a mess, completely ugly, IMO. An update is necessary.
Perhaps, some part is very hard to understand, I mean somewhere where simple functions were made complex, but yeah, that happens. Wink

Quote:Yes, the cache system resulted to be worse that querying the DB, that is way I dropped the idea.
Great.

Quote:edit: Also, the awards has space between each, which I dislike. When I view source, each award is in the newline, which is causing that extra space. If it was adjacent and not in the newline, the space won't be there. I even edited the template with numerous hacks, and still don't work. Unsure how each award is inserted into new line, any hack possible for that? lol.

Quote:I think I know what the problem is, if you disable HTML comments from the ACP settings it should be fixed. I will update that as well so that templates don't output the HTML comments when it is really no necessary as I had done with other plugins already.
I don't think that it is the problem, as in current version (1.0.7) I don't find any HTML comments section for plugin settings, or that you are referring to something else? Correct me if I'm wrong.

edit: Ah, were you referring to: Output template start/end comments? in server & op settings? I tried disabling that, still nothing.

What I suggest that instead of creating template for this thing, I would suggest building a custom function and calling it on postbit. For example, I tried creating custom function but that only resulted in outputting one award as the cache system is bugging it:

$custom_ougc_awards_postbit = "<span style=\"white-space:normal; width: 100%;\"><img src=\"".$award['image']."\" title=\"".$award['name']."\" alt=\"".$award['name']."\" /></span>";
$post['user_details'] = str_replace("<!-- OUGC AWARDS -->", $custom_ougc_awards_postbit, $post['user_details']);

Another thing which I find not in the plugin, but still being cached and called at places is the template named: ougc_awards_image , I cannot find it anywhere but it's still being called. You may want to have a look.

Quote:You suggestions are appreciated!
Your time is appreciated, too.

Another edit: I need to actually hurry due to current situations on implementing it, so perhaps for time being, could I get the query part (which also involves ordering awards in ascending order to reflect them by dates given and not in random order, hence why cache was failing my hopes) and a hack/fix for the spacing issue? Would really appreciate it. That's the only two things which are bugging the hell out of me, right now, haha.

Important things starts here Wrote:edit #3: I finally figured out a way to remove the space by removing the use of templates. I commented where you were evaluating 'postbit_ougc_awards' function and instead I'm now using:

$post['ougc_awards'] .= "<img src=\"".$award['image']."\" title=\"".$award['name']."\" alt=\"".$award['name']."\" />";

Which now remove extra white-space between the awards, please do correct me if the way I'm doing is wrong and not proper as I'm running out of ideas of what more I could do, lol.

If it's fine, then, now I only need the query part quickly so I can sort awards by date given.

edit #4: Okay so I rewrote the whole postbit function by removing the use of cache and using a query instead, and it seems to work fine, still testing though. So all issues I had are mostly solved. Let me know if you want me to post the postbit function I wrote.

But that runs quite queries, however, I'm now working on implementing cache to it if possible and then query the database, let's see if it works out. Will post an update.
Reply
#78
I would really like to use this on my Roleplaying forum. I know this is probably a complex feature to implement into the plugin, but I really need something like this. So far, non of the plugin I'm using really gives a "cloak" function so players can run things like "Habbits", "Weaknesses" without being visible to every user.


Can you implement a hidden award only the user itself can see it? And only the person who created the thread can post a command, the command will reveal everyone in the thread with a hidden award? So at the end of the game the OP can reveal players alternate identity and see if anyone's cheating.

Also a "cooldown period" after user turned on a hidden award, they'll have to wait 24 hours before they can remove this award from their description?

A cooldown period alone would be great, this would made possible to have players list their character's specialty. It prevents cheating.Toungue
Reply
#79
Quote:Another edit: I need to actually hurry due to current situations on implementing it, so perhaps for time being, could I get the query part (which also involves ordering awards in ascending order to reflect them by dates given and not in random order, hence why cache was failing my hopes) and a hack/fix for the spacing issue? Would really appreciate it. That's the only two things which are bugging the hell out of me, right now, haha.

This is what I use now:
// Show awards in profile function.
function ougc_awards_postbit(&$post)
{
	global $settings;

	$post['ougc_awards'] = '';
	$max_postbit = intval($settings['ougc_awards_postbit']);

	if(!$settings['ougc_awards_power'] || ($max_postbit < 1 && $max_postbit != -1))
	{
		if(my_strpos($post['user_details'], '<!--OUGC_AWARDS-->'))
		{
			$post['user_details'] = str_replace('<!--OUGC_AWARDS-->', '', $post['user_details']);
		}
		return;
	}

	// First we need to get our data
	if(THIS_SCRIPT == 'private.php')
	{
		global $db, $pm;

		$query = $db->query("
			SELECT a.aid, a.name, a.image, pm.uid
			FROM ".TABLE_PREFIX."ougc_awards a
			JOIN ".TABLE_PREFIX."ougc_awards_users ag ON (ag.aid=a.aid)
			JOIN ".TABLE_PREFIX."privatemessages pm ON (pm.uid=ag.uid)
			WHERE pm.pmid='{$pm['pmid']}' AND a.visible='1' AND a.type!='1'
			ORDER BY ag.date desc
			".($max_postbit == -1 ? '' : 'LIMIT '.$max_postbit)."
		");
	
		while($data = $db->fetch_array($query))
		{
			$ougc_awards_cache[$data['uid']][$data['aid']] = $data;
		}
		$awards = $ougc_awards_cache[$pm['uid']];
	}
	elseif(THIS_SCRIPT == 'announcements.php')
	{
		global $db, $aid;

		$query = $db->query("
			SELECT a.aid, a.name, a.image, ann.uid
			FROM ".TABLE_PREFIX."ougc_awards a
			JOIN ".TABLE_PREFIX."ougc_awards_users ag ON (ag.aid=a.aid)
			JOIN ".TABLE_PREFIX."announcements ann ON (ann.uid=ag.uid)
			WHERE ann.aid='{$aid}' AND a.visible='1' AND a.type!='1'
			ORDER BY ag.date desc
			".($max_postbit == -1 ? '' : 'LIMIT '.$max_postbit)."
		");

		while($data = $db->fetch_array($query))
		{
			$ougc_awards_cache[$data['uid']][$data['aid']] = $data;
		}
		$awards = $ougc_awards_cache[$pm['uid']];
	}
	else
	{
		static $ougc_awards_cache = null;
		if(!isset($ougc_awards_cache))
		{
			global $db, $pids;

			$query = $db->query("
				SELECT a.aid, a.name, a.image, p.uid
				FROM ".TABLE_PREFIX."ougc_awards a
				JOIN ".TABLE_PREFIX."ougc_awards_users ag ON (ag.aid=a.aid)
				JOIN ".TABLE_PREFIX."posts p ON (p.uid=ag.uid)
				WHERE p.{$pids} AND a.visible='1' AND a.type!='1'
				ORDER BY ag.date desc
				".($max_postbit == -1 ? '' : 'LIMIT '.$max_postbit)."
			");
		
			while($data = $db->fetch_array($query))
			{
				$ougc_awards_cache[$data['uid']][$data['aid']] = $data;
			}
		}
		$awards = $ougc_awards_cache[$post['uid']];
	}

	// User has no awards
	if(!(is_array($awards) && !empty($awards)))
	{
		if(my_strpos($post['user_details'], '<!--OUGC_AWARDS-->'))
		{
			$post['user_details'] = str_replace('<!--OUGC_AWARDS-->', '', $post['user_details']);
		}
		return;
	}

	global $templates;

	// Format the awards
	foreach($awards as $award)
	{
		$award['aid'] = intval($award['aid']);
		$award['name'] = ougc_awards_get_award_info('name', $award['aid'], $award['name']);
		$award['image'] = ougc_awards_get_icon($award['image'], $award['aid']);
		if($max_postbit == -1 || $count < $max_postbit)
		{
			$count++;
			$br = '';
			if($count == 1)
			{
				$br = '<br />'; // We insert a break if it is the first award.
			}
			eval('$post[\'ougc_awards\'] .= "'.$templates->get('postbit_ougc_awards', 1, 0).'";');
		}
	}

	if(my_strpos($post['user_details'], '<!--OUGC_AWARDS-->'))
	{
		$post['user_details'] = str_replace('<!--OUGC_AWARDS-->', '', $post['user_details']);
	}
}

Should work. A hack you say.. probably this works, find (in above code):
			eval('$post[\'ougc_awards\'] .= "'.$templates->get('postbit_ougc_awards', 1, 0).'";');

Replace:
			eval('$award_new = "'.$templates->get('postbit_ougc_awards', 1, 0).'";');
			$post['ougc_awards'] .= trim($award_new);
Reply
#80
Quote:Which now remove extra white-space between the awards, please do correct me if the way I'm doing is wrong and not proper as I'm running out of ideas of what more I could do, lol.

I wouldn't say it is worng, as long as it works for you untill the new version (which is suppose to fix it) is out. Hard-coded HTML code is not my style, so I will apply a [i]better[/b] fix.

Quote:But that runs quite queries, however, I'm now working on implementing cache to it if possible and then query the database, let's see if it works out. Will post an update.

Yes, querying in the postbit should be addressed with caution Smile

@Deadite, Sounds like a complex feature that will not really suit this plugin or benefit the admins who use this plugin at all. Sorry, but I wouldn't be implementing it. Your suggestion is appreciated though!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)