本文整理汇总了PHP中DiscussHelper::getJoomlaUserGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::getJoomlaUserGroups方法的具体用法?PHP DiscussHelper::getJoomlaUserGroups怎么用?PHP DiscussHelper::getJoomlaUserGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::getJoomlaUserGroups方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
// @rule: Test for user access if on 1.6 and above
if (DiscussHelper::getJoomlaVersion() >= '1.6') {
if (!JFactory::getUser()->authorise('discuss.manage.settings', 'com_easydiscuss')) {
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
JFactory::getApplication()->close();
}
}
// Initialise variables
$config = DiscussHelper::getConfig();
$jconfig = DiscussHelper::getJConfig();
$defaultSAId = DiscussHelper::getDefaultSAIds();
$joomlaVersion = DiscussHelper::getJoomlaVersion();
$joomlaGroups = DiscussHelper::getJoomlaUserGroups();
$this->assignRef('config', $config);
$this->assignRef('jconfig', $jconfig);
$this->assignRef('defaultSAId', $defaultSAId);
$this->assignRef('defaultLength', $defaultLength);
$this->assignRef('joomlaversion', $joomlaVersion);
$this->assignRef('joomlaGroups', $joomlaGroups);
if ($this->getLayout() == 'default') {
$app = JFactory::getApplication();
$app->redirect('index.php?option=com_easydiscuss&view=settings&layout=default_main_workflow&child=general');
}
parent::display($tpl);
}
示例2: diplayRole
public function diplayRole()
{
// Initialise variables
$mainframe = JFactory::getApplication();
$roleId = JRequest::getVar('role_id', '');
$role = DiscussHelper::getTable('Role');
$role->load($roleId);
$role->title = JString::trim($role->title);
$this->role = $role;
// Set default values for new entries.
if (empty($role->created_time)) {
$date = DiscussHelper::getHelper('Date')->dateWithOffSet();
$role->created_time = $date->toFormat();
$role->published = true;
}
$groups = DiscussHelper::getJoomlaUserGroups();
// Remove the selected usergroups
$db = DiscussHelper::getDbo();
$query = 'SELECT `usergroup_id` FROM `#__discuss_roles`';
$db->setQuery($query);
$result = $db->loadResultArray();
if (!empty($result)) {
foreach ($groups as $key => $group) {
if (in_array($group->id, $result) && $group->id != $role->usergroup_id) {
unset($groups[$key]);
}
}
}
$usergroupList = JHTML::_('select.genericlist', $groups, 'usergroup_id', 'class="full-width"', 'id', 'name', $role->usergroup_id);
$this->assignRef('role', $role);
$this->assignRef('usergroupList', $usergroupList);
$colors = array();
$colors[] = JHTML::_('select.option', 'success', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_SUCCESS'));
$colors[] = JHTML::_('select.option', 'warning', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_WARNING'));
$colors[] = JHTML::_('select.option', 'important', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_IMPORTANT'));
$colors[] = JHTML::_('select.option', 'info', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_INFO'));
$colors[] = JHTML::_('select.option', 'inverse', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_INVERSE'));
$colorList = JHTML::_('select.genericlist', $colors, 'colorcode', 'class="full-width"', 'value', 'text', $role->colorcode);
$this->assignRef('colorList', $colorList);
parent::display('edit');
}
示例3: form
public function form()
{
$app = JFactory::getApplication();
$id = JRequest::getInt('id', '');
$field = DiscussHelper::getTable('CustomFields');
$field->load($id);
$this->addPathway('Home', 'index.php?option=com_easydiscuss');
$this->addPathway('Custom Fields', 'index.php?option=com_easydiscuss&view=customfields');
$field->title = JString::trim($field->title);
$this->id = $field;
if (!$field) {
JToolBarHelper::title(JText::_('COM_EASYDISCUSS_ADD_NEW_CUSTOMFIELDS'), 'customs');
$this->addPathway('New Field', '');
} else {
JToolBarHelper::title(JText::_('COM_EASYDISCUSS_EDITING_CUSTOMFIELDS'), 'customs');
$this->addPathway('Editing Field', '');
}
JHTML::_('behavior.modal');
// Set default values for new entries.
if (empty($field->created_time)) {
$date = DiscussHelper::getHelper('Date')->dateWithOffSet();
$field->created_time = $date->toFormat();
$field->published = true;
}
$customAclItems = JTable::getInstance('CustomFieldsACL', 'Discuss');
$customFieldsAcl = $customAclItems->getCustomFieldsACL();
$assignedGroupACL = $field->getAssignedACL('group');
$assignedUserACL = $field->getAssignedACL('user');
$joomlaGroups = DiscussHelper::getJoomlaUserGroups();
$this->assignRef('field', $field);
$this->assignRef('assignedGroupACL', $assignedGroupACL);
$this->assignRef('assignedUserACL', $assignedUserACL);
$this->assignRef('customFieldsAcl', $customFieldsAcl);
$this->assignRef('joomlaGroups', $joomlaGroups);
parent::display();
}
示例4: saveACL
public function saveACL($post)
{
$catRuleItems = JTable::getInstance('CategoryAclItem', 'Discuss');
$categoryRules = $catRuleItems->getAllRuleItems();
$itemtypes = array('group', 'user');
$added = 0;
foreach ($categoryRules as $rule) {
foreach ($itemtypes as $type) {
$key = 'acl_' . $type . '_' . $rule->action;
if (isset($post[$key])) {
if (count($post[$key]) > 0) {
foreach ($post[$key] as $contendid) {
//now we reinsert again.
$catRule = JTable::getInstance('CategoryAclMap', 'Discuss');
$catRule->category_id = $this->id;
$catRule->acl_id = $rule->id;
$catRule->type = $type;
$catRule->content_id = $contendid;
$catRule->status = '1';
$catRule->store();
$added++;
}
//end foreach
}
//end if
}
//end if
}
}
// we need to handle if user forget to set the acl, we will assign a default
// set here using Joomla group.
if (empty($added)) {
// let assign this category a default acl items.
$defaultKeys = array('1', '2', '3', '4');
$joomlaGroups = DiscussHelper::getJoomlaUserGroups();
foreach ($defaultKeys as $ruleId) {
foreach ($joomlaGroups as $joomlaGroup) {
$catRule = JTable::getInstance('CategoryAclMap', 'Discuss');
$catRule->category_id = $this->id;
$catRule->acl_id = $ruleId;
$catRule->type = 'group';
$catRule->content_id = $joomlaGroup->id;
$catRule->status = '1';
$catRule->store();
}
}
}
}
示例5: saveCustomFieldRule
public function saveCustomFieldRule($fieldId = null, $form = null)
{
if ($fieldId == null || $form == null) {
return false;
}
$db = DiscussHelper::getDBO();
$types = array('user', 'group');
$acls = $this->getAllCustomFieldsACL();
$query = 'DELETE FROM ' . $db->nameQuote('#__discuss_customfields_rule') . ' WHERE ' . $db->nameQuote('field_id') . '=' . $db->quote($fieldId);
$db->setQuery($query);
$db->Query();
// If nobody assign any permission in the permission tab, everybody can use.
$allowAll = true;
foreach ($types as $type) {
foreach ($acls as $acl) {
// Check is it set and count does it have items inside the array
if (isset($form['acl_' . $type . '_' . $acl->action]) && count($form['acl_' . $type . '_' . $acl->action]) > 0) {
// EG: $form[ 'acl_user_view' ]
foreach ($form['acl_' . $type . '_' . $acl->action] as $myContentId) {
$table = DiscussHelper::getTable('CustomFieldsRule');
$table->field_id = $fieldId;
$table->acl_id = $acl->id;
$table->content_id = $myContentId;
$table->content_type = $type;
$table->status = '1';
$table->store();
// If there is at least one permission is set, do not allow eveybody to use.
$allowAll = false;
}
}
}
}
if ($allowAll) {
foreach ($acls as $acl) {
// Allow all group to use
$joomlaGroups = DiscussHelper::getJoomlaUserGroups();
foreach ($joomlaGroups as $joomlaGroup) {
$table = DiscussHelper::getTable('CustomFieldsRule');
$table->field_id = $fieldId;
$table->acl_id = $acl->id;
$table->content_id = $joomlaGroup->id;
$table->content_type = 'group';
$table->status = '1';
$table->store();
}
}
}
return true;
}
示例6: getAssignedACL
public function getAssignedACL($type = 'group')
{
$db = DiscussHelper::getDBO();
$acl = array();
$query = 'SELECT' . ' a.' . $db->nameQuote('field_id') . ',' . ' a.' . $db->nameQuote('content_id') . ',' . ' a.' . $db->nameQuote('status') . ',' . ' b.' . $db->nameQuote('id') . ' AS `acl_id`' . ' FROM ' . $db->nameQuote('#__discuss_customfields_rule') . ' AS a' . ' LEFT JOIN ' . $db->nameQuote('#__discuss_customfields_acl') . ' AS b' . ' ON a.' . $db->nameQuote('acl_id') . '=' . 'b.' . $db->nameQuote('id') . ' WHERE a.' . $db->nameQuote('field_id') . '=' . $db->Quote($this->id) . ' AND a.' . $db->nameQuote('content_type') . '=' . $db->Quote($type);
$db->setQuery($query);
$result = $db->loadObjectList();
if (count($result) > 0) {
$acl = null;
if ($type == 'group') {
$joomlaGroups = DiscussHelper::getJoomlaUserGroups();
$acl = $this->_mapRules($result, $joomlaGroups);
} else {
$users = $this->getAclUsers($result);
$acl = $this->_mapRules($result, $users);
}
return $acl;
} else {
return null;
}
}