Przeglądaj źródła

Ticket #4652 - 'Last Seen' status/field in profile info block.

AntonLV 2 lat temu
rodzic
commit
77bcd937e4

+ 1 - 1
install/sql/system.sql

@@ -1318,12 +1318,12 @@ CREATE TABLE `sys_accounts` (
   `added` int(11) NOT NULL DEFAULT '0',
   `changed` int(11) NOT NULL DEFAULT '0',
   `logged` int(11) NOT NULL DEFAULT '0',
+  `active` int(11) NOT NULL DEFAULT '0',
   `ip` varchar(40) NOT NULL DEFAULT '',
   `referred` varchar(255) NOT NULL DEFAULT '',
   `login_attempts` tinyint(4) NOT NULL DEFAULT '0',
   `locked` tinyint(4) NOT NULL DEFAULT '0',
   `password_expired` int(11) NOT NULL DEFAULT '0',
-  `active` int(11) NOT NULL DEFAULT '0',    
   PRIMARY KEY (`id`),
   UNIQUE KEY `email` (`email`(191)),
   KEY `added` (`added`),

+ 2 - 2
modules/base/profile/classes/BxBaseModProfileDb.php

@@ -21,7 +21,7 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
 
     public function getContentInfoById ($iContentId)
     {
-        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`logged` AS `profile_logged`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `c`.`id` = ?", $this->_oConfig->getName(), $iContentId);
+        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `c`.`id` = ?", $this->_oConfig->getName(), $iContentId);
         $aInfo = $this->getRow($sQuery);
         bx_alert('profile', 'content_info_by_id', $iContentId, 0, array('module' => $this->_oConfig->getName(), 'info' => &$aInfo));
         return $aInfo;
@@ -29,7 +29,7 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
 
     public function getContentInfoByProfileId ($iProfileId)
     {
-        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`logged` AS `profile_logged`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `p`.`id` = ?", $this->_oConfig->getName(), $iProfileId);
+        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `p`.`id` = ?", $this->_oConfig->getName(), $iProfileId);
         $aInfo = $this->getRow($sQuery);
         bx_alert('profile', 'content_info_by_profile_id', $iProfileId, 0, array('module' => $this->_oConfig->getName(), 'info' => &$aInfo));
         return $aInfo;

+ 7 - 2
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -210,9 +210,14 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
         ));
     }
 
-    protected function genCustomViewRowValueProfileLogged($aInput)
+    protected function genCustomViewRowValueProfileLastActive($aInput)
     {
-        return !empty($aInput['value']) ? bx_time_js($aInput['value']) : '';
+        $iLastActiveSession = 0;
+        if(!empty($this->_iContentId) && ($oProfile = BxDolProfile::getInstanceByContentAndType($this->_iContentId, $this->MODULE)) !== false)
+            $iLastActiveSession = (new BxDolSessionQuery())->getLastActivityAccount($oProfile->getAccountId());
+
+        $iLastActive = max($iLastActiveSession, (int)$aInput['value']);
+        return !empty($iLastActive) ? bx_time_js($iLastActive) : '';
     }
 
     protected function _associalFileWithContent($oStorage, $iFileId, $iProfileId, $iContentId, $sPictureField = '')

+ 2 - 2
modules/boonex/organizations/install/langs/en.xml

@@ -80,8 +80,8 @@
     <string name="_bx_orgs_form_profile_input_profile_status"><![CDATA[Status]]></string>
     <string name="_bx_orgs_form_profile_input_sys_profile_ip"><![CDATA[IP]]></string>
     <string name="_bx_orgs_form_profile_input_profile_ip"><![CDATA[IP]]></string>
