Changeset 2105

Show
Ignore:
Timestamp:
04/10/08 20:40:08 (4 months ago)
Author:
anarcat
Message:

crude implementation of permission change in the file browser

Contributed by: Mathieu Lutfy
Sponsored by: Koumbit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/admin/bro_main.php

    r2104 r2105  
    108108    } 
    109109    break; 
     110  case 7:  // Changement de permissions [ML] 
     111    if (!$bro->ChangePermissions($R, $d, $perm)) { 
     112      print $err->errstr(); 
     113    } 
     114    break; 
    110115  } 
    111116} 
     
    174179} 
    175180 
     181/* [ML] Changer les permissions : */ 
     182if ($formu==2 && $_REQUEST['actperms'] && count($d)) { 
     183  echo "<form action=\"bro_main.php\" method=\"post\">\n"; 
     184  echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n"; 
     185  echo "<input type=\"hidden\" name=\"formu\" value=\"7\" />\n"; 
     186  echo "<p>"._("Permissions")."</p>"; 
     187 
     188  $tmp_absdir = $bro->convertabsolute($R,0); 
     189 
     190  echo "<table border=\"1\">"; // FIXME, marco, ajouter classe css? 
     191  echo "<tr>"; 
     192  // echo "<th>" . 'File' . "</th><th>&nbsp;</th><th>Owner</th><th>Group</th><th>Other</th>"; // FIXME , i18n 
     193  echo "<th>" . 'File' . "</th><th>Permissions</th>"; // FIXME, i18n 
     194  echo "</tr>"; 
     195 
     196  for ($i=0;$i<count($d);$i++) { 
     197    $d[$i]=ssla($d[$i]); 
     198    $stats = stat($tmp_absdir . '/' . $d[$i]); 
     199    $modes = $stats[2]; 
     200 
     201    echo "<tr>"; 
     202    echo "<td>".$d[$i]."</td>"; 
     203 
     204    // Owner 
     205    echo "<td>"; 
     206    echo "<input type=\"hidden\" name=\"d[$i]\" value=\"".$d[$i]."\" />"; 
     207    // echo "<label>read <input type=\"checkbox\" name=\"perm[$i][r]\" value=\"1\" ". (($modes & 0000400) ? 'checked="checked"' : '') ." />"; 
     208    echo "<label>write <input type=\"checkbox\" name=\"perm[$i][w]\" value=\"1\" ". (($modes & 0000200) ? 'checked="checked"' : '') ." />"; 
     209    echo "</td>"; 
     210 
     211    echo "</tr>"; 
     212  } 
     213 
     214  echo "</table>"; 
     215 
     216  echo "<p><input type=\"submit\" class=\"inb\" name=\"submit\" value=\""._("Change permissions")."\" /></p>"; 
     217  echo "</form>\n"; 
     218  echo "<hr />\n"; 
     219} 
     220 
    176221/* We draw the file list and button bar only if there is files here ! */ 
    177222if (count($c)) { 
     
    190235 
    191236<input type="submit" class="inb" name="actrename" value="<?php __("Rename"); ?>" /> 
     237<input type="submit" class="inb" name="actperms" value="<?php __("Permissions"); ?>" /> <!-- [ML] --> 
    192238&nbsp;&nbsp;&nbsp; 
    193239<input type="submit" class="inb" name="actcopy" value="<?php __("Copy to"); ?>" /> 
  • alternc/trunk/bureau/class/m_bro.php

    r2101 r2105  
    383383      } 
    384384    } 
     385    return true; 
     386  } 
     387 
     388  /* ----------------------------------------------------------------- */ 
     389  /** Change les droits d'acces aux fichier de $d du dossier $R en $p 
     390   * @param string $R dossier dans lequel se trouve les fichiers à renommer. 
     391   * @param array of string $old Ancien nom des fichiers 
     392   * @param array of string $new Nouveau nom des fichiers 
     393   * @return boolean TRUE si les fichiers ont été renommés, FALSE si une erreur s'est produite. 
     394   */ 
     395  function ChangePermissions($R,$d,$perm) { 
     396    global $err; 
     397    $absolute=$this->convertabsolute($R,0); 
     398    if (!$absolute) { 
     399      $err->raise("bro",1); 
     400      return false; 
     401    } 
     402    for ($i=0;$i<count($d);$i++) { 
     403      $d[$i]=ssla($d[$i]); // strip slashes if needed 
     404      if (!strpos($d[$i],"/")) {  // caractère / interdit dans le nom du fichier 
     405        // @rename($absolute."/".$old[$i],$absolute."/".$old[$i].$alea); 
     406        $m = fileperms($absolute."/". $d[$i]); 
     407 
     408        // pour l'instant on se limite a "write" pour owner, puisque c'est le seul 
     409        // cas interessant compte tenu de la conf de Apache pour AlternC.. 
     410        if ($perm[$i]['w']) { 
     411          $m = $m | 128; 
     412        } else { 
     413          $m = $m ^ 128; 
     414        } 
     415        $m = $m | ($perm[$i]['w'] ? 128 : 0); // 0600 
     416        chmod($absolute."/".$d[$i], $m); 
     417        echo "chmod " . sprintf('%o', $m) . " file, was " . sprintf('%o', fileperms($absolute."/". $d[$i])). " -- " . $perm[$i]['w']; 
     418      } 
     419    } 
     420 
    385421    return true; 
    386422  } 
  • alternc/trunk/debian/changelog

    r2104 r2105  
    44    Marc Angles, sponsored by Koumbit 
    55  * styles can now be changed locally in admin/styles/base.css 
     6  * crude implementation of a permission change interface in the file browser 
    67 
    78 -- Antoine Beaupré <anarcat@koumbit.org>  Thu, 10 Apr 2008 13:56:22 -0400