Forums / Cotonti / Support / Grup color Core hack how can do ?

Lover
#1 2014-09-08 14:06

How can i do Group color ? with functions.php core hack ?

 

For do this critic zone code.

function cot_build_user($id, $user, $extra_attrs = '')
{
	if (!$id)
	{
		return empty($user) ? '' : $user;
	}
	else
	{
		return empty($user) ? '?' : cot_rc_link(cot_url('users', 'm=details&id='.$id.'&u='.$user), $user, $extra_attrs);
	}
}

 

im thinking some magic touch enough , and i hope somena can do this :)

Macik
#2 2014-09-08 16:06

In what plugin and what template you are using this function? What place of the site?

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Lover
#3 2014-09-08 18:47

Siena last version /system/functions.php  Open it !!!

i know wtih this code zone can core hack and we can do grup color

 

For example it was im using Genoa version ! and this code for me working , but with Siena its not working any :) Macik how can we do this ?

function sed_build_user($id, $user)
{
global $cfg;

if (($id==0 && !empty($user)))
{ $result = $user; }
elseif ($id==0)
{ $result = ''; }
else
{ $result = (!empty($user)) ? $user : '?'; }

$sql = sed_sql_query("SELECT gru_groupid FROM sed_groups_users WHERE gru_userid='$id' LIMIT 1");
$row = sed_sql_fetcharray($sql);

if ($row['gru_groupid']==5)
{
$result = "<img src=\"images/admin.png\"><a href=\"users.php?m=details&id=".$id."\"><font style=\"color:#bf0707;font-weight:bold;font-size: 9pt;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==4)
{
$result = "<a href=\"users.php?m=details&id=".$id."\"><font style=\"color:#a0a0a0;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==6)
{
$result = "<a href=\"users.php?m=details&id=".$id."\"><font style=\"color:#0000FF\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==7)
{
$result = "<a href=\"users.php?m=details&id=".$id."\"><font style=\"color:#FF0000;font-weight:bold\">".$result."</font></a>";
}
else
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."&amp;u='.$user.'\">".$user."</a>";

}
return($result);
}

 

Gökhan YILDIZ
#4 2014-09-08 19:41

change your function:

function cot_build_user($id, $user, $extra_attrs = '')
{
	global $db;
	if (!$id)
	{
		return empty($user) ? '' : $user;
	}
	else
	{
		$gdata = $db->query("SELECT gru_groupid FROM cot_groups_users WHERE gru_userid = $id LIMIT 1");
		$row = $gdata->fetch();
		return empty($user) ? '?' : $link='<a href="'.cot_url('users', 'm=details&id='.$id.'&u='.$user).'" class="group'.$row["gru_groupid"].'">'.$user.'</a>';
	}
}

open your css file and add anywhere:

 

a.group5{
	color:#FF0000;
	font-weight:bold;
}
a.group4{
	color:#000;
	font-weight:bold;
}
a.group3{
	color:#CC0;
	font-weight:bold;
}
a.group2{
	color:#ddd;
	font-weight:bold;
}
a.group1{
	color:#ccc;
	font-weight:bold;
}

 

Gökhan YILDIZ
Lover
#5 2014-09-08 20:15

Gökhan usta adamın dibisin ! ham maddesisin adamlığın bir fabrikası var ise ilk çıkan patentli ürünüsün teşekkür ederim

Gökhan YILDIZ
#6 2014-09-08 20:23

Rica ederim kolay gelsin

Gökhan YILDIZ
Macik
#7 2014-09-09 09:28

Core hack it's not a good solution anyway and a bad practice. I think it may be solved other way.

So I repeat my question once more: from what part of the site you call this funciton or what template use it?

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Gökhan YILDIZ
#8 2014-09-09 09:51
 
#39851 Macik:

Core hack it's not a good solution anyway and a bad practice. I think it may be solved other way.

So I repeat my question once more: from what part of the site you call this funciton or what template use it?

He's want to this solution

supposed to appear everywhere

Gökhan YILDIZ
Macik
#9 2014-09-09 13:23
#39853 Gökhan YILDIZ:

He's want to this solution

supposed to appear everywhere

I understand it. But there are no universal workaround (without corehack) for «everywhere», but for some paces it can be done with TPL or small plugin. 

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Gökhan YILDIZ
#10 2014-09-09 13:36
#39856 Macik:
#39853 Gökhan YILDIZ:

He's want to this solution

supposed to appear everywhere

I understand it. But there are no universal workaround (without corehack) for «everywhere», but for some paces it can be done with TPL or small plugin. 

it is a temporary solution. soon I'll make a plugin.

Gökhan YILDIZ
Kilandor
#11 2014-09-09 16:57

The current best solution that exists with no need for any core hacks would be to simply in any spot/area that shows or uses cot_build_user. Hook into that area, and overwrite the default tag by running it again and using the 3rd paramater to add a class.

Here is just an example file of how you could add a class to the username of forum posts which would result in a class of group# # being their main group. You would need to hook into every area that displays tags and fix them though.

<?PHP
/**
 * Example Plugin
 *
 * @package example
 * @version 1.0.0
 * @author Jason Booth (Kilandor)
 * @copyright Copyright (c) 2014 Jason Booth (Kilandor)
 * @license BSD
 */
/* ====================
[BEGIN_COT_EXT]
Hooks=forums.posts.loop
[END_COT_EXT]
==================== */

if (!defined('COT_CODE') { die('Wrong URL.'); }

$t->assign(array(
	'FORUMS_POSTS_ROW_POSTERNAME' => cot_build_user($row['fp_posterid'], htmlspecialchars($row['fp_postername']), array('class' => 'group'.$row['user_maingrp'])),
	));

 

On another note, this is a long desired feature. I have just pushed a new commit to allow for custom function to be used.

Added the ability to override cot_build_user with cot_build_user_custom

This will allow a plugin to create a custom system to do anything group colors, images, any style changes you want. Or for simple changes you can simply enable custom function file in your config and add a new function cot_build_user_custom and then do whatever you want. This is of course what a plugin would/could do.