Merge branch '1.10.x' into 1.10.x.doctrine

1.10.x
Julio Montoya 11 years ago
commit 10126862be
  1. 7
      certificates/index.php
  2. 19
      main/auth/sso/sso.Drupal.class.php
  3. 237
      main/course_description/course_description_controller.php
  4. 2
      main/gradebook/gradebook_display_certificate.php
  5. 9
      main/gradebook/lib/be/category.class.php
  6. 33
      main/inc/lib/hook/HookSkype.php
  7. 21
      main/inc/lib/hook/interfaces/HookSkypeEventInterface.php
  8. 20
      main/inc/lib/hook/interfaces/HookSkypeObserverInterface.php
  9. 5
      main/install/configuration.dist.php
  10. 4
      plugin/skype/README.md
  11. 9
      plugin/skype/config.php
  12. 8
      plugin/skype/index.php
  13. 10
      plugin/skype/install.php
  14. 9
      plugin/skype/lang/english.php
  15. 9
      plugin/skype/lang/spanish.php
  16. 10
      plugin/skype/plugin.php
  17. 2
      plugin/skype/readme.txt
  18. 34
      plugin/skype/src/HookSkype.php
  19. 88
      plugin/skype/src/Skype.php
  20. 10
      plugin/skype/uninstall.php

