Changeset 41

Show
Ignore:
Timestamp:
07/16/07 22:42:26 (18 months ago)
Author:
aarkerio
Message:

Newsletters

Location:
trunk/app
Files:
2 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/routes.php

    r22 r41  
    1414 * developement. 
    1515 */ 
    16     $Route->connect('/tests', array('controller' => 'tests', 'action' => 'index')); 
     16      $Route->connect('/blog/*/', array('controller'=>'Users', 'action'=>'blog')); 
    1717?> 
  • trunk/app/controllers/entries_controller.php

    r36 r41  
    3939   } 
    4040    
    41    public function search() 
    42    {     
     41   function search($keywords = '')  
     42   { 
    4343        $this->layout = 'portal'; 
    4444         
     
    4747        $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    4848         
    49          /* if (!empty($this->data["Entry"]) )  
    50         {    
    51             $data = $this->Lucene->query($this->data['Entry']['terms']); 
    52              
    53             $this->set('data', $data); 
    54         } */ 
    55    } 
     49        $searchFields = array('Entry.title', 'Entry.body', 'News.body', 'Page.body'); 
     50         
     51        $this->set('data', $this->Search->query($this->Product, $keywords, $searchFields, ALL, ANYWHERE)); 
     52    } 
    5653    
    5754   /** ====  ADMIN SECTION ====*/ 
     
    118115     $this->layout    = 'admin'; 
    119116      
    120      $this->set('categories', $this->Entry->Category->generateList()); 
     117     $this->set('subjects', $this->Entry->Subject->generateList()); 
    121118      
    122119     if (empty($this->data)) 
     
    129126         if ($this->Entry->save($this->data['Entry'])) 
    130127         { 
    131              $this->flash('Your entry has been updated.', '/admin/entries/listing'); 
     128             $this->msgFlash('The story has been updated.', '/admin/entries/listing'); 
    132129         } 
    133130     } 
  • trunk/app/controllers/news_controller.php

    r36 r41  
    6363        $fields     = array("News.id", "News.title", "News.comments", "News.body", "News.created", "News.reference", "News.theme_id", "News.user_id", "Theme.img", "Theme.theme", "User.username"); 
    6464         
    65         $this->pageTitle = 'Hacktivismo'; 
     65        $this->pageTitle = '::News'; 
    6666         
    6767        $this->set('data', $this->News->find($conditions, $fields, null, 1)); 
  • trunk/app/controllers/newsletters_controller.php

    r32 r41  
    66    *  Chipotle Software 
    77  */  
    8  
    9 loadModel('User'); 
    10 loadModel('Entry'); 
    118 
    129class NewslettersController extends AppController 
     
    1815    public function subscribe() 
    1916    { 
     17         $this->layout = 'portal'; 
    2018         $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    2119    } 
     
    6159        $this->layout = 'admin'; 
    6260         
    63         $conditions   = array("News.user_id" => $this->othAuth->user('id') );             // only the user's news 
     61        $conditions   = array("Newsletter.status" => 1);             // only the user's news 
    6462        $fields       = array("id", "title", "body", "created", "reference", "status", "subject_id", "user_id"); 
    65         $order        = "News.id DESC"; 
     63        $order        = "Newsletter.id DESC"; 
    6664        $limit        = 12; 
    6765         
     
    6967  } 
    7068   
    71     public function  all($subject_id = null) 
    72     { 
    73      $conditions = array("News.status"=>1); 
     69  public function all($page=1) 
     70  {   
     71     $this->layout = 'portal'; 
    7472      
    75      if ($subject_id != null) 
    76      { 
    77          $conditions["News.subject_id"] = $subject_id; 
    78      } 
     73     $conditions   = array("Newsletter.status"=>1); 
     74     $fields       = array("Newsletter.id", "Newsletter.title", "Newsletter.body", "Newsletter.created", "Newsletter.user_id"); 
     75     $order        = "Newsletter.id DESC"; 
     76     $limit        = 20; 
    7977      
    80      $fields     = array("id", "title", "body", "created", "reference", "subject_id", "user_id"); 
    81      $order      = "News.id DESC"; 
    82      $limit      = 12; 
    83        
    84          // move task from todo to done 
    85          $data = $this->Newsletter->findAll($conditions, $fields, $order, $limit, null, true); 
    86      //die(print_r($data)); 
    87      $this->set('data', $data); 
     78     $this->set('data', $this->Newsletter->findAll($conditions, $fields, $order, $limit)); 
    8879      
    89      $this->set('subjects', $this->Portal->cms()); // Using Portal component 
    90       
    91      $this->set('randomQuote', $this->Portal->quote()); // quote footer 
     80     $this->set('Element', $this->Portal->statics()); // Using Portal component 
    9281    } 
    9382     
    94     public function  delete($id) { 
    95        
    96        // deletes new from database 
    97         
     83   public function admin_delete($id)  
     84   { 
    9885      if ( $this->Newsletter->del($id) ) 
    9986      { 
    100             $this->flash('Your new have been removed', '/news/listing'); 
     87            $this->msgFlash('Your new have been removed', '/admin/newsletters/listing'); 
    10188      } 
    10289      else 
    10390      { 
    104             $this->flash('Database error!', '/news/listing'); 
    105       } 
    106      
     91            $this->msgFlash('Database error!', '/admin/newsletters/listing'); 
     92      }    
    10793    } 
    10894} 
  • trunk/app/controllers/podcasts_controller.php

    r15 r41  
    6363    } 
    6464   
    65   public function all($username=null, $entry_id=null) {    
     65  public function all($username=null, $entry_id=null)  
     66  {      
     67        $this->layout = 'portal'; 
     68         
    6669        $this->pageTitle = $username . '\'s Podcast'; 
    6770         
     
    8891        $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true));  
    8992         
    90         $this->set('subjects', $this->Portal->cms()); // Using Portal component 
    91          
    92         $this->set('randomQuote', $this->Portal->quote()); // quote footer 
     93        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    9394    } 
    9495     
  • trunk/app/controllers/users_controller.php

    r35 r41  
    1515loadModel('Catfaq'); 
    1616loadModel('Cover'); 
    17 loadModel('Poll'); 
    1817loadModel('News'); 
    1918loadModel('Confirm'); 
     
    2322    public $helpers          = array('Ajax', 'Form', 'User', 'Fck'); 
    2423     
    25     public $components       = array('Edublog', 'Portal', 'Email', 'Adds'); 
    26      
    27     public $displayField     = 'title'; 
     24    public $components       = array('Security', 'Edublog', 'Portal', 'Email', 'Adds', 'Mypagination'); 
    2825     
    2926    public function index($id = null) 
     
    3431    } 
    3532     
    36     public function blog($user_id, $entry_id = null) 
    37     {    
    38         $this->pageTitle = 'Karamelo Blog'; 
     33    public function blog($username = null, $page=1)  
     34    { 
     35        $this->layout    = 'blog'; 
     36         
     37        $this->pageTitle = $username . '\'s Blog'; 
     38         
     39        $this->Entry     = new Entry; 
     40         
     41        $user_id = $this->User->field("id", array("username"=>$username)); 
     42         
     43        //exit($user_id); 
     44         
     45        if ($username == null || $user_id == null) 
     46        { 
     47           $this->redirect("/"); 
     48        } 
     49         
     50        $order    = "Entry.id DESC"; 
     51         
     52        $fields   = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.themeblog_id", "Entry.id", "User.username", "Themeblog.title", "Themeblog.id"); 
     53         
     54        //pagination 
     55        $total_rows = $this->Entry->findCount(array("Entry.user_id"=>$user_id, "Entry.status"=>1));  
     56         
     57        $lmt        = 10; // limit news 
     58         
     59        $targetpage = "/blog/".$username."/"; 
     60         
     61        $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 
     62         
     63        $this->set('pagination', $pagination); 
     64         
     65        $offset     = (($page * $lmt) - 10); 
     66         
     67        $limit      = $lmt . " OFFSET " . $offset; 
     68         
     69        $conditions = array("Entry.user_id"=>$user_id); 
     70         
     71        $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit));  
    3972         
    4073        $this->layout    = $this->Edublog->layout($user_id); 
    4174         
    4275        $this->set('blog', $this->Edublog->blog($user_id)); 
    43          
    44         $this->set('Entry_id', $entry_id); 
    45          
    46         // blog entries 
    47         $this->Entry = new Entry; 
    48          
    49         $conditions      = array("Entry.status"=>1, "Entry.user_id"=>$user_id); 
    50          
    51         if ($entry_id != null) 
    52         { 
    53            $conditions["Entry.id"] = $entry_id; 
    54         } 
    55          
    56         $fields     = array("id", "title", "body", "created", "disc", "category_id", "user_id"); 
    57         $order      = "Entry.id DESC"; 
    58         $limit      = 10; 
    59          
    60         $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit, null, 2));  
    6176    } 
    6277     
     
    95110        { 
    96111             $this->data["User"]["passwd"] = md5($this->data["User"]["passwd"]); // MD5  
    97         } else { 
     112        }  
     113        else  
     114        { 
    98115             unset($this->data["User"]["passwd"]);       
    99116        } 
    100  
     117         
    101118        if ($this->User->save($this->data['User'])) 
    102119        { 
    103             $this->flash('User has been updated.','/entries/'); 
     120            $this->msgFlash('User has been updated.','/admin/users/listing'); 
    104121        } 
    105122    } 
     
    138155         
    139156        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    140     } 
    141      
    142     public function general() 
    143     { 
    144         $this->layout    = 'portal'; 
    145          
    146         $this->pageTitle = 'Welcome :: Karamelo E-learning on Web 2.0'; 
    147          
    148         $this->set('Element', $this->Portal->statics()); // Using Portal component 
    149          
    150         /**********  News  ****/ 
    151          
    152         $this->News = new News;  //Instantiate the model 
    153          
    154         $conditions = array("News.status"=>1); 
    155         $fields     = array("News.id", "News.title", "News.body", "News.created", "News.reference", "News.subject_id", "News.user_id"); 
    156         $order      = "News.id DESC"; 
    157         $limit      = 1; 
    158          
    159         $this->pageTitle = 'Karamelo E-learning on Web 2.0'; 
    160          
    161         $lastNew = $this->News->findAll($conditions, $fields, $order, $limit); 
    162          
    163         $this->set('new', $lastNew); 
    164          
    165157    } 
    166158     
  • trunk/app/views/elements/menu_b.thtml

    r1 r41  
    11<div id="menu_div"> 
    2    <a class="nav" href="/news/all/" title="News">News</a> 
    32   <a class="nav" href="/users/bloggers/" title="eduBlogs">eduBlogs</a> 
    43   <a class="nav" href="/podcasts/all/" title="Podcast">Podcast</a> 
    54   <a class="nav" href="/users/directory/" title="Directory">Directory</a> 
    6    <a class="nav" href="/newsletters/subscribe/" title="Newsletter">Newsletter</a> 
     5   <a class="nav" href="/newsletters/subscribe/" title="Newsletter">Newsletters</a> 
     6   <a class="nav" href="/events/view/" title="Coming soon">Events Calendar</a> 
    77</div> 
  • trunk/app/views/layouts/default.thtml

    r34 r41  
    11<html> 
    22<head> 
    3 <title>::MonoNeurona::</title> 
     3<title>::Karamelo e-Learning::</title> 
    44<style type="text/css"> 
    55body { 
  • trunk/app/views/newsletters/subscribe.thtml

    r1 r41  
    1 <?php echo $html->formTag('/nlemails/add', 'post', array('onsubmit'=>'return false')); ?> 
     1<?php echo $html->formTag('/newsletters/add', 'post', array('onsubmit'=>'return false')); ?> 
    22 
    33<fieldset> 
    44  <legend>Subscribe:</legend> 
    55      
    6      <?php echo $form->labelTag('Nlemails/email', 'Email:' );?><br /> 
    7      <?php echo $html->input('Nlemails/email', array("size" => 25, "maxlength" => 50)); ?> 
     6     <?php echo $form->labelTag('Newsletter/email', 'Email:' );?><br /> 
     7     <?php echo $html->input('Newsletter/email', array("size" => 25, "maxlength" => 50)); ?> 
    88     <br /><br /> 
    99     <?php echo $html->submit('Send'); ?> 
    1010</fieldset> 
    1111</form> 
     12 
     13<br /> 
     14 
     15<?php 
     16      echo $html->link('View pass newsletters', '/newsletters/all'); 
     17?> 
  • trunk/app/views/users/bloggers.thtml

    r1 r41  
    66 
    77<?php 
    8 foreach ($data as $key => $val) { 
     8foreach ($data as $key => $val)  
     9{ 
    910    echo '<p><b>Docent</b>: '.$data[$key]['User']['name'].' <br />'; 
    10     echo 'blog: <a href="/users/blog/'.$data[$key]['User']['id'].'/">'.$data[$key]['User']['name_blog'].'</a></p>'; 
     11    echo 'blog: <a href="/blog/'.$data[$key]['User']['username'].'">'.$data[$key]['User']['name_blog'].'</a></p>'; 
    1112} 
    1213?>