API15

Difference between revisions of "JPath/setPermissions"

From Joomla! Documentation

< API15:JPath
(New page: ===Description=== Chmods files and directories recursivly to given permissions <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JPath/setPermissions|E...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JPath/setPermissions|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JPath/setPermissions}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 83: Line 83:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JPath/setPermissions|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JPath/setPermissions}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 98: Line 98:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 13:41, 12 May 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Chmods files and directories recursivly to given permissions

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

setPermissions($path, $filemode= '0644', $foldermode= '0755')
Parameter Name Default Value Description
$path $path Root path to begin changing mode [without trailing slash]
$filemode '0644' $filemode Octal representation of the value to change file mode to [null = no change]
$foldermode '0755' $foldermode Octal representation of the value to change folder mode to [null = no change]

Returns[edit]

boolean True if successful [one fail means the whole operation failed]

Defined in[edit]

libraries/joomla/filesystem/path.php

Importing[edit]

jimport( 'joomla.filesystem.path' );

Source Body[edit]

function setPermissions($path, $filemode = '0644', $foldermode = '0755') {

        // Initialize return value
        $ret = true;

        if (is_dir($path))
        {
                $dh = opendir($path);
                while ($file = readdir($dh))
                {
                        if ($file != '.' && $file != '..') {
                                $fullpath = $path.'/'.$file;
                                if (is_dir($fullpath)) {
                                        if (!JPath::setPermissions($fullpath, $filemode, $foldermode)) {
                                                $ret = false;
                                        }
                                } else {
                                        if (isset ($filemode)) {
                                                if (!@ chmod($fullpath, octdec($filemode))) {
                                                        $ret = false;
                                                }
                                        }
                                } // if
                        } // if
                } // while
                closedir($dh);
                if (isset ($foldermode)) {
                        if (!@ chmod($path, octdec($foldermode))) {
                                $ret = false;
                        }
                }
        }
        else
        {
                if (isset ($filemode)) {
                        $ret = @ chmod($path, octdec($filemode));
                }
        } // if
        return $ret;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />