Changeset 308

Show
Ignore:
Timestamp:
03/05/08 10:57:33 (10 months ago)
Author:
aarkerio
Message:

Small Update

Location:
trunk/app
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r285 r308  
    2020     $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 
    2121     $this->Auth->authorize = 'controller';   
    22      $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert', 'vote') ); 
    23  
     22     $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert', 'vote', 'download') ); 
     23     $this->Auth->autoRedirect = true; 
    2424     $this->set('cU', $this->Auth->user());  // $cU current user array to use in the views if user logged 
    2525 } 
  • trunk/app/controllers/shares_controller.php

    r247 r308  
    66*/  
    77 
    8  
    98uses('sanitize'); 
    109 
     
    1312 public $helpers = array('Gags'); 
    1413    
    15  public $components = array('Edublog', 'Portal'); 
     14 public $components = array('Edublog', 'Portal', 'Adds'); 
    1615  
    1716 public function isAuthorized() 
     
    1918     if (isset($this->params[Configure::read('Routing.admin')])) 
    2019     { 
    21                                 if ($this->Auth->user('group_id') != 1) 
    22                                      { 
    23                                                   return false; 
    24                                                             } 
    25                                                            } 
    26                                                               return true; 
     20           if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2) 
     21           { 
     22                     return true; 
     23           } 
     24     } 
     25     return false; 
    2726 } 
    2827                                                             
     
    3534        $file            =  $this->Share->field('file', $conditions); 
    3635         
    37         $this->redirect("/files/userfiles/".$file); 
     36        if (!$file) 
     37    { 
     38             $this->redirect('/'); 
     39        } 
     40    else 
     41        { 
     42            $this->redirect("/files/userfiles/".$file); 
     43    } 
    3844  } 
    3945   
     
    4551        $fields          = array("id", "file", "description", "secret"); 
    4652        $order           = "id DESC"; 
    47         $limit           = 20; 
    48          
    49         $this->set('data', $this->Share->findAll($conditions, $fields, $order, $limit, null, true));  
     53        $limit           = 30; 
     54         
     55        $this->set('data', $this->Share->findAll($conditions, $fields, $order, $limit));  
    5056 
    5157        $this->layout = $this->Edublog->layout($user_id); 
     
    5763   === ADMIN METHOD === 
    5864  **/ 
    59     public function admin_listing() 
    60     {    
    61         $this->pageTitle = $this->othAuth->user('username') . '\'s Shares'; 
     65 public function admin_listing() 
     66 {    
     67        $this->pageTitle = $this->Auth->user('username') . '\'s Shares'; 
    6268         
    6369        $this->layout = 'admin'; 
    6470         
    65         $conditions   = array("Share.user_id"=>$this->othAuth->user('id')); 
     71        $conditions   = array("Share.user_id"=>$this->Auth->user('id')); 
    6672        $fields       = array("id", "file", "description", "created", "secret", "public"); 
    6773        $order        = "Share.id DESC"; 
     
    7480 {     
    7581    $this->layout    = 'admin'; 
    76     $this->Subject   = new Subject; 
    77     $this->set('optionElements', $this->Subject->generateList(null, 'title')); 
    78      
     82 
    7983    if (!empty($this->data["Share"]) && is_uploaded_file($this->data['Share']['file']['tmp_name'])) 
    8084    { 
     
    8488    $this->Sanitize = new Sanitize; 
    8589     
    86     $this->Sanitize->cleanArray($this->data["Share"]); //Hopefully this is enough 
     90    $this->Sanitize->clean($this->data["Share"]); //Hopefully this is enough 
    8791     
    8892    /* SUBMITTED INFORMATION - use what you need 
     
    129133    } 
    130134     
    131     $conditions  = array("user_id" =>  $this->othAuth->user('id')); 
     135    $conditions  = array("user_id" =>  $this->Auth->user('id')); 
    132136     
    133137    $order       = "Share.id DESC"; 
     
    146150    } 
    147151     
    148     $Name        = $this->othAuth->user('username') . "_" . $next_id . '.'. $extension; 
     152    $Name        = $this->Auth->user('username') . "_" . $next_id . '.'. $extension; 
    149153     
    150154    /** setup final file location and name */ 
     
    172176   $this->data['Share']['file']     = $final_filename; 
    173177   $this->data['Share']['secret']   = $this->Adds->genPassword(15); 
    174    $this->data['Share']['user_id']  = $this->othAuth->user('id'); 
     178   $this->data['Share']['user_id']  = $this->Auth->user('id'); 
    175179    
    176180   if ($this->Share->save($this->data["Share"])) 
  • trunk/app/views/quotes/admin_edit.ctp

    r307 r308  
    44 echo $html->getCrumbs(' / '); 
    55 
    6  echo $form->create('Quote', array('url' => 'quotes/admin_edit'));  
     6 echo $form->create('Quote');  
    77 echo $form->hidden('Quote.id'); 
    88?> 
  • trunk/app/views/shares/admin_listing.ctp

    r251 r308  
    1 <div class="title_section"><?php echo $othAuth->user('username'); ?>'s shared files</div> 
     1<div class="title_section"><?php echo $cU['User']['username']; ?>'s shared files</div> 
    22 
    3 <?php echo $html->link($html->image('actions/new.png', array("alt"=>"Add new share", "title"=>"Add new share")), '#', array("onclick"=>"hU()"), false, false); ?></p> 
    4  
    5 <?php $session->flash(); ?> 
     3<?php  
     4echo $html->para(null,  
     5                 $html->link( 
     6                             $html->image('actions/new.png', array('alt'=>'Add new share', 'title'=>'Add new share')),  
     7                             '#', array('onclick'=>'hU()'), false, false 
     8                             ) 
     9                 ); 
     10 $session->flash(); 
     11 ?></p> 
    612 
    713<div id="addshare" style="display:none"> 
    814   
    9   <?php echo $html->formTag('/admin/shares/add/','post', array("enctype"=>"multipart/form-data") ); ?> 
     15  <?php echo $form->create('Share', array('type'=>'file', 'action'=>'admin_add') ); ?> 
    1016  <fieldset> 
    1117     <legend>Upload Share</legend> 
    1218     <?php  
    13            echo $form->labelTag('Share/file', 'File:' ); 
    14            echo $html->file('Share/file');  
    15            echo $html->tagErrorMsg('Share/file', 'Title is required.');  
     19           echo $form->label('Share.file', 'File:' ); 
     20           echo $form->file('Share.file');  
     21           echo $form->error('Share.file', 'Title is required.');  
    1622 
    17            echo $form->labelTag('Share/description', 'Description:' ); 
    18            echo $html->input('Share/description', array("size"=>40));  
    19            echo $html->tagErrorMsg('Share/description', 'Title is required.');  
    20  
    21            echo $html->submit('Upload');  
    22      ?> 
    23 </fieldset> 
    24 </form> 
     23           echo $form->label('Share.description', 'Description:' ); 
     24           echo $form->input('Share.description', array("size"=>40));  
     25           echo $form->error('Share.description', 'Title is required.');  
     26           echo '</fieldset>'; 
     27           echo $form->end('Upload');  
     28    ?> 
    2529</div> 
    2630