| Author |
Message |
whiskey
Joined: Jul 14, 2005
Posts: 5
Status: Offline
|
  Posted:
Jul 14, 2005 - 05:07 AM |
|
I have tried a lot of things but none of them seem to work (maybe because i don't know much about php and pnrender)... anyways... here is a thing i tried...
i hacked the ns_newuser module to create a new photoshare gallery for each new user... the main pic should be used as advprofile pic...
in user menu (so the image remains there) i added after line 7 in advprofile_user_menu.tpl:
| Code: |
<?php
$dbhost = pnConfigGetVar('dbhost');
$dbuname = pnConfigGetVar('dbuname');
$dbpass = pnConfigGetVar('dbpass');
$dbname = pnConfigGetVar('dbname');
$nukeurl = pnGetBaseURL();
$count = ( isset($HTTP_GET_VARS['c']) ) ? intval($HTTP_GET_VARS['c']) : 15;
$count = ( $count == 0 ) ? 15 : $count;
//Main pic from user gallery
$mainpic = mysql_query("select nuke_photoshare_folders.ps_mainimage as mainimage from nuke_photoshare_folders");
$mainpic = mysql_result($mainpic,0,"mainimage");
echo "mainpic=$mainpic"
echo "\<img src=\"index.php?module=photoshare&type=show&func=viewimage&iid=$mainpic&thumbnail=1\">"; ?>
|
now ... what am i doing wrong? has anybody tried something like this? what is wrong with my syntax?
How would you get the data needed? it's just one tiny little number sitting there and i cannot get it to work jajaja
help or comments appreciated |
|
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Jul 14, 2005 - 02:09 PM |
|
Eww........
My first suggestion would be to drop that code......
Then, look at the advProfile/pntemplates/plugins...
Use the available code (take a plugin, rename it and adapt it) to get the your main image name (shouldn't there be a WHERE ??)...
(Do not use mysql_query, use the available $dbconn-> ....)
If you study the plugins right, at the end, all you'll have to put in the template is something like this :
| Code: |
<!--[psmainimage]-->
|
And your image will show if you did your plugin right.  |
_________________ Chestnut !
Administrator
PNConcept.com
Last edited by Chestnut on Jul 14, 2005 - 02:14 PM; edited 1 time in total |
|
 |
 |
whiskey
Joined: Jul 14, 2005
Posts: 5
Status: Offline
|
  Posted:
Jul 15, 2005 - 11:11 PM |
|
dont know where is the WHERE (lol)... maybe got lost somewhere...
thanks.. i will do and when its done i will post it somewhere here (for others to help me get it working right lol)
see ya... gotta lot to do with this |
|
|
|
 |
whiskey
Joined: Jul 14, 2005
Posts: 5
Status: Offline
|
  Posted:
Jul 17, 2005 - 09:15 AM |
|
Ok, here is what i tried
| Code: |
function.mainpic.php:
<?php
function smarty_function_mainpic($params, &$smarty)
{
if (!pnSecAuthAction(0, 'advProfile::', 'Plugin::mainpic.php', ACCESS_READ)) {
return false;
}
extract($params);
unset($params);
if (!isset($uid) || empty($uid)) {
return false;
}
if (!isset($template) || empty($template)) {
$template = pnModGetVar('advProfile', 'template');
}
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$tbl = &$pntable['photoshare_folders'];
$col = &$pntable['photoshare_folders_column'];
$sql = "SELECT $col[ps_mainimage],
FROM $tbl
WHERE $col[ps_owner] = '" . pnUserGetVar($uid);
$result = $dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
echo $dbconn->ErrorMsg();
return false;
}
if ($result->EOF) {
$mainpic = 0;
} else {
list($mainpic) = $result->fields;
}
$result->Close();
@include_once('modules/advProfile/pnlang/'.pnVarPrepForOS(pnUserGetLang()).'/mainpic.php');
if (isset($assign)) {
$smarty->assign($assign, $mainpic);
} else {
return $mainpic;
}
}
?>
|
But i get no output using
or
in the advprofile_user_menu.tpl
What am i doing wrong? I used pncuserpoints.php function as a base for the function.
Thanks in advance!
edited but still not working |
Last edited by whiskey on Jul 17, 2005 - 10:55 AM; edited 1 time in total |
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Jul 17, 2005 - 02:37 PM |
|
Use the code tag please.
And you had no sql Error ? There is one :
| Code: |
$sql = "SELECT $col[ps_mainimage],
FROM $tbl
WHERE $col[ps_owner] = '" . pnVarPrepForStore($uid)."'"; // <------ Fix
|
| Code: |
<!--[mainpic uid=$uid]-->
|
That should help getting nearer...
This part is useless :
| Code: |
if (!isset($template) || empty($template)) {
$template = pnModGetVar('advProfile', 'template');
}
|
Unless you use a template...
Be careful also if there is more than one file for this owner... If more than one file, then $mainpic will be an array and will output "Array" or nothing. |
_________________ Chestnut !
Administrator
PNConcept.com |
|
 |
 |
whiskey
Joined: Jul 14, 2005
Posts: 5
Status: Offline
|
  Posted:
Jul 18, 2005 - 05:09 AM |
|
At last it worked thanks... here its the code:
| Code: |
<?php
// File : $Id: function.mainpic.php,v 1.3 2005/05/16 16:29:19 Chestnut Exp $
// ----------------------------------------------------------------------
// PostNuke Content Management System
// Copyright (C) 2001 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Chestnut :: http://www.pnconcept.com
// Purpose of file: Last 10 Comments for the advProfile
// ----------------------------------------------------------------------
/**
* Smarty function to displays the main user pic for the ns_newuser hack + photoshare
*
* Example
* <!--[mainpic uid=$uid]-->
*
* @author F. Chestnut (yup, i just modded this file -whiskey- )
* @since 25/01/05
* @see function.mainpic.php::smarty_function_mainpic()
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @param string $uid userid
* @return string the results of the module function
*/
function smarty_function_mainpic($params, &$smarty)
{
if (!pnSecAuthAction(0, 'advProfile::', 'Plugin::mainpic.php', ACCESS_READ)) {
return false;
}
extract($params);
unset($params);
if (!isset($uid) || empty($uid)) {
return false;
}
if (!isset($template) || empty($template)) {
$template = pnModGetVar('advProfile', 'template');
}
pnModDBInfoLoad('photoshare');
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$tbl = $pntable['photoshare_folders'];
$col = &$pntable['photoshare_folders_column'];
$sql = "SELECT ps_mainimage
FROM $tbl
WHERE ps_owner = '" . pnVarPrepForStore($uid) . "'"; //
$result = $dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
echo $dbconn->ErrorMsg();
return false;
}
if ($result->EOF) {
$mainpic = 0;
} else {
list($mainpic) = $result->fields;
}
$result->Close();
return $mainpic;
}
?>
|
Now, you can see that i had to call the tables by their names... well i didn't found a way for them to work properly calling them:
| Code: |
$sql = "SELECT $col[ps_mainimage]
FROM $tbl
WHERE $col[ps_owner] = '" . pnVarPrepForStore($uid) . "'"; //
|
and i do not why but this works.
Now for the other part of the hack... i will post later because we have to make sure every new user has a unique album.
see ya |
|
|
|
 |
