From e97279639bc51f2c507118911d8985e5f4f02348 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 3 Nov 2007 11:04:07 +0000 Subject: [PATCH] Simple status box for the sidebar. git-svn-id: svn://svn.elgg.net/plugins@130 017ae15a-7f68-4291-a4b8-69d4775fb1eb --- status/css | 50 ++++++++++++++++++++++++++ status/js/ajax.js | 13 +++++++ status/js/ajax.js.bak | 13 +++++++ status/js/edit.js | 31 ++++++++++++++++ status/lib.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 status/css create mode 100644 status/js/ajax.js create mode 100644 status/js/ajax.js.bak create mode 100644 status/js/edit.js create mode 100644 status/lib.php diff --git a/status/css b/status/css new file mode 100644 index 0000000..75eba02 --- /dev/null +++ b/status/css @@ -0,0 +1,50 @@ +/* + CSS for the Guns widget +*/ + +#status-box { + background:#E5ECF3; + border:0px solid #1B5790; + padding:2px; + width:200px; +} + +#status-box textarea { + width:130px; +} + +#status-box h3 { + padding:3px; + font-size:12px; + margin-bottom:5px; +} + +#status-box h4 { + font-size:14px; + margin:0 0 0 4px; +} + +#status-box p { + font-size:1em; + margin:0 0 0 4px; +} + +#status-box a { + margin-left:170px; +} + +#status-box #gun-image { + background:#333; + display:block; + margin:3px; + text-align:center; + border:1px solid #000; +} + +#status-box #gun-image img { + margin:3px; + border:1px solid #000; + background:#555; + padding:1px; +} + diff --git a/status/js/ajax.js b/status/js/ajax.js new file mode 100644 index 0000000..43c075c --- /dev/null +++ b/status/js/ajax.js @@ -0,0 +1,13 @@ +Event.observe(window, 'load', init, false); + +function init(){ + $('greeting-submit').style.display = 'none'; + Event.observe('greeting-name', 'keyup', greet, false); +} + +function greet(){ + var url = 'greeting.php'; + var pars = 'greeting-name='+escape($F('greeting-name')); + var target = 'greeting'; + var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars}); +} \ No newline at end of file diff --git a/status/js/ajax.js.bak b/status/js/ajax.js.bak new file mode 100644 index 0000000..a5c92c9 --- /dev/null +++ b/status/js/ajax.js.bak @@ -0,0 +1,13 @@ +Event.observe(window, 'load', init, false); + +function init(){ + $('greeting-submit').style.display = 'none'; + Event.observe('greeting-name', 'keyup', greet, false); +} + +function greet(){ + var url = 'greeting.php'; + var pars = 'greeting-name='+escape($F('greeting-name')); + var target = 'greeting'; + var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars}); +} \ No newline at end of file diff --git a/status/js/edit.js b/status/js/edit.js new file mode 100644 index 0000000..661355d --- /dev/null +++ b/status/js/edit.js @@ -0,0 +1,31 @@ +/* ######################################################################### */ + +function crossbrowser_return_documentobject (objectid) { + + if (document.getElementById) { + return(document.getElementById(objectid)); + } else if (document.all) { + return(document.all[objectid]); + } else { + return(null); + } + +} + +/* ######################################################################### */ + +function toggleVisibility(destobjectid) { + + var obj = crossbrowser_return_documentobject(destobjectid); + + if (obj) { + if (obj.style.display != 'none') { + obj.style.display = 'none'; + } else { + obj.style.display = ''; + } + } + +} + +/* ######################################################################### */ diff --git a/status/lib.php b/status/lib.php new file mode 100644 index 0000000..7225578 --- /dev/null +++ b/status/lib.php @@ -0,0 +1,99 @@ + +**/ + +// sets up the plugin, leave blank +function status_pagesetup() { + +} + +// tells Elgg the widgets exists +function status_init() { + + global $CFG, $metatags, $template; + + // Add meta tags + $metatags .= ""; + + //include the css + $template['css'] .= file_get_contents($CFG->dirroot . "mod/status/css"); + + //set up the keyword for the pageshell + $CFG->templates->variables_substitute['statusdisplay'][]= "status_display"; + + //if a user edits their status - capture the result + if(optional_param("status:edit")) { + status_set_values(optional_param("status_desc")); + } +} + + function status_display() { + global $CFG, $page_owner; + $flag_name = "Status"; + $body = ''; + + //function to get this users values + $access = user_flag_get($flag_name, $page_owner); + + //Display the sidebar status box + $body .= "
"; + $body .= "

$flag_name: $access

"; + + //find out if the current user owns the page and is logged in + //then display the edit options + + if($page_owner == $_SESSION['userid']) { + $body .= '
'; + $body .= 'edit'; + $body .= << +
+

Update your status:

+ +END; + //if statement to populate the textarea when someone already has a status comment + if($access){ + $body .= "

"; + }else { + $body .= "

"; + } + + $body .= <<

+
+
+ +END; + $body .= '
'; + } + + $body .= ""; + return $body; +} + +function status_set_values($status_desc) { + global $page_owner; + $flag_name = "Status"; + + $status_value = $status_desc; + + //put in a check to make sure that the only person who can edit is the + //page owner (profile owner) in this case + if($page_owner == $_SESSION['userid']) { + + //set the user flag with the correct values + user_flag_set($flag_name, $status_value, $page_owner); + + } + +} + +?> \ No newline at end of file -- 2.11.4.GIT