aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2016-01-14 09:30:50 +0100
committermrjive <mrjive@mrjive.it>2016-01-14 09:30:50 +0100
commit5c937c5642e87750b55e15c9d9c1b863e5d5cfc1 (patch)
tree5ef2c09452b4d511f895d0fa3164fb614307f8c4 /mod
parent3206a46a9297dcbdc56c25512767dfb5bf66837b (diff)
parente500a08f152d641f60c7146c6a290042bdd37a73 (diff)
downloadvolse-hubzilla-5c937c5642e87750b55e15c9d9c1b863e5d5cfc1.tar.gz
volse-hubzilla-5c937c5642e87750b55e15c9d9c1b863e5d5cfc1.tar.bz2
volse-hubzilla-5c937c5642e87750b55e15c9d9c1b863e5d5cfc1.zip
Merge pull request #15 from redmatrix/master
updating from original codebase
Diffstat (limited to 'mod')
-rw-r--r--mod/admin.php44
-rw-r--r--mod/cover_photo.php391
-rw-r--r--mod/profile_photo.php4
-rw-r--r--mod/register.php64
-rw-r--r--mod/regmod.php4
-rw-r--r--mod/regver.php4
-rw-r--r--mod/share.php2
7 files changed, 491 insertions, 22 deletions
diff --git a/mod/admin.php b/mod/admin.php
index c175a4a61..2d859399b 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -1092,6 +1092,23 @@ function admin_page_plugins(&$a){
return '';
}
+ $enabled = in_array($plugin,$a->plugins);
+ $info = get_plugin_info($plugin);
+ $x = check_plugin_versions($info);
+
+ // disable plugins which are installed but incompatible versions
+
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($plugin, $a->plugins);
+ if ($idz !== false) {
+ unset($a->plugins[$idz]);
+ uninstall_plugin($plugin);
+ set_config("system","addon", implode(", ",$a->plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
if (x($_GET,"a") && $_GET['a']=="t"){
check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
@@ -1142,6 +1159,7 @@ function admin_page_plugins(&$a){
}
}
+
$t = get_markup_template('admin_plugins_details.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -1153,9 +1171,14 @@ function admin_page_plugins(&$a){
'$plugin' => $plugin,
'$status' => $status,
'$action' => $action,
- '$info' => get_plugin_info($plugin),
+ '$info' => $info,
'$str_author' => t('Author: '),
'$str_maintainer' => t('Maintainer: '),
+ '$str_minversion' => t('Minimum project version: '),
+ '$str_maxversion' => t('Maximum project version: '),
+ '$str_minphpversion' => t('Minimum PHP version: '),
+
+ '$disabled' => t('Disabled - version incompatibility'),
'$admin_form' => $admin_form,
'$function' => 'plugins',
@@ -1177,7 +1200,23 @@ function admin_page_plugins(&$a){
if (is_dir($file)){
list($tmp, $id) = array_map('trim', explode('/', $file));
$info = get_plugin_info($id);
- $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
+ $enabled = in_array($id,$a->plugins);
+ $x = check_plugin_versions($info);
+
+ // disable plugins which are installed but incompatible versions
+
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($id, $a->plugins);
+ if ($idz !== false) {
+ unset($a->plugins[$idz]);
+ uninstall_plugin($id);
+ set_config("system","addon", implode(", ",$a->plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
+ $plugins[] = array( $id, (($enabled)?"on":"off") , $info);
}
}
}
@@ -1190,6 +1229,7 @@ function admin_page_plugins(&$a){
'$baseurl' => $a->get_baseurl(true),
'$function' => 'plugins',
'$plugins' => $plugins,
+ '$disabled' => t('Disabled - version incompatibility'),
'$form_security_token' => get_form_security_token('admin_plugins'),
));
}
diff --git a/mod/cover_photo.php b/mod/cover_photo.php
new file mode 100644
index 000000000..fd7d794f5
--- /dev/null
+++ b/mod/cover_photo.php
@@ -0,0 +1,391 @@
+<?php
+
+/* @file cover_photo.php
+ @brief Module-file with functions for handling of profile-photos
+
+*/
+
+require_once('include/photo/photo_driver.php');
+require_once('include/identity.php');
+
+
+
+/* @brief Initalize the cover-photo edit view
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+function cover_photo_init(&$a) {
+
+ if(! local_channel()) {
+ return;
+ }
+
+ $channel = $a->get_channel();
+ profile_load($a,$channel['channel_address']);
+
+}
+
+/* @brief Evaluate posted values
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+function cover_photo_post(&$a) {
+
+ if(! local_channel()) {
+ return;
+ }
+
+ check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
+
+ if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
+
+ // phase 2 - we have finished cropping
+
+ if(argc() != 2) {
+ notice( t('Image uploaded but image cropping failed.') . EOL );
+ return;
+ }
+
+ $image_id = argv(1);
+
+ if(substr($image_id,-2,1) == '-') {
+ $scale = substr($image_id,-1,1);
+ $image_id = substr($image_id,0,-2);
+ }
+
+
+ $srcX = $_POST['xstart'];
+ $srcY = $_POST['ystart'];
+ $srcW = $_POST['xfinal'] - $srcX;
+ $srcH = $_POST['yfinal'] - $srcY;
+
+ $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND scale = 0 LIMIT 1",
+ dbesc($image_id),
+ intval(local_channel())
+ );
+
+ if($r) {
+
+ $base_image = $r[0];
+ $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data']));
+
+ $im = photo_factory($base_image['data'], $base_image['type']);
+ if($im->is_valid()) {
+
+ $g = q("select width, height from photo where resource_id = '%s' and uid = %d and scale = 3",
+ dbesc($image_id),
+ intval(local_channel())
+ );
+
+ // scale these numbers to the original photo instead of the scaled photo we operated on
+
+ $scaled_width = $g[0]['width'];
+ $scaled_height = $g[0]['height'];
+
+ if((! $scaled_width) || (! $scaled_height)) {
+ logger('potential divide by zero scaling cover photo');
+ return;
+ }
+
+ $orig_srcx = ( $r[0]['width'] / $scaled_width ) * $srcX;
+ $orig_srcy = ( $r[0]['height'] / $scaled_height ) * $srcY;
+ $orig_srcw = ( $srcW / $scaled_width ) * $r[0]['width'];
+ $orig_srch = ( $srcH / $scaled_height ) * $r[0]['height'];
+
+ $im->cropImageRect(1200,435,$orig_srcx, $orig_srcy, $orig_srcw, $orig_srch);
+
+ $aid = get_account_id();
+
+ $p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'],
+ 'filename' => $base_image['filename'], 'album' => t('Profile Photos'));
+
+ $p['scale'] = 7;
+ $p['photo_usage'] = PHOTO_COVER;
+
+ $r1 = $im->save($p);
+
+ $im->doScaleImage(850,310);
+ $p['scale'] = 8;
+
+ $r2 = $im->save($p);
+
+ if($r1 === false || $r2 === false) {
+ // if one failed, delete them all so we can start over.
+ notice( t('Image resize failed.') . EOL );
+ $x = q("delete from photo where resource_id = '%s' and uid = %d and scale >= 7 ",
+ dbesc($base_image['resource_id']),
+ local_channel()
+ );
+ return;
+ }
+
+ $channel = $a->get_channel();
+
+
+ }
+ else
+ notice( t('Unable to process image') . EOL);
+ }
+
+ goaway($a->get_baseurl() . '/profiles');
+ return; // NOTREACHED
+ }
+
+
+ $hash = photo_new_resource();
+ $smallest = 0;
+
+ require_once('include/attach.php');
+
+ $res = attach_store($a->get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
+
+ logger('attach_store: ' . print_r($res,true));
+
+ if($res && intval($res['data']['is_photo'])) {
+ $i = q("select * from photo where resource_id = '%s' and uid = %d and scale = 0",
+ dbesc($hash),
+ intval(local_channel())
+ );
+
+ if(! $i) {
+ notice( t('Image upload failed.') . EOL );
+ return;
+ }
+ $os_storage = false;
+
+ foreach($i as $ii) {
+ $smallest = intval($ii['scale']);
+ $os_storage = intval($ii['os_storage']);
+ $imagedata = $ii['data'];
+ $filetype = $ii['type'];
+
+ }
+ }
+
+ $imagedata = (($os_storage) ? @file_get_contents($imagedata) : $imagedata);
+ $ph = photo_factory($imagedata, $filetype);
+
+ if(! $ph->is_valid()) {
+ notice( t('Unable to process image.') . EOL );
+ return;
+ }
+
+ return cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
+
+}
+
+function send_cover_photo_activity($channel,$photo,$profile) {
+
+ // for now only create activities for the default profile
+
+ if(! intval($profile['is_default']))
+ return;
+
+ $arr = array();
+ $arr['item_thread_top'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
+ $arr['verb'] = ACTIVITY_UPDATE;
+
+ $arr['object'] = json_encode(array(
+ 'type' => $arr['obj_type'],
+ 'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'],
+ 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id'])
+ ));
+
+ if(stripos($profile['gender'],t('female')) !== false)
+ $t = t('%1$s updated her %2$s');
+ elseif(stripos($profile['gender'],t('male')) !== false)
+ $t = t('%1$s updated his %2$s');
+ else
+ $t = t('%1$s updated their %2$s');
+
+ $ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('profile photo') . '[/zrl]';
+
+ $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
+
+ $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
+
+ $acl = new AccessList($channel);
+ $x = $acl->get();
+ $arr['allow_cid'] = $x['allow_cid'];
+
+ $arr['allow_gid'] = $x['allow_gid'];
+ $arr['deny_cid'] = $x['deny_cid'];
+ $arr['deny_gid'] = $x['deny_gid'];
+
+ $arr['uid'] = $channel['channel_id'];
+ $arr['aid'] = $channel['channel_account_id'];
+
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $channel['channel_hash'];
+
+ post_activity_item($arr);
+
+
+}
+
+
+/* @brief Generate content of profile-photo view
+ *
+ * @param $a Current application
+ * @return void
+ *
+ */
+
+
+function cover_photo_content(&$a) {
+
+ if(! local_channel()) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ }
+
+ $channel = $a->get_channel();
+
+ $newuser = false;
+
+ if(argc() == 2 && argv(1) === 'new')
+ $newuser = true;
+
+ if(argv(1) === 'use') {
+ if (argc() < 3) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ };
+
+// check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
+
+ $resource_id = argv(2);
+
+ $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC",
+ intval(local_channel()),
+ dbesc($resource_id)
+ );
+ if(! $r) {
+ notice( t('Photo not available.') . EOL );
+ return;
+ }
+ $havescale = false;
+ foreach($r as $rr) {
+ if($rr['scale'] == 7)
+ $havescale = true;
+ }
+
+ $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1",
+ intval($r[0]['id']),
+ intval(local_channel())
+
+ );
+ if(! $r) {
+ notice( t('Photo not available.') . EOL );
+ return;
+ }
+
+ if(intval($r[0]['os_storage']))
+ $data = @file_get_contents($r[0]['data']);
+ else
+ $data = dbunescbin($r[0]['data']);
+
+ $ph = photo_factory($data, $r[0]['type']);
+ $smallest = 0;
+ if($ph->is_valid()) {
+ // go ahead as if we have just uploaded a new photo to crop
+ $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d and scale = 0",
+ dbesc($r[0]['resource_id']),
+ intval(local_channel())
+ );
+
+ if($i) {
+ $hash = $i[0]['resource_id'];
+ foreach($i as $ii) {
+ $smallest = intval($ii['scale']);
+ }
+ }
+ }
+
+ cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
+ }
+
+
+ if(! x($a->data,'imagecrop')) {
+
+ $tpl = get_markup_template('cover_photo.tpl');
+
+ $o .= replace_macros($tpl,array(
+ '$user' => $a->channel['channel_address'],
+ '$lbl_upfile' => t('Upload File:'),
+ '$lbl_profiles' => t('Select a profile:'),
+ '$title' => t('Upload Cover Photo'),
+ '$submit' => t('Upload'),
+ '$profiles' => $profiles,
+ '$form_security_token' => get_form_security_token("cover_photo"),
+// FIXME - yuk
+ '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . $a->get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. $a->get_baseurl() . '/photos/' . $a->channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')
+ ));
+
+ call_hooks('cover_photo_content_end', $o);
+
+ return $o;
+ }
+ else {
+ $filename = $a->data['imagecrop'] . '-3';
+ $resolution = 3;
+ $tpl = get_markup_template("cropcover.tpl");
+ $o .= replace_macros($tpl,array(
+ '$filename' => $filename,
+ '$profile' => intval($_REQUEST['profile']),
+ '$resource' => $a->data['imagecrop'] . '-3',
+ '$image_url' => $a->get_baseurl() . '/photo/' . $filename,
+ '$title' => t('Crop Image'),
+ '$desc' => t('Please adjust the image cropping for optimum viewing.'),
+ '$form_security_token' => get_form_security_token("cover_photo"),
+ '$done' => t('Done Editing')
+ ));
+ return $o;
+ }
+
+ return; // NOTREACHED
+}
+
+/* @brief Generate the UI for photo-cropping
+ *
+ * @param $a Current application
+ * @param $ph Photo-Factory
+ * @return void
+ *
+ */
+
+
+
+function cover_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
+
+ $max_length = get_config('system','max_image_length');
+ if(! $max_length)
+ $max_length = MAX_IMAGE_LENGTH;
+ if($max_length > 0)
+ $ph->scaleImage($max_length);
+
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ if($width < 300 || $height < 300) {
+ $ph->scaleImageUp(240);
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+ }
+
+
+ $a->data['imagecrop'] = $hash;
+ $a->data['imagecrop_resolution'] = $smallest;
+ $a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
+ return;
+}
+
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 2884505f0..0091d0585 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -502,8 +502,8 @@ function profile_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
$width = $ph->getWidth();
$height = $ph->getHeight();
- if($width < 300 || $height < 300) {
- $ph->scaleImageUp(200);
+ if($width < 500 || $height < 500) {
+ $ph->scaleImageUp(400);
$width = $ph->getWidth();
$height = $ph->getHeight();
}
diff --git a/mod/register.php b/mod/register.php
index 2e9967c60..853728e10 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -1,5 +1,6 @@
<?php
+require_once('include/identity.php');
function register_init(&$a) {
@@ -97,15 +98,22 @@ function register_post(&$a) {
require_once('include/security.php');
+ if($_REQUEST['name'])
+ set_aconfig($result['account']['account_id'],'register','channel_name',$_REQUEST['name']);
+ if($_REQUEST['nickname'])
+ set_aconfig($result['account']['account_id'],'register','channel_address',$_REQUEST['nickname']);
+ if($_REQUEST['permissions_role'])
+ set_aconfig($result['account']['account_id'],'register','permissions_role',$_REQUEST['permissions_role']);
+
+
$using_invites = intval(get_config('system','invitation_only'));
$num_invites = intval(get_config('system','number_invites'));
$invite_code = ((x($_POST,'invite_code')) ? notags(trim($_POST['invite_code'])) : '');
if($using_invites && $invite_code) {
q("delete * from register where hash = '%s'", dbesc($invite_code));
-// @FIXME - this total needs to be stored by account, but pconfig operates on channels
-// This also needs to be considered when using 'invites_remaining' in mod/invite.php
-// set_pconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
+ // @FIXME - this also needs to be considered when using 'invites_remaining' in mod/invite.php
+ set_aconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
}
if($policy == REGISTER_OPEN ) {
@@ -113,7 +121,7 @@ function register_post(&$a) {
$res = verify_email_address($result);
}
else {
- $res = send_verification_email($result['email'],$result['password']);
+ $res = send_register_success_email($result['email'],$result['password']);
}
if($res) {
info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ;
@@ -135,28 +143,43 @@ function register_post(&$a) {
}
authenticate_success($result['account'],true,false,true);
+
+ $new_channel = false;
+
+ if(get_config('system','auto_channel_create')) {
+ $new_channel = auto_channel_create($result['account']['account_id']);
+ if($new_channel['success']) {
+ $channel_id = $new_channel['channel']['channel_id'];
+ change_channel($channel_id);
+ $next_page = '~';
+ }
+ else
+ $new_channel = false;
+ }
+ if(! $new_channel) {
+ if(! strlen($next_page = get_config('system','workflow_register_next')))
+ $next_page = 'new_channel';
- if(! strlen($next_page = get_config('system','workflow_register_next')))
- $next_page = 'new_channel';
+ $_SESSION['workflow'] = true;
+ }
- $_SESSION['workflow'] = true;
-
goaway(z_root() . '/' . $next_page);
}
-
-
-
-
function register_content(&$a) {
$registration_is = '';
$other_sites = '';
if(get_config('system','register_policy') == REGISTER_CLOSED) {
+ if(get_config('system','directory_mode') == DIRECTORY_MODE_STANDALONE) {
+ notice( t('Registration on this site is disabled.') . EOL);
+ return;
+ }
+
require_once('mod/pubsites.php');
return pubsites_content($a);
}
@@ -200,7 +223,12 @@ function register_content(&$a) {
$password = ((x($_REQUEST,'password')) ? trim($_REQUEST['password']) : "" );
$password2 = ((x($_REQUEST,'password2')) ? trim($_REQUEST['password2']) : "" );
$invite_code = ((x($_REQUEST,'invite_code')) ? strip_tags(trim($_REQUEST['invite_code'])) : "" );
+ $name = ((x($_REQUEST,'name')) ? escape_tags(trim($_REQUEST['name'])) : "" );
+ $nickname = ((x($_REQUEST,'nickname')) ? strip_tags(trim($_REQUEST['nickname'])) : "" );
+ $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "" );
+ $auto_create = get_config('system','auto_channel_create');
+ $default_role = get_config('system','default_permissions_role');
require_once('include/bbcode.php');
@@ -214,7 +242,17 @@ function register_content(&$a) {
'$invite_desc' => t('Membership on this site is by invitation only.'),
'$label_invite' => t('Please enter your invitation code'),
'$invite_code' => $invite_code,
-
+ '$auto_create' => $auto_create,
+ '$label_name' => t('Channel Name'),
+ '$help_name' => t('Enter your name'),
+ '$label_nick' => t('Choose a short nickname'),
+ '$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
+ '$name' => $name,
+ '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
+ '$role' => array('permissions_role' , t('Channel Type'), ($privacy_role) ? $privacy_role : 'social', '<a href="help/roles" target="_blank">'.t('Read more about roles').'</a>',get_roles()),
+ '$default_role' => $default_role,
+ '$nickname' => $nickname,
+ '$submit' => t('Create'),
'$label_email' => t('Your email address'),
'$label_pass1' => t('Choose a password'),
'$label_pass2' => t('Please re-enter your password'),
diff --git a/mod/regmod.php b/mod/regmod.php
index c0a75ef48..a1d300e56 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -25,10 +25,10 @@ function regmod_content(&$a) {
$hash = argv(2);
if($cmd === 'deny') {
- if (!user_deny($hash)) killme();
+ if (! account_deny($hash)) killme();
}
if($cmd === 'allow') {
- if (!user_allow($hash)) killme();
+ if (! account_allow($hash)) killme();
}
}
diff --git a/mod/regver.php b/mod/regver.php
index c3ade2ee1..78f146ec5 100644
--- a/mod/regver.php
+++ b/mod/regver.php
@@ -13,10 +13,10 @@ function regver_content(&$a) {
$hash = argv(2);
if($cmd === 'deny') {
- if (!user_deny($hash)) killme();
+ if (! account_deny($hash)) killme();
}
if($cmd === 'allow') {
- if (!user_approve($hash)) killme();
+ if (! account_approve($hash)) killme();
}
}
diff --git a/mod/share.php b/mod/share.php
index 7ed6cf9a6..198a6b210 100644
--- a/mod/share.php
+++ b/mod/share.php
@@ -45,7 +45,7 @@ function share_init(&$a) {
$is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
if($is_photo) {
$object = json_decode($r[0]['object'],true);
- $photo_bb = $object['bbcode'];
+ $photo_bb = $object['body'];
}
if (strpos($r[0]['body'], "[/share]") !== false) {