本文整理汇总了PHP中CGroups::joinApproved方法的典型用法代码示例。如果您正苦于以下问题:PHP CGroups::joinApproved方法的具体用法?PHP CGroups::joinApproved怎么用?PHP CGroups::joinApproved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroups
的用法示例。
在下文中一共展示了CGroups::joinApproved方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _saveMember
private function _saveMember($groupId)
{
$group =& JTable::getInstance('Group', 'CTable');
$member =& JTable::getInstance('GroupMembers', 'CTable');
$group->load($groupId);
$params = $group->getParams();
$my = CFactory::getUser();
// Set the properties for the members table
$member->groupid = $group->id;
$member->memberid = $my->id;
CFactory::load('helpers', 'owner');
// @rule: If approvals is required, set the approved status accordingly.
$member->approved = $group->approvals == COMMUNITY_PRIVATE_GROUP ? '0' : 1;
// @rule: Special users should be able to join the group regardless if it requires approval or not
$member->approved = COwnerHelper::isCommunityAdmin() ? 1 : $member->approved;
// @rule: Invited users should be able to join the group immediately.
$groupInvite = JTable::getInstance('GroupInvite', 'CTable');
if ($groupInvite->load($groupId, $my->id)) {
$member->approved = 1;
}
//@todo: need to set the privileges
$member->permissions = '0';
$member->store();
$owner = CFactory::getUser($group->ownerid);
//trigger for onGroupJoin
$this->triggerGroupEvents('onGroupJoin', $group, $my->id);
// Update user group list
$my->updateGroupList();
// Test if member is approved, then we add logging to the activities.
if ($member->approved) {
CFactory::load('libraries', 'groups');
CGroups::joinApproved($groupId, $my->id);
}
return $member;
}
示例2: ajaxGroupJoinInvitation
/**
* Ajax function to join an group invitation
*
**/
public function ajaxGroupJoinInvitation($groupId)
{
$filter = JFilterInput::getInstance();
$groupId = $filter->clean($groupId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$json = array();
$my = CFactory::getUser();
// Get groups table
$table = JTable::getInstance('GroupInvite', 'CTable');
$keys = array('groupid' => $groupId, 'userid' => $my->id);
$table->load($keys);
if ($table->isOwner()) {
$group = JTable::getInstance('Group', 'CTable');
$member = JTable::getInstance('GroupMembers', 'CTable');
$group->load($groupId);
$params = $group->getParams();
// Set the properties for the members table
$member->groupid = $group->id;
$member->memberid = $my->id;
// @rule: If approvals is required, set the approved status accordingly.
$member->approved = $group->approvals == COMMUNITY_PRIVATE_GROUP ? '0' : 1;
// @rule: Special users should be able to join the group regardless if it requires approval or not
$member->approved = COwnerHelper::isCommunityAdmin() ? 1 : $member->approved;
$groupModel = CFactory::getModel('groups');
// @rule: If the Invitation is sent by group admin, do not need futher approval
if ($groupModel->isAdmin($table->creator, $groupId)) {
$member->approved = 1;
}
//@todo: need to set the privileges
$member->permissions = '0';
$member->store();
//trigger for onGroupJoin
$this->triggerEvents('onGroupJoin', $group, $my->id);
// Update user group list
$my->updateGroupList();
// Test if member is approved, then we add logging to the activities.
if ($member->approved) {
// remove the notication count
$table = JTable::getInstance('GroupInvite', 'CTable');
$keys = array('groupid' => $groupId, 'userid' => $my->id);
$table->load($keys);
$table->delete();
CGroups::joinApproved($groupId, $my->id);
$url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$json['success'] = true;
$json['message'] = JText::sprintf('COM_COMMUNITY_GROUPS_ACCEPTED_INVIT', $group->name, $url);
}
} else {
$json['error'] = JText::_('COM_COMMUNITY_GROUPS_NOT_INVITED_NOTIFICATION');
}
die(json_encode($json));
}
示例3: ajaxGroupJoinInvitation
/**
* Ajax function to join an group invitation
*
**/
public function ajaxGroupJoinInvitation($groupId)
{
$filter = JFilterInput::getInstance();
$groupId = $filter->clean($groupId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$objResponse = new JAXResponse();
$my = CFactory::getUser();
// Get groups table
$table =& JTable::getInstance('GroupInvite', 'CTable');
$table->load($groupId, $my->id);
if ($table->isOwner()) {
$group =& JTable::getInstance('Group', 'CTable');
$member =& JTable::getInstance('GroupMembers', 'CTable');
$group->load($groupId);
$params = $group->getParams();
// Set the properties for the members table
$member->groupid = $group->id;
$member->memberid = $my->id;
CFactory::load('helpers', 'owner');
// @rule: If approvals is required, set the approved status accordingly.
$member->approved = $group->approvals == COMMUNITY_PRIVATE_GROUP ? '0' : 1;
// @rule: Special users should be able to join the group regardless if it requires approval or not
$member->approved = COwnerHelper::isCommunityAdmin() ? 1 : $member->approved;
$groupModel = CFactory::getModel('groups');
// @rule: If the Invitation is sent by group admin, do not need futher approval
if ($groupModel->isAdmin($table->creator, $groupId)) {
$member->approved = 1;
}
//@todo: need to set the privileges
$member->permissions = '0';
$member->store();
//trigger for onGroupJoin
$this->triggerEvents('onGroupJoin', $group, $my->id);
// Test if member is approved, then we add logging to the activities.
if ($member->approved) {
CFactory::load('libraries', 'groups');
CGroups::joinApproved($groupId, $my->id);
$url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$objResponse->addScriptCall('joms.jQuery("#msg-pending-' . $group->id . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_GROUPS_ACCEPTED_INVIT', $group->name, $url)) . '");');
$objResponse->addScriptCall('joms.notifications.updateNotifyCount();');
$objResponse->addScriptCall('joms.jQuery("#noti-pending-group-' . $group->id . '").fadeOut(1000, function() { joms.jQuery("#noti-pending-group' . $group->id . '").remove();} );');
$objResponse->addScriptCall('aspan = joms.jQuery("#jsMenu .jsMenuIcon span"); aspan.html(parseInt(aspan.html())-1);');
}
} else {
$objResponse->addScriptCall('joms.jQuery("#error-pending-' . $group->id . '").html("' . JText::_('COM_COMMUNITY_GROUPS_NOT_INVITED_NOTIFICATION') . '");');
$objResponse->addScriptCall('joms.jQuery("#error-pending-' . $group->id . '").attr("class", "error");');
}
return $objResponse->sendResponse();
}