11
Mamba
Re: myalbum error dimension image
  • 2013/8/8 17:11

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


To fix the issue with photo size replace following code in /photo.php around line 50:

// Middle size calculation
$photo['width_height'] = '' ;
list( 
$max_w $max_h ) = explode'x' $myalbum_middlepixel ) ;
if( ! empty( 
$max_w ) && ! empty( $p['res_x'] ) ) {
    if( empty( 
$max_h ) ) $max_h $max_w ;
    if( 
$max_h $max_w $p['res_y'] / $p['res_x'] ) {
        if( 
$p['res_x'] > $max_w $photo['width_height'] = "width='$max_w'" ;
    } else {
        if( 
$p['res_y'] > $max_h $photo['width_height'] = "height='$max_h'" ;
    }
}

with this code:

// Middle size calculation
$photo['width_height'] = '' ;
list( 
$max_w $max_h ) = explode'x' $myalbum_middlepixel ) ;
if( ! empty( 
$max_w ) && ! empty( $photo_obj->getVar('res_x') ) ) {
    if( empty( 
$max_h ) ) $max_h $max_w ;
    if( 
$max_h $max_w $photo_obj->getVar('res_y') / $photo_obj->getVar('res_x') ) {
        if( 
$photo_obj->getVar('res_x') > $max_w $photo['width_height'] = "width='$max_w'" ;
    } else {
        if( 
$photo_obj->getVar('res_y') > $max_h $photo['width_height'] = "height='$max_h'" ;
    }
}


Please test it and let us know if it works.

This is what has happened:

1) GIJoe was using this code to update the count of hits:
// update hit count
$xoopsDB->queryF"UPDATE $table_photos SET hits=hits+1 WHERE lid='$lid' AND status>0" ) ;

$prs $xoopsDB->query"SELECT l.lid, l.cid, l.title, l.ext, l.res_x, l.res_y, l.status, l.date, l.hits, l.rating, l.votes, l.comments, l.submitter, t.description FROM $table_photos l LEFT JOIN $table_text t ON l.lid=t.lid WHERE l.lid=$lid AND status>0" ) ;
$p $xoopsDB->fetchArray$prs ) ;
if( 
$p == false ) {
    
redirect_header$mod_url.'/' _ALBM_NOMATCH ) ;
    exit ;
}


2) Wishcraft has converted it to use XOOPS API (which was a very good idea), by creating a "MyalbumPhotos" object, with a method:
function increaseHits($value 1) {
        return 
$GLOBALS['xoopsDB']->queryF"UPDATE ".$GLOBALS['xoopsDB']->prefix($GLOBALS['table_photos'])." SET hits=hits+".$value." WHERE `lid`='".$this->getVar('lid'). "' AND `status` > 0" ) ;
    }


3) So then he replaced the code in (1) with:
// update hit count
$photo_obj->increaseHits(1);


4) However, he didn't check if the $p variable is used anywhere else, which unfortunately was the case in the code to be replaced:

Quote:
if( ! empty( $max_w ) && ! empty( $p['res_x'] ) ) {:

As a result, the function was never executed, and the value $photo['width_height'] was never assigned.

Another problem: It seems like, when you go to:
/modules/myalbum/admin/photomanager.php
and select few pictures to delete, it deleted ALL my pictures on the test site.

I have to investigate it, but for the time being please DO NOT USE this function on your production side.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

12
Mamba
Re: myalbum error dimension image
  • 2013/8/8 21:22

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


Quote:
Another problem: It seems like, when you go to:
/modules/myalbum/admin/photomanager.php
and select few pictures to delete, it deleted ALL my pictures on the test site.

I have to investigate it, but for the time being please DO NOT USE this function on your production side.

OK, this seems to be fixed now.

What happened is that Wishcraft changed the original function in /include/functions.php:

// Delete photos hit by the $whr clause
function myalbum_delete_photos$whr )
{
    global 
$xoopsDB ;
    global 
$photos_dir $thumbs_dir $myalbum_mid ;
    global 
$table_photos $table_text $table_votedata ;

    
$prs $xoopsDB->query("SELECT lid, ext FROM $table_photos WHERE $whr) ;
    while( list( 
$lid $ext ) = $xoopsDB->fetchRow$prs ) ) {

        
xoops_comment_delete$myalbum_mid $lid ) ;
        
xoops_notification_deletebyitem$myalbum_mid 'photo' $lid ) ;

        
$xoopsDB->query"DELETE FROM $table_votedata WHERE lid=$lid) or die( "DB error: DELETE votedata table." ) ;
        
