2015-02-19 09:01:59 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
|
|
{
|
2021-02-10 16:50:20 +08:00
|
|
|
const
|
|
|
|
NAME = '',
|
|
|
|
CATEGORY = 'General',
|
|
|
|
DESCRIPTION = '';
|
|
|
|
|
2015-02-19 09:01:59 +08:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-08-31 00:04:54 +08:00
|
|
|
public function Init() : void
|
2015-02-19 09:01:59 +08:00
|
|
|
{
|
|
|
|
$this->UseLangs(true); // start use langs folder
|
|
|
|
|
|
|
|
$this->addJs('js/CustomUserSettings.js'); // add js file
|
|
|
|
|
2020-12-30 22:50:47 +08:00
|
|
|
$this->addJsonHook('JsonGetCustomUserData', 'JsonGetCustomUserData');
|
|
|
|
$this->addJsonHook('JsonSaveCustomUserData', 'JsonSaveCustomUserData');
|
2015-02-19 09:01:59 +08:00
|
|
|
|
2016-06-05 04:26:50 +08:00
|
|
|
$this->addTemplate('templates/PluginCustomSettingsTab.html');
|
2015-02-19 09:01:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2020-12-30 22:50:47 +08:00
|
|
|
public function JsonGetCustomUserData()
|
2015-02-19 09:01:59 +08:00
|
|
|
{
|
|
|
|
$aSettings = $this->getUserSettings();
|
|
|
|
|
|
|
|
$sUserFacebook = isset($aSettings['UserFacebook']) ? $aSettings['UserFacebook'] : '';
|
|
|
|
$sUserSkype = isset($aSettings['UserSkype']) ? $aSettings['UserSkype'] : '';
|
|
|
|
|
|
|
|
// or get user's data from your custom storage ( DB / LDAP / ... ).
|
|
|
|
|
|
|
|
\sleep(1);
|
2020-12-30 22:50:47 +08:00
|
|
|
return $this->jsonResponse(__FUNCTION__, array(
|
2015-02-19 09:01:59 +08:00
|
|
|
'UserFacebook' => $sUserFacebook,
|
|
|
|
'UserSkype' => $sUserSkype
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2020-12-30 22:50:47 +08:00
|
|
|
public function JsonSaveCustomUserData()
|
2015-02-19 09:01:59 +08:00
|
|
|
{
|
2020-12-30 22:50:47 +08:00
|
|
|
$sUserFacebook = $this->jsonParam('UserFacebook');
|
|
|
|
$sUserSkype = $this->jsonParam('UserSkype');
|
2015-02-19 09:01:59 +08:00
|
|
|
|
|
|
|
// or put user's data to your custom storage ( DB / LDAP / ... ).
|
|
|
|
|
|
|
|
\sleep(1);
|
2020-12-30 22:50:47 +08:00
|
|
|
return $this->jsonResponse(__FUNCTION__, $this->saveUserSettings(array(
|
2015-02-19 09:01:59 +08:00
|
|
|
'UserFacebook' => $sUserFacebook,
|
|
|
|
'UserSkype' => $sUserSkype
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|