How can include class OssPhotos in my component

Dani MR Posted in Beginning Developers 8 years ago

Hi,

I try include a function of the class OssnPhotos (AddPhoto()) inside a script /actions of myComponent. But the system don't found the class.

Example code:

require_once(__OSSN_PHOTOS__ . 'classes/OssnPhotos.php');

$addPhoto = new OssnPhotos;
$add = new OptionTrips;

$access = 'OSSN_PUBLIC';

if ($addPhoto->AddPhoto(130, 'ossnphoto', $access/input('privacy')/)){
redirect(REF);
} else {
redirect(REF);
}

Thanks!

Replies
Spanish Dani MR Replied 8 years ago

Exacly Zet!

Many many thanks!

German Michael Zülsdorff Replied 8 years ago

photos-submit instead of add-photos ....
and the wrong action url ...

yeah, just came across that. :)

good luck

Spanish Dani MR Replied 8 years ago

Sorry Zen.

Now is working, the problem was the callback id!! When I was pushing the button for save the file.

Sorry for spend your time!

Very friendly for all your help and attention.

Regards master

German Michael Zülsdorff Replied 8 years ago

Okay, perhaps time to clear up what your problem really is?

First you made us think you can't access the OssnPhoto class. Actually, it would lead to a PHP Fatal Error if you can't. But you got NO error, as I got no error when calling AddPhoto() from anywhere.

So: what exactly are you trying to achieve, that doesn't work?

Spanish Dani MR Replied 8 years ago

Tanks Zen!

But I don't found the problem :(

Regards

German Michael Zülsdorff Replied 8 years ago

Thanks, I'll look into it later this evening.

All I can tell so far is: An hour ago I placed your lines:

$addPhoto = new OssnPhotos;
$addPhoto->AddPhoto(306, 'ossnphoto', 2);

somewhere into my own component, and I had absolutely no problem reaching the AddPhoto function.
Thus, if something doesn't work as expected - why don't you place some error loggin into it, like:

//check if album guid is not less than 0 and validate photo uploader
 if (!empty($album) && $album > 0 && $this->album->album->owner_guid == ossn_loggedin_user()->guid) {
    error_log('check passed! album_owner: ' .  $this->album->album->owner_guid);

to verify where the code is running along from error_log file?

Spanish Dani MR Replied 8 years ago

OK. Zen I updated the repository ;)
https://github.com/tricotrin/OptionTrips/blob/master/actions/addPhoto.php

The log only showing:
[28-Feb-2016 23:24:01 Europe/Berlin] PHP WARNING: 2016-02-28 23:24:01 (CET): "array_search() expects parameter 2 to be array, null given" in file C:\xampp\htdocs\social1\social\libraries\ossn.lib.javascripts.php (line 199)

But this warning was old. No new.

Thanx a lot

German Michael Zülsdorff Replied 8 years ago

> $access /input("privacy")/ was a comment ;)

that's why I asked to update your repository. There's a much better chance to have look what's wrong.

Besides that: the class should have been populated to Ossn from within the OssnPhotos component already.

So, what exactly does your error_log file show?

Spanish Dani MR Replied 8 years ago

Sorry Zen,

$access /input("privacy")/ was a comment ;)

Then if I include:
require_once(OSSN_PHOTOS . 'classes/OssnPhotos.php');

In my action directory script (not in ossn_com.php). Is it correct?

Thanks a lot

German Michael Zülsdorff Replied 8 years ago

Oops: what is $access/input("privacy")/) ?!?

OSSN_PUBLIC is an access right (=2), defined in ossn.lib.system - not a path name! :)

(yes, and don't forget updating the repository)