Minor - format code.

1.9.x
Julio Montoya 12 years ago
parent cda0b5fa15
commit 13b8dfce57
  1. 6
      main/inc/lib/notification.lib.php
  2. 43
      main/inc/lib/promotion.lib.php
  3. 53
      main/inc/lib/timeline.lib.php

@ -140,7 +140,7 @@ class Notification extends Model
}
$user_info = api_get_user_info($user_id);
//Extra field was deleted or removed? Use the default status
// Extra field was deleted or removed? Use the default status.
if (empty($setting_info)) {
$user_setting = $default_status;
} else {
@ -172,7 +172,7 @@ class Notification extends Model
}
}
$params['sent_at'] = api_get_utc_datetime();
//Saving the notification to be sent some day
// Saving the notification to be sent some day.
default:
$params['dest_user_id'] = $user_id;
$params['dest_mail'] = $user_info['mail'];
@ -190,7 +190,7 @@ class Notification extends Model
* Formats the content in order to add the welcome message, the notification preference, etc
* @param string the content
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data()
* @param string
* @return string
* */
public function format_content($content, $sender_info)
{

@ -17,24 +17,25 @@ define ('PROMOTION_STATUS_INACTIVE',0);
/**
* @package chamilo.library
*/
class Promotion extends Model {
class Promotion extends Model
{
public $table;
public $columns = array('id','name','description','career_id','status','created_at','updated_at');
var $table;
var $columns = array('id','name','description','career_id','status','created_at','updated_at');
public function __construct() {
public function __construct()
{
$this->table = Database::get_main_table(TABLE_PROMOTION);
}
/**
* Get the count of elements
*/
public function get_count() {
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array(), 'first');
return $row['count'];
}
/**
* Copies the promotion to a new one
* @param integer Promotion ID
@ -42,7 +43,8 @@ class Promotion extends Model {
* @param boolean Whether or not to copy the sessions inside
* @return integer New promotion ID on success, false on failure
*/
public function copy($id, $career_id = null, $copy_sessions = false) {
public function copy($id, $career_id = null, $copy_sessions = false)
{
$pid = false;
$promotion = $this->get($id);
if (!empty($promotion)) {
@ -105,13 +107,19 @@ class Promotion extends Model {
/**
* Gets all promotions by career id
* @param int career id
* @param bool $order
* @return array results
*/
public function get_all_promotions_by_career_id($career_id, $order = false) {
public function get_all_promotions_by_career_id($career_id, $order = false)
{
return Database::select('*', $this->table, array('where'=>array('career_id = ?'=>$career_id),'order' =>$order));
}
public function get_status_list() {
/**
* @return array
*/
public function get_status_list()
{
return array(PROMOTION_STATUS_ACTIVE => get_lang('Active'), PROMOTION_STATUS_INACTIVE => get_lang('Inactive'));
}
@ -134,7 +142,8 @@ class Promotion extends Model {
* @param int promotion id
* @param int status (1, 0)
*/
public function update_all_sessions_status_by_promotion_id($promotion_id, $status) {
public function update_all_sessions_status_by_promotion_id($promotion_id, $status)
{
$session_list = SessionManager::get_all_sessions_by_promotion($promotion_id);
if (!empty($session_list)) {
foreach($session_list as $item) {
@ -152,8 +161,8 @@ class Promotion extends Model {
* @return obj form validator obj
*/
function return_form($url, $action = 'add') {
function return_form($url, $action = 'add')
{
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'careers';
$oFCKeditor->Width = '100%';
@ -209,7 +218,8 @@ class Promotion extends Model {
return $form;
}
public function save($params, $show_query = false) {
public function save($params, $show_query = false)
{
$id = parent::save($params, $show_query);
if (!empty($id)) {
event_system(LOG_PROMOTION_CREATE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id());
@ -217,7 +227,8 @@ class Promotion extends Model {
return $id;
}
public function delete($id) {
public function delete($id)
{
if (parent::delete($id)) {
SessionManager::clear_session_ref_promotion($id);
event_system(LOG_PROMOTION_DELETE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id());
@ -225,6 +236,4 @@ class Promotion extends Model {
return false;
}
}
}

@ -10,37 +10,47 @@
*/
define('TIMELINE_STATUS_ACTIVE', '1');
define('TIMELINE_STATUS_INACTIVE', '2');
/**
* Timeline model class definition
*/
class Timeline extends Model {
var $table;
var $columns = array('headline', 'type', 'start_date', 'end_date', 'text', 'media', 'media_credit', 'media_caption', 'title_slide', 'parent_id', 'status','c_id');
var $is_course_model = true;
class Timeline extends Model
{
public $table;
public $columns = array('headline', 'type', 'start_date', 'end_date', 'text', 'media', 'media_credit', 'media_caption', 'title_slide', 'parent_id', 'status','c_id');
public $is_course_model = true;
public function __construct() {
public function __construct()
{
$this->table = Database::get_course_table(TABLE_TIMELINE);
}
/**
* Get the count of elements
*/
public function get_count() {
public function get_count()
{
$course_id = api_get_course_int_id();
$row = Database::select('count(*) as count', $this->table, array('where' => array('parent_id = ? AND c_id = ?' => array('0', $course_id))), 'first');
return $row['count'];
}
public function get_all($where_conditions = array()) {
/**
* @param array $where_conditions
* @return array
*/
public function get_all($where_conditions = array())
{
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'headline ASC'));
}
/**
* Displays the title + grid
*/
public function listing() {
public function listing()
{
// action links
$html .= '<div class="actions">';
$html = '<div class="actions">';
//$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
$html .= '</div>';
@ -48,7 +58,8 @@ class Timeline extends Model {
return $html;
}
public function get_status_list() {
public function get_status_list()
{
return array(TIMELINE_STATUS_ACTIVE => get_lang('Active'), TIMELINE_STATUS_INACTIVE => get_lang('Inactive'));
}
@ -59,7 +70,8 @@ class Timeline extends Model {
* @param string action add, edit
* @return obj form validator obj
*/
public function return_form($url, $action) {
public function return_form($url, $action)
{
$form = new FormValidator('timeline', 'post', $url);
// Setting the form elements
$header = get_lang('Add');
@ -102,7 +114,13 @@ class Timeline extends Model {
return $form;
}
public function return_item_form($url, $action) {
/**
* @param $url
* @param $action
* @return FormValidator
*/
public function return_item_form($url, $action)
{
$form = new FormValidator('item_form', 'post', $url);
// Settting the form elements
@ -154,7 +172,12 @@ class Timeline extends Model {
}
public function save_item($params) {
/**
* @param array $params
* @return bool
*/
public function save_item($params)
{
$params['c_id'] = api_get_course_int_id();
$id = parent::save($params);
if (!empty($id)) {
@ -163,6 +186,10 @@ class Timeline extends Model {
return $id;
}
/**
* @param array $params
* @return bool
*/
public function save($params) {
$params['c_id'] = api_get_course_int_id();
$params['parent_id'] = '0';

Loading…
Cancel
Save