[Owncloud] Calling File operations from a public page.

Tharindu Dhananjaya Galappaththi tdgalappaththi at gmail.com
Fri Jun 28 06:42:28 UTC 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20130628/7030d659/attachment.html>


More information about the Owncloud mailing list