Calling File operations from a public page.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling File operations from a public page.

tharinduDG
I'm developing a app for owncloud and I have a public page which is produced by a guest template. 
From that page, I'm calling some functions of Filesystem namespace. But I'm getting an error. But when I tryed to load that page after logging in, then the error doesn't come. 

Here is the function call and the definition of the function that I try to call from the above mentioned guest template page.

$files = \OCA\CloudToCloud\CloudToCloudShare::getFiles($email,$dir);  // this is called from the 'public' page



    public static function getFiles($email,$dir){
        $query = \OC_DB::prepare("SELECT * FROM *PREFIX*c2c_share WHERE `email`=? ORDER BY `stime`");
        $result = $query->execute(array($email));
        $files = array();

        if($dir == ""){
            while ($aFile = $result->fetchRow()) {
                if($aFile['item_type'] == "file"){
                   $name = $aFile['file_target'];
                   $path = \OC\Files\Filesystem::getPath($aFile['item_source']);
                   $parent_path = substr($path,0,strrpos($path,'/')+1);
                   $dir_content = \OC\Files\Filesystem::getDirectoryContent($parent_path);

                    foreach($dir_content as $i){
                        if($i['name'] == $name && $i['type']=="file"){
                            $files[] = $i;
                            break;
                        }
                    }
                }else{
                    $name = $aFile['file_target'];
                    $path = \OC\Files\Filesystem::getPath($aFile['item_source']);
                    $parent_path = substr($path,0,strrpos($path,'/')+1);
                    $dir_content = \OC\Files\Filesystem::getDirectoryContent($parent_path);
                    foreach($dir_content as $i){
                        if($i['name'] == $name && $i['type']=="dir"){
                            $files[] = $i;
                            break;
                        }
                    }
                }
            }
        }else{
            while($aFile = $result->fetchRow()){
                if($aFile['item_type'] == "dir" && $aFile['file_target'] == $dir){
                    $path = \OC\Files\Filesystem::getPath($aFile['item_source']);
                    $dir_content = \OC\Files\Filesystem::getDirectoryContent($path);
                    foreach($dir_content as $i){
                            $files[] = $i;
                    }
                }
            }

        }
        return $files;
    }

Please help me to resolve this error. 
Thank YOu


_______________________________________________
Owncloud mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/owncloud
Reply | Threaded
Open this post in threaded view
|

Re: Calling File operations from a public page.

Chris-3
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Calling File operations from a public page.

tharinduDG
The error is  : [error] [client 127.0.0.1] PHP Fatal error:  Call to a member function getPath() on a non-object in /var/www/owncloud5/lib/files/filesystem.php on line 638


On Fri, Jun 28, 2013 at 1:05 PM, Chris <[hidden email]> wrote:
Hi,

i can't help you with this but just a comment to this:

> But I'm getting an error

NEVER, EVER!!!! post something like this. If you're getting an error then
post it because nobody can guess what error you've got.



--
View this message in context: http://owncloud.10557.n7.nabble.com/Calling-File-operations-from-a-public-page-tp9936p9937.html
Sent from the ownCloud mailing list archive at Nabble.com.
_______________________________________________
Owncloud mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/owncloud


_______________________________________________
Owncloud mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/owncloud