mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-08-19 07:10:57 +00:00
Merge pull request #30 from fabrixxm/master
viewsrc: show message source in a fancybox via ajax
This commit is contained in:
commit
64a429ed31
3 changed files with 58 additions and 1 deletions
44
rememberoid/rememberoid.php
Normal file
44
rememberoid/rememberoid.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Name: Remember OpenID Login
|
||||||
|
* Description: Autologin with last openid used
|
||||||
|
* Version: 1.0
|
||||||
|
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrixxm>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function rememberoid_install(){
|
||||||
|
register_hook('init_1','addon/rememberoid/rememberoid.php','rememberoid_init');
|
||||||
|
register_hook('logging_out','addon/rememberoid/rememberoid.php','rememberoid_logout');
|
||||||
|
register_hook('login_hook','addon/rememberoid/rememberoid.php','rememberoid_form');
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberoid_uninstall(){
|
||||||
|
unregister_hook('init_1','addon/rememberoid/rememberoid.php','rememberoid_init');
|
||||||
|
unregister_hook('logging_out','addon/rememberoid/rememberoid.php','rememberoid_logout');
|
||||||
|
unregister_hook('login_hook','addon/rememberoid/rememberoid.php','rememberoid_form');
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberoid_init(&$a) {
|
||||||
|
if (x($_COOKIE, "remember_oid") && !x($_SESSION['openid']) && !x($_SESSION,'authenticated') && !x($_POST,'auth-params') && $a->module === 'home' ){
|
||||||
|
$_POST['openid_url'] = $_COOKIE["remember_oid"];
|
||||||
|
$_POST['auth-params'] = 1;
|
||||||
|
}
|
||||||
|
if (x($_POST,'auth-params') && $_POST['openid_url'] && $_POST['openid_url']!="" && $_POST['remember_oid']){
|
||||||
|
setcookie('remember_oid', $_POST['openid_url'], time()+60*60*24*30, "/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberoid_logout(&$a) {
|
||||||
|
setcookie("rembember_oid", "", time()-3600);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberoid_form(&$a, &$o){
|
||||||
|
$tpl = get_markup_template("field_checkbox.tpl");
|
||||||
|
$html = replace_macros($tpl, array(
|
||||||
|
'$field' => array('remember_oid', t("Autologin with this OpenId"), false,''),
|
||||||
|
));
|
||||||
|
|
||||||
|
$o = preg_replace("|<div *id=[\"']login_openid[\"']>|", "<div id='login_openid'>".$html, $o);
|
||||||
|
|
||||||
|
}
|
|
@ -11,13 +11,25 @@
|
||||||
|
|
||||||
function viewsrc_install() {
|
function viewsrc_install() {
|
||||||
register_hook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
register_hook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
||||||
|
register_hook('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function viewsrc_uninstall() {
|
function viewsrc_uninstall() {
|
||||||
unregister_hook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
unregister_hook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
|
||||||
|
unregister_hook('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function viewsrc_page_end(&$a, &$o){
|
||||||
|
$a->page['htmlhead'] .= <<< EOS
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$('a[href*="/viewsrc/"]').fancybox();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
EOS;
|
||||||
|
}
|
||||||
|
|
||||||
function viewsrc_item_photo_menu(&$a,&$b) {
|
function viewsrc_item_photo_menu(&$a,&$b) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
|
|
|
@ -19,7 +19,8 @@ function widgets_uninstall() {
|
||||||
|
|
||||||
|
|
||||||
function widgets_settings_post(){
|
function widgets_settings_post(){
|
||||||
|
if(! local_user())
|
||||||
|
return;
|
||||||
if (isset($_POST['widgets-submit'])){
|
if (isset($_POST['widgets-submit'])){
|
||||||
del_pconfig(local_user(), 'widgets', 'key');
|
del_pconfig(local_user(), 'widgets', 'key');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue