commit
0d77174c6f
@ -0,0 +1,92 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Application\Migrations\Schema\V111; |
||||
|
||||
use Application\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\DBAL\Types\Type; |
||||
|
||||
/** |
||||
* Class Version20160610142700 |
||||
* Integrate the Skype plugin and create new settings current to enable it |
||||
* @package Application\Migrations\Schema\V111 |
||||
*/ |
||||
class Version20160610142700 extends AbstractMigrationChamilo |
||||
{ |
||||
/** |
||||
* @param Schema $schema |
||||
* @throws \Doctrine\DBAL\DBALException |
||||
* @throws \Doctrine\DBAL\Schema\SchemaException |
||||
*/ |
||||
public function up(Schema $schema) |
||||
{ |
||||
$dataList = $this |
||||
->connection |
||||
->executeQuery(" |
||||
SELECT id FROM extra_field |
||||
WHERE variable = 'skype' AND extra_field_type = 1 |
||||
") |
||||
->fetchAll(); |
||||
|
||||
if (empty($dataList)) { |
||||
$this->addSql(" |
||||
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) |
||||
VALUES (1, 1, 'skype', 'Skype', 1, 1, now()) |
||||
"); |
||||
} |
||||
|
||||
$this->addSql(" |
||||
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) |
||||
VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, now()) |
||||
"); |
||||
|
||||
$this->addSettingCurrent( |
||||
'allow_show_skype_account', |
||||
null, |
||||
'radio', |
||||
'Platform', |
||||
'true', |
||||
'AllowShowSkypeAccountTitle', |
||||
'AllowShowSkypeAccountComment', |
||||
null, |
||||
null, |
||||
1, |
||||
true, |
||||
false, |
||||
[ |
||||
['value' => 'false', 'text' => 'No'], |
||||
['value' => 'true', 'text' => 'Yes'] |
||||
] |
||||
); |
||||
|
||||
$this->addSettingCurrent( |
||||
'allow_show_linkedin_url', |
||||
null, |
||||
'radio', |
||||
'Platform', |
||||
'true', |
||||
'AllowShowLinkedInUrlTitle', |
||||
'AllowShowLinkedInUrlComment', |
||||
null, |
||||
null, |
||||
1, |
||||
true, |
||||
false, |
||||
[ |
||||
['value' => 'false', 'text' => 'No'], |
||||
['value' => 'true', 'text' => 'Yes'] |
||||
] |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param Schema $schema |
||||
* @throws \Doctrine\DBAL\DBALException |
||||
* @throws \Doctrine\DBAL\Schema\SchemaException |
||||
*/ |
||||
public function down(Schema $schema) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
@ -1,4 +0,0 @@ |
||||
Skype Plugin |
||||
============== |
||||
|
||||
Create Skype user field |
||||
@ -1,9 +0,0 @@ |
||||
<?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'; |
||||
@ -1,8 +0,0 @@ |
||||
<?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'; |
||||
@ -1,10 +0,0 @@ |
||||
<?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(); |
||||
@ -1,9 +0,0 @@ |
||||
<?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.'; |
||||
@ -1,9 +0,0 @@ |
||||
<?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.'; |
||||
@ -1,10 +0,0 @@ |
||||
<?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(); |
||||
@ -1,34 +0,0 @@ |
||||
<?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 |
||||
} |
||||
} |
||||
} |
||||
@ -1,91 +0,0 @@ |
||||
<?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( |
||||
'variable', |
||||
Database::get_main_table(TABLE_EXTRA_FIELD), |
||||
array( |
||||
'where'=> array( |
||||
'variable = ?' => array( |
||||
'skype' |
||||
) |
||||
) |
||||
) |
||||
); |
||||
|
||||
if (empty($result)) { |
||||
$extraField = new ExtraField('user'); |
||||
$extraField->save(array( |
||||
'field_type' => ExtraField::FIELD_TYPE_TEXT, |
||||
'variable' => 'skype', |
||||
'display_text' => 'Skype', |
||||
'visible' => 1, |
||||
'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); |
||||
} |
||||
|
||||
} |
||||
@ -1,10 +0,0 @@ |
||||
<?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…
Reference in new issue