Просмотр исходного кода

#33 - Views integration into Persons module.

AntonLV 13 лет назад
Родитель
Сommit
36523afd8c

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -31,6 +31,7 @@ class BxPersonsConfig extends BxDolModuleConfig {
     public static $OBJECT_IMAGES_TRANSCODER_PICTURE = 'bx_persons_picture';
     public static $OBJECT_IMAGES_TRANSCODER_COVER = 'bx_persons_cover';
     public static $OBJECT_IMAGES_TRANSCODER_COVER_THUMB = 'bx_persons_cover_thumb';
+	public static $OBJECT_VIEWS = 'bx_persons';
 
     /**
      * Constructor

+ 3 - 0
modules/boonex/persons/classes/BxPersonsFormPerson.php

@@ -126,6 +126,9 @@ class BxPersonsFormPerson extends BxTemplFormView {
                 $this->_deleteFile ($aContentInfo[$sField], $aVals['storage_object']);
         }
 
+        bx_import('BxDolView');
+		BxDolView::getObjectInstance(BxPersonsConfig::$OBJECT_VIEWS, $iContentId)->onObjectDelete();
+
         return parent::delete($iContentId);
     }
 

+ 4 - 0
modules/boonex/persons/classes/BxPersonsModule.php

@@ -147,6 +147,10 @@ class BxPersonsModule extends BxDolModule implements iBxDolProfileService {
             $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
         if (!$iContentId)
             return false;
+
+		bx_import('BxDolView');
+		BxDolView::getObjectInstance(BxPersonsConfig::$OBJECT_VIEWS, $iContentId)->doView();
+
         bx_import('ProfileForms', $this->_aModule);
         $oProfileForms = new BxPersonsProfileForms($this);
         return $oProfileForms->viewDataForm((int)$iContentId);

+ 2 - 1
modules/boonex/persons/install/sql/disable.sql

@@ -34,7 +34,8 @@ DELETE FROM `sys_menu_sets` WHERE `module` = 'bx_persons';
 DELETE FROM `sys_menu_items` WHERE `module` = 'bx_persons' OR `set_name` IN('bx_persons_view_submenu', 'bx_persons_view_actions', 'bx_persons_view_actions_more');
 
 -- ACL
-
 DELETE `sys_acl_actions`, `sys_acl_matrix` FROM `sys_acl_actions`, `sys_acl_matrix` WHERE `sys_acl_matrix`.`IDAction` = `sys_acl_actions`.`ID` AND `sys_acl_actions`.`Module` = 'bx_persons';
 DELETE FROM `sys_acl_actions` WHERE `Module` = 'bx_persons';
 
+-- VIEWS
+DELETE FROM `sys_objects_view` WHERE `Name`='bx_persons';

+ 4 - 0
modules/boonex/persons/install/sql/enable.sql

@@ -228,3 +228,7 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 (@iModerator, @iIdActionProfileEditAny),
 (@iAdministrator, @iIdActionProfileEditAny);
 
+
+-- VIEWS
+INSERT INTO `sys_objects_view` (`name`, `table_track`, `period`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_count`, `class_name`, `class_file`) VALUES 
+('bx_persons', 'bx_persons_views_track', '86400', '1', 'bx_persons_data', 'id', 'views', '', '');

+ 11 - 5
modules/boonex/persons/install/sql/install.sql

@@ -1,6 +1,5 @@
 
--- TABLE: PROFILES 
-
+-- TABLE: PROFILES
 CREATE TABLE IF NOT EXISTS `bx_persons_data` (
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `author` int(10) unsigned NOT NULL,
@@ -10,12 +9,11 @@ CREATE TABLE IF NOT EXISTS `bx_persons_data` (
   `cover` int(11) NOT NULL,
   `fullname` varchar(255) NOT NULL,
   `sex` int(11) NOT NULL,
+  `views` int(11) NOT NULL default '0',
   PRIMARY KEY (`id`)
 );
 
-
 -- TABLE: STORAGES & TRANSCODERS
-
 CREATE TABLE `bx_persons_pictures` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `profile_id` int(10) unsigned NOT NULL,
@@ -48,8 +46,16 @@ CREATE TABLE `bx_persons_pictures_resized` (
   UNIQUE KEY `remote_id` (`remote_id`)
 );
 
--- FORMS
+-- TABLE: VIEWS
+CREATE TABLE `bx_persons_views_track` (
+  `object_id` int(11) NOT NULL default '0',
+  `viewer_id` int(11) NOT NULL default '0',
+  `viewer_nip` int(11) unsigned NOT NULL default '0',
+  `date` int(11) NOT NULL default '0',
+  KEY `id` (`object_id`,`viewer_id`,`viewer_nip`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
+-- FORMS
 INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_person', 'bx_persons', '_bx_persons_form_person', '', 'a:1:{s:7:\"enctype\";s:19:\"multipart/form-data\";}', 'bx_persons_data', 'id', '', '', 'do_submit', '', 0, 1, 'BxPersonsFormPerson', 'modules/boonex/persons/classes/BxPersonsFormPerson.php');
 

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

@@ -1,6 +1,5 @@
 
 -- TABLE: PROFILES 
-
 DROP TABLE IF EXISTS `bx_persons_data`;
 DELETE FROM sys_profiles WHERE `type` = 'bx_persons';
 
@@ -10,8 +9,10 @@ DELETE FROM sys_profiles WHERE `type` = 'bx_persons';
 DROP TABLE IF EXISTS `bx_persons_pictures`; 
 DROP TABLE IF EXISTS `bx_persons_pictures_resized`;
 
--- FORMS
+-- TABLE: VIEWS
+DROP TABLE IF EXISTS `bx_persons_views_track`;
 
+-- FORMS
 DELETE FROM `sys_objects_form` WHERE `module` = 'bx_persons';
 
 DELETE FROM `sys_form_displays` WHERE `module` = 'bx_persons';