Skip to content

Instantly share code, notes, and snippets.

@beautyfree
Created January 13, 2014 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beautyfree/8406024 to your computer and use it in GitHub Desktop.
Save beautyfree/8406024 to your computer and use it in GitHub Desktop.
<?php
class PluginCloseprofile_ActionProfile extends PluginCloseprofile_Inherit_ActionProfile {
/**
* Проверка корректности профиля
*/
protected function CheckUserProfile() {
if(parent::CheckUserProfile() === false) return false;
/**
* Смотрим свой профиль
*/
if($this->oUserCurrent and $this->oUserCurrent->getId()==$this->oUserProfile->getId()) {
return true;
}
/**
* Профиль админа
*/
if($this->oUserProfile->isAdministrator()) {
return true;
}
/**
* Чужой профиль
*/
// Зареганным показываем своих
if($this->oUserCurrent) {
$aOpenBlogsProfile = $this->Blog_GetAccessibleBlogsByUser($this->oUserProfile);
$aOpenBlogsCurrent = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
if(count(array_intersect($aOpenBlogsProfile,$aOpenBlogsCurrent)) == 0) return false;
// Незареганным нет если в закрытых
} else {
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserProfile);
if(count($aOpenBlogs) > 0) return false;
}
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment