diff options
-rw-r--r-- | data/templates/default/bookmarkcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | data/templates/default/bookmarks.tpl.php | 2 | ||||
-rw-r--r-- | data/templates/default/sidebar.block.menu.php | 2 | ||||
-rw-r--r-- | data/templates/default/tagcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | data/templates/minimal/bookmarkcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | data/templates/minimal/bookmarks.tpl.php | 2 | ||||
-rw-r--r-- | data/templates/minimal/sidebar.block.menu.php | 2 | ||||
-rw-r--r-- | data/templates/minimal/tagcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | data/templates/sscuttlizr/bookmarkcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | data/templates/sscuttlizr/bookmarks.tpl.php | 2 | ||||
-rw-r--r-- | data/templates/sscuttlizr/sidebar.block.menu.php | 2 | ||||
-rw-r--r-- | data/templates/sscuttlizr/tagcommondescriptionedit.tpl.php | 9 | ||||
-rw-r--r-- | src/SemanticScuttle/Model/User.php | 27 | ||||
-rw-r--r-- | src/SemanticScuttle/Service/AuthUser.php | 12 | ||||
-rw-r--r-- | src/SemanticScuttle/Service/User.php | 7 | ||||
-rw-r--r-- | www/profile.php | 5 |
16 files changed, 85 insertions, 32 deletions
diff --git a/data/templates/default/bookmarkcommondescriptionedit.tpl.php b/data/templates/default/bookmarkcommondescriptionedit.tpl.php index 807c58b..306086e 100644 --- a/data/templates/default/bookmarkcommondescriptionedit.tpl.php +++ b/data/templates/default/bookmarkcommondescriptionedit.tpl.php @@ -30,8 +30,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="'.createURL('profile', $lastUser['username']).'">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="'.createURL('profile', $lastUser['username']).'">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 2a3d169..0f88a60 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -86,7 +86,7 @@ if ($userservice->isLoggedOn()) { /* personal tag description */ if($currenttag!= '' && $user!='') { $userObject = $userservice->getUserByUsername($user); - if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?> + if($userObject && $tagservice->getDescription($currenttag, $userObject['uId'])) { ?> <p class="commondescription"><?php $pDescription = $tagservice->getDescription($currenttag, $userObject['uId']); diff --git a/data/templates/default/sidebar.block.menu.php b/data/templates/default/sidebar.block.menu.php index 94a9fa2..dfb2c25 100644 --- a/data/templates/default/sidebar.block.menu.php +++ b/data/templates/default/sidebar.block.menu.php @@ -63,7 +63,7 @@ if (sizeof($menuTags) > 0 || ($userid != 0 && $userid === $logged_on_userid)) { </table> <?php $cUser = $userservice->getUser($userid); ?> -<?php if($userid>0): ?> +<?php if($cUser && $userid>0): ?> <?php if($userid==$logged_on_userid): ?> <p style="text-align:right"><a href="<?php echo createURL('alltags', $cUser['username']); ?>" title="<?php echo T_('See all your tags')?>"><?php echo T_('all your tags'); ?></a> →</p> <?php else: ?> diff --git a/data/templates/default/tagcommondescriptionedit.tpl.php b/data/templates/default/tagcommondescriptionedit.tpl.php index 207cfd2..f52d5b0 100644 --- a/data/templates/default/tagcommondescriptionedit.tpl.php +++ b/data/templates/default/tagcommondescriptionedit.tpl.php @@ -20,8 +20,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="' . createURL('profile', $lastUser['username']) . '">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="' . createURL('profile', $lastUser['username']) . '">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/data/templates/minimal/bookmarkcommondescriptionedit.tpl.php b/data/templates/minimal/bookmarkcommondescriptionedit.tpl.php index b1114d7..4629d72 100644 --- a/data/templates/minimal/bookmarkcommondescriptionedit.tpl.php +++ b/data/templates/minimal/bookmarkcommondescriptionedit.tpl.php @@ -33,8 +33,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="'.createURL('profile', $lastUser['username']).'">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="'.createURL('profile', $lastUser['username']).'">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/data/templates/minimal/bookmarks.tpl.php b/data/templates/minimal/bookmarks.tpl.php index 1510d44..86749bc 100644 --- a/data/templates/minimal/bookmarks.tpl.php +++ b/data/templates/minimal/bookmarks.tpl.php @@ -87,7 +87,7 @@ if ($userservice->isLoggedOn()) { /* personal tag description */ if($currenttag!= '' && $user!='') { $userObject = $userservice->getUserByUsername($user); - if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?> + if($userObject && $tagservice->getDescription($currenttag, $userObject['uId'])) { ?> <p class="commondescription"><?php $pDescription = $tagservice->getDescription($currenttag, $userObject['uId']); diff --git a/data/templates/minimal/sidebar.block.menu.php b/data/templates/minimal/sidebar.block.menu.php index 94a9fa2..dfb2c25 100644 --- a/data/templates/minimal/sidebar.block.menu.php +++ b/data/templates/minimal/sidebar.block.menu.php @@ -63,7 +63,7 @@ if (sizeof($menuTags) > 0 || ($userid != 0 && $userid === $logged_on_userid)) { </table> <?php $cUser = $userservice->getUser($userid); ?> -<?php if($userid>0): ?> +<?php if($cUser && $userid>0): ?> <?php if($userid==$logged_on_userid): ?> <p style="text-align:right"><a href="<?php echo createURL('alltags', $cUser['username']); ?>" title="<?php echo T_('See all your tags')?>"><?php echo T_('all your tags'); ?></a> →</p> <?php else: ?> diff --git a/data/templates/minimal/tagcommondescriptionedit.tpl.php b/data/templates/minimal/tagcommondescriptionedit.tpl.php index e46c184..bde2ff8 100644 --- a/data/templates/minimal/tagcommondescriptionedit.tpl.php +++ b/data/templates/minimal/tagcommondescriptionedit.tpl.php @@ -24,8 +24,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="' . createURL('profile', $lastUser['username']) . '">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="' . createURL('profile', $lastUser['username']) . '">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/data/templates/sscuttlizr/bookmarkcommondescriptionedit.tpl.php b/data/templates/sscuttlizr/bookmarkcommondescriptionedit.tpl.php index b1114d7..4629d72 100644 --- a/data/templates/sscuttlizr/bookmarkcommondescriptionedit.tpl.php +++ b/data/templates/sscuttlizr/bookmarkcommondescriptionedit.tpl.php @@ -33,8 +33,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="'.createURL('profile', $lastUser['username']).'">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="'.createURL('profile', $lastUser['username']).'">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/data/templates/sscuttlizr/bookmarks.tpl.php b/data/templates/sscuttlizr/bookmarks.tpl.php index 2df30db..c87a337 100644 --- a/data/templates/sscuttlizr/bookmarks.tpl.php +++ b/data/templates/sscuttlizr/bookmarks.tpl.php @@ -87,7 +87,7 @@ if ($userservice->isLoggedOn()) { /* personal tag description */ if($currenttag!= '' && $user!='') { $userObject = $userservice->getUserByUsername($user); - if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?> + if($userObject && $tagservice->getDescription($currenttag, $userObject['uId'])) { ?> <p class="commondescription"><?php $pDescription = $tagservice->getDescription($currenttag, $userObject['uId']); diff --git a/data/templates/sscuttlizr/sidebar.block.menu.php b/data/templates/sscuttlizr/sidebar.block.menu.php index 94a9fa2..dfb2c25 100644 --- a/data/templates/sscuttlizr/sidebar.block.menu.php +++ b/data/templates/sscuttlizr/sidebar.block.menu.php @@ -63,7 +63,7 @@ if (sizeof($menuTags) > 0 || ($userid != 0 && $userid === $logged_on_userid)) { </table> <?php $cUser = $userservice->getUser($userid); ?> -<?php if($userid>0): ?> +<?php if($cUser && $userid>0): ?> <?php if($userid==$logged_on_userid): ?> <p style="text-align:right"><a href="<?php echo createURL('alltags', $cUser['username']); ?>" title="<?php echo T_('See all your tags')?>"><?php echo T_('all your tags'); ?></a> →</p> <?php else: ?> diff --git a/data/templates/sscuttlizr/tagcommondescriptionedit.tpl.php b/data/templates/sscuttlizr/tagcommondescriptionedit.tpl.php index e46c184..bde2ff8 100644 --- a/data/templates/sscuttlizr/tagcommondescriptionedit.tpl.php +++ b/data/templates/sscuttlizr/tagcommondescriptionedit.tpl.php @@ -24,8 +24,13 @@ window.onload = function() { if(strlen($description['cdDatetime'])>0) { echo T_('Last modification:').' '.$description['cdDatetime'].', '; $lastUser = $userservice->getUser($description['uId']); - echo '<a href="' . createURL('profile', $lastUser['username']) . '">' - . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + if ($lastUser) { + echo '<a href="' . createURL('profile', $lastUser['username']) . '">' + . SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>'; + } + else { + echo 'Unknown user'; + } } ?> </td> diff --git a/src/SemanticScuttle/Model/User.php b/src/SemanticScuttle/Model/User.php index 3fbbaa0..96dddbf 100644 --- a/src/SemanticScuttle/Model/User.php +++ b/src/SemanticScuttle/Model/User.php @@ -83,7 +83,9 @@ class SemanticScuttle_Model_User if (!isset($this->privateKey)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->privateKey = $user['privateKey']; + if ($user) { + $this->privateKey = $user['privateKey']; + } } //2023-12-20 add line to avoid 'Deprecated' warning if (is_null($this->privateKey)) return null; @@ -106,7 +108,12 @@ class SemanticScuttle_Model_User if (!isset($this->name)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->name = $user['name']; + if ($user) { + $this->name = $user['name']; + } + else { + $this->name = 'unknown'; + } } return $this->name; } @@ -122,7 +129,9 @@ class SemanticScuttle_Model_User if (!isset($this->email)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->email = $user['email']; + if ($user) { + $this->email = $user['email']; + } } return $this->email; } @@ -138,7 +147,9 @@ class SemanticScuttle_Model_User if(!isset($this->homepage)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->homepage = $user['homepage']; + if ($user) { + $this->homepage = $user['homepage']; + } } return $this->homepage; } @@ -154,7 +165,9 @@ class SemanticScuttle_Model_User if(!isset($this->content)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->content = $user['uContent']; + if ($user) { + $this->content = $user['uContent']; + } } return $this->content; } @@ -171,7 +184,9 @@ class SemanticScuttle_Model_User if(!isset($this->content)) { $us = SemanticScuttle_Service_Factory::get('User'); $user = $us->getUser($this->id); - $this->datetime = $user['uDatetime']; + if ($user) { + $this->datetime = $user['uDatetime']; + } } return $this->datetime; } diff --git a/src/SemanticScuttle/Service/AuthUser.php b/src/SemanticScuttle/Service/AuthUser.php index 9447ee4..f0bc908 100644 --- a/src/SemanticScuttle/Service/AuthUser.php +++ b/src/SemanticScuttle/Service/AuthUser.php @@ -168,10 +168,12 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User //user must have changed password in external auth. //we need to update the local database. $user = $this->getUserByUsername($username); - $this->_updateuser( - $user['uId'], $this->getFieldName('password'), - $this->sanitisePassword($password) - ); + if ($user) { + $this->_updateuser( + $user['uId'], $this->getFieldName('password'), + $this->sanitisePassword($password) + ); + } return parent::login($username, $password, $remember); } @@ -229,4 +231,4 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User } } -?>
\ No newline at end of file +?> diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 917c7c9..675c4fb 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -395,7 +395,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService { if (is_numeric($user)) { $user = $this->getUser($user); - $user = $user['username']; + if ($user) { + $user = $user['username']; + } + else { + $user = 'unknown'; + } } else if (is_array($user)) { $user = $user['username']; } diff --git a/www/profile.php b/www/profile.php index 6a4222e..88e58e5 100644 --- a/www/profile.php +++ b/www/profile.php @@ -130,10 +130,11 @@ if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) { } } $userinfo = $userservice->getObjectUserByUsername($user); - $tplVars['privateKey'] = $userinfo->getPrivateKey(true); - if ($userservice->isPrivateKeyValid($userinfo->getPrivateKey())) { + if ($userinfo && $userservice->isPrivateKeyValid($userinfo->getPrivateKey())) { + $tplVars['privateKey'] = $userinfo->getPrivateKey(true); $tplVars['privateKeyIsEnabled'] = 'checked="checked"'; } else { + $tplVars['privateKey'] = null; $tplVars['privateKeyIsEnabled'] = ''; } } |