$xoopsDB->query"DELETE FROM $table_text WHERE lid=$lid) or die( "DB error: DELETE text table." ) ;
        
$xoopsDB->query"DELETE FROM $table_photos WHERE lid=$lid) or die( "DB error: DELETE photo table." ) ;
    
        @
unlink"$photos_dir/$lid.$ext) ;
        @
unlink"$photos_dir/$lid.gif" ) ;
        @
unlink"$thumbs_dir/$lid.$ext) ;
        @
unlink"$thumbs_dir/$lid.gif" ) ;
    }
}


to a new one that would use XOOPS API and Criteria class:

function myalbum_delete_photos$criteria null )
{
    
$photos_handler xoops_getmodulehandler('photos'$GLOBALS['mydirname']);
    
$photos $photos_handler->getObjects($criteria);
    foreach( 
$photos as $lid => $photo ) {
        
$photos_handler->delete($photo);
    }
}


This function expected as input "$criteria" object.

However, he didn't update the function in the photomanager.php, that was calling it:

foreach( $_POST['ids'] as $lid ) {
        
myalbum_delete_photos"lid=".intval$lid ) ) ;
    }


So it was sending a string like: "lid=2", which of course was not a $criteria object that the function myalbum_delete_photos was expecting. As a results, XOOPS was deleting all photos.

I'll test is some more and commit it to SVN...
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

13
Mamba
Re: myalbum error dimension image
  • 2013/8/8 22:13

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


OK, I've committed the changes to XOOPS SVN. Please read more here in this thread
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

14
cerbero
Re: myalbum error dimension image
  • 2013/8/9 8:07

  • cerbero

  • Not too shy to talk

  • Posts: 191

  • Since: 2003/9/11


thanks for your efforts mamba, changing the code in photo.php results in:
Fatal error: Can't use method return value in write context in /home/xxx/lahiguerita/modules/myalbum/photo.php on line 54

and updating with SVN 3.07 rc3 gets:
Fatal error: Can't use method return value in write context in /home/xxx/lahiguerita/modules/myalbum/photo.php on line 55

in foto view

15
Mamba
Re: myalbum error dimension image
  • 2013/8/9 15:11

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


Ok, try to replace the code in photo.php with this one:

$photo['width_height'] = '' ;
$res_x $photo_obj->getVar('res_x');
$res_y $photo_obj->getVar('res_y');
list( 
$max_w $max_h ) = explode'x' $myalbum_middlepixel ) ;
//if( ! empty( $max_w ) && ! empty( $p['res_x'] ) ) {
if( ! empty( $max_w ) && ! empty( $res_x ) ) {
    if( empty( 
$max_h ) ) $max_h $max_w ;
    if( 
$max_h $max_w $res_y $res_x ) {
        if( 
$res_x $max_w $photo['width_height'] = "width='$max_w'" ;
    } else {
        if( 
$res_y $max_h $photo['width_height'] = "height='$max_h'" ;
    }
}
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

16
cerbero
Re: myalbum error dimension image
  • 2013/8/12 9:05

  • cerbero

  • Not too shy to talk

  • Posts: 191

  • Since: 2003/9/11


ok mamba, that works like a charm, thanks a lot

only an advice:
Aviso: Undefined offset: 1 en el archivo /modules/myalbum/photo.php y lí­nea 65

let's try to solve the pagination issue?

17
Mamba
Re: myalbum error dimension image
  • 2013/8/12 12:58

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


Quote:
ok mamba, that works like a charm, thanks a lot

Great! I am glad to hear it!

Quote:
let's try to solve the pagination issue?

There is also issues with the "Submitted photos" tab.

I'll look into it when I find some time this or next week...
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

18
cerbero
Re: myalbum error dimension image
  • 2013/8/13 8:38

  • cerbero

  • Not too shy to talk

  • Posts: 191

  • Since: 2003/9/11


Glad to hear you, could be a pity loosing a so great and usefull module, thanks again

19
Mamba
Re: myalbum error dimension image
  • 2013/8/13 23:29

  • Mamba

  • Moderator

  • Posts: 11258

  • Since: 2004/4/23


The above issues should be now fixed in Version 3.07 RC3

Let me know if the pagination works now for you. If not, please submit screenshots and point to the issues.

Have fun testing
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Login

Who's Online

61 user(s) are online (42 user(s) are browsing Support Forums)


Members: 0


Guests: 61


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits