aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AccessList.php131
-rw-r--r--include/identity.php5
-rwxr-xr-xinclude/importdoc.php31
-rw-r--r--include/menu.php32
-rw-r--r--include/photos.php86
-rw-r--r--include/poller.php3
-rw-r--r--include/text.php56
-rw-r--r--include/widgets.php12
8 files changed, 225 insertions, 131 deletions
diff --git a/include/AccessList.php b/include/AccessList.php
new file mode 100644
index 000000000..46e66d33d
--- /dev/null
+++ b/include/AccessList.php
@@ -0,0 +1,131 @@
+<?php
+
+
+class AccessList {
+
+ private $allow_cid;
+ private $allow_gid;
+ private $deny_cid;
+ private $deny_gid;
+
+ /* indicates if we are using the default constructor values or values that have been set explicitly. */
+
+ private $explicit;
+
+ function __construct($channel) {
+
+ if($channel) {
+ $this->allow_cid = $channel['channel_allow_cid'];
+ $this->allow_gid = $channel['channel_allow_gid'];
+ $this->deny_cid = $channel['channel_deny_cid'];
+ $this->deny_gid = $channel['channel_deny_gid'];
+ }
+ else {
+ $this->allow_cid = '';
+ $this->allow_gid = '';
+ $this->deny_cid = '';
+ $this->deny_gid = '';
+ }
+
+ $this->explicit = false;
+ }
+
+ function get_explicit() {
+ return $this->explicit;
+ }
+
+ function set($arr,$explicit = true) {
+ $this->allow_cid = $arr['allow_cid'];
+ $this->allow_gid = $arr['allow_gid'];
+ $this->deny_cid = $arr['deny_cid'];
+ $this->deny_gid = $arr['deny_gid'];
+
+ $this->explicit = $explicit;
+ }
+
+ function get() {
+ return array(
+ 'allow_cid' => $this->allow_cid,
+ 'allow_gid' => $this->allow_gid,
+ 'deny_cid' => $this->deny_cid,
+ 'deny_gid' => $this->deny_gid,
+ );
+ }
+
+ function set_from_array($arr,$explicit = true) {
+ $this->allow_cid = perms2str((is_array($arr['contact_allow']))
+ ? $arr['contact_allow'] : explode(',',$arr['contact_allow']));
+ $this->allow_gid = perms2str((is_array($arr['group_allow']))
+ ? $arr['group_allow'] : explode(',',$arr['group_allow']));
+ $this->deny_cid = perms2str((is_array($arr['contact_deny']))
+ ? $arr['contact_deny'] : explode(',',$arr['contact_deny']));
+ $this->deny_gid = perms2str((is_array($arr['group_deny']))
+ ? $arr['group_deny'] : explode(',',$arr['group_deny']));
+
+ $this->explicit = $explicit;
+ }
+
+ function is_private() {
+ return (($this->allow_cid || $this->allow_gid || $this->deny_cid || $this->deny_gid) ? true : false);
+ }
+
+}
+
+/**
+ * @brief Used to wrap ACL elements in angle brackets for storage.
+ *
+ * @param[in,out] array &$item
+ */
+function sanitise_acl(&$item) {
+ if (strlen($item))
+ $item = '<' . notags(trim($item)) . '>';
+ else
+ unset($item);
+}
+
+/**
+ * @brief Convert an ACL array to a storable string.
+ *
+ * @param array $p
+ * @return array
+ */
+function perms2str($p) {
+ $ret = '';
+
+ if (is_array($p))
+ $tmp = $p;
+ else
+ $tmp = explode(',', $p);
+
+ if (is_array($tmp)) {
+ array_walk($tmp, 'sanitise_acl');
+ $ret = implode('', $tmp);
+ }
+
+ return $ret;
+}
+
+
+/**
+ * @brief Turn user/group ACLs stored as angle bracketed text into arrays.
+ *
+ * turn string array of angle-bracketed elements into string array
+ * e.g. "<123xyz><246qyo><sxo33e>" => array(123xyz,246qyo,sxo33e);
+ *
+ * @param string $s
+ * @return array
+ */
+function expand_acl($s) {
+ $ret = array();
+
+ if(strlen($s)) {
+ $t = str_replace('<','',$s);
+ $a = explode('>',$t);
+ foreach($a as $aa) {
+ if($aa)
+ $ret[] = $aa;
+ }
+ }
+
+ return $ret;
+}
diff --git a/include/identity.php b/include/identity.php
index 871d85700..d822dc69c 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -427,7 +427,7 @@ function create_identity($arr) {
}
}
- call_hooks('register_account', $newuid);
+ call_hooks('create_identity', $newuid);
proc_run('php','include/directory.php', $ret['channel']['channel_id']);
}
@@ -565,7 +565,8 @@ function identity_basic_export($channel_id, $items = false) {
if(! $items)
return $ret;
- $r = q("select likes.*, item.mid from likes left join item on likes.iid = item.id where likes.channel_id = %d",
+
+ $r = q("select * from likes where channel_id = %d",
intval($channel_id)
);
diff --git a/include/importdoc.php b/include/importdoc.php
new file mode 100755
index 000000000..9cce35c50
--- /dev/null
+++ b/include/importdoc.php
@@ -0,0 +1,31 @@
+<?php
+
+require_once('include/cli_startup.php');
+
+cli_startup();
+
+require_once('mod/help.php');
+
+function update_docs_dir($s) {
+ $f = basename($s);
+ $d = dirname($s);
+ if($s === 'doc/html')
+ return;
+
+ $files = glob("$d/$f");
+ if($files) {
+ foreach($files as $fi) {
+ if($fi === 'doc/html')
+ continue;
+ if(is_dir($fi))
+ update_docs_dir("$fi/*");
+ else
+ store_doc_file($fi);
+ }
+ }
+}
+
+update_docs_dir('doc/*');
+
+
+
diff --git a/include/menu.php b/include/menu.php
index d20df1d6e..7ed931a59 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -3,6 +3,7 @@
require_once('include/security.php');
require_once('include/bbcode.php');
+
function menu_fetch($name,$uid,$observer_xchan) {
$sql_options = permissions_sql($uid);
@@ -299,19 +300,18 @@ function menu_add_item($menu_id, $uid, $arr) {
$channel = get_app()->get_channel();
}
- $str_group_allow = perms2str($arr['group_allow']);
- $str_contact_allow = perms2str($arr['contact_allow']);
- $str_group_deny = perms2str($arr['group_deny']);
- $str_contact_deny = perms2str($arr['contact_deny']);
+ $acl = new AccessList($channel);
+ $acl->set_from_array($arr);
+ $p = $acl->get();
$r = q("insert into menu_item ( mitem_link, mitem_desc, mitem_flags, allow_cid, allow_gid, deny_cid, deny_gid, mitem_channel_id, mitem_menu_id, mitem_order ) values ( '%s', '%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d ) ",
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
- dbesc($str_contact_allow),
- dbesc($str_group_allow),
- dbesc($str_contact_deny),
- dbesc($str_group_deny),
+ dbesc($p['allow_cid']),
+ dbesc($p['allow_gid']),
+ dbesc($p['deny_cid']),
+ dbesc($p['deny_gid']),
intval($uid),
intval($menu_id),
intval($mitem_order)
@@ -341,19 +341,19 @@ function menu_edit_item($menu_id, $uid, $arr) {
$channel = get_app()->get_channel();
}
- $str_group_allow = perms2str($arr['group_allow']);
- $str_contact_allow = perms2str($arr['contact_allow']);
- $str_group_deny = perms2str($arr['group_deny']);
- $str_contact_deny = perms2str($arr['contact_deny']);
+ $acl = new AccessList($channel);
+ $acl->set_from_array($arr);
+ $p = $acl->get();
+
$r = q("update menu_item set mitem_link = '%s', mitem_desc = '%s', mitem_flags = %d, allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', mitem_order = %d where mitem_channel_id = %d and mitem_menu_id = %d and mitem_id = %d",
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
- dbesc($str_contact_allow),
- dbesc($str_group_allow),
- dbesc($str_contact_deny),
- dbesc($str_group_deny),
+ dbesc($p['allow_cid']),
+ dbesc($p['allow_gid']),
+ dbesc($p['deny_cid']),
+ dbesc($p['deny_gid']),
intval($mitem_order),
intval($uid),
intval($menu_id),
diff --git a/include/photos.php b/include/photos.php
index 04018ac0d..b4129fbf1 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -34,16 +34,6 @@ function photo_upload($channel, $observer, $args) {
*/
$album = $args['album'];
-// $newalbum = $args['newalbum'];
-
-// logger('photo_upload: album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
-
-// if(! $album) {
-// if($newalbum)
-// $album = $newalbum;
-// else
-// $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y-m');
-// }
if(intval($args['visible']) || $args['visible'] === 'true')
$visible = 1;
@@ -55,38 +45,20 @@ function photo_upload($channel, $observer, $args) {
// all other settings. 'allow_cid' being passed from an external source takes priority over channel settings.
// ...messy... needs re-factoring once the photos/files integration stabilises
- if(array_key_exists('allow_cid',$args)) {
- $str_group_allow = $args['allow_gid'];
- $str_contact_allow = $args['allow_cid'];
- $str_group_deny = $args['deny_gid'];
- $str_contact_deny = $args['deny_cid'];
- }
- else {
- $str_group_allow = $channel['channel_allow_gid'];
- $str_contact_allow = $channel['channel_allow_cid'];
- $str_group_deny = $channel['channel_deny_gid'];
- $str_contact_deny = $channel['channel_deny_cid'];
- }
-
- if($args['directory']) {
- $str_group_allow = $args['directory']['allow_gid'];
- $str_contact_allow = $args['directory']['allow_cid'];
- $str_group_deny = $args['directory']['deny_gid'];
- $str_contact_deny = $args['directory']['deny_cid'];
- }
-
+ $acl = new AccessList($channel);
+ if(array_key_exists('directory',$args) && $args['directory'])
+ $acl->set($args['directory']);
+ if(array_key_exists('allow_cid',$args))
+ $acl->set($args);
if( (array_key_exists('group_allow',$args))
|| (array_key_exists('contact_allow',$args))
|| (array_key_exists('group_deny',$args))
|| (array_key_exists('contact_deny',$args))) {
-
- $str_group_allow = perms2str(((is_array($args['group_allow'])) ? $args['group_allow'] : explode(',',$args['group_allow'])));
- $str_contact_allow = perms2str(((is_array($args['contact_allow'])) ? $args['contact_allow'] : explode(',',$args['contact_allow'])));
- $str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny'])));
- $str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny'])));
-
+ $acl->set_from_array($args);
}
+ $ac = $acl->get();
+
$os_storage = 0;
if($args['os_path'] && $args['getimagesize']) {
@@ -200,8 +172,8 @@ function photo_upload($channel, $observer, $args) {
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL,
- 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
- 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
+ 'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'],
+ 'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'],
'os_storage' => $os_storage, 'os_path' => $args['os_path']
);
if($args['created'])
@@ -320,26 +292,26 @@ function photo_upload($channel, $observer, $args) {
if($lat && $lon)
$arr['coord'] = $lat . ' ' . $lon;
- $arr['aid'] = $account_id;
- $arr['uid'] = $channel_id;
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['item_hidden'] = $item_hidden;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $photo_hash;
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $observer['xchan_hash'];
- $arr['title'] = $title;
- $arr['allow_cid'] = $str_contact_allow;
- $arr['allow_gid'] = $str_group_allow;
- $arr['deny_cid'] = $str_contact_deny;
- $arr['deny_gid'] = $str_group_deny;
- $arr['verb'] = ACTIVITY_POST;
- $arr['item_wall'] = 1;
- $arr['item_origin'] = 1;
+ $arr['aid'] = $account_id;
+ $arr['uid'] = $channel_id;
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = 'photo';
+ $arr['resource_id'] = $photo_hash;
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $observer['xchan_hash'];
+ $arr['title'] = $title;
+ $arr['allow_cid'] = $ac['allow_cid'];
+ $arr['allow_gid'] = $ac['allow_gid'];
+ $arr['deny_cid'] = $ac['deny_cid'];
+ $arr['deny_gid'] = $ac['deny_gid'];
+ $arr['verb'] = ACTIVITY_POST;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
$arr['item_thread_top'] = 1;
-
- $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
+ $arr['item_private'] = intval($acl->is_private());
+ $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
// We should also put a width_x_height on large photos. Left as an exercise for
// devs looking for simple stuff to fix.
diff --git a/include/poller.php b/include/poller.php
index f44298a9f..030394486 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -175,6 +175,9 @@ function poller_run($argv, $argc){
logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())),true));
}
+
+ proc_run('php', 'include/importdoc.php');
+
/**
* End Cron Weekly
*/
diff --git a/include/text.php b/include/text.php
index f27a9ce68..e4735ac48 100644
--- a/include/text.php
+++ b/include/text.php
@@ -458,63 +458,7 @@ function alt_pager(&$a, $i, $more = '', $less = '') {
}
-/**
- * @brief Turn user/group ACLs stored as angle bracketed text into arrays.
- *
- * turn string array of angle-bracketed elements into string array
- * e.g. "<123xyz><246qyo><sxo33e>" => array(123xyz,246qyo,sxo33e);
- *
- * @param string $s
- * @return array
- */
-function expand_acl($s) {
- $ret = array();
- if(strlen($s)) {
- $t = str_replace('<','',$s);
- $a = explode('>',$t);
- foreach($a as $aa) {
- if($aa)
- $ret[] = $aa;
- }
- }
-
- return $ret;
-}
-
-/**
- * @brief Used to wrap ACL elements in angle brackets for storage.
- *
- * @param[in,out] array &$item
- */
-function sanitise_acl(&$item) {
- if (strlen($item))
- $item = '<' . notags(trim($item)) . '>';
- else
- unset($item);
-}
-
-/**
- * @brief Convert an ACL array to a storable string.
- *
- * @param array $p
- * @return array
- */
-function perms2str($p) {
- $ret = '';
-
- if (is_array($p))
- $tmp = $p;
- else
- $tmp = explode(',', $p);
-
- if (is_array($tmp)) {
- array_walk($tmp, 'sanitise_acl');
- $ret = implode('', $tmp);
- }
-
- return $ret;
-}
/**
* @brief Generate a guaranteed unique (for this domain) item ID for ATOM.
diff --git a/include/widgets.php b/include/widgets.php
index 5e70730a3..42d9db19a 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1063,3 +1063,15 @@ function widget_tasklist($arr) {
}
+
+function widget_helpindex($arr) {
+ $o .= '<div class="widget">' . '<h3>' . t('Documentation') . '</h3>';
+ $o .= '<ul class="nav nav-pills nav-stacked">';
+ $o .= '<li><a href="help/general">' . t('Project/Site Information') . '</a></li>';
+ $o .= '<li><a href="help/members">' . t('For Members') . '</a></li>';
+ $o .= '<li><a href="help/admins">' . t('For Administrators') . '</a></li>';
+ $o .= '<li><a href="help/develop">' . t('For Developers') . '</a></li>';
+ $o .= '</ul></div>';
+ return $o;
+
+} \ No newline at end of file