aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php22
-rw-r--r--include/config.php19
-rw-r--r--include/identity.php42
-rw-r--r--include/photo/photo_driver.php3
-rw-r--r--include/photo/photo_gd.php17
-rw-r--r--include/photo/photo_imagick.php18
-rwxr-xr-xinclude/plugin.php37
-rw-r--r--include/widgets.php4
8 files changed, 150 insertions, 12 deletions
diff --git a/include/account.php b/include/account.php
index e448bdcc6..dae0f4895 100644
--- a/include/account.php
+++ b/include/account.php
@@ -11,6 +11,7 @@ require_once('include/text.php');
require_once('include/language.php');
require_once('include/datetime.php');
require_once('include/crypto.php');
+require_once('include/identity.php');
function check_account_email($email) {
@@ -329,7 +330,7 @@ function send_reg_approval_email($arr) {
return($delivered ? true : false);
}
-function send_verification_email($email,$password) {
+function send_register_success_email($email,$password) {
$email_msg = replace_macros(get_intltext_template('register_open_eml.tpl'), array(
'$sitename' => get_config('system','sitename'),
@@ -353,7 +354,7 @@ function send_verification_email($email,$password) {
* @param string $hash
* @return array|boolean
*/
-function user_allow($hash) {
+function account_allow($hash) {
$ret = array('success' => false);
@@ -406,6 +407,9 @@ function user_allow($hash) {
pop_lang();
+ if(get_config('system','auto_channel_create'))
+ auto_channel_create($register[0]['uid']);
+
if ($res) {
info( t('Account approved.') . EOL );
return true;
@@ -414,7 +418,7 @@ function user_allow($hash) {
/**
- * @brief Denies a user registration.
+ * @brief Denies an account registration.
*
* This does not have to go through user_remove() and save the nickname
* permanently against re-registration, as the person was not yet
@@ -423,7 +427,8 @@ function user_allow($hash) {
* @param string $hash
* @return boolean
*/
-function user_deny($hash) {
+
+function account_deny($hash) {
$register = q("SELECT * FROM register WHERE hash = '%s' LIMIT 1",
dbesc($hash)
@@ -452,11 +457,14 @@ function user_deny($hash) {
}
+// called from regver to activate an account from the email verification link
-function user_approve($hash) {
+function account_approve($hash) {
$ret = array('success' => false);
+ // Note: when the password in the register table is 'verify', the uid actually contains the account_id
+
$register = q("SELECT * FROM `register` WHERE `hash` = '%s' and password = 'verify' LIMIT 1",
dbesc($hash)
);
@@ -491,6 +499,10 @@ function user_approve($hash) {
intval($register[0]['uid'])
);
+
+ if(get_config('system','auto_channel_create'))
+ auto_channel_create($register[0]['uid']);
+
info( t('Account verified. Please login.') . EOL );
return true;
diff --git a/include/config.php b/include/config.php
index c94d25eb8..f65e4a470 100644
--- a/include/config.php
+++ b/include/config.php
@@ -531,3 +531,22 @@ function del_xconfig($xchan, $family, $key) {
);
return $ret;
}
+
+
+// account configuration storage is built on top of the under-utilised xconfig
+
+function load_aconfig($account_id) {
+ load_xconfig('a_' . $account_id);
+}
+
+function get_aconfig($account_id, $family, $key) {
+ return get_xconfig('a_' . $account_id, $family, $key);
+}
+
+function set_aconfig($account_id, $family, $key, $value) {
+ return set_xconfig('a_' . $account_id, $family, $key, $value);
+}
+
+function del_aconfig($account_id, $family, $key) {
+ return del_xconfig('a_' . $account_id, $family, $key);
+} \ No newline at end of file
diff --git a/include/identity.php b/include/identity.php
index cfedd243a..1d908056f 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -1695,3 +1695,45 @@ function profiles_build_sync($channel_id) {
build_sync_packet($channel_id,array('profile' => $r));
}
}
+
+
+function auto_channel_create($account_id) {
+
+ if(! $account_id)
+ return false;
+
+ $arr = array();
+ $arr['account_id'] = $account_id;
+ $arr['name'] = get_aconfig($account_id,'register','channel_name');
+ $arr['nickname'] = legal_webbie(get_aconfig($account_id,'register','channel_address'));
+ $arr['permissions_role'] = get_aconfig($account_id,'register','permissions_role');
+
+ del_aconfig($account_id,'register','channel_name');
+ del_aconfig($account_id,'register','channel_address');
+ del_aconfig($account_id,'register','permissions_role');
+
+ if((! $arr['name']) || (! $arr['nickname'])) {
+ $x = q("select * from account where account_id = %d limit 1",
+ intval($account_id)
+ );
+ if($x) {
+ if(! $arr['name'])
+ $arr['name'] = substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@'));
+ if(! $arr['nickname'])
+ $arr['nickname'] = legal_webbie(substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@')));
+ }
+ }
+ if(! $arr['permissions_role'])
+ $arr['permissions_role'] = 'social';
+
+ if(validate_channelname($arr['name']))
+ return false;
+ if($arr['nickname'] === 'sys')
+ $arr['nickname'] = $arr['nickname'] . mt_rand(1000,9999);
+
+ $arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999)));
+
+ return create_identity($arr);
+
+}
+
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 0de3b9c97..dce92d8da 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -69,6 +69,8 @@ abstract class photo_driver {
abstract function cropImage($max,$x,$y,$w,$h);
+ abstract function cropImageRect($maxx,$maxy,$x,$y,$w,$h);
+
abstract function imageString();
@@ -229,6 +231,7 @@ abstract class photo_driver {
$this->doScaleImage($dest_width,$dest_height);
}
+
public function scaleImageSquare($dim) {
if(!$this->is_valid())
return FALSE;
diff --git a/include/photo/photo_gd.php b/include/photo/photo_gd.php
index 2ac7287e4..24bdc204f 100644
--- a/include/photo/photo_gd.php
+++ b/include/photo/photo_gd.php
@@ -108,6 +108,23 @@ class photo_gd extends photo_driver {
$this->setDimensions();
}
+ public function cropImageRect($maxx,$maxy,$x,$y,$w,$h) {
+ if(!$this->is_valid())
+ return FALSE;
+
+ $dest = imagecreatetruecolor( $maxx, $maxy );
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
+ imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $maxx, $maxy, $w, $h);
+ if($this->image)
+ imagedestroy($this->image);
+ $this->image = $dest;
+ $this->setDimensions();
+ }
+
+
+
public function imageString() {
if(!$this->is_valid())
return FALSE;
diff --git a/include/photo/photo_imagick.php b/include/photo/photo_imagick.php
index 3f84fd06c..32bb61342 100644
--- a/include/photo/photo_imagick.php
+++ b/include/photo/photo_imagick.php
@@ -163,6 +163,24 @@ class photo_imagick extends photo_driver {
$this->doScaleImage($max,$max);
}
+ public function cropImageRect($maxx,$maxy,$x,$y,$w,$h) {
+ if(!$this->is_valid())
+ return FALSE;
+
+ $this->image->setFirstIterator();
+ do {
+ $this->image->cropImage($w, $h, $x, $y);
+ /**
+ * We need to remove the canvas,
+ * or the image is not resized to the crop:
+ * http://php.net/manual/en/imagick.cropimage.php#97232
+ */
+ $this->image->setImagePage(0, 0, 0, 0);
+ } while ($this->image->nextImage());
+
+ $this->doScaleImage($maxx,$maxy);
+ }
+
public function imageString() {
if(!$this->is_valid())
return FALSE;
diff --git a/include/plugin.php b/include/plugin.php
index 4da73dfd8..2bc363556 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -348,19 +348,46 @@ function get_plugin_info($plugin){
} else {
$info[$k][] = array('name' => $v);
}
- } else {
-// if (array_key_exists($k, $info)){
- $info[$k] = $v;
-// }
+ }
+ else {
+ $info[$k] = $v;
}
}
}
}
-
return $info;
}
+function check_plugin_versions($info) {
+
+ if(! is_array($info))
+ return true;
+
+ if(array_key_exists('minversion',$info)) {
+ if(version_compare(trim($info['minversion']),STD_VERSION, '>=')) {
+ logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('maxversion',$info)) {
+ if(version_compare(STD_VERSION,trim($info['maxversion']), '>')) {
+ logger('maxversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('minphpversion',$info)) {
+ if(version_compare(trim($info['minphpversion']),PHP_VERSION, '>=')) {
+ logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+
/**
* @brief Parse theme comment in search of theme infos.
diff --git a/include/widgets.php b/include/widgets.php
index a7d06d39e..033ba44fe 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -170,8 +170,8 @@ function widget_follow($args) {
}
return replace_macros(get_markup_template('follow.tpl'),array(
'$connect' => t('Add New Connection'),
- '$desc' => t('Enter the channel address'),
- '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
+ '$desc' => t('Enter channel address'),
+ '$hint' => t('Examples: bob@example.com, https://example.com/barbara'),
'$follow' => t('Connect'),
'$abook_usage_message' => $abook_usage_message
));