aboutsummaryrefslogtreecommitdiffstats
path: root/addon/statusnet
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-06-19 15:54:55 -0700
committerFriendika <info@friendika.com>2011-06-19 15:54:55 -0700
commit7c28e5893228320a2180a58aa68d913744d17e05 (patch)
tree5a8ca8b637ad654cae2d9b930e6730ef4ee3ff6f /addon/statusnet
parentfba2056b1ffb77c087feb05035f68736539e20ad (diff)
parent001982cac0c343f6405fa4191292e3f8efbd4df3 (diff)
downloadvolse-hubzilla-7c28e5893228320a2180a58aa68d913744d17e05.tar.gz
volse-hubzilla-7c28e5893228320a2180a58aa68d913744d17e05.tar.bz2
volse-hubzilla-7c28e5893228320a2180a58aa68d913744d17e05.zip
Merge pull request #121 from fabrixxm/admin
Admin update
Diffstat (limited to 'addon/statusnet')
-rw-r--r--addon/statusnet/admin.tpl16
-rw-r--r--addon/statusnet/statusnet.php64
2 files changed, 79 insertions, 1 deletions
diff --git a/addon/statusnet/admin.tpl b/addon/statusnet/admin.tpl
new file mode 100644
index 000000000..b40adf35a
--- /dev/null
+++ b/addon/statusnet/admin.tpl
@@ -0,0 +1,16 @@
+{{ for $sites as $s }}
+ {{ inc field_input.tpl with $field=$s.sitename }}{{ endinc }}
+ {{ inc field_input.tpl with $field=$s.apiurl }}{{ endinc }}
+ {{ inc field_input.tpl with $field=$s.secret }}{{ endinc }}
+ {{ inc field_input.tpl with $field=$s.key }}{{ endinc }}
+ {{ if $s.delete }}
+ {{ inc field_checkbox.tpl with $field=$s.delete }}{{ endinc }}
+ <hr>
+ {{ else }}
+ <p>Fill this form to add a new site</p>
+ {{ endif }}
+
+{{ endfor }}
+
+
+<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php
index e24ebc1ee..cb0f87764 100644
--- a/addon/statusnet/statusnet.php
+++ b/addon/statusnet/statusnet.php
@@ -59,7 +59,6 @@ function statusnet_install() {
register_hook('plugin_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
register_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
-
logger("installed statusnet");
}
@@ -350,3 +349,66 @@ function statusnet_post_hook(&$a,&$b) {
}
}
+function statusnet_plugin_admin_post(&$a){
+
+ $sites = array();
+
+ foreach($_POST['sitename'] as $id=>$sitename){
+ $sitename=trim($sitename);
+ $apiurl=trim($_POST['apiurl'][$id]);
+ $secret=trim($_POST['secret'][$id]);
+ $key=trim($_POST['key'][$id]);
+ if ($sitename!="" &&
+ $apiurl!="" &&
+ $secret!="" &&
+ $key!="" &&
+ !x($_POST['delete'][$id])){
+
+ $sites[] = Array(
+ 'sitename' => $sitename,
+ 'apiurl' => $apiurl,
+ 'secret' => $secret,
+ 'key' => $key
+ );
+ }
+ }
+
+ $sites = set_config('statusnet','sites', $sites);
+
+}
+
+function statusnet_plugin_admin(&$a, &$o){
+
+ $sites = get_config('statusnet','sites');
+ $sitesform=array();
+ if (is_array($sites)){
+ foreach($sites as $id=>$s){
+ $sitesform[] = Array(
+ 'sitename' => Array("sitename[$id]", "Site name", $s['sitename'], ""),
+ 'apiurl' => Array("apiurl[$id]", "Api url", $s['apiurl'], ""),
+ 'secret' => Array("secret[$id]", "Secret", $s['secret'], ""),
+ 'key' => Array("key[$id]", "Key", $s['key'], ""),
+ 'delete' => Array("delete[$id]", "Delete", False , "Check to delete this preset"),
+ );
+ }
+ }
+ /* empty form to add new site */
+ $id++;
+ $sitesform[] = Array(
+ 'sitename' => Array("sitename[$id]", "Site name", "", ""),
+ 'apiurl' => Array("apiurl[$id]", "Api url", "", ""),
+ 'secret' => Array("secret[$id]", "Secret", "", ""),
+ 'key' => Array("key[$id]", "Key", "", ""),
+ );
+
+
+ $t = file_get_contents( dirname(__file__). "/admin.tpl" );
+ $o = replace_macros($t, array(
+ '$submit' => t('Submit'),
+
+ '$sites' => $sitesform,
+
+ ));
+
+
+}