aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/auth.php45
-rw-r--r--include/items.php15
2 files changed, 49 insertions, 11 deletions
diff --git a/include/auth.php b/include/auth.php
index fe09ef160..bc77e5dbc 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -132,17 +132,38 @@ else {
}
if((x($_POST,'auth-params')) && $_POST['auth-params'] === 'login') {
- // process login request
-
- $r = q("SELECT * FROM `user`
- WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
- dbesc(trim($_POST['openid_url'])),
- dbesc(trim($_POST['openid_url'])),
- dbesc($encrypted));
- if(($r === false) || (! count($r))) {
- notice( t('Login failed.') . EOL );
- goaway($a->get_baseurl());
- }
+
+ $addon_auth = array(
+ 'name' => trim($_POST['openid_url']),
+ 'password' => trim($_POST['password']),
+ 'authenticated' => 0
+ );
+
+ /**
+ *
+ * A plugin indicates successful login by setting 'authenticated' to non-zero value
+ * Plugins should never set 'authenticated' except to indicate success - as hooks may be chained
+ * and later plugins should not interfere with an earlier one that succeeded.
+ *
+ */
+
+ call_hooks('authenticate', $addon_auth);
+
+ if(! $addon_auth['authenticated']) {
+ // process login request
+
+ $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
+ AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ dbesc(trim($_POST['openid_url'])),
+ dbesc(trim($_POST['openid_url'])),
+ dbesc($encrypted)
+ );
+ if(($r === false) || (! count($r))) {
+ notice( t('Login failed.') . EOL );
+ goaway($a->get_baseurl());
+ }
+ }
+
$_SESSION['uid'] = $r[0]['uid'];
$_SESSION['theme'] = $r[0]['theme'];
$_SESSION['authenticated'] = 1;
@@ -167,6 +188,8 @@ else {
intval($_SESSION['uid'])
);
+ call_hooks('logged_in', $a->user);
+
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] .'"');
if(($a->module !== 'home') && isset($_SESSION['return_url']))
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
diff --git a/include/items.php b/include/items.php
index 75445ee49..c00ec93ae 100644
--- a/include/items.php
+++ b/include/items.php
@@ -158,7 +158,12 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
));
+ call_hooks('atom_feed', $atom);
+
if(! count($items)) {
+
+ call_hooks('atom_feed_end', $atom);
+
$atom .= '</feed>' . "\r\n";
return $atom;
}
@@ -177,7 +182,10 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
$atom .= atom_entry($item,$type,null,$owner,true);
}
+ call_hooks('atom_feed_end', $atom);
+
$atom .= '</feed>' . "\r\n";
+
return $atom;
}
@@ -491,6 +499,8 @@ function get_atom_elements($feed,$item) {
$res['target'] .= '</target>' . "\n";
}
+// call_hooks('parse_atom', array('feed' => $feed, 'item' => $item, 'result' => $res));
+
return $res;
}
@@ -1231,6 +1241,9 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) {
$o .= "<uri>$uri</uri>\r\n";
$o .= '<link rel="photo" type="image/jpeg" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
$o .= '<link rel="avatar" type="image/jpeg" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
+
+ call_hooks('atom_author', $o);
+
$o .= "</$tag>\r\n";
return $o;
}
@@ -1287,6 +1300,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
if($mentioned)
$o .= $mentioned;
+ call_hooks('atom_entry', $o);
+
$o .= '</entry>' . "\r\n";
return $o;