allow moderated comments like wordpress if permissions are compatible
This commit is contained in:
@@ -2306,3 +2306,69 @@ function channel_codeallowed($channel_id) {
|
||||
|
||||
}
|
||||
|
||||
function anon_identity_init($reqvars) {
|
||||
|
||||
$x = [ 'request_vars' => $reqvars, 'xchan' => null, 'success' => 'unset' ];
|
||||
call_hooks('anon_identity_init',$x);
|
||||
if($x['success'] !== 'unset' && intval($x['success']) && $x['xchan'])
|
||||
return $x['xchan'];
|
||||
|
||||
// allow a captcha handler to over-ride
|
||||
if($x['success'] !== 'unset' && (intval($x['success']) === 0))
|
||||
return false;
|
||||
|
||||
|
||||
$anon_name = strip_tags(trim($reqvars['anonname']));
|
||||
$anon_email = strip_tags(trim($reqvars['anonmail']));
|
||||
$anon_url = strip_tags(trim($reqvars['anonurl']));
|
||||
|
||||
if(! ($anon_name && $anon_email)) {
|
||||
logger('anonymous commenter did not complete form');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(! validate_email($anon_email)) {
|
||||
logger('enonymous email not valid');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(! $anon_url)
|
||||
$anon_url = z_root();
|
||||
|
||||
$x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1",
|
||||
dbesc($anon_email),
|
||||
dbesc($anon_email)
|
||||
);
|
||||
|
||||
if(! $x) {
|
||||
xchan_store_lowlevel([
|
||||
'xchan_guid' => $anon_email,
|
||||
'xchan_hash' => $anon_email,
|
||||
'xchan_name' => $anon_name,
|
||||
'xchan_url' => $anon_url,
|
||||
'xchan_network' => 'unknown',
|
||||
'xchan_name_date' => datetime_convert()
|
||||
]);
|
||||
|
||||
$x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1",
|
||||
dbesc($anon_email),
|
||||
dbesc($anon_email)
|
||||
);
|
||||
|
||||
$photo = z_root() . '/' . get_default_profile_photo(300);
|
||||
$photos = import_xchan_photo($photo,$anon_email);
|
||||
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' ",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc($photos[3]),
|
||||
dbesc($anon_email),
|
||||
dbesc($anon_email)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return $x[0];
|
||||
|
||||
}
|
||||
@@ -533,6 +533,10 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||
}
|
||||
|
||||
elseif ($mode === 'moderate') {
|
||||
$profile_owner = local_channel();
|
||||
}
|
||||
|
||||
elseif ($mode === 'photos') {
|
||||
$profile_onwer = App::$profile['profile_uid'];
|
||||
$page_writeable = ($profile_owner == local_channel());
|
||||
@@ -577,7 +581,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
||||
|
||||
if($items) {
|
||||
|
||||
if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
|
||||
if(in_array($mode, [ 'network-new', 'search', 'community', 'moderate' ])) {
|
||||
|
||||
// "New Item View" on network page or search page results
|
||||
// - just loop through the items and format them minimally for display
|
||||
@@ -609,14 +613,14 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
||||
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
|
||||
&& ($item['id'] != $item['parent']))
|
||||
continue;
|
||||
$nickname = $item['nickname'];
|
||||
// $nickname = $item['nickname'];
|
||||
}
|
||||
else
|
||||
$nickname = App::$user['nickname'];
|
||||
// else
|
||||
// $nickname = App::$user['nickname'];
|
||||
|
||||
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
|
||||
if($item['author-link'] && (! $item['author-name']))
|
||||
$profile_name = $item['author-link'];
|
||||
// $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
|
||||
// if($item['author-link'] && (! $item['author-name']))
|
||||
// $profile_name = $item['author-link'];
|
||||
|
||||
$sp = false;
|
||||
$profile_link = best_link_url($item,$sp);
|
||||
@@ -625,7 +629,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
||||
else
|
||||
$profile_link = zid($profile_link);
|
||||
|
||||
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
|
||||
// $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
|
||||
|
||||
$profile_name = $item['author']['xchan_name'];
|
||||
$profile_link = $item['author']['xchan_url'];
|
||||
@@ -679,6 +683,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
||||
'template' => $tpl,
|
||||
'toplevel' => 'toplevel_item',
|
||||
'mode' => $mode,
|
||||
'approve' => t('Approve'),
|
||||
'delete' => t('Delete'),
|
||||
'id' => (($preview) ? 'P0' : $item['item_id']),
|
||||
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url),
|
||||
'profile_url' => $profile_link,
|
||||
|
||||
@@ -906,7 +906,7 @@ function import_author_unknown($x) {
|
||||
$photos = import_xchan_photo($x['photo']['src'],$x['url']);
|
||||
|
||||
if($photos) {
|
||||
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'unknown'",
|
||||
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' and xchan_network = 'unknown'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
|
||||
Reference in New Issue
Block a user