Welcome to Geeklog, Anonymous Wednesday, November 27 2024 @ 08:26 pm EST
Geeklog Forums
Top download block for filemgmt plugin
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
I updated the top download block for filemgmt plugin. This block now check rights for category access.
{
//For filemgmt plugin >= 1.5
global $_DB_table_prefix, $_USER;
$poplist = '';
$_FM_TABLES['filemgmt_cat'] = $_DB_table_prefix . 'filemgmt_category';
$_FM_TABLES['filemgmt_filedetail'] = $_DB_table_prefix . 'filemgmt_filedetail';
$query = "SELECT f.* FROM {$_FM_TABLES['filemgmt_filedetail']} AS f
LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c
ON c.cid = f.cid
";
if (isset($_USER['uid']) AND $_USER['uid'] > 1) {
$uid = $_USER['uid'];
} else {
$uid = 1;
}
$_GROUPS = SEC_getUserGroups($uid);
$groupsql = '';
if (count($_GROUPS) == 1) {
$groupsql .= " WHERE c.grp_access = '" . current($_GROUPS) ."'";
} else {
$groupsql .= " WHERE c.grp_access IN (" . implode(',',array_values($_GROUPS)) .")";
}
$query .= $groupsql;
//Files limit is 5. Change it if you need
$query .= " ORDER BY hits DESC LIMIT 0 , 5";
$result = mysql_query($query);
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '';
$popular[] = '<a href="' . $_CONF['site_url']
. '/filemgmt/index.php?id=' . $A['lid'] . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
Text Formatted Code
function phpblock_topdl(){
//For filemgmt plugin >= 1.5
global $_DB_table_prefix, $_USER;
$poplist = '';
$_FM_TABLES['filemgmt_cat'] = $_DB_table_prefix . 'filemgmt_category';
$_FM_TABLES['filemgmt_filedetail'] = $_DB_table_prefix . 'filemgmt_filedetail';
$query = "SELECT f.* FROM {$_FM_TABLES['filemgmt_filedetail']} AS f
LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c
ON c.cid = f.cid
";
if (isset($_USER['uid']) AND $_USER['uid'] > 1) {
$uid = $_USER['uid'];
} else {
$uid = 1;
}
$_GROUPS = SEC_getUserGroups($uid);
$groupsql = '';
if (count($_GROUPS) == 1) {
$groupsql .= " WHERE c.grp_access = '" . current($_GROUPS) ."'";
} else {
$groupsql .= " WHERE c.grp_access IN (" . implode(',',array_values($_GROUPS)) .")";
}
$query .= $groupsql;
//Files limit is 5. Change it if you need
$query .= " ORDER BY hits DESC LIMIT 0 , 5";
$result = mysql_query($query);
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '';
$popular[] = '<a href="' . $_CONF['site_url']
. '/filemgmt/index.php?id=' . $A['lid'] . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
12
12
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Yes you're right, this might be
New version
function phpblock_topdl()
{
//For filemgmt plugin >= 1.5
global $_DB_table_prefix, $_USER;
$poplist = '';
$_FM_TABLES['filemgmt_cat'] = $_DB_table_prefix . 'filemgmt_category';
$_FM_TABLES['filemgmt_filedetail'] = $_DB_table_prefix . 'filemgmt_filedetail';
$query = "SELECT f.* FROM {$_FM_TABLES['filemgmt_filedetail']} AS f
LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c
ON c.cid = f.cid
";
if (isset($_USER['uid']) AND $_USER['uid'] > 1) {
$uid = $_USER['uid'];
} else {
$uid = 1;
}
$_GROUPS = SEC_getUserGroups($uid);
$groupsql = '';
if (count($_GROUPS) == 1) {
$groupsql .= " WHERE c.grp_access = '" . current($_GROUPS) ."'";
} else {
$groupsql .= " WHERE c.grp_access IN (" . implode(',',array_values($_GROUPS)) .")";
}
$query .= $groupsql;
//Files limit is 5. Change it if you need
$query .= " ORDER BY hits DESC LIMIT 0 , 5";
$result = DB_query($query);
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '';
$popular[] = '<a href="' . $_CONF['site_url']
. '/filemgmt/index.php?id=' . $A['lid'] . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Thanks,
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
Text Formatted Code
$result = DB_query($query);New version
Text Formatted Code
function phpblock_topdl()
{
//For filemgmt plugin >= 1.5
global $_DB_table_prefix, $_USER;
$poplist = '';
$_FM_TABLES['filemgmt_cat'] = $_DB_table_prefix . 'filemgmt_category';
$_FM_TABLES['filemgmt_filedetail'] = $_DB_table_prefix . 'filemgmt_filedetail';
$query = "SELECT f.* FROM {$_FM_TABLES['filemgmt_filedetail']} AS f
LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c
ON c.cid = f.cid
";
if (isset($_USER['uid']) AND $_USER['uid'] > 1) {
$uid = $_USER['uid'];
} else {
$uid = 1;
}
$_GROUPS = SEC_getUserGroups($uid);
$groupsql = '';
if (count($_GROUPS) == 1) {
$groupsql .= " WHERE c.grp_access = '" . current($_GROUPS) ."'";
} else {
$groupsql .= " WHERE c.grp_access IN (" . implode(',',array_values($_GROUPS)) .")";
}
$query .= $groupsql;
//Files limit is 5. Change it if you need
$query .= " ORDER BY hits DESC LIMIT 0 , 5";
$result = DB_query($query);
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '';
$popular[] = '<a href="' . $_CONF['site_url']
. '/filemgmt/index.php?id=' . $A['lid'] . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Thanks,
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
10
12
Quote
All times are EST. The time is now 08:26 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content