Changeset 477

Show
Ignore:
Timestamp:
05/12/08 18:05:35 (8 months ago)
Author:
aarkerio
Message:

Messages to all class

Location:
trunk/app
Files:
5 modified

Legend:

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

    r393 r477  
    119119        } 
    120120    } 
    121 } 
     121 } 
     122 // change status published/draft 
     123 public function admin_change($status, $catfaq_id) 
     124 {  
     125    $this->data['Catfaq']['status'] = ($status == 0 ) ? 1 : 0; 
     126     
     127    $this->data['Catfaq']['id']     = $catfaq_id; 
     128     
     129    if ($this->Test->save($this->data['Catfaq'])) 
     130    { 
     131         $this->msgFlash('Category status changed', '/admin/catfaqs/listing'); 
     132    } 
     133 } 
    122134 
    123135 public function admin_delete($id) 
    124136 { 
    125137    if ($this->Catfaq->del($id)) 
    126     { 
     138    { 
    127139         $this->msgFlash('FAQ category has been deleted.', '/admin/catfaqs/listing/'); 
    128     } 
     140    } 
    129141 }    
    130142} 
  • trunk/app/controllers/messages_controller.php

    r472 r477  
    11<?php 
    22/** 
    3 Chipotle Software TM 
    4 Manuel Montoya 2002-2008  
    5 GPLv3 manuel<arroba>mononeurona<punto>org 
     3@company: Chipotle Software TM 
     4@author: Manuel Montoya 2002-2008  
     5@license: GPLv3 manuel<arroba>mononeurona<punto>org 
    66*/  
    77 
     
    122122    } 
    123123 } 
     124 
     125  private function __sendAll($user_id, $vclassroom_id, $blogger_id) 
     126  {  
     127    $email = $this->Message->User->field('User.email', array('User.id'=>$user_id)); 
     128      
     129    $this->layout          = 'default'; 
     130    $this->set('vclassroom_id', $vclassroom_id); 
     131    $this->set('blogger_id',    $blogger_id); 
     132    $this->Email->to       = $email; 
     133 
     134    // this could be just a string too 
     135    $this->Email->subject  = 'Karamelo e-Learning:: New message'; 
     136    $this->Email->replyTo  = 'support@karamelo.org'; 
     137    $this->Email->from     = 'Chipotle-software.com'; 
     138    $this->Email->template = 'teacher';  
     139    $this->Email->sendAs   = 'text'; // because we like to send pretty mail 
     140 
     141    //Do not pass any args to send() 
     142    if ( $this->Email->send() ): 
     143                return true; 
     144    else: 
     145                return false; 
     146    endif; 
     147 } 
    124148  
    125149 /**=== ADMIN METHODS ===**/   
     
    158182        //exit(print_r($data)); 
    159183         
    160         foreach($data as $val) 
    161         {  
    162           $this->Message->create(); 
    163            
    164           //exit(print_r($val)); 
    165            
    166           $this->data["Message"]["user_id"] = $val["User"]["id"]; 
    167            
    168           if ($this->Message->save($this->data["Message"])): 
    169                 $j++; 
    170           else: 
    171                exit('error on save'); 
    172       endif; 
    173         } 
     184        foreach($data as $val):  
     185           $this->Message->create(); 
     186           
     187           //exit(print_r($val)); 
     188           
     189           $this->data["Message"]["user_id"] = $val["User"]["id"]; 
     190           
     191           if ($this->Message->save($this->data["Message"])): 
     192                  $j++; 
     193           else: 
     194                 exit('error on save'); 
     195       endif; 
     196    endforeach; 
    174197        $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 
    175198     } 
     
    208231  
    209232    if ($this->Message->save($this->data['Message'])): 
    210             $this->__sendMessage($this->data['Message']['user_id'], $this->data['Message']['vclassroom_id']); 
    211             $messages++; 
     233          $this->__sendAll($this->data['Message']['user_id'],$this->data['Message']['vclassroom_id'],$this->data['Message']['sender']); 
     234          $messages++; 
    212235    endif; 
    213236  endforeach; 
    214237     
    215   $this->set('messages', $messages); 
    216  
    217   $this->msgFlash($messages . ' sent to group','/admin/vclassroom/members/'.$this->data['Message']['vclassroom_id']);   
     238  $this->msgFlash($messages . ' messages sent to group','/admin/vclassrooms/members/'.$this->data['Message']['vclassroom_id']);   
    218239 } 
    219240  
  • trunk/app/models/vclassroom.php

    r474 r477  
    374374  } 
    375375/* 
    376  *  check if studen already found treasure 
     376 *  check if student belongs to class group 
    377377 *  int treasure_id  
    378  *  int user_id       
     378 *  int user_id  
     379 *  int group_id      
    379380 *  int vclassroom_id 
    380381 *  return boolean 
    381382 */ 
    382383 public function belongs($user_id, $vclassroom_id) 
    383  { 
     384 {  
    384385   $conditions =  array("UsersVclassroom.user_id"=>$user_id, "UsersVclassroom.vclassroom_id"=>$vclassroom_id); 
    385386 
     
    392393   endif; 
    393394 } 
    394  
    395395} 
    396396?> 
  • trunk/app/views/catfaqs/admin_listing.ctp

    r306 r477  
    77echo $html->addCrumb('FAQs', '/admin/catfaqs/listing');  
    88echo $html->getCrumbs(' / ');  
     9 
     10echo '<div id="loading" style="display: none;">'; 
     11                  echo $html->image("static/loading.gif", array("alt"=>"Loading")); 
     12echo '</div>'; 
     13     
     14echo  $html->para(null, $ajax->link($html->image('actions/new.png', array("alt"=>"Add new category", "title"=>"Add new category")),                   '/admin/catfaqs/add',  
     15     array("update" => "updater","loading"=>"Element.show('loading');Element.hide('updater');", "complete"=>"Element.hide('loading');Effect.Appear('updater')"),  
     16                null, false)); 
     17 
     18echo $ajax->div('updater') . $ajax->divEnd('updater'); 
     19 
     20//exit(print_r($data)); 
     21foreach ($data as $val): 
     22 $tmp  = $html->div('butonright', $gags->sendEdit($val['Catfaq']['id'], 'catfaqs')); 
     23 $tmp .= $html->link($val['Catfaq']['title'], '/admin/faqs/listing/'.$val['Catfaq']['id']); 
     24 $tmp .= $html->para(null,  $val['Catfaq']['description']); 
     25 $tmp .= $html->link($gags->setStatus($val['Catfaq']['status']),'/admin/catfaqs/change/'.$val['Catfaq']['status'].'/'.$val['Catfaq']['id']); 
     26  $tmp .= $html->div('butonright', $gags->confirmDel($val['Catfaq']['id'], 'catfaqs')); 
     27  echo $html->div('grayblock', $tmp); 
     28endforeach; 
    929?> 
    10  
    11 <p> 
    12 <?php 
    13  echo '<div id="loading" style="display: none;">'; 
    14                   echo $html->image("static/loading.gif", array("alt"=>"Loading")); 
    15  echo '</div>'; 
    16      
    17  echo  $ajax->link($html->image('actions/new.png', array("alt"=>"Add new category", "title"=>"Add new category")),                   '/admin/catfaqs/add',  
    18      array("update" => "updater","loading"=>"Element.show('loading');Element.hide('updater');", "complete"=>"Element.hide('loading');Effect.Appear('updater')"),  
    19                 null, false); 
    20  
    21 echo $ajax->div('updater'); 
    22 echo $ajax->divEnd('updater'); 
    23 ?></p> 
    24  
    25 <?php 
    26 //exit(print_r($data)); 
    27 foreach ($data as $val) 
    28 { 
    29  echo '<div style="padding:6px 3px 28px 4px;margin:10px 0 5px 0;border:1px dotted gray;">'; 
    30       echo '<div class="butonright">' .$gags->sendEdit($val['Catfaq']['id'], 'catfaqs') . '</div>'; 
    31       echo $html->link($val['Catfaq']['title'], '/admin/faqs/listing/'.$val['Catfaq']['id']); 
    32       echo '<p style="margin-left:15px;">'. $val['Catfaq']['description']  . '</p>'; 
    33       echo '<div class="butonright">'. $gags->confirmDel($val['Catfaq']['id'], 'catfaqs') .'</div>'; 
    34  echo '</div>'; 
    35 } 
    36 ?>