-    <string name="_bx_orgs_form_profile_input_sys_profile_logged"><![CDATA[Last Seen]]></string>
-    <string name="_bx_orgs_form_profile_input_profile_logged"><![CDATA[Last Seen]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_profile_last_active"><![CDATA[Last Seen]]></string>
+    <string name="_bx_orgs_form_profile_input_profile_last_active"><![CDATA[Last Seen]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_added"><![CDATA[Added]]></string>
     <string name="_bx_orgs_form_profile_input_date_added"><![CDATA[Added]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_changed"><![CDATA[Updated]]></string>

+ 3 - 3
modules/boonex/organizations/install/sql/install.sql

@@ -348,7 +348,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_organization', 'bx_organizations', 'profile_email', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_profile_email', '_bx_orgs_form_profile_input_profile_email', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_organization', 'bx_organizations', 'profile_status', '', '', 0, 'custom', '_bx_orgs_form_profile_input_sys_profile_status', '_bx_orgs_form_profile_input_profile_status', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_organization', 'bx_organizations', 'profile_ip', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_profile_ip', '_bx_orgs_form_profile_input_profile_ip', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
-('bx_organization', 'bx_organizations', 'profile_logged', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_profile_logged', '_bx_orgs_form_profile_input_profile_logged', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
+('bx_organization', 'bx_organizations', 'profile_last_active', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_profile_last_active', '_bx_orgs_form_profile_input_profile_last_active', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_organization', 'bx_organizations', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_organization', 'bx_organizations', 'added', '', '', 0, 'datetime', '_bx_orgs_form_profile_input_sys_date_added', '_bx_orgs_form_profile_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_organization', 'bx_organizations', 'changed', '', '', 0, 'datetime', '_bx_orgs_form_profile_input_sys_date_changed', '_bx_orgs_form_profile_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
@@ -393,7 +393,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_organization_view', 'profile_email', 192, 1, 3),
 ('bx_organization_view', 'profile_status', 192, 1, 4),
 ('bx_organization_view', 'profile_ip', 192, 1, 5),
-('bx_organization_view', 'profile_logged', 192, 1, 6),
+('bx_organization_view', 'profile_last_active', 192, 1, 6),
 ('bx_organization_view', 'added', 192, 1, 7),
 ('bx_organization_view', 'changed', 192, 1, 8),
 ('bx_organization_view', 'friends_count', 2147483647, 1, 9),
@@ -404,7 +404,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_organization_view_full', 'org_desc', 2147483647, 0, 3),
 ('bx_organization_view_full', 'profile_email', 192, 1, 4),
 ('bx_organization_view_full', 'profile_status', 192, 1, 5),
-('bx_organization_view_full', 'profile_logged', 192, 1, 6);
+('bx_organization_view_full', 'profile_last_active', 192, 1, 6);
 
 -- FORMS: Price
 INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES

+ 2 - 2
modules/boonex/persons/install/langs/en.xml

@@ -68,8 +68,8 @@
     <string name="_bx_persons_form_profile_input_profile_status"><![CDATA[Status]]></string>
     <string name="_bx_persons_form_profile_input_sys_profile_ip"><![CDATA[IP]]></string>
     <string name="_bx_persons_form_profile_input_profile_ip"><![CDATA[IP]]></string>
-    <string name="_bx_persons_form_profile_input_sys_profile_logged"><![CDATA[Last Seen]]></string>
-    <string name="_bx_persons_form_profile_input_profile_logged"><![CDATA[Last Seen]]></string>
+    <string name="_bx_persons_form_profile_input_sys_profile_last_active"><![CDATA[Last Seen]]></string>
+    <string name="_bx_persons_form_profile_input_profile_last_active"><![CDATA[Last Seen]]></string>
     <string name="_bx_persons_form_profile_input_sys_skills"><![CDATA[Skills]]></string>
     <string name="_bx_persons_form_profile_input_skills"><![CDATA[Skills]]></string>
     <string name="_bx_persons_form_profile_input_sys_date_added"><![CDATA[Added]]></string>

+ 3 - 3
modules/boonex/persons/install/sql/install.sql

@@ -294,7 +294,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_person', 'bx_persons', 'profile_email', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_email', '_bx_persons_form_profile_input_profile_email', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0, ''),
 ('bx_person', 'bx_persons', 'profile_status', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_status', '_bx_persons_form_profile_input_profile_status', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0, ''),
 ('bx_person', 'bx_persons', 'profile_ip', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_ip', '_bx_persons_form_profile_input_profile_ip', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0, ''),
-('bx_person', 'bx_persons', 'profile_logged', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_logged', '_bx_persons_form_profile_input_profile_logged', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0, ''),
+('bx_person', 'bx_persons', 'profile_last_active', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_last_active', '_bx_persons_form_profile_input_profile_last_active', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0, ''),
 ('bx_person', 'bx_persons', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'skills', 'bx_person_skills', '', 0, 'nested_form', '_bx_persons_form_profile_input_sys_skills', '_bx_persons_form_profile_input_skills', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, 'sys_form_fields_votes'),
 ('bx_person', 'bx_persons', 'added', '', '', 0, 'datetime', '_bx_persons_form_profile_input_sys_date_added', '_bx_persons_form_profile_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
@@ -347,7 +347,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_person_view', 'profile_email', 192, 1, 5),
 ('bx_person_view', 'profile_status', 192, 1, 6),
 ('bx_person_view', 'profile_ip', 192, 1, 7),
-('bx_person_view', 'profile_logged', 192, 1, 8),
+('bx_person_view', 'profile_last_active', 192, 1, 8),
 ('bx_person_view', 'added', 192, 1, 9),
 ('bx_person_view', 'changed', 192, 1, 10),
 ('bx_person_view', 'friends_count', 2147483647, 1, 11),
@@ -360,7 +360,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_person_view_full', 'description', 2147483647, 0, 5),
 ('bx_person_view_full', 'profile_email', 192, 1, 6),
 ('bx_person_view_full', 'profile_status', 192, 1, 7),
-('bx_person_view_full', 'profile_logged', 192, 1, 8),
+('bx_person_view_full', 'profile_last_active', 192, 1, 8),
 
 ('bx_person_skills', 'skill_name', 2147483647, 1, 1),
 ('bx_person_skills_view', 'skill_name', 2147483647, 1, 1);

+ 2 - 2
modules/boonex/russian/data/langs/bx_organizations/ru.xml

@@ -76,8 +76,8 @@
     <string name="_bx_orgs_form_profile_input_profile_status"><![CDATA[Статус]]></string>
     <string name="_bx_orgs_form_profile_input_sys_profile_ip"><![CDATA[IP]]></string>
     <string name="_bx_orgs_form_profile_input_profile_ip"><![CDATA[IP]]></string>
-    <string name="_bx_orgs_form_profile_input_sys_profile_logged"><![CDATA[Последний визит]]></string>
-    <string name="_bx_orgs_form_profile_input_profile_logged"><![CDATA[Последний визит]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_profile_last_active"><![CDATA[Последний раз видели]]></string>
+    <string name="_bx_orgs_form_profile_input_profile_last_active"><![CDATA[Последний раз видели]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_orgs_form_profile_input_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_changed"><![CDATA[Дата обновления]]></string>

+ 2 - 2
modules/boonex/russian/data/langs/bx_persons/ru.xml

@@ -66,8 +66,8 @@
     <string name="_bx_persons_form_profile_input_profile_status"><![CDATA[Статус]]></string>
     <string name="_bx_persons_form_profile_input_sys_profile_ip"><![CDATA[IP]]></string>
     <string name="_bx_persons_form_profile_input_profile_ip"><![CDATA[IP]]></string>
-    <string name="_bx_persons_form_profile_input_sys_profile_logged"><![CDATA[Последний визит]]></string>
-    <string name="_bx_persons_form_profile_input_profile_logged"><![CDATA[Последний визит]]></string>
+    <string name="_bx_persons_form_profile_input_sys_profile_last_active"><![CDATA[Последний раз видели]]></string>
+    <string name="_bx_persons_form_profile_input_profile_last_active"><![CDATA[Последний раз видели]]></string>
     <string name="_bx_persons_form_profile_input_sys_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_persons_form_profile_input_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_persons_form_profile_input_sys_date_changed"><![CDATA[Дата обновления]]></string>