/** * _get_all_permitted_users * * @return array **/ private function _get_all_permitted_users($forum_ids = array()) { $mFAcc = array(); // get Froumaccess object for users with $forum_ids $criteria = new Criteriacompo(); if (!empty($forum_ids)) { $criteria->add(new criteria('forum_id', $forum_ids, 'IN')); } $criteria->add(new criteria('uid', 0, '>')); $criteria->add(new criteria('groupid', NULL)); foreach ($this->getObjects($criteria) as $mF) { $forum_id = $mF->get('forum_id'); $uid = $mF->get('uid'); $fgAccArr = unserialize($mF->get('permissions')); foreach ($fgAccArr as $key => $val) { if ((int) $val > 0) { $mFAcc[$key][$forum_id][$uid] = $uid; } } } return $mFAcc; }
/** * _update_user * * @param void * * @return void **/ private function _update_user() { $db =& $this->mRoot->mController->mDB; $mReq = $this->mRoot->mContext->mRequest; $member_handler =& xoops_gethandler('member'); $mHandler = $this->_getHandler(); $criteria = new Criteriacompo(); $criteria->add(new criteria('forum_id', $this->forum_id)); $criteria->add(new criteria('groupid', NULL)); $criteria->add(new criteria('uid', 0, '>')); $mHandler->deleteAll($criteria); //$db->query( "DELETE FROM ".$db->prefix($this->mAsset->mDirname."_forumaccess")." WHERE forum_id=$this->forum_id AND uid>0" ) ; $can_read = $can_post = $can_edit = $can_delete = $post_auto_approved = $is_moderator = false; // $p_post =$mReq->getRequest('can_post'); // $can_post_ = is_array( $p_post ) ? $p_post : array() ; $p_read = $mReq->getRequest('can_read'); // $can_read_ = is_array( $p_read ) ? $p_read + $can_post_ : $can_post_ ; foreach ($p_read as $uid => $can_read) { $uid = (int) $uid; if ($can_read) { $p = $mReq->getRequest('permission'); $perms = $p[$uid]; $perm_arr = array(); foreach ($perms as $key => $val) { $perm_arr[$key] = empty($val) ? 0 : 1; } $mObject = $mHandler->create(); $mObject->set('forum_id', $this->forum_id); $mObject->set('groupid', NULL); $mObject->set('uid', $uid); $mObject->set('permissions', serialize($perm_arr)); $mHandler->insert($mObject, false); } } $p_uname = $mReq->getRequest('new_uname'); $p_uid = $mReq->getRequest('new_uid'); if (is_array($p_uid) || is_array($p_uname)) { for ($i = 0; $i < 5; $i++) { if ((int) $p_uid[$i] >= 0) { $uid = (int) $p_uid[$i]; $user = $member_handler->getUser($uid); } if (!empty($p_uname[$i])) { $criteria = new Criteria('uname', addslashes($p_uname[$i])); @(list($user) = $member_handler->getUsers($criteria)); $uid = $user->uid(); } if (is_object($user)) { $p = $mReq->getRequest('new_permission'); $perms = $p[$i]; $perm_arr = array(); foreach ($perms as $key => $val) { $perm_arr[$key] = empty($val) ? 0 : 1; } $mObject = $mHandler->create(); $mObject->set('forum_id', $this->forum_id); $mObject->set('groupid', NULL); $mObject->set('uid', $uid); $mObject->set('permissions', serialize($perm_arr)); $mHandler->insert($mObject, false); } } } }
/** * _setGroups * * @return array **/ private function _getGroups() { // get all groups $group_handler =& xoops_gethandler('group'); $criteria = new Criteriacompo(); $criteria->setSort('groupid', 'DESC'); $groups =& $group_handler->getObjects($criteria); // make Access Control array by Groups $grpNames = array(); foreach ($groups as $group) { $gid = (int) $group->getVar('groupid'); $grpNames[$gid] = $group->getVar('name'); } return $grpNames; }