Changeset 34

Show
Ignore:
Timestamp:
07/16/07 16:10:24 (18 months ago)
Author:
aarkerio
Message:

Add themes scaffold and some images

Location:
trunk/app
Files:
23 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/ecourses_controller.php

    r31 r34  
    4242    } 
    4343     
    44     public function admin_add() { 
     44    public function admin_add()  
     45    { 
    4546     
    4647    //die(print_r($this->data)); 
  • trunk/app/controllers/entries_controller.php

    r31 r34  
    1111 
    1212class EntriesController extends AppController { 
    13      
    14     public $helpers       = array('Ajax', 'Form', 'Fck'); 
    15      
    16     public $displayField  = 'Blog'; 
    17      
    18     public $components    = array('Edublog', 'Portal'); 
    19      
    20     public function admin_start($order = null) 
    21     { 
    22         if (!$this->othAuth->user('id')) 
    23         { 
    24             die($this->redirect('/users/general')); // Get Out!!! 
    25         } 
    26          
    27         $this->layout    = 'admin'; 
    28         $this->pageTitle = 'Entries'; 
    29          
    30         $conditions = null; 
    31         $fields     = array("id", "title", "body", "category_id"); 
    32         $data       = $this->Entry->findAll( $conditions, $fields, $order, null, null, true ); 
    33          
    34         $this->set('data', $data);  
    35     } 
    3613    
    37    public function admin_listing($order = null) { 
    38         
    39        $this->layout    = 'admin'; 
    40         
    41        $conditions = array("Entry.user_id"=>$this->othAuth->user('id')); 
    42         
    43        $data = $this->Entry->findAll($conditions, $order); 
    44         
    45        $this->set('data', $data); 
    46         
    47    } 
     14   public $helpers       = array('Ajax', 'Form', 'Fck'); 
    4815    
    49    public function results($string) { 
     16   public $components    = array('Edublog', 'Portal'); 
     17    
     18   public function results($string)  
     19   { 
    5020        
    5121       $conditions = array("Entry.body"=>$string); 
     
    5626   } 
    5727    
    58    public function rss($user_id) { 
     28   public function rss($user_id)  
     29   { 
    5930        
    6031       $this->layout    = 'rss'; 
     
    7142    
    7243   public function search() 
    73    { 
     44   {     
     45        $this->layout = 'portal'; 
     46         
    7447        $this->pageTitle = 'Search Results :: Karamelo E-learning on Web 2.0'; 
    7548         
    76         $this->set('subjects', $this->Portal->cms()); // Using Portal component 
     49        $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    7750         
    78         $this->set('randomQuote', $this->Portal->quote()); // quote footer 
    79          
    80         if (!empty($this->data) )  
     51         /* if (!empty($this->data["Entry"]) )  
    8152        {    
    8253            $data = $this->Lucene->query($this->data['Entry']['terms']); 
    8354             
    8455            $this->set('data', $data); 
    85         } 
     56        } */ 
    8657   } 
    8758    
    88    public function add() 
     59   public function admin_add() 
    8960   { 
    9061     
    9162    $this->layout    = 'admin'; 
    9263    // adds new blog entries  
    93    if ( empty($this->params['data']) )   
     64   if ( empty($this->data) )   
    9465   { 
    9566      
     
    10980   { 
    11081     
    111     //$this->Sanitize = new Sanitize; 
     82    $this->Sanitize = new Sanitize; 
    11283     
    113     //$this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
    114        
    115        
    116       if ($this->Entry->save($this->params['data'])) 
     84    $this->Sanitize->paranoid($this->data["Entry"]["title"]); //Hopefully this is enough 
     85     
     86      if ($this->Entry->save($this->data["Entry"])) 
    11787      {  
    118             $this->redirect('/entries/listing'); 
    119       } else { 
    120             $this->flash('Database error!', '/entries/listing'); 
     88            $this->msgFlash('Story has been added', '/admin/entries/listing'); 
     89      }  
     90      else  
     91      { 
     92            $this->flash('Database error!', '/admin/entries/listing'); 
    12193      } 
    12294   } 
    12395  } 
     96  /** ===  ADMIN SECTION */ 
    12497   
    125   public function edit($id = null) 
     98  public function admin_start($order = null) 
     99  { 
     100        if (!$this->othAuth->user('id')) 
     101        { 
     102            die($this->redirect('/users/general')); // Get Out!!! 
     103        } 
     104         
     105        $this->layout    = 'admin'; 
     106        $this->pageTitle = 'Entries'; 
     107         
     108        $conditions = null; 
     109        $fields     = array("id", "title", "body", "category_id"); 
     110        $data       = $this->Entry->findAll( $conditions, $fields, $order, null, null, true ); 
     111         
     112        $this->set('data', $data);  
     113  } 
     114   
     115  public function admin_listing($order = null)  
     116  { 
     117        
     118       $this->layout    = 'admin'; 
     119        
     120       $conditions = array("Entry.user_id"=>$this->othAuth->user('id')); 
     121        
     122       $data = $this->Entry->findAll($conditions, $order); 
     123        
     124       $this->set('data', $data); 
     125        
     126  } 
     127   
     128  public function admin_edit($id = null) 
    126129  { 
    127130     $this->layout    = 'admin'; 
     
    138141         if ($this->Entry->save($this->data['Entry'])) 
    139142         { 
    140              $this->flash('Your entry has been updated.', '/entries/listing'); 
     143             $this->flash('Your entry has been updated.', '/admin/entries/listing'); 
    141144         } 
    142145     } 
    143    } 
     146  } 
    144147  
    145   public function delete($id) 
    146   { 
     148 public function admin_delete($id) 
     149 { 
    147150    $this->Entry->del($id); 
    148151     
    149     $this->flash('The entry with id: '.$id.' has been deleted.', '/entries/listing'); 
     152    $this->msgFlash('The entry has been deleted.', '/admin/entries/listing'); 
    150153  } 
    151154} 
  • trunk/app/controllers/news_controller.php

    r31 r34  
    2121  public function view($page=1)  
    2222  {      
     23        $this->layout = 'portal'; 
     24         
    2325        //pagination 
    2426        $total_rows = $this->News->findCount(array("status"=>1));  
  • trunk/app/controllers/users_controller.php

    r31 r34  
    6161    } 
    6262     
    63     public function about($user_id) { 
     63    public function about($user_id)  
     64    { 
    6465         
    6566        $this->pageTitle = 'About me'; 
     
    7576    } 
    7677     
    77     public function admin_edit($id = null) { 
     78    public function admin_edit($id = null)  
     79    { 
    7880     
    7981    $this->layout    = 'admin'; 
     
    104106} 
    105107 
    106   public function admin_listing($order = null) { 
     108  public function admin_listing($order = null)  
     109  { 
    107110        
    108111       $this->layout    = 'admin'; 
     
    121124   public function alumni() 
    122125    { 
     126        $this->layout    = 'portal'; 
     127         
    123128        $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 
    124129         
     
    137142    public function general() 
    138143    { 
     144        $this->layout    = 'portal'; 
     145         
    139146        $this->pageTitle = 'Welcome :: Karamelo E-learning on Web 2.0'; 
    140147         
    141         $this->Cover = new Cover; 
    142          
    143         $conditions  = array("Cover.status"=>1, "Cover.group_id"=>6); 
    144         $fields      = array("id", "title", "body", "created"); 
    145         $order       = "Cover.id DESC"; 
    146         $limit       = 1; 
    147          
    148         $this->set('cover', $this->Cover->findAll($conditions, $fields, $order, $limit)); 
    149          
    150         $this->set('Element', $this->Portal->statics()); // Using Portal component 
    151          
    152          
     148        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    153149         
    154150        /**********  News  ****/ 
     
    167163        $this->set('new', $lastNew); 
    168164         
    169          
    170         /**********  Poll  ****/ 
    171          
    172         $this->Poll = new Poll;  //Instantiate the model 
    173          
    174         $conditions = array("status"=>1); 
    175         $fields     = array("Poll.id", "Poll.question"); 
    176         $order      = "Poll.id DESC"; 
    177         $limit      = 1; 
    178          
    179         $this->set('poll', $this->Poll->findAll($conditions, $fields, $order, $limit, null, 2)); 
    180          
    181         /********** last blogs Entries  ****/ 
    182         $this->Entry = new Entry;  //Instantiate the model 
    183          
    184         $conditions = array("Entry.status"=>1); 
    185         $fields     = array("Entry.id", "Entry.title", "Entry.created", "Entry.user_id"); 
    186         $order      = "Entry.id DESC"; 
    187         $limit      = 10; 
    188          
    189         $this->set('entries', $this->Entry->findAll($conditions, $fields, $order, $limit, null, 2)); 
    190          
    191         $this->set('Element', $this->Portal->statics()); // Using Portal component 
    192          
    193          
    194165    } 
    195166     
    196167    public function parents() 
    197168    { 
     169        $this->layout    = 'portal'; 
     170         
    198171        $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 
    199172         
     
    214187    public function academics() 
    215188    { 
     189        $this->layout    = 'portal'; 
     190         
    216191        $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 
    217192         
     
    255230        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    256231         
    257          
     232        $this->layout    = 'portal'; 
    258233         
    259234        /********** list teachers  ****/ 
     
    278253        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    279254         
    280          
     255        $this->layout    = 'portal'; 
    281256    } 
    282257    
     
    287262        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    288263         
    289          
     264        $this->layout    = 'portal'; 
    290265    } 
    291266 
    292267     
    293268    public function bloggers($order = 'username', $desc = 'DESC') 
    294     { 
     269    {    
     270        $this->layout    = 'portal'; 
     271         
    295272        $conditions  =  array("group_id"=>1); 
    296273        $fields      =  array("id", "username", "name", "name_blog", "created"); 
     
    300277         
    301278        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    302          
    303          
    304279    } 
    305280    public function login() 
     
    311286        
    312287        
    313        if (isset($this->params['data'])) 
     288       if (isset($this->data)) 
    314289       {  
    315           $auth_num = $this->othAuth->login($this->params['data']['User']); 
     290          $auth_num = $this->othAuth->login($this->data['User']); 
    316291           
    317292          $this->set('auth_msg', $this->othAuth->getMsg($auth_num)); 
     
    321296     
    322297    public function logout() 
    323     { 
     298    {   
    324299       $this->othAuth->logout(); 
    325300        
    326        $this->redirect('/users/general'); 
    327     } 
    328      
    329     public function noaccess() 
     301       $this->redirect('/news/view'); 
     302    } 
     303     
     304   public function noaccess() 
    330305   { 
    331     $this->flash("You don't have permissions to access this page.",'/users/login'); 
     306      $this->flash("You don't have permissions to access this page.",'/users/login'); 
    332307   } 
    333308    
    334309   public function register() 
    335310   { 
     311    $this->layout    = 'portal'; 
     312     
     313     
    336314    $this->Group = new Group; 
    337315     
     
    345323    $this->layout = 'ajax'; 
    346324    // adds new classroom to database 
    347     if (!empty($this->params['data'])) 
     325    if (!empty($this->data)) 
    348326    { 
    349327    //die(print_r($this->params)); 
     
    356334     
    357335    /** Check Passwd **/ 
    358     if (strlen($this->params['data']['User']['passwd']) < 6) 
     336    if (strlen($this->data['User']['passwd']) < 6) 
    359337    { 
    360338       $message['pwd_worng'] = "The password has less than 6 characters "; 
    361339    } 
    362340     
    363     if (strpos($this->params['data']['User']['username'], ' '))  // nos spaces 
     341    if (strpos($this->data['User']['username'], ' '))  // nos spaces 
    364342    { 
    365343       $message['username_spaces'] = "Your username should not contain spaces"; 
     
    367345     
    368346    /** username check **/ 
    369     if (strlen($this->params['data']['User']['username']) < 5) 
     347    if (strlen($this->data['User']['username']) < 5) 
    370348    { 
    371349       $message['pwd_username'] = "The username has less than 5 characters "; 
     
    373351     
    374352    /** name check **/ 
    375     if (strlen($this->params['data']['User']['name']) < 5) 
     353    if (strlen($this->data['User']['name']) < 5) 
    376354    { 
    377355       $message['pwd_username'] = "The name is too short"; 
    378356    } 
    379357     
    380     if (strpos($this->params['data']['User']['passwd'], ' '))  // nos spaces 
     358    if (strpos($this->data['User']['passwd'], ' '))  // nos spaces 
    381359    { 
    382360       $message['username_spaces'] = "Your password should not contain spaces"; 
     
    384362     
    385363    /** description check **/ 
    386     if (strlen($this->params['data']['User']['description']) < 5) 
     364    if (strlen($this->data['User']['description']) < 5) 
    387365    { 
    388366       $message['description_too_short'] = "C'mon pal, talk us about you!"; 
     
    390368     
    391369    /** email check **/ 
    392     if ($this->Adds->validEmail($this->params['data']['User']['email']) === false) 
     370    if ($this->Adds->validEmail($this->data['User']['email']) === false) 
    393371    { 
    394372       $message['pwd_username'] = "The email is invalid"; 
     
    396374     
    397375    /** Check the user **/ 
    398     $username        = $this->User->field('username', array("username" => $this->params['data']['User']['username'])); 
     376    $username        = $this->User->field('username', array("username" => $this->data['User']['username'])); 
    399377     
    400378    if ($username != null) 
     
    404382     
    405383    /** Check the email **/ 
    406     $email        = $this->User->field('email', array("email" => $this->params['data']['User']['email'])); 
     384    $email        = $this->User->field('email', array("email" => $this->data['User']['email'])); 
    407385     
    408386    if ($email != null) 
     
    411389    } 
    412390     
    413     if ( $this->params['data']['User']['group_id'] == 5 && $this->params['data']['User']['code'] != $code) 
     391    if ( $this->data['User']['group_id'] == 5 && $this->data['User']['code'] != $code) 
    414392    { 
    415393        $message['wrong_code'] = "The teacher's code is incorrect"; 
     
    424402    $this->Sanitize = new Sanitize; 
    425403     
    426     $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
    427      
    428     $this->params['data']['User']['passwd'] = md5($this->params['data']['User']['passwd']); // MD5 
    429     $this->params['data']['User']['active'] = 0; 
    430      
    431       if ($this->User->save($this->params['data'])) 
     404    $this->Sanitize->cleanArray($this->data); //Hopefully this is enough 
     405     
     406    $this->data['User']['passwd'] = md5($this->data['User']['passwd']); // MD5 
     407    $this->data['User']['active'] = 0; 
     408     
     409      if ($this->User->save($this->data)) 
    432410      { 
    433411         
    434412        $this->Confirm = new Confirm;                                                    //confirm model 
    435         $this->params['data']['Confirm']['user_id']  = $this->User->getLastInsertID();   //the user id 
    436         $this->params['data']['Confirm']['secret']   = $this->Adds->genPassword(14);      
    437          
    438         if ($this->Confirm->save($this->params['data']))  // put the user in confirm model, this is, waiting confirmation 
     413        $this->data['Confirm']['user_id']  = $this->User->getLastInsertID();   //the user id 
     414        $this->data['Confirm']['secret']   = $this->Adds->genPassword(14);      
     415         
     416        if ($this->Confirm->save($this->data))  // put the user in confirm model, this is, waiting confirmation 
    439417        { 
    440418          //Send the confirmation email 
    441           if ( $this->sendMail($this->params['data']['User']['email'], $this->params['data']['Confirm']['secret']) )  
     419          if ( $this->sendMail($this->data['User']['email'], $this->data['Confirm']['secret']) )  
    442420          {        
    443421              $this->set('message', array("Suceess"=>"<h2>You have been registered!</h2> <p>A confirmation email have  
    444                   been sent to: ".$this->params['data']['User']['email']." </p>")); 
     422                  been sent to: ".$this->data['User']['email']." </p>")); 
    445423               $this->set('ok', true); 
    446424               $this->render('validate', 'ajax'); 
     
    459437  } 
    460438   
     439  /** === ADMIN SECTION ==***/ 
    461440   
    462441  /*** DELETE  **/  
     
    478457  } 
    479458 /****   AVATAR   ***/ 
    480  public function avatar() { 
    481      
    482     //die(print_r($this->params)); 
    483      
     459 public function avatar()  
     460 { 
    484461    $this->layout    = 'admin'; 
    485462     
    486     if (!empty($this->params['data']) && is_uploaded_file($this->params['data']['User']['file']['tmp_name'])) 
    487     { 
    488      
    489     // echo "tmp_name : ". $this->params['data']['User']['file']['tmp_name'] . "<br />"; // usefull print 
     463    if (!empty($this->data) && is_uploaded_file($this->data['User']['file']['tmp_name'])) 
     464    { 
     465     
     466    // echo "tmp_name : ". $this->data['User']['file']['tmp_name'] . "<br />"; // usefull print 
    490467     
    491468    $this->Sanitize = new Sanitize; 
    492469     
    493     $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
     470    $this->Sanitize->cleanArray($this->data); //Hopefully this is enough 
    494471     
    495472    /** SUBMITTED INFORMATION - use what you need 
     
    505482    $maxfilesize  = 2097152; /** 2MB max size */ 
    506483     
    507     $imgfile_name = $this->params['data']['User']['file']['name']; 
    508      
    509     $imgfile_size = $this->params['data']['User']['file']['size']; 
    510      
    511     $imgfile      = $this->params['data']['User']['file']['tmp_name']; 
     484    $imgfile_name = $this->data['User']['file']['name']; 
     485     
     486    $imgfile_size = $this->data['User']['file']['size']; 
     487     
     488    $imgfile      = $this->data['User']['file']['tmp_name']; 
    512489       
    513     $type         = $this->params['data']['User']['file']['type']; 
     490    $type         = $this->data['User']['file']['type']; 
    514491     
    515492    /** Security: checks to see if file is an image, if not do not allow upload ==*/ 
     
    560537   /** Database stuff  **/ 
    561538    
    562    $this->params['data']['User']['avatar'] = $final_filename; 
    563     
    564    if ($this->User->save($this->params['data'])) 
    565      { 
     539   $this->data['User']['avatar'] = $final_filename; 
     540    
     541   if ($this->User->save($this->data)) 
     542    { 
    566543           $this->redirect('/users/edit/'. $this->othAuth->user('id')); 
    567      } 
    568       
    569      /** delete the temporary uploaded file **/ 
     544    } 
     545     
     546    /** delete the temporary uploaded file **/ 
    570547   unlink($imgfile); 
    571548    
     
    573550} 
    574551 
    575 private function get_extension($imagetype) { 
     552private function get_extension($imagetype)  
     553{ 
    576554      
    577555     if ( empty($imagetype) ) 
  • trunk/app/models/theme.php