Minor - format code.

1.10.x
Julio Montoya 11 years ago
parent 30a0c06647
commit 9d9620267b
  1. 35
      main/inc/email_editor.php
  2. 22
      main/inc/lib/SequenceManager.php
  3. 25
      main/inc/lib/message.lib.php
  4. 50
      main/inc/lib/promotion.lib.php
  5. 5
      main/inc/lib/redirect.class.php
  6. 4
      main/inc/lib/skill.lib.php

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This script contains the code to edit and send an e-mail to one of * This script contains the code to edit and send an e-mail to one of
* the platform's users. * the platform's users.
@ -11,7 +12,7 @@
// name of the language file that needs to be included // name of the language file that needs to be included
use \ChamiloSession as Session; use ChamiloSession as Session;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
@ -70,15 +71,33 @@ $form->setDefaults($defaults);
if ($form->validate()) { if ($form->validate()) {
$text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS')." ".api_get_path(WEB_PATH); $text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS')." ".api_get_path(WEB_PATH);
$email_administrator=Security::remove_XSS($_POST['dest']); $email_administrator = Security::remove_XSS($_POST['dest']);
$user_id=api_get_user_id(); $user_id = api_get_user_id();
$title=Security::remove_XSS($_POST['email_title']); $title = Security::remove_XSS($_POST['email_title']);
$content=Security::remove_XSS($_POST['email_text']); $content = Security::remove_XSS($_POST['email_text']);
if (!empty($_user['mail'])) { if (!empty($_user['mail'])) {
api_mail_html('', $email_administrator, $title, $text, api_get_person_name($_user['firstname'], $_user['lastname']), $_user['mail']); api_mail_html(
UserManager::send_message_in_outbox($email_administrator, $user_id, $title, $content); '',
$email_administrator,
$title,
$text,
api_get_person_name($_user['firstname'], $_user['lastname']),
$_user['mail']
);
UserManager::send_message_in_outbox(
$email_administrator,
$user_id,
$title,
$content
);
} else { } else {
api_mail_html('', $email_administrator, $title, $text, get_lang('Anonymous')); api_mail_html(
'',
$email_administrator,
$title,
$text,
get_lang('Anonymous')
);
} }
$orig = $_SESSION['origin_url']; $orig = $_SESSION['origin_url'];
Session::erase('origin_url'); Session::erase('origin_url');

@ -27,9 +27,11 @@ class SequenceManager
while ($temp_pre_req = Database::fetch_array($result, 'ASSOC')){ while ($temp_pre_req = Database::fetch_array($result, 'ASSOC')){
$pre_req[] = intval($temp_pre_req['sequence_row_entity_id']); $pre_req[] = intval($temp_pre_req['sequence_row_entity_id']);
} }
return $pre_req; return $pre_req;
} }
} }
return false; return false;
} }
@ -69,6 +71,7 @@ class SequenceManager
while ($temp_next = Database::fetch_array($result, 'ASSOC')){ while ($temp_next = Database::fetch_array($result, 'ASSOC')){
$next[] = $temp_next; $next[] = $temp_next;
} }
return $next; return $next;
} }
} }
@ -95,9 +98,11 @@ class SequenceManager
while ($temp_entity = Database::fetch_array($result, 'ASSOC')){ while ($temp_entity = Database::fetch_array($result, 'ASSOC')){
$entity[] = $temp_entity; $entity[] = $temp_entity;
} }
return $entity; return $entity;
} }
} }
return false; return false;
} }
@ -106,10 +111,15 @@ class SequenceManager
* @param int $user_id * @param int $user_id
* @param int $session_id * @param int $session_id
* @param int $rule_id * @param int $rule_id
*
* @return bool * @return bool
*/ */
public static function validate_rule_by_row_id($row_entity_id, $user_id = null, $session_id, $rule_id = 1) public static function validate_rule_by_row_id(
{ $row_entity_id,
$user_id = null,
$session_id,
$rule_id = 1
) {
if (self::_debug) { if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__); error_log('Entering '.__FUNCTION__.' in '.__FILE__);
} }
@ -133,6 +143,7 @@ class SequenceManager
} }
} }
} }
return false; return false;
} }
@ -157,14 +168,17 @@ class SequenceManager
while ($temp_condition = Database::fetch_array($result, 'ASSOC')) { while ($temp_condition = Database::fetch_array($result, 'ASSOC')) {
$condition[] = $temp_condition; $condition[] = $temp_condition;
} }
return $condition; return $condition;
} }
} }
return false; return false;
} }
/** /**
* @param int $rule_id * @param int $rule_id
*
* @return array|bool * @return array|bool
*/ */
public static function get_method_by_rule_id($rule_id = 1) public static function get_method_by_rule_id($rule_id = 1)
@ -187,6 +201,7 @@ class SequenceManager
while ($temp_method = Database::fetch_array($result, 'ASSOC')){ while ($temp_method = Database::fetch_array($result, 'ASSOC')){
$method[] = $temp_method; $method[] = $temp_method;
} }
return $method; return $method;
} }
} }
@ -196,6 +211,7 @@ class SequenceManager
/** /**
* @param int $row_entity_id * @param int $row_entity_id
*
* @return array|bool * @return array|bool
*/ */
public static function get_value_by_row_entity_id($row_entity_id) public static function get_value_by_row_entity_id($row_entity_id)
@ -213,9 +229,11 @@ class SequenceManager
while ($temp_value = Database::fetch_array($result, 'ASSOC')){ while ($temp_value = Database::fetch_array($result, 'ASSOC')){
$value[] = $temp_value; $value[] = $temp_value;
} }
return $value; return $value;
} }
} }
return false; return false;
} }

