Gallery: API Core ShowItem:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: ==Admin's views don't increase view count== Within ShowItem.inc there's code that increments an album's view count when the album is viewed. To ignore views made by anyone with admin priv...)
 
无编辑摘要
 
第1行: 第1行:
==Admin's views don't increase view count==
==管理员查看不计入查看次数==
Within ShowItem.inc there's code that increments an album's view count when the album is viewed. To ignore views made by anyone with admin privileges, you need to:
在ShowItem.inc中,有代码可以实现相册查看次数统计。如果不计入具有管理权限的用户查看,你需要:
* Find out if the user viewing the page is an admin
* 查明正在查看此页的用户是否是管理员
* Only call incrementItemViewCount() if the user is not an admin
* 如果该用户不是管理员则仅呼叫incrementItemViewCount()
This is how it is done (around line 106, v2.1 and line 120, v.2.2):
以下为操作方法(2.1版中,大约在106行;2.2版则是120行):
  /* Is the user an admin? */
  /* 该用户是否为管理员?*/
  list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
  list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
  if ($ret) {
  if ($ret) {
     return array($ret->wrap(__FILE__, __LINE__), null);
     return array($ret->wrap(__FILE__, __LINE__), null);
   }
   }
   /* Increment the view count */
   /* 增加查看次数*/
   if (!$isAdmin) {
   if (!$isAdmin) {
     $ret = GalleryCoreApi::incrementItemViewCount($item->getId());
     $ret = GalleryCoreApi::incrementItemViewCount($item->getId());
第17行: 第17行:
   }
   }


This is how it is done (around line 106, v2.0.x):
以下为操作方法(2.0.x版中,大约在106行):
/* Is the user an admin? */
/*该用户是否为管理员?*/
  list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
  list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
  if ($ret->isError()) {
  if ($ret->isError()) {
     return array($ret->wrap(__FILE__, __LINE__), null);
     return array($ret->wrap(__FILE__, __LINE__), null);
  }
  }
/* Increment the view count */
  /* 增加查看次数*/
  if (!$isAdmin) {
  if (!$isAdmin) {
     $ret = GalleryCoreApi::incrementItemViewCount($item->getId());
     $ret = GalleryCoreApi::incrementItemViewCount($item->getId());

2008年11月29日 (六) 15:31的最新版本

管理员查看不计入查看次数[ ]

在ShowItem.inc中,有代码可以实现相册查看次数统计。如果不计入具有管理权限的用户查看,你需要:

  • 查明正在查看此页的用户是否是管理员
  • 如果该用户不是管理员则仅呼叫incrementItemViewCount()

以下为操作方法(2.1版中,大约在106行;2.2版则是120行):

/* 该用户是否为管理员?*/
list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
if ($ret) {
    return array($ret->wrap(__FILE__, __LINE__), null);
 }
 /* 增加查看次数*/
 if (!$isAdmin) {
    $ret = GalleryCoreApi::incrementItemViewCount($item->getId());
    if ($ret) {
       return array($ret->wrap(__FILE__, __LINE__), null);
    }
 }

以下为操作方法(2.0.x版中,大约在106行): /*该用户是否为管理员?*/

list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
if ($ret->isError()) {
    return array($ret->wrap(__FILE__, __LINE__), null);
}
 /* 增加查看次数*/
if (!$isAdmin) {
    $ret = GalleryCoreApi::incrementItemViewCount($item->getId());
    if ($ret->isError()) {
        return array($ret->wrap(__FILE__, __LINE__), null);
    }
}