Add Skype plugin - refs #7609
	
		
	
				
					
				
			
							parent
							
								
									bd2a20581e
								
							
						
					
					
						commit
						3744e3099d
					
				@ -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…
					
					
				
		Reference in new issue