当前位置: 首页>>代码示例>>PHP>>正文


PHP UserDao::getInvitations方法代码示例

本文整理汇总了PHP中UserDao::getInvitations方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDao::getInvitations方法的具体用法?PHP UserDao::getInvitations怎么用?PHP UserDao::getInvitations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserDao的用法示例。


在下文中一共展示了UserDao::getInvitations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: policyCheck

 /**
  * Check whether the given policy is valid for the given community and user.
  *
  * @param  CommunityDao $communityDao community DAO
  * @param  null|UserDao $userDao user DAO
  * @param  int $policy policy
  * @return bool true if the given policy is valid for the given community and user
  * @throws Zend_Exception
  */
 public function policyCheck($communityDao, $userDao = null, $policy = MIDAS_POLICY_READ)
 {
     if (!$communityDao instanceof CommunityDao || !is_numeric($policy)) {
         throw new Zend_Exception('Error in param: communityDao should be a CommunityDao and policy should be numeric.');
     }
     if ($userDao == null) {
         $userId = -1;
     } elseif (!$userDao instanceof UserDao) {
         throw new Zend_Exception('Should be an user.');
     } else {
         $userId = $userDao->getUserId();
         if ($userDao->isAdmin()) {
             return true;
         }
     }
     $privacy = $communityDao->getPrivacy();
     switch ($policy) {
         case MIDAS_POLICY_READ:
             if ($privacy != MIDAS_COMMUNITY_PRIVATE) {
                 return true;
             } elseif ($userId == -1) {
                 return false;
             } else {
                 $user_groups = $userDao->getGroups();
                 $member_group = $communityDao->getMemberGroup();
                 foreach ($user_groups as $group) {
                     if ($group->getKey() == $member_group->getKey()) {
                         return true;
                     }
                 }
                 $invitations = $userDao->getInvitations();
                 foreach ($invitations as $invitation) {
                     if ($invitation->getCommunityId() == $communityDao->getKey()) {
                         return true;
                     }
                 }
                 return false;
             }
             break;
         case MIDAS_POLICY_WRITE:
             if ($userId == -1) {
                 return false;
             } else {
                 $user_groups = $userDao->getGroups();
                 $moderator_group = $communityDao->getModeratorGroup();
                 $admin_group = $communityDao->getAdminGroup();
                 foreach ($user_groups as $group) {
                     if ($group->getKey() == $moderator_group->getKey() || $group->getKey() == $admin_group->getKey()) {
                         return true;
                     }
                 }
                 return false;
             }
             break;
         case MIDAS_POLICY_ADMIN:
             if ($userId == -1) {
                 return false;
             } else {
                 $user_groups = $userDao->getGroups();
                 $admin_group = $communityDao->getAdminGroup();
                 foreach ($user_groups as $group) {
                     if ($group->getKey() == $admin_group->getKey()) {
                         return true;
                     }
                 }
                 return false;
             }
             break;
         default:
             return false;
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:81,代码来源:CommunityModelBase.php

示例2: removeInvitation

 /**
  * Remove invitation.
  *
  * @param CommunityDao $communityDao
  * @param UserDao $userDao
  * @return bool
  * @throws Zend_Exception
  */
 public function removeInvitation($communityDao, $userDao)
 {
     if ($userDao == null) {
         return false;
     }
     $invitations = $userDao->getInvitations();
     foreach ($invitations as $invitation) {
         if ($invitation->getCommunityId() == $communityDao->getKey()) {
             /** @var FeedModel $feedModel */
             $feedModel = MidasLoader::loadModel('Feed');
             $feeds = $feedModel->getFeedByResourceAndType(array(MIDAS_FEED_COMMUNITY_INVITATION), $invitation);
             foreach ($feeds as $feed) {
                 $feedModel->delete($feed);
             }
             $this->delete($invitation);
             return true;
         }
     }
     return false;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:CommunityInvitationModelBase.php


注:本文中的UserDao::getInvitations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。