@ -13,6 +13,13 @@ $certificate = new Certificate($_GET['id']);
switch ($action) {
case 'export':
if (
api_get_configuration_value('hide_certificate_export_link') ||
(api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
) {
api_not_allowed(true);
}
$certificate->generate(array('hide_print_button' => true));
if ($certificate->html_file_is_generated()) {

@ -52,7 +52,11 @@ class ssoDrupal
*/
public function logout()
{
header('Location: '.$this->deauth_url);
if (empty($_GET['no_redirect'])) {
header('Location: '.$this->deauth_url);
} else {
header('Location: '.$this->protocol.$this->domain);
}
exit;
}
@ -64,11 +68,14 @@ class ssoDrupal
// Generate a single usage token that must be encoded by the master
$_SESSION['sso_challenge'] = api_generate_password(48);
// Redirect browser to the master URL
$params = 'sso_referer='.urlencode($this->referer).'&sso_target='.urlencode($this->target).'&sso_challenge='.urlencode($_SESSION['sso_challenge']);
if (strpos($this->master_url, "?") === false) {
$params = "?{$params}";
} else {
$params = "&{$params}";
$params = '';
if (empty($_GET['no_redirect'])) {
$params = 'sso_referer='.urlencode($this->referer).'&sso_target='.urlencode($this->target).'&sso_challenge='.urlencode($_SESSION['sso_challenge']);
if (strpos($this->master_url, "?") === false) {
$params = "?{$params}";
} else {
$params = "&{$params}";
}
}
header('Location: '.$this->master_url.$params);
exit;

@ -0,0 +1,237 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class CourseDescriptionController
* This file contains class used like controller,
* it should be included inside a dispatcher file (e.g: index.php)
* @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.course_description
*/
class CourseDescriptionController
{
private $toolname;
private $view;
/**
* Constructor
*/
public function __construct()
{
$this->toolname = 'course_description';
$this->view = new View($this->toolname);
}
/**
* It's used for listing course description,
* render to listing view
* @param boolean true for listing history (optional)
* @param array message for showing by action['edit','add','destroy'] (optional)
*/
public function listing($history=false, $messages=array())
{
$course_description = new CourseDescription();
$session_id = api_get_session_id();
$course_description->set_session_id($session_id);
$data = array();
$course_description_data = $course_description->get_description_data();
$data['descriptions'] = $course_description_data['descriptions'];
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['messages'] = $messages;
$browser = api_get_navigator();
if (!is_array($data['descriptions'])) {
$data['descriptions'] = array($data['descriptions']);
}
foreach ($data['descriptions'] as $description) {
if (strpos($description, '<iframe') !== false && $browser['name'] == 'Chrome') {
header("X-XSS-Protection: 0");
}
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('listing');
$this->view->render();
}
/**
* It's used for editing a course description,
* render to listing or edit view
* @param int description type
*/
public function edit($id, $description_type)
{
$course_description = new CourseDescription();
$session_id = api_get_session_id();
$course_description->set_session_id($session_id);
$data = array();
$data['id'] = $id;
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
$check = Security::check_token();
if ($check) {
$title = $_POST['title'];
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
$content = WCAG_Rendering::prepareXHTML();
} else {
$content = $_POST['contentDescription'];
}
$description_type = $_POST['description_type'];
$id = $_POST['id'];
$progress = $_POST['progress'];
$course_description->set_description_type($description_type);
$course_description->set_title($title);
$course_description->set_content($content);
$course_description->set_progress($progress);
$thematic_advance = $course_description->get_data_by_id($id);
if (!empty($thematic_advance)) {
$course_description->set_id($id);
$affected_rows = $course_description->update();
} else {
$affected_rows = $course_description->insert();
}
Security::clear_token();
}
if ($affected_rows) {
$message['edit'] = true;
}
$this->listing(false, $message);
} else {
$data['error'] = 1;
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['question'] = $course_description->get_default_question();
$data['information'] = $course_description->get_default_information();
$data['description_title'] = $_POST['title'];
$data['description_content'] = $_POST['contentDescription'];
$data['description_type'] = $_POST['description_type'];
$data['progress'] = $_POST['progress'];
$data['descriptions'] = $course_description->get_data_by_id($_POST['id']);
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('edit');
$this->view->render();
}
} else {
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['question'] = $course_description->get_default_question();
$data['information'] = $course_description->get_default_information();
$data['description_type'] = $description_type;
if (!empty($id)) {
if (isset($_GET['id_session'])) {
$session_id = intval($_GET['id_session']);
}
$course_description_data = $course_description->get_data_by_id($id, null, $session_id);
$data['description_type'] = $course_description_data['description_type'];
$data['description_title'] = $course_description_data['description_title'];
$data['description_content'] = $course_description_data['description_content'];
$data['progress'] = $course_description_data['progress'];
$data['descriptions'] = $course_description->get_data_by_description_type($description_type, null, $session_id);
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('edit');
$this->view->render();
}
}
/**
* It's used for adding a course description,
* render to listing or add view
*/
public function add()
{
$course_description = new CourseDescription();
$session_id = api_get_session_id();
$course_description->set_session_id($session_id);
$data = array();
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
$check = Security::check_token();
if ($check) {
$title = $_POST['title'];
if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
$content = WCAG_Rendering::prepareXHTML();
} else {
$content = $_POST['contentDescription'];
}
$description_type = $_POST['description_type'];
if ($description_type >= ADD_BLOCK) {
$course_description->set_description_type($description_type);
$course_description->set_title($title);
$course_description->set_content($content);
$affected_rows = $course_description->insert(api_get_course_int_id());
}
Security::clear_token();
}
if ($affected_rows) {
$message['add'] = true;
}
$this->listing(false,$message);
} else {
$data['error'] = 1;
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['question'] = $course_description->get_default_question();
$data['information'] = $course_description->get_default_information();
$data['description_title'] = $_POST['title'];
$data['description_content'] = $_POST['contentDescription'];
$data['description_type'] = $_POST['description_type'];
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('add');
$this->view->render();
}
} else {
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['question'] = $course_description->get_default_question();
$data['information'] = $course_description->get_default_information();
$data['description_type'] = $course_description->get_max_description_type();
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('add');
$this->view->render();
}
}
/**
* It's used for destroy a course description,
* render to listing view
* @param int description type
*/
public function destroy($id)
{
$course_description = new CourseDescription();
$session_id = api_get_session_id();
$course_description->set_session_id($session_id);
if (!empty($id)) {
$course_description->set_id($id);
$affected_rows = $course_description->delete();
}
if ($affected_rows) {
$message['destroy'] = true;
}
$this->listing(false, $message);
}
}

@ -180,7 +180,7 @@ echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn
$url = api_get_self().'?action=delete_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default'));
if (count($certificate_list) > 0) {
if (count($certificate_list) > 0 && !api_get_configuration_value('hide_certificate_export_link')) {
$url = api_get_self().'?action=export_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default'));
}

