<?php
namespace uhome\controller;
ini_set('max_execution_time', '0');
class Folder extends Uhome {
	/*
	 * pk1 uid
	 * pk2 re
	 * pk3   
	 * pk4 日期
	 */
    public function index(){
    	$folder =  M("folder")->where(array('reid'=>0,'uid'=>session("user_auth.id")))->select();
    	$this->folder = $folder;
    	$this->display();
    }
    
    public function lists($re=''){
    	$uid=session("user_auth.id");
    	$spk = array (
		    'pk1' => $uid,
		    'pk2' => $re,
	        'pk3' => array('type' => 'INF_MAX'),
	        'pk4' => '',
		);
		$epk = array (
		    'pk1' => $uid,
		    'pk2' => $re,
	        'pk3' => array('type' => 'INF_MIN'),
	        'pk4' => '',
		);
		
		$list=O('folder')->select(array(
			'spk'=>$spk,
			'epk'=>$epk,
			'filter'=>array('status'=>array('eq',0)),
		));
		
		$this->ajaxReturn($list);
		
    }
    
    public function add(){
    	$uid=session("user_auth.id");
		$attr=I('attr',array());
		$attr['status']=0;
		$pk=array ( 
	        'pk1' => $uid,
	        'pk2' => I('re',''),
	        'pk3' => '',
	        'pk4' => getTime(),
	    );
		$re=O('folder')->add(array(
			'pk'=>$pk,
			'attr'=>$attr,
		));
    	$this->ajaxReturn($re);
    }
    
    public function mod(){
    	$uid=session("user_auth.id");
		$attr=I('attr',array());
		$pk=array(
			'pk1'=>$uid,
			'pk2'=>I('pk2',''),
			'pk3'=>I('pk3',''),
			'pk4'=>I('pk4',''),
		);
		$re=O('folder')->save(array(
			'pk'=>$pk,
			'attr'=>$attr,
		));
    	$this->ajaxReturn($re);
    	
    }
	
    
}