@ -24,6 +24,7 @@ class MessageManager
foreach ($userlist as $user_id) { foreach ($userlist as $user_id) {
$online_user_list[$user_id] = GetFullUserName($user_id).($current_user_id == $user_id ? ("&nbsp;(".get_lang('Myself').")") : ("")); $online_user_list[$user_id] = GetFullUserName($user_id).($current_user_id == $user_id ? ("&nbsp;(".get_lang('Myself').")") : (""));
} }
return $online_user_list; return $online_user_list;
} }
@ -70,6 +71,7 @@ class MessageManager
WHERE user_receiver_id=".api_get_user_id()." AND msg_status=".MESSAGE_STATUS_UNREAD; WHERE user_receiver_id=".api_get_user_id()." AND msg_status=".MESSAGE_STATUS_UNREAD;
$result = Database::query($sql); $result = Database::query($sql);
$i = Database::num_rows($result); $i = Database::num_rows($result);
return $i; return $i;
} }
@ -84,6 +86,7 @@ class MessageManager
for ($i = 0; $i < count($user_connect); $i++) { for ($i = 0; $i < count($user_connect); $i++) {
$user_id_list[$i] = $user_connect[$i][0]; $user_id_list[$i] = $user_connect[$i][0];
} }
return $user_id_list; return $user_id_list;
} }
@ -234,6 +237,7 @@ class MessageManager
); );
Display::addFlash(Display::return_message($warning , 'warning')); Display::addFlash(Display::return_message($warning , 'warning'));
return false; return false;
} }
@ -392,17 +396,17 @@ class MessageManager
// get message id from data found early for other receiver user // get message id from data found early for other receiver user
$sql = "SELECT id FROM $table_message $sql = "SELECT id FROM $table_message
WHERE WHERE
user_sender_id ='{$row_message['user_sender_id']}' AND user_sender_id ='{$row_message['user_sender_id']}' AND
title='{$row_message['title']}' AND title='{$row_message['title']}' AND
content='{$row_message['content']}' AND content='{$row_message['content']}' AND
group_id='{$row_message['group_id']}' AND group_id='{$row_message['group_id']}' AND
user_receiver_id='$receiver_user_id'"; user_receiver_id='$receiver_user_id'";
$rs_msg_id = Database::query($sql); $rs_msg_id = Database::query($sql);
$row = Database::fetch_array($rs_msg_id); $row = Database::fetch_array($rs_msg_id);
// update parent_id for other user receiver // update parent_id for other user receiver
$sql = "UPDATE $table_message SET parent_id = '{$row[id]}' $sql = "UPDATE $table_message SET parent_id = ".$row['id']."
WHERE id = '$message_id'"; WHERE id = $message_id";
Database::query($sql); Database::query($sql);
} }
@ -418,7 +422,8 @@ class MessageManager
return false; return false;
$user_receiver_id = intval($user_receiver_id); $user_receiver_id = intval($user_receiver_id);
$id = intval($id); $id = intval($id);
$sql = "SELECT * FROM $table_message WHERE id=".$id." AND msg_status<>4;"; $sql = "SELECT * FROM $table_message
WHERE id=".$id." AND msg_status<>4";
$rs = Database::query($sql); $rs = Database::query($sql);
if (Database::num_rows($rs) > 0) { if (Database::num_rows($rs) > 0) {
@ -462,14 +467,16 @@ class MessageManager
$query = "UPDATE $table_message SET msg_status=3 $query = "UPDATE $table_message SET msg_status=3
WHERE user_sender_id='$user_sender_id' AND id='$id'"; WHERE user_sender_id='$user_sender_id' AND id='$id'";
$result = Database::query($query); $result = Database::query($query);
return $result; return $result;
} }
return false; return false;
} }
/** /**
* Saves a message attachment files * Saves a message attachment files
* @param array $_FILES['name'] * @param array $file_attach $_FILES['name']
* @param string a comment about the uploaded file * @param string a comment about the uploaded file
* @param int message id * @param int message id
* @param int receiver user id (optional) * @param int receiver user id (optional)

@ -10,7 +10,15 @@
class Promotion extends Model class Promotion extends Model
{ {
public $table; public $table;
public $columns = array('id','name','description','career_id','status','created_at','updated_at'); public $columns = array(
'id',
'name',
'description',
'career_id',
'status',
'created_at',
'updated_at',
);
/** /**
* Constructor * Constructor
@ -95,6 +103,7 @@ class Promotion extends Model
$pid = $this->save($new); $pid = $this->save($new);
} }
} }
return $pid; return $pid;
} }
@ -106,7 +115,14 @@ class Promotion extends Model
*/ */
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)); return Database::select(
'*',
$this->table,
array(
'where' => array('career_id = ?' => $career_id),
'order' => $order,
)
);
} }
/** /**
@ -114,7 +130,10 @@ class Promotion extends Model
*/ */
public function get_status_list() public function get_status_list()
{ {
return array(PROMOTION_STATUS_ACTIVE => get_lang('Active'), PROMOTION_STATUS_INACTIVE => get_lang('Inactive')); return array(
PROMOTION_STATUS_ACTIVE => get_lang('Active'),
PROMOTION_STATUS_INACTIVE => get_lang('Inactive'),
);
} }
/** /**
@ -123,7 +142,7 @@ class Promotion extends Model
*/ */
public function display() public function display()
{ {
// action links // Action links
echo '<div class="actions" style="margin-bottom:20px">'; echo '<div class="actions" style="margin-bottom:20px">';
echo '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>'; echo '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_promotion.png',get_lang('Add'),'','32').'</a>'; echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_promotion.png',get_lang('Add'),'','32').'</a>';
@ -134,12 +153,12 @@ class Promotion extends Model
/** /**
* Update all session status by promotion * Update all session status by promotion
* @param int promotion id * @param int $promotion_id
* @param int status (1, 0) * @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); $session_list = SessionManager::get_all_sessions_by_promotion($promotion_id);
if (!empty($session_list)) { if (!empty($session_list)) {
foreach($session_list as $item) { foreach($session_list as $item) {
SessionManager::set_session_status($item['id'], $status); SessionManager::set_session_status($item['id'], $status);
@ -150,8 +169,9 @@ class Promotion extends Model
/** /**
* Returns a Form validator Obj * Returns a Form validator Obj
* @todo the form should be auto generated * @todo the form should be auto generated
* @param string url * @param string $url
* @param string header name * @param string $action
*
* @return FormValidator * @return FormValidator
*/ */
public function return_form($url, $action = 'add') public function return_form($url, $action = 'add')
@ -166,7 +186,12 @@ class Promotion extends Model
$form->addElement('header', '', $header); $form->addElement('header', '', $header);
$form->addElement('hidden', 'id', $id); $form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70','id' => 'name')); $form->addElement(
'text',
'name',
get_lang('Name'),
array('size' => '70', 'id' => 'name')
);
$form->addHtmlEditor( $form->addHtmlEditor(
'description', 'description',
get_lang('Description'), get_lang('Description'),
@ -214,7 +239,8 @@ class Promotion extends Model
} }
/** /**
* @param $params * @param array $params
*
* @param bool $show_query * @param bool $show_query
* @return bool * @return bool
*/ */
@ -234,7 +260,7 @@ class Promotion extends Model
} }
/** /**
* @param $id * @param int $id
* @return bool * @return bool
*/ */
public function delete($id) public function delete($id)

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Send a redirect to the user agent and exist * Send a redirect to the user agent and exist
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
@ -92,7 +93,7 @@ class Redirect
} }
} }
global $_configuration; global $_configuration;
if (!isset($_configuration['redirect_admin_to_courses_list']) or if (!isset($_configuration['redirect_admin_to_courses_list']) ||
$_configuration['redirect_admin_to_courses_list'] === 'false' $_configuration['redirect_admin_to_courses_list'] === 'false'
) { ) {
// If the user is a platform admin, redirect to the main admin page // If the user is a platform admin, redirect to the main admin page
@ -137,7 +138,7 @@ class Redirect
/** /**
* Redirects the user to a given URL through the header('location: ...') function * Redirects the user to a given URL through the header('location: ...') function
* @param $url * @param string $url
*/ */
protected static function navigate($url) protected static function navigate($url)
{ {

@ -14,7 +14,7 @@ class SkillProfile extends Model
*/ */
public function __construct() public function __construct()
{ {
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_PROFILE); $this->table = Database::get_main_table(TABLE_MAIN_SKILL_PROFILE);
$this->table_rel_profile = Database::get_main_table(TABLE_MAIN_SKILL_REL_PROFILE); $this->table_rel_profile = Database::get_main_table(TABLE_MAIN_SKILL_REL_PROFILE);
} }
@ -28,6 +28,7 @@ class SkillProfile extends Model
ON(p.id = sp.profile_id) "; ON(p.id = sp.profile_id) ";
$result = Database::query($sql); $result = Database::query($sql);
$profiles = Database::store_result($result, 'ASSOC'); $profiles = Database::store_result($result, 'ASSOC');
return $profiles; return $profiles;
} }
@ -45,6 +46,7 @@ class SkillProfile extends Model
description = '$description' description = '$description'
WHERE id = $profileId "; WHERE id = $profileId ";
$result = Database::query($sql); $result = Database::query($sql);
return $result; return $result;
} }

Loading…
Cancel
Save