Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit ce57f3d

Browse files
author
Charles Marion
committed
0009692: View count should use cookie
1 parent b98337d commit ce57f3d

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

core/AppController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ public function preDispatch()
183183
$this->logged = false;
184184
}
185185

186+
Zend_Registry::set('userSession', $user);
187+
186188
$this->view->lang = Zend_Registry::get('configGlobal')->application->lang;
187189
//create a global javascript json array
188190
$jsonGlobal = array(

core/models/base/CommunityModelBase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ function incrementViewCount($communityDao)
7979
{
8080
throw new Zend_Exception("Error param.");
8181
}
82+
$user = Zend_Registry::get('userSession');
83+
if(isset($user))
84+
{
85+
if(isset($user->viewedCommunities[$communityDao->getKey()]))
86+
{
87+
return;
88+
}
89+
else
90+
{
91+
$user->viewedCommunities[$communityDao->getKey()] = true;
92+
}
93+
}
8294
$communityDao->view++;
8395
$this->save($communityDao);
8496
} //end incrementViewCount

core/models/base/FolderModelBase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ function incrementViewCount($folder)
6464
{
6565
throw new Zend_Exception("Error param.");
6666
}
67+
$user = Zend_Registry::get('userSession');
68+
if(isset($user))
69+
{
70+
if(isset($user->viewedFolder[$folder->getKey()]))
71+
{
72+
return;
73+
}
74+
else
75+
{
76+
$user->viewedFolder[$folder->getKey()] = true;
77+
}
78+
}
6779
$folder->view++;
6880
$this->save($folder);
6981
}//end incrementViewCount

core/models/base/ItemModelBase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ function incrementViewCount($itemdao)
101101
{
102102
throw new Zend_Exception("Error param.");
103103
}
104+
$user = Zend_Registry::get('userSession');
105+
if(isset($user))
106+
{
107+
if(isset($user->viewedItems[$itemdao->getKey()]))
108+
{
109+
return;
110+
}
111+
else
112+
{
113+
$user->viewedItems[$itemdao->getKey()] = true;
114+
}
115+
}
104116
$itemdao->view++;
105117
$this->save($itemdao);
106118
}//end incrementViewCount

0 commit comments

Comments
 (0)