Minor - format code.

pull/2487/head
jmontoyaa 8 years ago
parent 5a3d83c218
commit e0ca9fcc09
  1. 16
      main/exercise/Hpdownload.php
  2. 10
      main/inc/lib/AnnouncementManager.php
  3. 57
      main/inc/lib/timeline.lib.php
  4. 26
      main/webservices/soap.php
  5. 115
      plugin/sepe/ws/Sepe.php
  6. 6
      plugin/sepe/ws/service.php

@ -1,14 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This script shows the list of exercises for administrators and students. * This script shows the list of exercises for administrators and students.
* @package chamilo.exercise * @package chamilo.exercise
* @author Istvan Mandak * @author Istvan Mandak
* @version $Id: Hpdownload.php 22201 2009-07-17 19:57:03Z cfasanando $ * @version $Id: Hpdownload.php 22201 2009-07-17 19:57:03Z cfasanando $
*/ */
/**
* Code
*/
session_cache_limiter('public'); session_cache_limiter('public');
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -133,17 +130,12 @@ if ($content_type == 'text/html') {
$prehref = "javascript:void(0);"; $prehref = "javascript:void(0);";
$posthref = api_get_path(WEB_CODE_PATH)."main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; $posthref = api_get_path(WEB_CODE_PATH)."main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
$newcontent = str_replace($prehref, $posthref, $newcontent); $newcontent = str_replace($prehref, $posthref, $newcontent);
$prehref = "class=\"GridNum\" onclick="; $prehref = "class=\"GridNum\" onclick=";
$posthref = "class=\"GridNum\" onMouseover="; $posthref = "class=\"GridNum\" onMouseover=";
$newcontent = str_replace($prehref, $posthref, $newcontent); $newcontent = str_replace($prehref, $posthref, $newcontent);
header('Content-length: '.strlen($newcontent)); header('Content-length: '.strlen($newcontent));
// Dipsp. // Dipsp.
echo $newcontent; echo $newcontent;
exit(); exit();
} }

