aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/cloud.php110
-rw-r--r--mod/editblock.php17
-rw-r--r--mod/editlayout.php17
-rw-r--r--mod/editwebpage.php15
-rw-r--r--mod/impel.php121
-rw-r--r--mod/item.php25
-rw-r--r--mod/mail.php5
-rw-r--r--mod/message.php22
-rw-r--r--mod/openid.php4
-rw-r--r--mod/photo.php8
-rw-r--r--mod/photos.php118
-rw-r--r--mod/siteinfo.php62
-rw-r--r--mod/thing.php2
13 files changed, 331 insertions, 195 deletions
diff --git a/mod/cloud.php b/mod/cloud.php
index 1765c0b69..28c59872d 100644
--- a/mod/cloud.php
+++ b/mod/cloud.php
@@ -1,31 +1,35 @@
<?php
/**
* @file mod/cloud.php
- * @brief Initialize Red Matrix's cloud (SabreDAV)
+ * @brief Initialize RedMatrix's cloud (SabreDAV).
*
+ * Module for accessing the DAV storage area.
*/
- use Sabre\DAV;
- require_once('vendor/autoload.php');
+use Sabre\DAV;
+use RedMatrix\RedDAV;
- // workaround for HTTP-auth in CGI mode
- if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
- $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ;
- if(strlen($userpass)) {
- list($name, $password) = explode(':', $userpass);
- $_SERVER['PHP_AUTH_USER'] = $name;
- $_SERVER['PHP_AUTH_PW'] = $password;
- }
- }
+// composer autoloader for SabreDAV
+require_once('vendor/autoload.php');
- if(x($_SERVER,'HTTP_AUTHORIZATION')) {
- $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ;
- if(strlen($userpass)) {
- list($name, $password) = explode(':', $userpass);
- $_SERVER['PHP_AUTH_USER'] = $name;
- $_SERVER['PHP_AUTH_PW'] = $password;
- }
+// workaround for HTTP-auth in CGI mode
+if (x($_SERVER, 'REDIRECT_REMOTE_USER')) {
+ $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ;
+ if(strlen($userpass)) {
+ list($name, $password) = explode(':', $userpass);
+ $_SERVER['PHP_AUTH_USER'] = $name;
+ $_SERVER['PHP_AUTH_PW'] = $password;
+ }
+}
+
+if (x($_SERVER, 'HTTP_AUTHORIZATION')) {
+ $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ;
+ if(strlen($userpass)) {
+ list($name, $password) = explode(':', $userpass);
+ $_SERVER['PHP_AUTH_USER'] = $name;
+ $_SERVER['PHP_AUTH_PW'] = $password;
}
+}
/**
* @brief Fires up the SabreDAV server.
@@ -33,63 +37,59 @@
* @param App &$a
*/
function cloud_init(&$a) {
-
// call ($currenttheme)_init since we're operating outside of index.php
-
- $theme_info_file = "view/theme/".current_theme()."/php/theme.php";
+ $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php";
if (file_exists($theme_info_file)){
require_once($theme_info_file);
- if(function_exists(str_replace('-','_',current_theme()) . '_init')) {
- $func = str_replace('-','_',current_theme()) . '_init';
+ if (function_exists(str_replace('-', '_', current_theme()) . '_init')) {
+ $func = str_replace('-', '_', current_theme()) . '_init';
$func($a);
}
}
require_once('include/reddav.php');
- if(! is_dir('store'))
- os_mkdir('store',STORAGE_DEFAULT_PERMISSIONS,false);
+ if (! is_dir('store'))
+ os_mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false);
$which = null;
- if(argc() > 1)
+ if (argc() > 1)
$which = argv(1);
$profile = 0;
- $channel = $a->get_channel();
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n" ;
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n";
- if($which)
+ if ($which)
profile_load($a, $which, $profile);
$auth = new RedBasicAuth();
$ob_hash = get_observer_hash();
- if($ob_hash) {
- if(local_user()) {
+ if ($ob_hash) {
+ if (local_user()) {
$channel = $a->get_channel();
$auth->setCurrentUser($channel['channel_address']);
- $auth->channel_name = $channel['channel_address'];
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
$auth->channel_account_id = $channel['channel_account_id'];
if($channel['channel_timezone'])
- $auth->timezone = $channel['channel_timezone'];
+ $auth->setTimezone($channel['channel_timezone']);
}
$auth->observer = $ob_hash;
}
- if($_GET['davguest'])
+ if ($_GET['davguest'])
$_SESSION['davguest'] = true;
- $_SERVER['QUERY_STRING'] = str_replace(array('?f=','&f='),array('',''),$_SERVER['QUERY_STRING']);
+ $_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']);
$_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']);
- $_SERVER['QUERY_STRING'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism','',$_SERVER['QUERY_STRING']);
+ $_SERVER['QUERY_STRING'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['QUERY_STRING']);
- $_SERVER['REQUEST_URI'] = str_replace(array('?f=','&f='),array('',''),$_SERVER['REQUEST_URI']);
+ $_SERVER['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
- $_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism','',$_SERVER['REQUEST_URI']);
+ $_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
$rootDirectory = new RedDirectory('/', $auth);
@@ -101,44 +101,52 @@ function cloud_init(&$a) {
$server->addPlugin($lockPlugin);
- // The next section of code allows us to bypass prompting for http-auth if a FILE is being accessed anonymously and permissions
- // allow this. This way one can create hotlinks to public media files in their cloud and anonymous viewers won't get asked to login.
- // If a DIRECTORY is accessed or there are permission issues accessing the file and we aren't previously authenticated via zot,
- // prompt for HTTP-auth. This will be the default case for mounting a DAV directory.
- // In order to avoid prompting for passwords for viewing a DIRECTORY, add the URL query parameter 'davguest=1'
+ // The next section of code allows us to bypass prompting for http-auth if a
+ // FILE is being accessed anonymously and permissions allow this. This way
+ // one can create hotlinks to public media files in their cloud and anonymous
+ // viewers won't get asked to login.
+ // If a DIRECTORY is accessed or there are permission issues accessing the
+ // file and we aren't previously authenticated via zot, prompt for HTTP-auth.
+ // This will be the default case for mounting a DAV directory.
+ // In order to avoid prompting for passwords for viewing a DIRECTORY, add
+ // the URL query parameter 'davguest=1'.
$isapublic_file = false;
$davguest = ((x($_SESSION, 'davguest')) ? true : false);
- if((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) {
+ if ((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) {
try {
$x = RedFileData('/' . $a->cmd, $auth);
if($x instanceof RedFile)
$isapublic_file = true;
}
- catch ( Exception $e ) {
+ catch (Exception $e) {
$isapublic_file = false;
}
}
- if((! $auth->observer) && (! $isapublic_file) && (! $davguest)) {
+ if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) {
try {
- $auth->Authenticate($server, t('Red Matrix - Guests: Username: {your email address}, Password: +++'));
+ $auth->Authenticate($server, t('RedMatrix - Guests: Username: {your email address}, Password: +++'));
}
- catch ( Exception $e) {
+ catch (Exception $e) {
logger('mod_cloud: auth exception' . $e->getMessage());
http_status_exit($e->getHTTPCode(), $e->getMessage());
}
}
-
+ require_once('include/RedDAV/RedBrowser.php');
// provide a directory view for the cloud in Red Matrix
- $browser = new RedBrowser($auth);
+ $browser = new RedDAV\RedBrowser($auth);
$auth->setBrowserPlugin($browser);
$server->addPlugin($browser);
+ // Experimental QuotaPlugin
+// require_once('include/RedDAV/QuotaPlugin.php');
+// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
+
// All we need to do now, is to fire up the server
$server->exec();
diff --git a/mod/editblock.php b/mod/editblock.php
index 536ddd7d2..3b6ce4bbf 100644
--- a/mod/editblock.php
+++ b/mod/editblock.php
@@ -152,6 +152,23 @@ function editblock_content(&$a) {
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
$o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />';
+
+ $x = array(
+ 'type' => 'block',
+ 'title' => $itm[0]['title'],
+ 'body' => $itm[0]['body'],
+ 'term' => $itm[0]['term'],
+ 'created' => $itm[0]['created'],
+ 'edited' => $itm[0]['edited'],
+ 'mimetype' => $itm[0]['mimetype'],
+ 'pagetitle' => $page_title,
+ 'mid' => $itm[0]['mid']
+ );
+
+ $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
+
+
+
return $o;
}
diff --git a/mod/editlayout.php b/mod/editlayout.php
index 1e8a6e990..89cae2b0c 100644
--- a/mod/editlayout.php
+++ b/mod/editlayout.php
@@ -145,6 +145,23 @@ function editlayout_content(&$a) {
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
$o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
+
+ $x = array(
+ 'type' => 'layout',
+ 'title' => $itm[0]['title'],
+ 'body' => $itm[0]['body'],
+ 'term' => $itm[0]['term'],
+ 'created' => $itm[0]['created'],
+ 'edited' => $itm[0]['edited'],
+ 'mimetype' => $itm[0]['mimetype'],
+ 'pagetitle' => $page_title,
+ 'mid' => $itm[0]['mid']
+ );
+
+ $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
+
+
+
return $o;
}
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index 9fe76ba98..41b5bb3e7 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -185,6 +185,21 @@ function editwebpage_content(&$a) {
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
$o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />';
+
+ $x = array(
+ 'type' => 'webpage',
+ 'title' => $itm[0]['title'],
+ 'body' => $itm[0]['body'],
+ 'term' => $itm[0]['term'],
+ 'created' => $itm[0]['created'],
+ 'edited' => $itm[0]['edited'],
+ 'mimetype' => $itm[0]['mimetype'],
+ 'pagetitle' => $page_title,
+ 'mid' => $itm[0]['mid']
+ );
+
+ $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
+
return $o;
}
diff --git a/mod/impel.php b/mod/impel.php
new file mode 100644
index 000000000..1c7541bef
--- /dev/null
+++ b/mod/impel.php
@@ -0,0 +1,121 @@
+<?php /** @file */
+
+// import page design element
+
+
+function impel_init(&$a) {
+
+ $ret = array('success' => false);
+
+ if(! local_user())
+ json_return_and_die($ret);
+
+ logger('impel: ' . print_r($_REQUEST,true), LOGGER_DATA);
+
+ $elm = $_REQUEST['element'];
+ $x = base64url_decode($elm);
+ if(! $x)
+ json_return_and_die($ret);
+
+ $j = json_decode($x,true);
+ if(! $j)
+ json_return_and_die($ret);
+
+
+ $channel = $a->get_channel();
+
+ $arr = array();
+
+ switch($j['type']) {
+ case 'webpage':
+ $arr['item_restrict'] = ITEM_WEBPAGE;
+ $namespace = 'WEBPAGE';
+ $installed_type = t('webpage');
+ break;
+ case 'block':
+ $arr['item_restrict'] = ITEM_BUILDBLOCK;
+ $namespace = 'BUILDBLOCK';
+ $installed_type = t('block');
+ break;
+ case 'layout':
+ $arr['item_restrict'] = ITEM_PDL;
+ $namespace = 'PDL';
+ $installed_type = t('layout');
+ break;
+ default:
+ logger('mod_impel: unrecognised element type' . print_r($j,true));
+ break;
+ }
+ $arr['uid'] = local_user();
+ $arr['aid'] = $channel['channel_account_id'];
+ $arr['title'] = $j['title'];
+ $arr['body'] = $j['body'];
+ $arr['term'] = $j['term'];
+ $arr['created'] = datetime_convert('UTC','UTC', $j['created']);
+ $arr['edited'] = datetime_convert('UTC','UTC',$j['edited']);
+ $arr['owner_xchan'] = get_observer_hash();
+ $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash());
+ $arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
+
+ if(! $j['mid'])
+ $j['mid'] = item_message_id();
+
+ $arr['mid'] = $arr['parent_mid'] = $j['mid'];
+
+
+ if($j['pagetitle']) {
+ require_once('library/urlify/URLify.php');
+ $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
+ }
+
+
+
+ // Verify ability to use html or php!!!
+
+ $execflag = false;
+
+ if($arr['mimetype'] === 'application/x-php') {
+ $z = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
+ intval(local_user())
+ );
+
+ if($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) {
+ $execflag = true;
+ }
+ }
+
+ $remote_id = 0;
+
+ $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
+ dbesc($pagetitle),
+ dbesc($namespace),
+ intval(local_user())
+ );
+ $i = q("select id from item where mid = '%s' and uid = %d limit 1",
+ dbesc($arr['mid']),
+ intval(local_user())
+ );
+ if($z && $i) {
+ $remote_id = $z[0]['id'];
+ $arr['id'] = $i[0]['id'];
+ // don't update if it has the same timestamp as the original
+ if($arr['edited'] > $i[0]['edited'])
+ $x = item_store_update($arr,$execflag);
+ }
+ else {
+ $x = item_store($arr,$execflag);
+ }
+ if($x['success'])
+ $item_id = $x['item_id'];
+
+
+ update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
+
+
+ $ret['success'] = true;
+
+ info( sprintf( t('%s element installed'), $installed_type));
+
+ json_return_and_die(true);
+
+} \ No newline at end of file
diff --git a/mod/item.php b/mod/item.php
index 7f25b35b8..2364e6abf 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -81,18 +81,22 @@ function item_post(&$a) {
$layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): '');
$plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : '');
+ // allow API to bulk load a bunch of imported items with sending out a bunch of posts.
+ $nopush = ((x($_REQUEST,'nopush')) ? intval($_REQUEST['nopush']) : 0);
+
/*
- Check service class limits
- */
+ * Check service class limits
+ */
if (local_user() && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) {
- $ret=item_check_service_class(local_user(),x($_REQUEST,'webpage'));
- if (!$ret['success']) {
- notice( t($ret['message']) . EOL) ;
- if(x($_REQUEST,'return'))
+ $ret = item_check_service_class(local_user(),x($_REQUEST,'webpage'));
+ if (!$ret['success']) {
+ notice( t($ret['message']) . EOL) ;
+ if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
killme();
+ }
}
- }
+
if($pagetitle) {
require_once('library/urlify/URLify.php');
$pagetitle = strtolower(URLify::transliterate($pagetitle));
@@ -780,7 +784,9 @@ function item_post(&$a) {
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
- proc_run('php', "include/notifier.php", 'edit_post', $post_id);
+ if(! $nopush)
+ proc_run('php', "include/notifier.php", 'edit_post', $post_id);
+
if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($a->get_baseurl() . "/" . $return_path );
@@ -866,7 +872,8 @@ function item_post(&$a) {
call_hooks('post_local_end', $datarray);
- proc_run('php', 'include/notifier.php', $notify_type, $post_id);
+ if(! $nopush)
+ proc_run('php', 'include/notifier.php', $notify_type, $post_id);
logger('post_complete');
diff --git a/mod/mail.php b/mod/mail.php
index d6d802fe7..f4897149a 100644
--- a/mod/mail.php
+++ b/mod/mail.php
@@ -72,7 +72,10 @@ function mail_post(&$a) {
if(! ($their_perms & PERMS_W_MAIL)) {
notice( t('Selected channel has private message restrictions. Send failed.'));
- return;
+ // reported issue: let's still save the message and continue. We'll just tell them
+ // that nothing useful is likely to happen. They might have spent hours on it.
+ // return;
+
}
}
diff --git a/mod/message.php b/mod/message.php
index c14bf2161..7f3b6180a 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -61,18 +61,18 @@ function message_content(&$a) {
foreach($r as $rr) {
$o .= replace_macros($tpl, array(
- '$id' => $rr['id'],
- '$from_name' => $rr['from']['xchan_name'],
- '$from_url' => chanlink_hash($rr['from_xchan']),
+ '$id' => $rr['id'],
+ '$from_name' => $rr['from']['xchan_name'],
+ '$from_url' => chanlink_hash($rr['from_xchan']),
'$from_photo' => $rr['from']['xchan_photo_s'],
- '$to_name' => $rr['to']['xchan_name'],
- '$to_url' => chanlink_hash($rr['to_xchan']),
- '$to_photo' => $rr['to']['xchan_photo_s'],
- '$subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'),
- '$delete' => t('Delete message'),
- '$body' => smilies(bbcode($rr['body'])),
- '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')),
- '$seen' => $rr['seen']
+ '$to_name' => $rr['to']['xchan_name'],
+ '$to_url' => chanlink_hash($rr['to_xchan']),
+ '$to_photo' => $rr['to']['xchan_photo_s'],
+ '$subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'),
+ '$delete' => t('Delete conversation'),
+ '$body' => smilies(bbcode($rr['body'])),
+ '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')),
+ '$seen' => $rr['seen']
));
}
$o .= alt_pager($a,count($r));
diff --git a/mod/openid.php b/mod/openid.php
index 2112e0af4..ce7fe22ba 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -127,6 +127,8 @@ function openid_content(&$a) {
elseif($photo_other)
$pphoto = $photo_other;
+ $mimetype = guess_image_type($pphoto);
+
$x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,
xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date,
xchan_name_date, xchan_flags)
@@ -135,7 +137,7 @@ function openid_content(&$a) {
dbesc(''),
dbesc(''),
dbesc(''),
- dbesc('image/jpeg'),
+ dbesc($mimetype),
dbesc($pphoto),
dbesc($addr),
dbesc($url),
diff --git a/mod/photo.php b/mod/photo.php
index 9302278b6..0329fe0a8 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -71,7 +71,7 @@ function photo_init(&$a) {
}
if(! isset($data)) {
$data = file_get_contents($default);
- $mimetype = 'image/jpeg';
+ $mimetype = 'image/png';
}
}
else {
@@ -176,15 +176,15 @@ function photo_init(&$a) {
case 4:
$data = file_get_contents(get_default_profile_photo());
- $mimetype = 'image/jpeg';
+ $mimetype = 'image/png';
break;
case 5:
$data = file_get_contents(get_default_profile_photo(80));
- $mimetype = 'image/jpeg';
+ $mimetype = 'image/png';
break;
case 6:
$data = file_get_contents(get_default_profile_photo(48));
- $mimetype = 'image/jpeg';
+ $mimetype = 'image/png';
break;
default:
killme();
diff --git a/mod/photos.php b/mod/photos.php
index 0ff0e29c9..dc593f22b 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -653,11 +653,8 @@ function photos_content(&$a) {
intval($a->pager['itemspage'])
);
- $o .= '<div class="section-title-wrapper">';
- $o .= '<h2>' . $album . '</h2>';
- $o .= '<div class="section-title-submenu">';
if($cmd === 'edit') {
- if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
+ if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) {
if($a->get_template_engine() === 'internal') {
$album_e = template_escape($album);
@@ -679,35 +676,21 @@ function photos_content(&$a) {
}
}
else {
- if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
+ if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) {
- $o .= '<a href="'. $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '/edit' . '">' . t('Edit Album') . '</a>';
+ $edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '/edit');
}
}
}
if($_GET['order'] === 'posted')
- $o .= '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '" >' . t('Show Newest First') . '</a>';
+ $order = array(t('Show Newest First'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album));
else
- $o .= '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted" >' . t('Show Oldest First') . '</a>';
+ $order = array(t('Show Oldest First'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted');
- /*
- if($can_post) {
- $o .= '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album) . '" >' . t('Upload New Photos') . '</<a>';
- }
- */
-
- $o .= '</div>'; // section-title-submenu
- $o .= '</div>'; // section-title-wrapper
-
- $ajaxout = '';
-
- $tpl = get_markup_template('photo_album.tpl');
+ $photos = array();
if(count($r)) {
$twist = 'rotright';
- $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
- $o .= '<div id="photo-album-contents">';
-
foreach($r as $rr) {
if($twist == 'rotright')
@@ -720,57 +703,58 @@ function photos_content(&$a) {
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
-
-// prettyphoto has potential license issues, so we can no longer include it in core
-// The following lines would need to be modified so that they are provided in theme specific files
-// instead of core modules for themes that wish to make use of prettyphoto. I would suggest
-// the feature as a per-theme display option and putting the rel line inside a template.
-
-// if(feature_enabled($a->data['channel']['channel_id'],'prettyphoto')){
-// $imagelink = ($a->get_baseurl() . '/photo/' . $rr['resource_id'] . '.' . $ext );
-// $rel=("prettyPhoto[pp_gal]");
-// }
-// else {
- $imagelink = ($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id']
- . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
- $rel=("photo");
-// }
-
-
- $tmp = replace_macros($tpl,array(
- '$id' => $rr['id'],
- '$twist' => ' ' . $twist . rand(2,4),
- '$photolink' => $imagelink,
- '$rel' => $rel,
- '$phototitle' => t('View Photo'),
- '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
- '$imgalt' => $imgalt_e,
- '$desc'=> $desc_e,
- '$ext' => $ext,
- '$hash'=> $rr['resource_id'],
- ));
- if($_REQUEST['aj'])
- $ajaxout .= $tmp;
- else
- $o .= $tmp;
+ $imagelink = ($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
+
+ $rel=("photo");
+
+ $photos[] = array(
+ 'id' => $rr['id'],
+ 'twist' => ' ' . $twist . rand(2,4),
+ 'link' => $imagelink,
+ 'rel' => $rel,
+ 'title' => t('View Photo'),
+ 'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
+ 'alt' => $imgalt_e,
+ 'desc'=> $desc_e,
+ 'ext' => $ext,
+ 'hash'=> $rr['resource_id'],
+ );
}
}
+
if($_REQUEST['aj']) {
- if(! $r) {
- $ajaxout .= '<div id="content-complete"></div>';
- echo $ajaxout;
- killme();
+ if($photos) {
+ $o = replace_macros(get_markup_template('photosajax.tpl'),array(
+ '$photos' => $photos,
+ ));
+ }
+ else {
+ $o = '<div id="content-complete"></div>';
}
- echo $ajaxout;
- echo '<script>justifyPhotosAjax();</script>';
+ echo $o;
+ killme();
+ }
+ else {
+ $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
+ $tpl = get_markup_template('photo_album.tpl');
+ $o .= replace_macros($tpl, array(
+ '$photos' => $photos,
+ '$album' => $album,
+ '$can_post' => $can_post,
+ '$upload' => array(t('Upload'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
+ '$order' => $order,
+ '$edit' => $edit
+ ));
+
+ }
+
+ if((! $photos) && ($_REQUEST['aj'])) {
+ $o .= '<div id="content-complete"></div>';
+ echo $o;
killme();
}
- $o .= '<div id="page-end"></div>';
- $o .= '</div>'; // photo-album-contents
- $o .= '<div id="photo-album-end"></div>';
- $o .= '<script>$(document).ready(function() { loadingPage = false; justifyPhotos(); });</script>';
- $o .= '<div id="page-spinner"></div>';
// $o .= paginate($a);
return $o;
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index bdae14edb..de55c69cf 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -4,7 +4,8 @@ function siteinfo_init(&$a) {
if ($a->argv[1]=="json"){
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
-
+ $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_SECONDARY','DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_STANDALONE');
+
$sql_extra = '';
$r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 ) and account_default_channel = channel_id");
@@ -49,57 +50,20 @@ function siteinfo_init(&$a) {
$site_info = get_config('system','info');
$site_name = get_config('system','sitename');
- // Statistics (from statistics.json plugin)
+ //Statistics
+ $channels_total_stat = intval(get_config('system','channels_total_stat'));
+ $channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat'));
+ $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat'));
+ $local_posts_stat = intval(get_config('system','local_posts_stat'));
- $r = q("select count(channel_id) as channels_total from channel left join account on account_id = channel_account_id
- where account_flags = 0 ");
- if($r)
- $channels_total = $r[0]['channels_total'];
-
- $r = q("select channel_id from channel left join account on account_id = channel_account_id
- where account_flags = 0 and account_lastlog > UTC_TIMESTAMP - INTERVAL 6 MONTH");
- if($r) {
- $s = '';
- foreach($r as $rr) {
- if($s)
- $s .= ',';
- $s .= intval($rr['channel_id']);
- }
- $x = q("select uid from item where uid in ( $s ) and (item_flags & %d) and created > UTC_TIMESTAMP - INTERVAL 6 MONTH group by uid",
- intval(ITEM_WALL)
- );
- if($x)
- $channels_active_halfyear = count($x);
- }
-
- $r = q("select channel_id from channel left join account on account_id = channel_account_id
- where account_flags = 0 and account_lastlog > UTC_TIMESTAMP - INTERVAL 1 MONTH");
- if($r) {
- $s = '';
- foreach($r as $rr) {
- if($s)
- $s .= ',';
- $s .= intval($rr['channel_id']);
- }
- $x = q("select uid from item where uid in ( $s ) and ( item_flags & %d ) and created > UTC_TIMESTAMP - INTERVAL 1 MONTH group by uid",
- intval(ITEM_WALL)
- );
- if($x)
- $channels_active_monthly = count($x);
- }
-
- $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE (item_flags & %d) ",
- intval(ITEM_WALL)
- );
- if (is_array($posts))
- $local_posts = $posts[0]["local_posts"];
-
$data = Array(
'version' => RED_VERSION,
'commit' => $commit,
'url' => z_root(),
'plugins' => $visible_plugins,
'register_policy' => $register_policy[$a->config['system']['register_policy']],
+ 'directory_mode' => $directory_mode[$a->config['system']['directory_mode']],
+ 'language' => get_config('system','language'),
'diaspora_emulation' => get_config('system','diaspora_enabled'),
'rss_connections' => get_config('system','feed_contacts'),
'default_service_restrictions' => $service_class,
@@ -107,10 +71,10 @@ function siteinfo_init(&$a) {
'site_name' => (($site_name) ? $site_name : ''),
'platform' => RED_PLATFORM,
'info' => (($site_info) ? $site_info : ''),
- 'channels_total' => $channels_total,
- 'channels_active_halfyear' => $channels_active_halfyear,
- 'channels_active_monthly' => $channels_active_monthly,
- 'local_posts' => $local_posts
+ 'channels_total' => $channels_total_stat,
+ 'channels_active_halfyear' => $channels_active_halfyear_stat,
+ 'channels_active_monthly' => $channels_active_monthly_stat,
+ 'local_posts' => $local_posts_stat
);
json_return_and_die($data);
}
diff --git a/mod/thing.php b/mod/thing.php
index 73722c5fa..c12976f22 100644
--- a/mod/thing.php
+++ b/mod/thing.php
@@ -67,8 +67,6 @@ function thing_init(&$a) {
-
-
if($term_hash) {
$t = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1",
intval(TERM_OBJ_THING),