@ -1852,7 +1852,7 @@ class Category implements GradebookItem
$url,
array(
'target' => '_blank',
'class' => 'btn'
'class' => 'btn btn-default'
)
);
@ -1866,6 +1866,13 @@ class Category implements GradebookItem
"$url&action=export"
);
if (
api_get_configuration_value('hide_certificate_export_link') ||
(api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
) {
$exportToPDF = null;
}
$html = array(
'certificate_link' => $certificates,
'pdf_link' => $exportToPDF

@ -0,0 +1,33 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookEventSkype
* @var \SplObjectStorage $observers
*/
class HookEventSkype extends HookEvent implements HookSkypeEventInterface
{
/**
* Constructor
*/
protected function __construct()
{
parent::__construct('HookEventSkype');
}
/**
* Update all the observers
* @param int $type
*
* @return int
*/
public function notifySkype($type)
{
/** @var \HookSkypeObserverInterface $observer */
$this->eventData['type'] = $type;
foreach ($this->observers as $observer) {
$observer->hookEventSkype($this);
}
return 1;
}
}

@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes
* @package chamilo.library.hook
*/
/**
* Interface HookSkypeEventInterface
*/
interface HookSkypeEventInterface extends HookEventInterface
{
/**
* Update all the observers
* @param int $type
*
* @return int
*/
public function notifySkype($type);
}

@ -0,0 +1,20 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains all Hook interfaces and their relation.
* They are used for Hook classes
* @package chamilo.library.hook
*/
/**
* Interface SkypeHookInterface
*/
interface HookSkypeObserverInterface extends HookObserverInterface
{
/**
* @param HookSkypeObserverInterface $hook
*
* @return int
*/
public function hookEventSkype(HookSkypeEventInterface $hook);
}

@ -297,4 +297,7 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['limit_session_admin_role'] = false;
// Show session description
//$_configuration['show_session_description'] = false;
// Hide only for students the link to export certificates to PDF
//$_configuration['hide_certificate_export_link_students'] = false;
// Hide for all user roles the link to export certificates to PDF
//$_configuration['hide_certificate_export_link'] = false;

@ -0,0 +1,4 @@
Skype Plugin
==============
Create Skype user field

@ -0,0 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
require_once api_get_path(SYS_PATH) . 'main/inc/global.inc.php';

@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
require_once __DIR__ . '/config.php';

@ -0,0 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Initialization install
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
require_once __DIR__ . '/config.php';
Skype::create()->install();

@ -0,0 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Strings to english L10n
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
$strings['plugin_title'] = 'Skype';
$strings['plugin_comment'] = 'This plugin creates a Skype user field.';

@ -0,0 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Strings to spanish L10n
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
$strings['plugin_title'] = 'Skype';
$strings['plugin_comment'] = 'Este plugin crea un campo de usuario Skype.';

@ -0,0 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Get the plugin info
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
require_once __DIR__.'/config.php';
$plugin_info = Skype::create()->get_info();

@ -0,0 +1,2 @@
<h1>Skype Plugin</h1>
<p>Create Skype user field</p>

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Create Skype user field
*
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
class HookObserverSkype extends HookObserver implements HookSkypeObserverInterface
{
/**
* Class constructor
*/
public function __construct()
{
parent::__construct(
'plugin/skype/src/Skype.php', 'skype'
);
}
/**
* Create Skype user field when plugin is enabled
* @param HookSkypeEventInterface $hook The hook
*/
public function hookEventSkype(HookSkypeEventInterface $hook)
{
$data = $hook->getEventData();
if ($data['type'] === HOOK_EVENT_TYPE_PRE) {
// Code
}
}
}

@ -0,0 +1,88 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Create Skype user field
*
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
class Skype extends Plugin implements HookPluginInterface
{
/**
* Class constructor
*/
protected function __construct()
{
parent::__construct('0.1', 'Imanol Losada Oriol');
}
/**
* Instance the plugin
* @staticvar null $result
* @return Skype
*/
static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* Install the plugin
*/
public function install()
{
$this->installHook();
$result = Database::select(
'field_variable',
Database::get_main_table(TABLE_MAIN_USER_FIELD),
array(
'where'=> array(
'field_variable = ?' => array(
'skype'
)
)
)
);
if (empty($result)) {
$extraField = new Extrafield('user');
$extraField->save(array(
'field_variable' => 'skype',
'field_display_text' => 'Skype',
'field_visible' => 1,
'field_changeable' => 1
));
}
}
/**
* Uninstall the plugin
* @return void
*/
public function uninstall()
{
$this->uninstallHook();
}
/**
* Install the Skype hook
*/
public function installHook()
{
$hook = HookObserverSkype::create();
HookEventSkype::create()->attach($hook);
}
/**
* Uninstall the Skype hook
*/
public function uninstallHook()
{
$hook = HookObserverSkype::create();
HookEventSkype::create()->detach($hook);
}
}

@ -0,0 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Initialization uninstall
* @author Imanol Losada Oriol <imanol.losada@beeznest.com>
* @package chamilo.plugin.skype
*/
require_once __DIR__ . '/config.php';
Skype::create()->uninstall();
Loading…
Cancel
Save