whiskey
Joined: Jul 14, 2005
Posts: 5
Status: Offline
|
  Posted:
Jul 18, 2005 - 05:54 AM |
|
Note that the previous plugin will work when you create a photoshare album for each new user (yes, previous users will require you to create them an album)
go to user.php from ns_newuser and somewhere insert this:
| Code: |
// Add photoshare entry to postnuke for this user
$psdate= UNIX_TIMESTAMP(pnVarPrepForStore($user_regdate))
$result = &$dbconn->Execute("INSERT INTO nuke_photoshare_folders (ps_id, ps_owner, ps_createddate, ps_modifieddate, ps_title, ps_description, ps_topic, ps_template, ps_blockfromlist, ps_hidepnframe, ps_parentfolder, ps_accesslevel, ps_viewkey, ps_mainimage)
VALUES (". pnVarPrepForStore($uid) . ", " . pnVarPrepForStore($uid) . ", " . $psdate . ", " . $psdate . ", " . pnVarPrepForStore($uid) . ", " . pnVarPrepForStore($uid) . ", -1, 'book', 0, 0, -1, 0, NULL, NULL)");
// Resume your work now
|
below this:
| Code: |
// Let any hooks know that we have created a new item
pnModCallHooks('item', 'create', $uid, 'uid');
|
which is somewhere around line 440 - 442
This code creates a new sql entry for your user into photoshare folders after they create their entry, it uses the book template as default, you can change to any other template you want. Also uses the nuke preffix and the photoshare standard name so keep that in mind.
Now this takes care for new users, but not for existing ones... i will see how to fix this (maybe a php script to read your existing users and create them new albums? i dont know), and if you create the user manually via admin, such user will not have (yet) a new album. Easy, just go and create one yourself for him/her. (yes as soon as i find how i will post the hack for this).
Next we should take care about a couple of things... for example, as chestnut points out, if multiple albums are generated (sub albums), multiple main pictures will be defined for each user and multiple outputs will generate an array... Maybe we can make it select just main folders ( adding to the WHERE in the query something like AND ps_parentfolder = -1. Also we will want to make sure that photoshare will not create a new folder with the same number as a new user... (this hack is also in the TODO bin), maybe creating manually a folder with a really really large number (so new users get the lower numbers and sub folders will autoincrement from lets say 123456789 and forth XD ), but until i try it i will not recommend it.
Now for my website i do not need multiple albums per user (yet), so there will be no "create new album" function (nor delete function)... any new hack needed i will post here.
Thanks for the help! |
|
|
|
 |
|
|
|