Exemple #1
0
 /**
  * 检查目录是否存在
  * @return Int
  * @author weizhifeng
  **/
 protected function dir_exist()
 {
     //对当前的目录进行检查
     if (isset($this->post['dir_id'])) {
         $folder_id = (int) $this->post['dir_id'];
     } else {
         //检查站点有没有根目录,如没有则添加
         $check_count = $this->kc_folder->count(array('where' => array('site_id' => 1, 'level_depth' => 1)));
         if ($check_count <= 0) {
             $root_folder = array('site_id' => 1, 'parent_id' => '0', 'sub_folder_ids' => '', 'name' => 'image', 'level_depth' => 1, 'date_add' => date('Y-m-d H:i:s'), 'date_upd' => date('Y-m-d H:i:s'));
             $folder_id = $this->kc_folder->create($root_folder);
         } else {
             $root_folder = $this->kc_folder->lists(array('where' => array('site_id' => 1, 'level_depth' => 1)));
             $folder_id = $root_folder[0]['id'];
         }
     }
     // 检查目录是否存在
     $folder = $this->kc_folder->get($folder_id);
     if ($folder['id'] == 0) {
         $this->error_msg(Kohana::lang('o_kc.folder_not_exist'));
     } else {
         return $folder_id;
     }
 }