Ignore:
Timestamp:
Jun 26, 2014 5:37:23 PM (11 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php

    r12 r16  
    154154                if (file_exists($file) && count($aryDataSet) > 0) {
    155155                        $h = fopen ($file, $flag);
    156                         foreach ($aryDataSet as $key => $line) {
     156                        foreach ($aryDataSet as $key => $aryTmp) {
    157157                                $line = implode(',',$aryTmp);
    158                                 fwrite($line."\n", $h);
     158                                fwrite($h, $line."\n");
    159159                        }
    160160                        fclose ($h);
     
    176176        }
    177177       
     178        public function rename ($id, $newName, $type = 'directory') {
     179               
     180                if (!$newName || !$id) return FALSE;
     181                $aryObj = $type == 'directory' ? $this->getAllDirectory() : $this->getAllFile();
     182                $dbFile = $type == 'directory' ? $dbFile = 'directory.db' : $dbFile = 'file.db';
     183               
     184                if (count($aryObj) > 0) {
     185                        foreach ($aryObj as $key => $obj) {
     186                                if ($obj['id'] == $id) break;
     187                        }
     188                       
     189                        $aryObj[$key]['name'] = $newName;
     190                       
     191                        return $this->writeDB($dbFile, $aryObj);
     192                }
     193               
     194                return FALSE;
     195        }
     196       
    178197}
Note: See TracChangeset for help on using the changeset viewer.