Minor - format code

1.10.x
Julio Montoya 12 years ago
parent 32e6e6fa3a
commit 5ce22b6c7a
  1. 4
      main/admin/career_dashboard.php
  2. 56
      main/admin/promotions.php
  3. 148
      main/blog/blog.php
  4. 66
      main/inc/lib/event_email_template.class.php
  5. 42
      main/inc/lib/grade_model.lib.php
  6. 19
      main/inc/lib/message.lib.php
  7. 10
      main/inc/lib/sessionmanager.lib.php
  8. 3
      main/inc/lib/system_announcements.lib.php

@ -27,9 +27,9 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions'));
Display :: display_header($nameTools);
Display :: display_header();
$form = new FormValidator('filter_form','GET', api_get_self());
$form = new FormValidator('filter_form', 'GET', api_get_self());
$career = new Career();

@ -25,25 +25,25 @@ $interbreadcrumb[] = array('url' => 'career_dashboard.php','name' => get_lang('C
$action = isset($_GET['action']) ? $_GET['action'] : null;
$check = Security::check_token('request');
$token = Security::get_token();
$token = Security::get_token();
if ($action == 'add') {
$interbreadcrumb[]=array('url' => 'promotions.php','name' => get_lang('Promotions'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Add'));
} elseif ($action == 'edit') {
$interbreadcrumb[]=array('url' => 'promotions.php','name' => get_lang('Promotions'));
$interbreadcrumb[]=array('url' => 'promotions.php','name' => get_lang('Promotions'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Edit'));
} else {
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Promotions'));
}
// The header.
Display::display_header($tool_name);
Display::display_header();
// Tool name
if (isset($_GET['action']) && $_GET['action'] == 'add') {
$tool = 'Add';
$interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Promotion'));
$interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Promotion'));
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
$tool = 'Modify';
@ -58,7 +58,7 @@ $column_model = array(
array('name'=>'career', 'index'=>'career', 'width'=>'100', 'align'=>'left'),
array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left','sortable'=>'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false'),
);
);
$extra_params['autowidth'] = 'true'; //use the width of the parent
//$extra_params['editurl'] = $url; //use the width of the parent
@ -73,12 +73,12 @@ $action_links = 'function action_formatter (cellvalue, options, rowObject) {
?>
<script>
$(function() {
<?php
echo Display::grid_js('promotions', $url,$columns,$column_model,$extra_params,array(), $action_links, true);
$(function() {
<?php
echo Display::grid_js('promotions', $url,$columns,$column_model,$extra_params,array(), $action_links, true);
?>
});
</script>
</script>
<?php
$promotion = new Promotion();
@ -99,55 +99,55 @@ switch ($action) {
}
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']);
$form = $promotion->return_form($url, 'add');
$form = $promotion->return_form($url, 'add');
// The validation or display
if ($form->validate()) {
if ($form->validate()) {
if ($check) {
$values = $form->exportValues();
$res = $promotion->save($values);
$values = $form->exportValues();
$res = $promotion->save($values);
if ($res) {
Display::display_confirmation_message(get_lang('ItemAdded'));
}
}
}
$promotion->display();
} else {
echo '<div class="actions">';
echo '<div class="actions">';
echo Display::url(Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM), api_get_self());
echo '</div>';
echo '</div>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
break;
case 'edit':
//Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
//Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $promotion->return_form($url, 'edit');
// The validation or display
if ($form->validate()) {
if ($form->validate()) {
if ($check) {
$values = $form->exportValues();
$values = $form->exportValues();
$res = $promotion->update($values);
$promotion->update_all_sessions_status_by_promotion_id($values['id'], $values['status']);
$promotion->update_all_sessions_status_by_promotion_id($values['id'], $values['status']);
if ($values['status']) {
Display::display_confirmation_message(sprintf(get_lang('PromotionXUnarchived'), $values['name']), false);
} else {
Display::display_confirmation_message(sprintf(get_lang('PromotionXArchived'), $values['name']), false);
}
}
}
$promotion->display();
} else {
echo '<div class="actions">';
echo '<div class="actions">';
echo Display::url(Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM), api_get_self());
echo '</div>';
echo '</div>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
break;
case 'delete':
case 'delete':
if ($check) {
// Action handling: deleting an obj
$res = $promotion->delete($_GET['id']);
@ -155,17 +155,17 @@ switch ($action) {
Display::display_confirmation_message(get_lang('ItemDeleted'));
}
}
$promotion->display();
$promotion->display();
break;
case 'copy':
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
if ($check) {
$res = $promotion->copy($_GET['id'], null, true);
$res = $promotion->copy($_GET['id'], null, true);
if ($res) {
Display::display_confirmation_message(get_lang('ItemCopied').' - '.get_lang('ExerciseAndLPsAreInvisibleInTheNewCourse'));
}
}
}
$promotion->display();
break;

@ -26,60 +26,50 @@ $current_course_tool = TOOL_BLOGS;
// notice for unauthorized people.
api_protect_course_script(true);
//session
if(isset($_GET['id_session'])) {
$_SESSION['id_session'] = intval($_GET['id_session']);
}
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs');
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$current_page = $_GET['action'];
$current_page = isset($_GET['action']) ? $_GET['action'] : null;
/*
PROCESSING
*/
/* PROCESSING */
$safe_post_title = Security::remove_XSS($_POST['post_title']);
$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']);
$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY);
$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY);
$safe_comment_title = Security::remove_XSS($_POST['comment_title']);
$safe_task_name = Security::remove_XSS($_POST['task_name']);
$safe_task_description = Security::remove_XSS($_POST['task_description']);
$safe_post_title = isset($_POST['post_title']) ? Security::remove_XSS($_POST['post_title']) : null;
$safe_post_file_comment = isset($_POST['post_file_comment']) ? Security::remove_XSS($_POST['post_file_comment']) : null;
$safe_post_full_text = isset($_POST['post_full_text']) ? Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY) : null;
$safe_comment_text = isset($_POST['comment_text']) ? Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY) : null;
$safe_comment_title = isset($_POST['comment_title']) ? Security::remove_XSS($_POST['comment_title']) : null;
$safe_task_name = isset($_POST['task_name']) ? Security::remove_XSS($_POST['task_name']) : null;
$safe_task_description = isset($_POST['task_description']) ? Security::remove_XSS($_POST['task_description']) : null;
if (!empty($_POST['new_post_submit']) AND !empty($_POST['post_title'])) {
Blog :: create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment,$blog_id);
Blog::create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment,$blog_id);
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded'));
}
if (!empty($_POST['edit_post_submit']))
{
if (!empty($_POST['edit_post_submit'])) {
$safe_post_title = Security::remove_XSS($_POST['post_title']);
Blog :: edit_post($_POST['post_id'], $safe_post_title, $safe_post_full_text, $blog_id);
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited'));
}
if (!empty($_POST['new_comment_submit']))
{
if (!empty($_POST['new_comment_submit'])) {
Blog :: create_comment($safe_comment_title, $safe_comment_text, $safe_post_file_comment,$blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded'));
}
if (!empty($_POST['new_task_submit']))
{
Blog :: create_task($blog_id, $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'], $_POST['chkCommentsDelete'], $_POST['task_color']);
if (!empty($_POST['new_task_submit'])){
Blog::create_task($blog_id, $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'], $_POST['chkCommentsDelete'], $_POST['task_color']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated'));
}
if (isset($_POST['edit_task_submit']))
{
if (isset($_POST['edit_task_submit'])) {
Blog :: edit_task($_POST['blog_id'], $_POST['task_id'], $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'],$_POST['chkCommentsDelete'], $_POST['task_color']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskEdited'));
}
if (!empty($_POST['assign_task_submit']))
{
if (!empty($_POST['assign_task_submit'])) {
Blog :: assign_task($blog_id, $_POST['task_user_id'], $_POST['task_task_id'], $_POST['task_year']."-".$_POST['task_month']."-".$_POST['task_day']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssigned'));
}
@ -94,8 +84,7 @@ if (!empty($_POST['new_task_execution_submit']))
Blog :: create_comment($safe_comment_title, $safe_comment_text, $blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id'], $_POST['task_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentCreated'));
}
if (!empty($_POST['register']))
{
if (!empty($_POST['register'])) {
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id)
{
@ -103,8 +92,8 @@ if (!empty($_POST['register']))
}
}
}
if (!empty($_POST['unregister']))
{
if (!empty($_POST['unregister'])) {
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id)
{
@ -112,35 +101,32 @@ if (!empty($_POST['unregister']))
}
}
}
if (!empty($_GET['register']))
{
if (!empty($_GET['register'])) {
Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered'));
$flag = 1;
}
if (!empty($_GET['unregister']))
{
if (!empty($_GET['unregister'])) {
Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
}
if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks')
{
if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') {
if (isset($_GET['do']) && $_GET['do'] == 'delete')
{
Blog :: delete_task($blog_id, (int)$_GET['task_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted'));
}
if (isset($_GET['do']) && $_GET['do'] == 'delete_assignment')
{
if (isset($_GET['do']) && $_GET['do'] == 'delete_assignment') {
Blog :: delete_assigned_task($blog_id, Database::escape_string((int)$_GET['task_id']), Database::escape_string((int)$_GET['user_id']));
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted'));
}
}
if (isset($_GET['action']) && $_GET['action'] == 'view_post')
{
if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
$task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0;
if (isset($_GET['do']) && $_GET['do'] == 'delete_comment')
@ -196,9 +182,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post')
*/
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js"></script>';
// Set bredcrumb
switch ($current_page)
{
switch ($current_page){
case 'new_post' :
$nameTools = get_lang('NewPost');
$interbreadcrumb[] = array ('url' => "blog.php?blog_id=$blog_id", "name" => Blog :: get_blog_title($blog_id));
@ -235,14 +219,11 @@ switch ($current_page)
}
// feedback messages
if (!empty($return_message))
{
if ($return_message['type'] == 'confirmation')
{
if (!empty($return_message)) {
if ($return_message['type'] == 'confirmation') {
Display::display_confirmation_message($return_message['message']);
}
if ($return_message['type'] == 'error')
{
if ($return_message['type'] == 'error') {
Display::display_error_message($return_message['message']);
}
}
@ -271,12 +252,12 @@ Display::display_introduction_section(TOOL_BLOG);
<td width="10%" style="float;left;" class="blog_left" valign="top">
<?php
$month = (int)$_GET['month'] ? (int)$_GET['month'] : (int) date('m');
$year = (int)$_GET['year'] ? (int)$_GET['year'] : date('Y');
Blog :: display_minimonthcalendar($month, $year, $blog_id);
$month = isset($_GET['month']) ? (int)$_GET['month'] : (int) date('m');
$year = isset($_GET['year']) ? (int)$_GET['year'] : date('Y');
Blog::display_minimonthcalendar($month, $year, $blog_id);
?>
<br />
<br />
<table width="100%">
<tr>
@ -307,11 +288,11 @@ Blog :: display_minimonthcalendar($month, $year, $blog_id);
<td valign="top" class="blog_right">
<?php
if ($error)
if (isset($error)) {
Display :: display_error_message($message);
}
if ($flag == '1')
{
if (isset($flag) && $flag == '1') {
$current_page = "manage_tasks";
Blog :: display_assign_task_form($blog_id);
}
@ -353,21 +334,14 @@ switch ($current_page) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
Blog :: display_form_new_post($blog_id);
}
else
{
if (isset ($_GET['filter']) && !empty ($_GET['filter']))
{
} else {
if (isset($_GET['filter']) && !empty($_GET['filter'])) {
Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter']));
}
else
{
} else {
Blog :: display_blog_posts($blog_id);
}
}
}
else
{
} else {
api_not_allowed();
}
break;
@ -377,22 +351,17 @@ switch ($current_page) {
case 'edit_post' :
$task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0;
if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id))
{
if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) {
// we show the form if
// 1. no post data
// 2. there is post data and the required field is empty
if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title'])))
{
if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) {
// if there is post data there is certainly an error in the form
if ($_POST)
{
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
Blog :: display_form_edit_post($blog_id, Database::escape_string((int)$_GET['post_id']));
}
else
{
} else {
if (isset ($_GET['filter']) && !empty ($_GET['filter']))
{
Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter']));
@ -402,30 +371,26 @@ switch ($current_page) {
Blog :: display_blog_posts($blog_id);
}
}
}
else
{
} else {
api_not_allowed();
}
break;
case 'manage_members' :
if (api_is_allowed('BLOG_'.$blog_id, 'member_management'))
{
if (api_is_allowed('BLOG_'.$blog_id, 'member_management')) {
Blog :: display_form_user_subscribe($blog_id);
echo '<br /><br />';
Blog :: display_form_user_unsubscribe($blog_id);
}
else
} else {
api_not_allowed();
}
break;
case 'manage_rights' :
Blog :: display_form_user_rights($blog_id);
break;
case 'manage_tasks' :
if (api_is_allowed('BLOG_'.$blog_id, 'task_management'))
{
if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) {
if (isset($_GET['do']) && $_GET['do'] == 'add')
{
Blog :: display_new_task_form($blog_id);
@ -463,12 +428,9 @@ switch ($current_page) {
break;
case '' :
default :
if (isset ($_GET['filter']) && !empty ($_GET['filter']))
{
if (isset ($_GET['filter']) && !empty ($_GET['filter'])) {
Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter']));
}
else
{
} else {
Blog :: display_blog_posts($blog_id);
}
}
@ -477,5 +439,5 @@ switch ($current_page) {
</tr>
</table>
<?php
// Display the footer
Display::display_footer();

@ -13,18 +13,18 @@
* @package chamilo.library
*/
class EventEmailTemplate extends Model {
var $table;
var $columns = array('id', 'message','subject','event_type_name','activated');
public function __construct() {
$this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
}
}
public function get_all($where_conditions = array()) {
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
}
}
/**
* Displays the title + grid
*/
@ -32,64 +32,58 @@ class EventEmailTemplate extends Model {
// action links
$content = Display::actions(array(
array(
'url' => 'event_type.php' ,
'url' => 'event_type.php' ,
'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
)
)
);
$content .= Display::grid_html('event_email_template');
$content .= Display::grid_html('event_email_template');
return $content;
}
public function get_status_list() {
return array(EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enabled'), EVENT_EMAIL_TEMPLATE_INACTIVE=> get_lang('Disabled'));
}
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return obj form validator obj
*/
public function return_form($url, $action) {
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'careers';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
public function return_form($url, $action)
{
$form = new FormValidator('career', 'post', $url);
// Settting the form elements
$header = get_lang('Add');
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list();
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
}
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
// Setting the defaults
$defaults = $this->get($id);
if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
@ -97,17 +91,17 @@ class EventEmailTemplate extends Model {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
return $form;
}
public function get_count() {
public function get_count() {
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
/*
public function save($params) {
$id = parent::save($params);
@ -116,9 +110,9 @@ class EventEmailTemplate extends Model {
}
return $id;
}
public function delete($id) {
parent::delete($id);
event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
} */
} */
}

@ -23,11 +23,18 @@ class GradeModel extends Model
$this->table = Database::get_main_table(TABLE_GRADE_MODEL);
}
/**
* @param array $where_conditions
* @return array
*/
public function get_all($where_conditions = array())
{
return Database::select('*', $this->table, array('where' => $where_conditions, 'order' => 'name ASC'));
}
/**
* @return mixed
*/
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array(), 'first');
@ -55,24 +62,15 @@ class GradeModel extends Model
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
*/
public function return_form($url, $action)
{
$oFCKeditor = new FCKeditor('description');
$oFCKeditor->ToolbarSet = 'grade_model';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
$form = new FormValidator('grades', 'post', $url);
// Settting the form elements
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
@ -223,6 +221,10 @@ class GradeModel extends Model
return $form;
}
/**
* @param $id
* @return array|null
*/
public function get_components($id)
{
$obj = new GradeModelComponents();
@ -233,6 +235,11 @@ class GradeModel extends Model
return null;
}
/**
* @param $params
* @param bool $show_query
* @return bool
*/
public function save($params, $show_query = false)
{
$id = parent::save($params, $show_query);
@ -250,6 +257,10 @@ class GradeModel extends Model
return $id;
}
/**
* @param array $params
* @return bool|void
*/
public function update($params)
{
parent::update($params);
@ -268,6 +279,10 @@ class GradeModel extends Model
//$params['components']
}
/**
* @param int $id
* @return bool|void
*/
public function delete($id)
{
parent::delete($id);
@ -308,10 +323,11 @@ class GradeModel extends Model
}
}
//@todo move in another file
class GradeModelComponents extends Model
{
var $table;
var $columns = array(
public $table;
public $columns = array(
'id',
'title',
'percentage',
@ -333,4 +349,4 @@ class GradeModelComponents extends Model
return $id;
}
}
}

@ -16,6 +16,10 @@
*/
class MessageManager
{
/**
* @param int $current_user_id
* @return array
*/
public static function get_online_user_list($current_user_id)
{
//@todo this is a bad idea to parse all users online
@ -73,8 +77,6 @@ class MessageManager
public static function get_number_of_messages($unread = false)
{
$table_message = Database::get_main_table(TABLE_MESSAGE);
$condition_msg_status = '';
if ($unread) {
$condition_msg_status = ' msg_status = '.MESSAGE_STATUS_UNREAD.' ';
} else {
@ -247,6 +249,7 @@ class MessageManager
}
// Save attachment file for inbox messages
if (is_array($file_attachments)) {
$i = 0;
foreach ($file_attachments as $file_attach) {
@ -495,7 +498,7 @@ class MessageManager
} else {
$new_file_name = uniqid('');
$usergroup = new UserGroup();
$message_user_id = '';
if (!empty($receiver_user_id)) {
$message_user_id = $receiver_user_id;
} else {
@ -514,11 +517,12 @@ class MessageManager
// If this directory does not exist - we create it.
if (!file_exists($path_message_attach)) {
@mkdir($path_message_attach, api_get_permissions_for_new_directories(), true);
mkdir($path_message_attach, api_get_permissions_for_new_directories(), true);
}
$new_path = $path_message_attach.$new_file_name;
if (is_uploaded_file($file_attach['tmp_name'])) {
$result = @copy($file_attach['tmp_name'], $new_path);
copy($file_attach['tmp_name'], $new_path);
}
$safe_file_comment = Database::escape_string($file_comment);
$safe_file_name = Database::escape_string($file_name);
@ -526,7 +530,7 @@ class MessageManager
// Storing the attachments if any
$sql = "INSERT INTO $tbl_message_attach(filename,comment, path,message_id,size)
VALUES ( '$safe_file_name', '$safe_file_comment', '$safe_new_file_name' , '$message_id', '".$file_attach['size']."' )";
$result = Database::query($sql);
Database::query($sql);
}
}
@ -546,7 +550,6 @@ class MessageManager
$sql = "SELECT * FROM $table_message_attach WHERE message_id = '$message_id'";
$rs = Database::query($sql);
$new_paths = array();
$usergroup = new UserGroup();
while ($row = Database::fetch_array($rs)) {
$path = $row['path'];
@ -563,7 +566,7 @@ class MessageManager
if (is_file($path_message_attach.$path)) {
if (rename($path_message_attach.$path, $path_message_attach.$new_path)) {
$sql_upd = "UPDATE $table_message_attach set path='$new_path' WHERE id ='$attach_id'";
$rs_upd = Database::query($sql_upd);
Database::query($sql_upd);
}
}
}

@ -1914,12 +1914,12 @@ class SessionManager
return array();
}
function get_all_sessions_by_promotion($id) {
static function get_all_sessions_by_promotion($id) {
$t = Database::get_main_table(TABLE_MAIN_SESSION);
return Database::select('*', $t, array('where'=>array('promotion_id = ?'=>$id)));
}
function suscribe_sessions_to_promotion($promotion_id, $list) {
static function suscribe_sessions_to_promotion($promotion_id, $list) {
$t = Database::get_main_table(TABLE_MAIN_SESSION);
$params = array();
$params['promotion_id'] = 0;
@ -1939,7 +1939,8 @@ class SessionManager
* @param int session id
* @param int status
*/
public function set_session_status($session_id, $status) {
public static function set_session_status($session_id, $status)
{
$t = Database::get_main_table(TABLE_MAIN_SESSION);
$params['visibility'] = $status;
Database::update($t, $params, array('id = ?'=>$session_id));
@ -1963,7 +1964,7 @@ class SessionManager
* @param $set_exercises_lp_invisible
* @return int
*/
public function copy_session($id, $copy_courses = true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false) {
public static function copy_session($id, $copy_courses = true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false) {
$id = intval($id);
$params = self::fetch($id);
@ -2944,6 +2945,5 @@ class SessionManager
$sql = "select * FROM $tableSession WHERE session_category_id = $categoryId";
$result = Database::query($sql);
return Database::store_result($result);
}
}

@ -285,7 +285,8 @@ class SystemAnnouncementManager
* @return array An array with all available system announcements (as php
* objects)
*/
public static function get_all_announcements() {
public static function get_all_announcements()
{
$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$now = api_get_utc_datetime();
$sql = "SELECT *, IF( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible FROM $db_table";

Loading…
Cancel
Save