예제 #1
0
 function invalidateEntry(&$model, $id = null, $fields = null)
 {
     if (is_null($id)) {
         $id = $model->id;
     }
     if (empty($id)) {
         return false;
     }
     $node = $model->node($model->myNodeRef($id), false, true);
     if (!empty($node)) {
         if (empty($fields)) {
             $fields = array(0 => null);
         }
         $tmp = $model->Invalidation->belongsTo;
         $res = true;
         $model->Invalidation->belongsTo = array();
         App::import('Lib', 'TimeUtil');
         foreach ((array) $fields as $field) {
             $data = array('node_id' => $node['Node']['id'], 'field' => $field);
             $opt = array('fields' => array('id', 'id'), 'conditions' => array('node_id ' => $node['Node']['id']));
             if (!empty($field)) {
                 $opt['conditions']['field'] = $field;
             }
             $old = $model->Invalidation->find('list', $opt);
             if (!empty($old)) {
                 $old = array_keys($old);
                 //debug($old);
                 $data['id'] = array_shift($old);
                 $model->Invalidation->deleteAll(array('id' => $old));
             }
             $model->Invalidation->create();
             $data['time'] = TimeUtil::relTime();
             if (!$model->Invalidation->save($data)) {
                 $res = false;
                 break;
             }
         }
         $model->Invalidation->belongsTo = $tmp;
         return $res;
         //$data = array('node_id'=>$node['Node']['id'],'fields'=>$fields);
         //return $model->Invalidation->save($data);
     }
     return false;
 }
예제 #2
0
파일: link.php 프로젝트: kevthunder/arch
 function initialize(&$controller, $settings = array())
 {
     $this->controller =& $controller;
     App::import('Lib', 'TimeUtil');
     $this->startTime = (string) TimeUtil::relTime();
 }