JomSocial: Preventing Album Reposts When Uploading Single Picture

I’ve been working on another site and it features JomSocial (Joomla 2.5, JomSocial 3.0) along with the “activities” module that lists the latest activity as far as pictures, videos, comments, forum, etc.

One of my biggest irritations with the activity list was this:

I created separate album, say per city or subject and would upload maybe 5 pictures one day.   Months later, when I go to upload a new photo pertaining to that subject/album, not only would my new photo show up in the activities feed, but ALL photos (up to the limit of 5), even if they were months old.  It would make other updates of photos drop down the feed and the new photos become lost.  So, today I dug in the code and created a bit of a mod.  I’m sure it might be buggy or can be improved upon, but for now – it gets the job done.

in file:  /components/com_community/libraries/photos.php

at line 81, after

$albumsHelper = new CAlbumsHelper( $album );  insert this:
$db = JFactory::getDBO();
$sql = “SELECT * FROM #__community_photos WHERE `albumid`=”.$album->id
.” AND `id`=” . $photoid
.” AND `status` != ‘temp'”;
$result = $db->loadObject();
$created = $result->created;

at line 116, replace:

$sql = “SELECT * FROM #__community_photos WHERE `albumid`=”.$album->id
  .” AND `status` != ‘temp'”
  .” ORDER BY `id` DESC LIMIT 0, 5″;


//$sql = “SELECT * FROM #__community_photos WHERE `albumid`=”.$album->id
//.” AND `status` != ‘temp'”
//.” ORDER BY `id` DESC LIMIT 0, 5″;
$sql = “SELECT * FROM #__community_photos WHERE `albumid`=”.$album->id.” AND `created` LIKE ‘”.date(‘Y-m-d’,strtotime($created))
.”%’ AND `status` != ‘temp'”
.” ORDER BY `id` DESC LIMIT 0, 5″;

What I aimed to do is …

Continue Reading

Connecting to and Calling An AS400 Program with i5_toolkit

I’m starting to document some of the ways I’ve begun to use Aura’s EasyCom i5 Connect package to connect PHP to our as400. This has been a long process of trying to webify some of our programs and get the information out.  (btw, we’re a small business and yearly the package is about $600 – very, very reasonable.)

Currently, we have a webserver (Windows Server) that hosts our website. On it, we installed the required Aura software (a Windows exe GUI and a PHP extension) to connect to our as400. The PHP pages then utilize that PHP extension to make calls to our as400. On our as400 side, our programmer created small programs to access the larger programs we need. So, I pass say 3 parameters via PHP, make a call via Ericom i5, and then the RPG does the brainwork. It passes back my requested parameters and sets up a datafile I can query using basic ODBC and mySQL. We may change this in the future, but we like the logic work taking place in RPG on the as400 (where all our data resides anyway) and PHP being the fetcher of such data.

So, first up,  here’s how I connect to the as400 (after initial setup):

	*  AS400 Management
		// connect to the iSeries / prepare for procedure call - port can be set up thru Aura GUI
		// keeping username and password in session to be able to connect to as400 as needed
		function i5_conn_AS400(){
			$conn = i5_connect('', $_SESSION['CONN_USER'], $_SESSION['CONN_PASSWORD']);

			if (!$conn) {
				$error = i5_error();
				echo " Error during connection\n";
				echo "<BR> Error number: ".$error["num"];
				echo "<BR> Error category: ".$error["cat"];
				echo "<BR> Error message: ".$error["msg"];
				echo "<BR> Error description: ".$error["desc"];
				trigger_error("I5 connection fails", E_USER_ERROR);
			return $conn;

Then, here’s the preparation of parameters and call to the as400:

/* Set the Value of the Parameters */
$desc = array (
array ("name"=>"PARM1", "io"=>I5_INOUT, "type"=>I5_TYPE_CHAR, "length"=> 50),
array ("name"=>"PARM2", "io"=>I5_INOUT, "type"=> I5_TYPE_PACKED, "length"=> "8.0"),
array ("name"=>"PARM3", "io"=>I5_INOUT, "type"=>I5_TYPE_CHAR, "length"=> 1)

$prog = i5_program_prepare("PGMLIB/WEBLIB", $desc);

if ($prog === FALSE) {
$errorTab = i5_error();
echo "Program prepare failed <br>\n";

/* Execute Program */
$params = array ("PARM1"=>$sessID,"PARM2"=>$PARM2,"PARM3"=>$PARM3);
$retvals = array ("PARM1"=>"PARM1","PARM2"=>"PARM2","PARM3"=>"PARM3");

$ret = i5_program_call($prog, $params, $retvals) ;

if (!$ret){
trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);

$ret = i5_program_close ($prog);

if (!$ret){
trigger_error("i5_program_close error : ".i5_errormsg(), E_USER_ERROR);

I’ve actually created a connection “class” for both the Aura i5 connect and the odbc connect. That way when needed, I can simply call a function and connect to each as needed. I’m still VERY new to this all (and I just learned PHP), but figure I’d document some of this process as I go along. I have two sites currently running on this logic.

Continue Reading