Show
Ignore:
Timestamp:
04/24/08 19:10:16 (7 months ago)
Author:
fabry
Message:

ability to keep track of the downloaded "offsite" pbis

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • websites/pbidir.com/bibivu/bin/start.php

    r1755 r1770  
    379379                        return; 
    380380                } 
    381  
    382                 $this->load_library('pbi_release'); 
    383                 $filters = array(); 
    384                 $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y'); 
    385                 $filters[] = array('field'=>'current_status_id', 'operator'=>'=', 'value'=>'100'); 
    386                 $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$this->uri->get_num(4)); 
    387                 $pbi_release = $this->pbi_release->get_record($filters)->get_info(); 
    388                 if(!isset($pbi_release['id']) || $pbi_release['id']!=$this->uri->get_num(4) || $pbi_release['pbi_id']!=$this->uri->get_num(3)){ 
    389                         //package doesn't exists 
    390                         $this->display->assign('message', 'Package Release not found!'); 
    391                         $this->display('message'); 
    392                         return; 
    393                 } 
    394381                $this->display->assign('pbi', $pbi); 
    395                 $this->display->assign('pbi_release', $pbi_release); 
    396                 if($this->uri->get_num(5)>0){ 
    397                         $filters = array(); 
    398                         $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y'); 
    399                         $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$this->uri->get_num(5)); 
    400                         $mirror = $this->table_prototype->get_record($filters, 'mirror')->get_info(); 
    401                         if(!isset($mirror['id']) || $mirror['id']!=$this->uri->get_num(5)){ 
    402                                 //package doesn't exists 
    403                                 $this->display->assign('message', 'Mirror not found!'); 
    404                                 $this->display('message'); 
    405                                 return; 
    406                         } 
    407                         $this->table_prototype->insert()->from('download')->set('pbi_id',$pbi['id'])->set('download_type_id','1')->set('mirror_id',$mirror['id'])->do_db(); 
    408          
     382 
     383                if($pbi['offsite_download_url']!=''){ 
     384                        //offsite download 
    409385                        $filters = array(); 
    410386                        $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$pbi['id']); 
    411387                        $this->pbi->update()->set('total_download','total_download+1',true)->where()->do_db(); 
    412          
     388 
     389                        $this->table_prototype->insert()->from('download')->set('pbi_id',$pbi['id'])->set('download_type_id','3')->set('mirror_id',0)->do_db(); 
     390 
     391                        $mirror['url'] = $pbi['offsite_download_url']; 
    413392                        $this->display->assign('mirror', $mirror); 
    414393         
     
    416395                        $this->display('download'); 
    417396                } else { 
    418                         //have to choose the mirror to use 
     397                        $this->load_library('pbi_release'); 
    419398                        $filters = array(); 
    420399                        $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y'); 
    421                         $filters[] = array('field'=>'last_update', 'operator'=>'>', 'value'=>$pbi['date_last_status_id']); 
    422                         $mirror = $this->table_prototype->get_all($filters, array('name ASC','last_update DESC'), array(), '','mirror'); 
    423                         $this->display->assign('mirror', $mirror); 
    424                         $this->display->assign('title', 'Downloading '.$pbi['name'].' - Choose a mirror'); 
    425                         $this->display('choose_mirror'); 
     400                        $filters[] = array('field'=>'current_status_id', 'operator'=>'=', 'value'=>'100'); 
     401                        $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$this->uri->get_num(4)); 
     402                        $pbi_release = $this->pbi_release->get_record($filters)->get_info(); 
     403                        if(!isset($pbi_release['id']) || $pbi_release['id']!=$this->uri->get_num(4) || $pbi_release['pbi_id']!=$this->uri->get_num(3)){ 
     404                                //package doesn't exists 
     405                                $this->display->assign('message', 'Package Release not found!'); 
     406                                $this->display('message'); 
     407                                return; 
     408                        } 
     409                        $this->display->assign('pbi_release', $pbi_release); 
     410                        if($this->uri->get_num(5)>0){ 
     411                                $filters = array(); 
     412                                $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y'); 
     413                                $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$this->uri->get_num(5)); 
     414                                $mirror = $this->table_prototype->get_record($filters, 'mirror')->get_info(); 
     415                                if(!isset($mirror['id']) || $mirror['id']!=$this->uri->get_num(5)){ 
     416                                        //package doesn't exists 
     417                                        $this->display->assign('message', 'Mirror not found!'); 
     418                                        $this->display('message'); 
     419                                        return; 
     420                                } 
     421                                $this->table_prototype->insert()->from('download')->set('pbi_id',$pbi['id'])->set('download_type_id','1')->set('mirror_id',$mirror['id'])->do_db(); 
     422                 
     423                                $filters = array(); 
     424                                $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$pbi['id']); 
     425                                $this->pbi->update()->set('total_download','total_download+1',true)->where()->do_db(); 
     426                 
     427                                $this->display->assign('mirror', $mirror); 
     428                 
     429                                $this->display->assign('title', 'Downloading '.$pbi['name']); 
     430                                $this->display('download'); 
     431                        } else { 
     432                                //have to choose the mirror to use 
     433                                $filters = array(); 
     434                                $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y'); 
     435                                $filters[] = array('field'=>'last_update', 'operator'=>'>', 'value'=>$pbi['date_last_status_id']); 
     436                                $mirror = $this->table_prototype->get_all($filters, array('name ASC','last_update DESC'), array(), '','mirror'); 
     437                                $this->display->assign('mirror', $mirror); 
     438                                $this->display->assign('title', 'Downloading '.$pbi['name'].' - Choose a mirror'); 
     439                                $this->display('choose_mirror'); 
     440                        } 
    426441                } 
    427442        }