@ -1180,12 +1180,12 @@ class AnnouncementManager
*/ */
public static function get_attachment($announcementId) public static function get_attachment($announcementId)
{ {
$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); $table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
$announcementId = intval($announcementId); $announcementId = intval($announcementId);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$row = array(); $row = array();
$sql = 'SELECT id, path, filename, comment $sql = 'SELECT id, path, filename, comment
FROM ' . $tbl_announcement_attachment.' FROM '.$table.'
WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcementId; WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcementId;
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) != 0) { if (Database::num_rows($result) != 0) {
@ -1725,8 +1725,7 @@ class AnnouncementManager
if (api_is_allowed_to_edit(false, true)) { if (api_is_allowed_to_edit(false, true)) {
// check teacher status // check teacher status
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
if (api_get_group_id() == 0) { if (api_get_group_id() == 0) {
$group_condition = ''; $group_condition = '';
} else { } else {
@ -1754,7 +1753,7 @@ class AnnouncementManager
} }
} else { } else {
// students only get to see the visible announcements // students only get to see the visible announcements
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
$group_memberships = GroupManager::get_group_ids($_course['real_id'], $userId); $group_memberships = GroupManager::get_group_ids($_course['real_id'], $userId);
if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
@ -1834,7 +1833,6 @@ class AnnouncementManager
ORDER BY display_order DESC ORDER BY display_order DESC
LIMIT 0, $maximum"; LIMIT 0, $maximum";
} else { } else {
if (api_get_course_setting('allow_user_edit_announcement')) { if (api_get_course_setting('allow_user_edit_announcement')) {
$cond_user_id = " AND ( $cond_user_id = " AND (
ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL

@ -36,7 +36,19 @@ class Timeline extends Model
public function get_count() public function get_count()
{ {
$course_id = api_get_course_int_id(); $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'); $row = Database::select(
'count(*) as count',
$this->table,
array(
'where' => array(
'parent_id = ? AND c_id = ?' => array(
'0',
$course_id
)
)
),
'first'
);
return $row['count']; return $row['count'];
} }
@ -46,7 +58,11 @@ class Timeline extends Model
*/ */
public function get_all($where_conditions = array()) public function get_all($where_conditions = array())
{ {
return Database::select('*', $this->table, array('where'=>$where_conditions, 'order' =>'headline ASC')); return Database::select(
'*',
$this->table,
array('where' => $where_conditions, 'order' => 'headline ASC')
);
} }
/** /**
@ -65,7 +81,10 @@ class Timeline extends Model
public function get_status_list() public function get_status_list()
{ {
return array(TIMELINE_STATUS_ACTIVE => get_lang('Active'), TIMELINE_STATUS_INACTIVE => get_lang('Inactive')); return array(
TIMELINE_STATUS_ACTIVE => get_lang('Active'),
TIMELINE_STATUS_INACTIVE => get_lang('Inactive')
);
} }
/** /**
@ -88,7 +107,6 @@ class Timeline extends Model
$form->addElement('hidden', 'id', $id); $form->addElement('hidden', 'id', $id);
$form->addElement('text', 'headline', get_lang('Name'), array('size' => '70')); $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70'));
//$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list(); $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list); $form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') { if ($action == 'edit') {
@ -126,7 +144,6 @@ class Timeline extends Model
*/ */
public function return_item_form($url, $action) public function return_item_form($url, $action)
{ {
$form = new FormValidator('item_form', 'post', $url); $form = new FormValidator('item_form', 'post', $url);
// Setting the form elements // Setting the form elements
$header = get_lang('Add'); $header = get_lang('Add');
@ -152,9 +169,6 @@ class Timeline extends Model
$form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('start_date', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('start_date', get_lang('ThisFieldIsRequired'), 'required');
//$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
if ($action == 'edit') { if ($action == 'edit') {
// Setting the defaults // Setting the defaults
$defaults = $this->get($id); $defaults = $this->get($id);
@ -162,19 +176,11 @@ class Timeline extends Model
} else { } else {
$form->addButtonCreate(get_lang('Add'), 'submit'); $form->addButtonCreate(get_lang('Add'), 'submit');
} }
/*if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}*/
$form->setDefaults($defaults); $form->setDefaults($defaults);
// Setting the rules // Setting the rules
$form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
return $form; return $form;
} }
/** /**
@ -195,7 +201,8 @@ class Timeline extends Model
* @param array $params * @param array $params
* @return bool * @return bool
*/ */
public function save($params) { public function save($params)
{
$params['c_id'] = api_get_course_int_id(); $params['c_id'] = api_get_course_int_id();
$params['parent_id'] = '0'; $params['parent_id'] = '0';
$params['type'] = 'default'; $params['type'] = 'default';
@ -206,16 +213,19 @@ class Timeline extends Model
return $id; return $id;
} }
public function delete($id) { public function delete($id)
{
parent::delete($id); parent::delete($id);
//event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
} }
public function get_url($id) { public function get_url($id)
{
return api_get_path(WEB_AJAX_PATH).'timeline.ajax.php?a=get_timeline_content&id='.intval($id); return api_get_path(WEB_AJAX_PATH).'timeline.ajax.php?a=get_timeline_content&id='.intval($id);
} }
public function get_timeline_content($id) { public function get_timeline_content($id)
{
$timeline = array(); $timeline = array();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$timeline['timeline'] = $this->process_item($this->get($id)); $timeline['timeline'] = $this->process_item($this->get($id));
@ -224,7 +234,8 @@ class Timeline extends Model
return $timeline; return $timeline;
} }
function process_items($items) { function process_items($items)
{
foreach ($items as &$item) { foreach ($items as &$item) {
$item = $this->process_item($item); $item = $this->process_item($item);
} }
@ -234,7 +245,9 @@ class Timeline extends Model
} }
return $new_array; return $new_array;
} }
function process_item($item) {
function process_item($item)
{
$item['startDate'] = $item['start_date']; $item['startDate'] = $item['start_date'];
unset($item['start_date']); unset($item['start_date']);
if (!empty($item['end_date'])) { if (!empty($item['end_date'])) {

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.webservices * @package chamilo.webservices
*/ */
@ -10,13 +11,15 @@ $libpath = api_get_path(LIBRARY_PATH);
/** /**
* SOAP error handler. Handles an error sending a SOAP fault * SOAP error handler. Handles an error sending a SOAP fault
*/ */
class WSSoapErrorHandler implements WSErrorHandler { class WSSoapErrorHandler implements WSErrorHandler
{
/** /**
* Handles the error by sending a SOAP fault through the server * Handles the error by sending a SOAP fault through the server
* *
* @param WSError Error to handle * @param WSError Error to handle
*/ */
public function handle($error) { public function handle($error)
{
$server = WSSoapServer::singleton(); $server = WSSoapServer::singleton();
$server->fault(strval($error->code), $error->message); $server->fault(strval($error->code), $error->message);
} }
@ -25,7 +28,8 @@ class WSSoapErrorHandler implements WSErrorHandler {
/** /**
* SOAP server wrapper implementing a Singleton * SOAP server wrapper implementing a Singleton
*/ */
class WSSoapServer { class WSSoapServer
{
/** /**
* SOAP server instance * SOAP server instance
* *
@ -34,15 +38,17 @@ class WSSoapServer {
private static $_instance; private static $_instance;
/** /**
* Private constructor * Constructor
*/ */
private function __construct() { public function __construct()
{
} }
/** /**
* Singleton method * Singleton method
*/ */
public static function singleton() { public static function singleton()
{
if (!isset(self::$_instance)) { if (!isset(self::$_instance)) {
self::$_instance = new soap_server(); self::$_instance = new soap_server();
// Set the error handler // Set the error handler
@ -88,7 +94,13 @@ $s->wsdl->addComplexType(
'', '',
'SOAP-ENC:Array', 'SOAP-ENC:Array',
array(), array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')), 'tns:extras' array(
array(
'ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:extras[]'
)
),
'tns:extras'
); );
/* /*

@ -258,7 +258,6 @@ class Sepe
"ACCION_FORMATIVA"=>$crearAccionInputArray['ACCION_FORMATIVA'] "ACCION_FORMATIVA"=>$crearAccionInputArray['ACCION_FORMATIVA']
) )
); );
} }
$startDate = self::fixDate($startDate); $startDate = self::fixDate($startDate);
@ -810,24 +809,80 @@ class Sepe
$idEspecialidad->AREA_PROFESIONAL = $aux['professional_area']; $idEspecialidad->AREA_PROFESIONAL = $aux['professional_area'];
$idEspecialidad->CODIGO_ESPECIALIDAD = $aux['specialty_code']; $idEspecialidad->CODIGO_ESPECIALIDAD = $aux['specialty_code'];
$params[0] = new SoapVar($idEspecialidad, SOAP_ENC_OBJECT, NULL, null, 'ID_ESPECIALIDAD', null); $params[0] = new SoapVar(
$idEspecialidad,
SOAP_ENC_OBJECT,
null,
null,
'ID_ESPECIALIDAD',
null
);
$centroImparticion = new stdClass(); $centroImparticion = new stdClass();
$centroImparticion->ORIGEN_CENTRO = $aux['center_origin']; $centroImparticion->ORIGEN_CENTRO = $aux['center_origin'];
$centroImparticion->CODIGO_CENTRO = $aux['center_code']; $centroImparticion->CODIGO_CENTRO = $aux['center_code'];
$params[1] = new SoapVar($centroImparticion, SOAP_ENC_OBJECT, NULL, null, 'CENTRO_IMPARTICION', null); $params[1] = new SoapVar(
$params[2] = new SoapVar(self::undoFixDate($aux['start_date']), XSD_STRING, NULL, null, 'FECHA_INICIO', null); $centroImparticion,
$params[3] = new SoapVar(self::undoFixDate($aux['end_date']), XSD_STRING, NULL, null, 'FECHA_FIN', null); SOAP_ENC_OBJECT,
$params[4] = new SoapVar($aux['modality_impartition'], XSD_STRING, NULL, null, 'MODALIDAD_IMPARTICION', null); null,
null,
'CENTRO_IMPARTICION',
null
);
$params[2] = new SoapVar(
self::undoFixDate($aux['start_date']),
XSD_STRING,
null,
null,
'FECHA_INICIO',
null
);
$params[3] = new SoapVar(
self::undoFixDate($aux['end_date']),
XSD_STRING,
null,
null,
'FECHA_FIN',
null
);
$params[4] = new SoapVar(
$aux['modality_impartition'],
XSD_STRING,
null,
null,
'MODALIDAD_IMPARTICION',
null
);
$obj = new stdClass(); $obj = new stdClass();
$obj->HORAS_PRESENCIAL = $aux['classroom_hours']; $obj->HORAS_PRESENCIAL = $aux['classroom_hours'];
$obj->HORAS_TELEFORMACION = $aux['distance_hours']; $obj->HORAS_TELEFORMACION = $aux['distance_hours'];
$params[5] = new SoapVar($obj, SOAP_ENC_OBJECT, NULL, null, 'DATOS_DURACION', null); $params[5] = new SoapVar(
$params[6] = new SoapVar($classroomCenterList, SOAP_ENC_OBJECT, null, null, 'CENTROS_SESIONES_PRESENCIALES', null); $obj,
$params[7] = new SoapVar($trainingTutors, SOAP_ENC_OBJECT, null, null, 'TUTORES_FORMADORES', null); SOAP_ENC_OBJECT,
null,
null,
'DATOS_DURACION',
null
);
$params[6] = new SoapVar(
$classroomCenterList,
SOAP_ENC_OBJECT,
null,
null,
'CENTROS_SESIONES_PRESENCIALES',
null
);
$params[7] = new SoapVar(
$trainingTutors,
SOAP_ENC_OBJECT,
null,
null,
'TUTORES_FORMADORES',
null
);
$obj = new stdClass(); $obj = new stdClass();
@ -873,8 +928,21 @@ class Sepe
$obj->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_EVALUACION = $aux['evaluation_activity_count']; $obj->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_EVALUACION = $aux['evaluation_activity_count'];
} }
$params[8] = new SoapVar($obj, SOAP_ENC_OBJECT, null, null, 'USO', null); $params[8] = new SoapVar(
$specialty[] = new SoapVar($params, SOAP_ENC_OBJECT, null, null, 'ESPECIALIDAD'); $obj,
SOAP_ENC_OBJECT,
null,
null,
'USO',
null
);
$specialty[] = new SoapVar(
$params,
SOAP_ENC_OBJECT,
null,
null,
'ESPECIALIDAD'
);
} }
} else { } else {
return array( return array(
@ -921,7 +989,13 @@ class Sepe
$obj->FECHA_FIN = $endDate; $obj->FECHA_FIN = $endDate;
} }
$obj = new SoapVar($obj, SOAP_ENC_OBJECT, null, null, 'TUTORIA_PRESENCIAL'); $obj = new SoapVar(
$obj,
SOAP_ENC_OBJECT,
null,
null,
'TUTORIA_PRESENCIAL'
);
$classroomTutorials->append($obj); $classroomTutorials->append($obj);
} }
@ -943,7 +1017,14 @@ class Sepe
$obj->FECHA_BAJA = $leavingDate; $obj->FECHA_BAJA = $leavingDate;
} }
$obj->TUTORIAS_PRESENCIALES = new SoapVar($classroomTutorials, SOAP_ENC_OBJECT, null, null, 'TUTORIAS_PRESENCIALES', null); $obj->TUTORIAS_PRESENCIALES = new SoapVar(
$classroomTutorials,
SOAP_ENC_OBJECT,
null,
null,
'TUTORIAS_PRESENCIALES',
null
);
$obj->EVALUACION_FINAL = new stdClass(); $obj->EVALUACION_FINAL = new stdClass();
if (!empty($tmp['center_origin']) && !empty($tmp['center_code'])) { if (!empty($tmp['center_origin']) && !empty($tmp['center_code'])) {
@ -975,7 +1056,13 @@ class Sepe
if (isset($tmp['final_score']) && $tmp['final_score'] != '') { if (isset($tmp['final_score']) && $tmp['final_score'] != '') {
$obj->RESULTADOS->PUNTUACION_FINAL = $tmp['final_score']; $obj->RESULTADOS->PUNTUACION_FINAL = $tmp['final_score'];
} }
$specialtyParticipant[] = new SoapVar($obj, SOAP_ENC_OBJECT, null, null, 'ESPECIALIDAD'); $specialtyParticipant[] = new SoapVar(
$obj,
SOAP_ENC_OBJECT,
null,
null,
'ESPECIALIDAD'
);
} }
$params = new stdClass(); $params = new stdClass();

@ -20,7 +20,6 @@ require_once api_get_path(SYS_PLUGIN_PATH).'sepe/src/wsse/soap-server-wsse.php';
$ns = api_get_path(WEB_PLUGIN_PATH)."sepe/ws/ProveedorCentroTFWS.wsdl"; $ns = api_get_path(WEB_PLUGIN_PATH)."sepe/ws/ProveedorCentroTFWS.wsdl";
$wsdl = api_get_path(SYS_PLUGIN_PATH)."sepe/ws/ProveedorCentroTFWS.wsdl"; $wsdl = api_get_path(SYS_PLUGIN_PATH)."sepe/ws/ProveedorCentroTFWS.wsdl";
$serviceUrl = api_get_path(WEB_PLUGIN_PATH).'sepe/ws/service.php'; $serviceUrl = api_get_path(WEB_PLUGIN_PATH).'sepe/ws/service.php';
class CustomServer extends Zend\Soap\Server class CustomServer extends Zend\Soap\Server
@ -113,9 +112,8 @@ if (!empty($post)) {
$WSKey = $doc->getElementsByTagName('Password')->item(0)->nodeValue; $WSKey = $doc->getElementsByTagName('Password')->item(0)->nodeValue;
$s = new WSSESoapServer($doc); $s = new WSSESoapServer($doc);
if (!empty($WSUser) && !empty($WSKey)) { if (!empty($WSUser) && !empty($WSKey)) {
if (authenticate($WSUser,$WSKey)) { if (authenticate($WSUser, $WSKey)) {
// pointing to the current file here // pointing to the current file here
$options = array( $options = array(
'soap_version' => SOAP_1_1 'soap_version' => SOAP_1_1
@ -137,8 +135,6 @@ if (!empty($post)) {
} else { } else {
error_log('not processed'); error_log('not processed');
} }
} else { } else {
$contents = file_get_contents($wsdl); $contents = file_get_contents($wsdl);
header('Content-type: application/xml'); header('Content-type: application/xml');

Loading…
Cancel
Save