Merge pull request #655 from ilosada/7609

C#7609 - Add Skype plugin
1.10.x
Julio 10 years ago
commit e5a3454be7
  1. 33
      main/inc/lib/hook/HookSkype.php
  2. 21
      main/inc/lib/hook/interfaces/HookSkypeEventInterface.php
  3. 20
      main/inc/lib/hook/interfaces/HookSkypeObserverInterface.php
  4. 4
      plugin/skype/README.md
  5. 9
      plugin/skype/config.php
  6. 8
      plugin/skype/index.php
  7. 10
      plugin/skype/install.php
  8. 9
      plugin/skype/lang/english.php
  9. 9
      plugin/skype/lang/spanish.php
  10. 10
      plugin/skype/plugin.php
  11. 2
      plugin/skype/readme.txt
  12. 34
      plugin/skype/src/HookSkype.php
  13. 88
      plugin/skype/src/Skype.php
  14. 10
      plugin/skype/uninstall.php

@ -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);
}

@ -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