Ejemplo n.º 1
1
 public function save()
 {
     $group = $this->group;
     $roles = array();
     if (array_key_exists("roles", $group)) {
         $roles = $group["roles"];
         unset($group["roles"]);
     }
     $groupObj = new CUserGroup();
     $groupObj->setAttributes($group);
     /**
      * Удаляем старые задачи группы и пользователей
      */
     foreach (CActiveRecordProvider::getWithCondition(TABLE_USER_GROUP_HAS_ROLES, "user_group_id = " . $groupObj->getId())->getItems() as $ar) {
         $ar->remove();
     }
     $groupObj->save();
     /**
      * Создаем новые задачи группы и пользователей
      */
     foreach ($roles as $role => $level) {
         if ($level != 0) {
             $ar = new CActiveRecord(array("id" => null, "user_group_id" => $groupObj->getId(), "task_id" => $role, "task_rights_id" => $level));
             $ar->setTable(TABLE_USER_GROUP_HAS_ROLES);
             $ar->insert();
         }
     }
 }
 public function actionSaveMembers()
 {
     $aclItems = CRequest::getArray("members");
     $group = new CUserGroup();
     $group->setAttributes(CRequest::getArray($group::getClassName()));
     // удаляем все старые записи и создаем новые
     $transaction = new CTransaction();
     foreach ($group->getACLRelations()->getItems() as $item) {
         $item->remove();
     }
     // создаем новый записи
     foreach ($aclItems["id"] as $key => $value) {
         $entry = new CACLGroupEntry();
         $entry->group_id = $group->getId();
         $entry->setType($aclItems["type"][$key]);
         $entry->setValue($value);
         $entry->save();
     }
     $transaction->commit();
     $this->redirect("?action=index");
 }
Ejemplo n.º 3
0
 /**
  * Update Users
  *
  * {@source}
  * @access public
  * @static
  * @since 1.8
  * @version 1
  *
  * @param _array $users multidimensional array with Users data
  * @param string $users['userid']
  * @param string $users['name']
  * @param string $users['surname']
  * @param array $users['alias']
  * @param string $users['passwd']
  * @param string $users['url']
  * @param int $users['autologin']
  * @param int $users['autologout']
  * @param string $users['lang']
  * @param string $users['theme']
  * @param int $users['refresh']
  * @param int $users['rows_per_page']
  * @param int $users['type']
  * @param array $users['user_medias']
  * @param string $users['user_medias']['mediatypeid']
  * @param string $users['user_medias']['address']
  * @param int $users['user_medias']['severity']
  * @param int $users['user_medias']['active']
  * @param string $users['user_medias']['period']
  * @return boolean
  */
 public static function update($users)
 {
     global $USER_DETAILS;
     $errors = array();
     $result = true;
     $self = false;
     if (USER_TYPE_SUPER_ADMIN != $USER_DETAILS['type']) {
         self::setError(__METHOD__, ZBX_API_ERROR_PERMISSIONS, S_CUSER_ERROR_ONLY_SUPER_ADMIN_CAN_UPDATE_USERS);
         return false;
     }
     $users = zbx_toArray($users);
     $userids = zbx_objectValues($users, 'userid');
     $options = array('userids' => zbx_objectValues($users, 'userid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1);
     $upd_users = self::get($options);
     foreach ($users as $gnum => $user) {
         //add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_USER, 'User ['.$user['alias'].']');
     }
     self::BeginTransaction(__METHOD__);
     if (bccomp($USER_DETAILS['userid'], $user['userid']) == 0) {
         $self = true;
     }
     foreach ($users as $unum => $user) {
         $user_db_fields = $upd_users[$user['userid']];
         // check if we change guest user
         if ($user_db_fields['alias'] == ZBX_GUEST_USER && isset($user['alias']) && $user['alias'] != ZBX_GUEST_USER) {
             $errors[] = array('errno' => ZBX_API_ERROR_PARAMETERS, 'error' => S_CUSER_ERROR_CANT_RENAME_GUEST_USER);
             $result = false;
             break;
         }
         // unset if not changed passwd
         if (isset($user['passwd']) && !is_null($user['passwd'])) {
             $user['passwd'] = md5($user['passwd']);
         } else {
             unset($user['passwd']);
         }
         //---------
         if (!check_db_fields($user_db_fields, $user)) {
             $errors[] = array('errno' => ZBX_API_ERROR_PARAMETERS, 'error' => S_CUSER_ERROR_WRONG_FIELD_FOR_USER);
             $result = false;
             break;
         }
         // copy from frontend {
         $sql = 'SELECT userid ' . ' FROM users ' . ' WHERE alias=' . zbx_dbstr($user['alias']) . ' AND ' . DBin_node('userid', id2nodeid($user['userid']));
         $db_user = DBfetch(DBselect($sql));
         if ($db_user && $db_user['userid'] != $user['userid']) {
             $errors[] = array('errno' => ZBX_API_ERROR_PARAMETERS, 'error' => S_CUSER_ERROR_USER_EXISTS_FIRST_PART . ' ' . $user['alias'] . ' ' . S_CUSER_ERROR_USER_EXISTS_SECOND_PART);
             $result = false;
             break;
         }
         $sql = 'UPDATE users SET ' . ' name=' . zbx_dbstr($user['name']) . ', ' . ' surname=' . zbx_dbstr($user['surname']) . ', ' . ' alias=' . zbx_dbstr($user['alias']) . ', ' . ' passwd=' . zbx_dbstr($user['passwd']) . ', ' . ' url=' . zbx_dbstr($user['url']) . ', ' . ' autologin='******'autologin'] . ', ' . ' autologout=' . $user['autologout'] . ', ' . ' lang=' . zbx_dbstr($user['lang']) . ', ' . ' theme=' . zbx_dbstr($user['theme']) . ', ' . ' refresh=' . $user['refresh'] . ', ' . ' rows_per_page=' . $user['rows_per_page'] . ', ' . ' type=' . $user['type'] . ' WHERE userid=' . $user['userid'];
         $result = DBexecute($sql);
         // if(isset($user['usrgrps']) && !is_null($user['usrgrps'])){
         // $user_groups = CHostGroup::get(array('userids' => $user['userid']));
         // $user_groupids = zbx_objectValues($user_groups, 'usrgrpid');
         // $new_groupids = zbx_objectValues($user['usrgrps'], 'usrgrpid');
         // $groups_to_add = array_diff($new_groupids, $user_groupids);
         // if(!empty($groups_to_add)){
         // $result &= self::massAdd(array('users' => $user, 'usrgrps' => $groups_to_add));
         // }
         // $groups_to_del = array_diff($user_groupids, $new_groupids);
         // if(!empty($groups_to_del)){
         // $result &= self::massRemove(array('users' => $user, 'usrgrps' => $groups_to_del));
         // }
         // }
         if ($result && isset($user['usrgrps']) && !is_null($user['usrgrps'])) {
             DBexecute('DELETE FROM users_groups WHERE userid=' . $user['userid']);
             $options = array('usrgrpids' => zbx_objectValues($user['usrgrps'], 'usrgrpid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1);
             $usrgrps = CUserGroup::get($options);
             foreach ($usrgrps as $groupid => $group) {
                 if (!$result) {
                     break;
                 }
                 if ($group['gui_access'] == GROUP_GUI_ACCESS_DISABLED && $self) {
                     $errors[] = array('errno' => ZBX_API_ERROR_PARAMETERS, 'error' => S_CUSER_ERROR_USER_UNABLE_RESTRICT_SELF_GUI_ACCESS_PART1 . ' ' . $group['name'] . ' ' . S_CUSER_ERROR_USER_UNABLE_RESTRICT_SELF_GUI_ACCESS_PART2);
                     $result = false;
                     break;
                 }
                 if ($group['users_status'] == GROUP_STATUS_DISABLED && $self) {
                     $errors[] = array('errno' => ZBX_API_ERROR_PARAMETERS, 'error' => S_CUSER_ERROR_USER_CANT_DISABLE_SELF_PART1 . ' ' . $group['name'] . ' ' . S_CUSER_ERROR_USER_CANT_DISABLE_SELF_PART2);
                     $result = false;
                     break;
                 }
                 $users_groups_id = get_dbid('users_groups', 'id');
                 $result = DBexecute('INSERT INTO users_groups (id, usrgrpid, userid) VALUES (' . $users_groups_id . ',' . $groupid . ',' . $user['userid'] . ')');
             }
         }
         /*
         			if($result && !is_null($user['user_medias'])){
         				$result = DBexecute('DELETE FROM media WHERE userid='.$userid);
         				foreach($user['user_medias'] as $media_data){
         					if(!$result) break;
         					$mediaid = get_dbid('media', 'mediaid');
         					$result = DBexecute('INSERT INTO media (mediaid, userid, mediatypeid, sendto, active, severity, period)'.
         						' VALUES ('.$mediaid.','.$userid.','.$media_data['mediatypeid'].','.
         							zbx_dbstr($media_data['sendto']).','.$media_data['active'].','.$media_data['severity'].','.
         							zbx_dbstr($media_data['period']).')');
         				}
         			}
         //*/
         // } copy from frontend
     }
     $result = self::EndTransaction($result, __METHOD__);
     if ($result) {
         return array('userids' => $userids);
     } else {
         self::setMethodErrors(__METHOD__, $errors);
         return false;
     }
 }
Ejemplo n.º 4
0
$cmbConf = new CComboBox('config', 'users.php', 'javascript: redirect(this.options[this.selectedIndex].value);');
$cmbConf->addItem('usergrps.php', S_USER_GROUPS);
$cmbConf->addItem('users.php', S_USERS);
$frmForm->addItem(array($cmbConf, new CButton('form', S_CREATE_USER)));
$user_wdgt = new CWidget();
$user_wdgt->addPageHeader(S_CONFIGURATION_OF_USERS_AND_USER_GROUPS, $frmForm);
//echo SBR;
if (isset($_REQUEST['form'])) {
    $userForm = getUserForm(get_request('userid', null));
    $user_wdgt->addItem($userForm);
} else {
    $form = new CForm(null, 'get');
    $cmbUGrp = new CComboBox('filter_usrgrpid', $_REQUEST['filter_usrgrpid'], 'submit()');
    $cmbUGrp->addItem(0, S_ALL_S);
    $options = array('output' => API_OUTPUT_EXTEND, 'sortfield' => 'name');
    $usrgrps = CUserGroup::get($options);
    foreach ($usrgrps as $ugnum => $usrgrp) {
        $cmbUGrp->addItem($usrgrp['usrgrpid'], $usrgrp['name']);
    }
    $form->addItem(array(S_USER_GROUP . SPACE, $cmbUGrp));
    $numrows = new CDiv();
    $numrows->setAttribute('name', 'numrows');
    $user_wdgt->addHeader(S_USERS_BIG, $form);
    $user_wdgt->addHeader($numrows);
    $form = new CForm(null, 'post');
    $form->setName('users');
    $table = new CTableInfo(S_NO_USERS_DEFINED);
    $table->setHeader(array(new CCheckBox('all_users', NULL, "checkAll('" . $form->getName() . "','all_users','group_userid');"), make_sorting_header(S_ALIAS, 'alias'), make_sorting_header(S_NAME, 'name'), make_sorting_header(S_SURNAME, 'surname'), make_sorting_header(S_USER_TYPE, 'type'), S_GROUPS, S_IS_ONLINE_Q, S_LOGIN, S_GUI_ACCESS, S_API_ACCESS, S_DEBUG_MODE, S_STATUS));
    // User table
    $options = array('output' => API_OUTPUT_EXTEND, 'select_usrgrps' => API_OUTPUT_EXTEND, 'get_access' => 1, 'limit' => $config['search_limit'] + 1);
    if ($_REQUEST['filter_usrgrpid'] > 0) {
Ejemplo n.º 5
0
function validate_operation($operation)
{
    if (isset($operation['esc_period']) && ($operation['esc_period'] > 0 && $operation['esc_period'] < 60)) {
        error(S_INCORRECT_ESCALATION_PERIOD);
        return false;
    }
    switch ($operation['operationtype']) {
        case OPERATION_TYPE_MESSAGE:
            switch ($operation['object']) {
                case OPERATION_OBJECT_USER:
                    $users = CUser::get(array('userids' => $operation['objectid'], 'output' => API_OUTPUT_EXTEND));
                    if (empty($users)) {
                        error(S_INCORRECT_USER);
                        return false;
                    }
                    break;
                case OPERATION_OBJECT_GROUP:
                    $usrgrps = CUserGroup::get(array('usrgrpids' => $operation['objectid'], 'output' => API_OUTPUT_EXTEND));
                    if (empty($usrgrps)) {
                        error(S_INCORRECT_GROUP);
                        return false;
                    }
                    break;
                default:
                    error(S_INCORRECT_OBJECT_TYPE);
                    return false;
            }
            break;
        case OPERATION_TYPE_COMMAND:
            return validate_commands($operation['longdata']);
        case OPERATION_TYPE_HOST_ADD:
        case OPERATION_TYPE_HOST_REMOVE:
        case OPERATION_TYPE_HOST_ENABLE:
        case OPERATION_TYPE_HOST_DISABLE:
            break;
        case OPERATION_TYPE_GROUP_ADD:
        case OPERATION_TYPE_GROUP_REMOVE:
            $groups = CHostGroup::get(array('groupids' => $operation['objectid'], 'output' => API_OUTPUT_SHORTEN, 'editable' => 1));
            if (empty($groups)) {
                error(S_INCORRECT_GROUP);
                return false;
            }
            break;
        case OPERATION_TYPE_TEMPLATE_ADD:
        case OPERATION_TYPE_TEMPLATE_REMOVE:
            $tpls = CTemplate::get(array('templateids' => $operation['objectid'], 'output' => API_OUTPUT_SHORTEN, 'editable' => 1));
            if (empty($tpls)) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        default:
            error(S_INCORRECT_OPERATION_TYPE);
            return false;
    }
    return true;
}
Ejemplo n.º 6
0
 $table->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $form->getName() . "','all_scripts','scripts');"), make_sorting_header(S_NAME, 'name'), make_sorting_header(S_COMMAND, 'command'), S_USER_GROUP, S_HOST_GROUP, S_HOST_ACCESS));
 $sortfield = getPageSortField('name');
 $sortorder = getPageSortOrder();
 $options = array('output' => API_OUTPUT_EXTEND, 'editable' => 1, 'select_groups' => API_OUTPUT_EXTEND);
 $scripts = CScript::get($options);
 // sorting
 order_result($scripts, $sortfield, $sortorder);
 // PAGING UPPER
 $paging = getPagingLine($scripts);
 $scripts_wdgt->addItem($paging);
 //---------
 foreach ($scripts as $snum => $script) {
     $scriptid = $script['scriptid'];
     $user_group_name = S_ALL_S;
     if ($script['usrgrpid'] > 0) {
         $user_group = CUserGroup::get(array('usrgrpids' => $script['usrgrpid'], 'extendoutput' => 1));
         $user_group = reset($user_group);
         $user_group_name = $user_group['name'];
     }
     $host_group_name = S_ALL_S;
     if ($script['groupid'] > 0) {
         $group = array_pop($script['groups']);
         $host_group_name = $group['name'];
     }
     $table->addRow(array(new CCheckBox('scripts[' . $script['scriptid'] . ']', 'no', NULL, $script['scriptid']), new CLink($script['name'], 'scripts.php?form=1' . '&scriptid=' . $script['scriptid'] . '#form'), htmlspecialchars($script['command']), $user_group_name, $host_group_name, PERM_READ_WRITE == $script['host_access'] ? S_WRITE : S_READ));
 }
 // PAGING FOOTER
 $table->addRow(new CCol($paging));
 //		$items_wdgt->addItem($paging);
 //---------
 //----- GO ------
Ejemplo n.º 7
0
     }
     $hosts = CHost::get($options);
     $objects = array_merge($templates, $hosts);
     foreach ($objects as $row) {
         $name = new CSpan($row['host'], 'link');
         $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
         $name->setAttribute('onclick', $action . " close_window(); return false;");
         $table->addRow($name);
     }
     $table->show();
 } else {
     if ($srctbl == 'usrgrp') {
         $table = new CTableInfo(S_NO_GROUPS_DEFINED);
         $table->setHeader(array(S_NAME));
         $options = array('nodeids' => $nodeid, 'output' => API_OUTPUT_EXTEND);
         $usergroups = CUserGroup::get($options);
         order_result($usergroups, 'name');
         foreach ($usergroups as $tnu => $row) {
             $name = new CSpan(get_node_name_by_elid($row['usrgrpid'], null, ': ') . $row['name'], 'link');
             $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
             $name->onClick($action . ' close_window(); return false;');
             $table->addRow($name);
         }
         $table->show();
     } else {
         if ($srctbl == 'users') {
             $table = new CTableInfo(S_NO_USERS_DEFINED);
             $table->setHeader(array(S_ALIAS, S_NAME, S_SURNAME));
             $options = array('nodeids' => $nodeid, 'output' => API_OUTPUT_EXTEND);
             $users = CUser::get($options);
             order_result($users, 'alias');
Ejemplo n.º 8
0
 private static function usergroup($action, $params)
 {
     CUserGroup::$error = array();
     switch ($action) {
         default:
             $result = call_user_func(array('CUserGroup', $action), $params);
     }
     self::$result = $result;
 }
Ejemplo n.º 9
0
function insert_usergroups_form()
{
    $frm_title = S_USER_GROUP;
    if (isset($_REQUEST['usrgrpid'])) {
        $usrgrp = CUserGroup::get(array('usrgrpids' => $_REQUEST['usrgrpid'], 'extendoutput' => 1));
        $usrgrp = reset($usrgrp);
        $frm_title = S_USER_GROUP . ' "' . $usrgrp['name'] . '"';
    }
    if (isset($_REQUEST['usrgrpid']) && !isset($_REQUEST['form_refresh'])) {
        $name = $usrgrp['name'];
        $users_status = $usrgrp['users_status'];
        $gui_access = $usrgrp['gui_access'];
        $api_access = $usrgrp['api_access'];
        $debug_mode = $usrgrp['debug_mode'];
        $group_users = array();
        $sql = 'SELECT DISTINCT u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . $_REQUEST['usrgrpid'];
        $db_users = DBselect($sql);
        while ($db_user = DBfetch($db_users)) {
            $group_users[$db_user['userid']] = $db_user['userid'];
        }
        $group_rights = array();
        $sql = 'SELECT r.*, n.name as node_name, g.name as name ' . ' FROM groups g ' . ' LEFT JOIN rights r on r.id=g.groupid ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE r.groupid=' . $_REQUEST['usrgrpid'];
        $db_rights = DBselect($sql);
        while ($db_right = DBfetch($db_rights)) {
            if (isset($db_right['node_name'])) {
                $db_right['name'] = $db_right['node_name'] . ':' . $db_right['name'];
            }
            $group_rights[$db_right['id']] = array('permission' => $db_right['permission'], 'name' => $db_right['name'], 'id' => $db_right['id']);
        }
    } else {
        $name = get_request('gname', '');
        $users_status = get_request('users_status', GROUP_STATUS_ENABLED);
        $gui_access = get_request('gui_access', GROUP_GUI_ACCESS_SYSTEM);
        $api_access = get_request('api_access', GROUP_API_ACCESS_DISABLED);
        $debug_mode = get_request('debug_mode', GROUP_DEBUG_MODE_DISABLED);
        $group_users = get_request('group_users', array());
        $group_rights = get_request('group_rights', array());
    }
    $perm_details = get_request('perm_details', 0);
    order_result($group_rights, 'name');
    $frmUserG = new CFormTable($frm_title, 'usergrps.php');
    $frmUserG->setHelp('web.users.groups.php');
    if (isset($_REQUEST['usrgrpid'])) {
        $frmUserG->addVar('usrgrpid', $_REQUEST['usrgrpid']);
    }
    $grName = new CTextBox('gname', $name, 49);
    $grName->attributes['style'] = 'width: 280px';
    $frmUserG->addRow(S_GROUP_NAME, $grName);
    $frmUserG->addVar('group_rights', $group_rights);
    /////////////////
    // create table header +
    $selusrgrp = get_request('selusrgrp', 0);
    $cmbGroups = new CComboBox('selusrgrp', $selusrgrp, 'submit()');
    $cmbGroups->addItem(0, S_ALL_S);
    $sql = 'SELECT usrgrpid, name FROM usrgrp WHERE ' . DBin_node('usrgrpid') . ' ORDER BY name';
    $result = DBselect($sql);
    while ($row = DBfetch($result)) {
        $cmbGroups->addItem($row['usrgrpid'], $row['name']);
    }
    // -
    // create user twinbox +
    $user_tb = new CTweenBox($frmUserG, 'group_users', $group_users, 10);
    $sql_from = '';
    $sql_where = '';
    if ($selusrgrp > 0) {
        $sql_from = ', users_groups g ';
        $sql_where = ' AND u.userid=g.userid AND g.usrgrpid=' . $selusrgrp;
    }
    $sql = 'SELECT DISTINCT u.userid, u.alias ' . ' FROM users u ' . $sql_from . ' WHERE ' . DBcondition('u.userid', $group_users) . ' OR (' . DBin_node('u.userid') . $sql_where . ' ) ORDER BY u.alias';
    $result = DBselect($sql);
    while ($row = DBfetch($result)) {
        $user_tb->addItem($row['userid'], $row['alias']);
    }
    $frmUserG->addRow(S_USERS, $user_tb->get(S_IN . SPACE . S_GROUP, array(S_OTHER . SPACE . S_GROUPS . SPACE . '|' . SPACE, $cmbGroups)));
    // -
    /////////////////
    /*
    		$lstUsers = new CListBox('group_users_to_del[]');
    		$lstUsers->attributes['style'] = 'width: 280px';
    
    		foreach($group_users as $userid => $alias){
    			$lstUsers->addItem($userid,	$alias);
    		}
    
    		$frmUserG->addRow(S_USERS,
    			array(
    				$lstUsers,
    				BR(),
    				new CButton('add_user',S_ADD,
    					"return PopUp('popup_users.php?dstfrm=".$frmUserG->getName().
    					"&list_name=group_users_to_del[]&var_name=group_users',600,300);"),
    				(count($group_users) > 0) ? new CButton('del_group_user',S_DELETE_SELECTED) : null
    			));
    */
    /////////////////
    $granted = true;
    if (isset($_REQUEST['usrgrpid'])) {
        $granted = granted2update_group($_REQUEST['usrgrpid']);
    }
    if ($granted) {
        $cmbGUI = new CComboBox('gui_access', $gui_access);
        $cmbGUI->addItem(GROUP_GUI_ACCESS_SYSTEM, user_auth_type2str(GROUP_GUI_ACCESS_SYSTEM));
        $cmbGUI->addItem(GROUP_GUI_ACCESS_INTERNAL, user_auth_type2str(GROUP_GUI_ACCESS_INTERNAL));
        $cmbGUI->addItem(GROUP_GUI_ACCESS_DISABLED, user_auth_type2str(GROUP_GUI_ACCESS_DISABLED));
        $frmUserG->addRow(S_GUI_ACCESS, $cmbGUI);
        $cmbStat = new CComboBox('users_status', $users_status);
        $cmbStat->addItem(GROUP_STATUS_ENABLED, S_ENABLED);
        $cmbStat->addItem(GROUP_STATUS_DISABLED, S_DISABLED);
        $frmUserG->addRow(S_USERS_STATUS, $cmbStat);
    } else {
        $frmUserG->addVar('gui_access', $gui_access);
        $frmUserG->addRow(S_GUI_ACCESS, new CSpan(user_auth_type2str($gui_access), 'green'));
        $frmUserG->addVar('users_status', GROUP_STATUS_ENABLED);
        $frmUserG->addRow(S_USERS_STATUS, new CSpan(S_ENABLED, 'green'));
    }
    $cmbAPI = new CComboBox('api_access', $api_access);
    $cmbAPI->addItem(GROUP_API_ACCESS_ENABLED, S_ENABLED);
    $cmbAPI->addItem(GROUP_API_ACCESS_DISABLED, S_DISABLED);
    $frmUserG->addRow(S_API_ACCESS, $cmbAPI);
    $cmbDebug = new CComboBox('debug_mode', $debug_mode);
    $cmbDebug->addItem(GROUP_DEBUG_MODE_ENABLED, S_ENABLED);
    $cmbDebug->addItem(GROUP_DEBUG_MODE_DISABLED, S_DISABLED);
    $frmUserG->addRow(S_DEBUG_MODE, $cmbDebug);
    $table_Rights = new CTable(S_NO_RIGHTS_DEFINED, 'right_table');
    $lstWrite = new CListBox('right_to_del[read_write][]', null, 20);
    $lstRead = new CListBox('right_to_del[read_only][]', null, 20);
    $lstDeny = new CListBox('right_to_del[deny][]', null, 20);
    foreach ($group_rights as $id => $element_data) {
        if ($element_data['permission'] == PERM_DENY) {
            $lstDeny->addItem($id, $element_data['name']);
        } else {
            if ($element_data['permission'] == PERM_READ_ONLY) {
                $lstRead->addItem($id, $element_data['name']);
            } else {
                if ($element_data['permission'] == PERM_READ_WRITE) {
                    $lstWrite->addItem($id, $element_data['name']);
                }
            }
        }
    }
    $table_Rights->setHeader(array(S_READ_WRITE, S_READ_ONLY, S_DENY), 'header');
    $table_Rights->addRow(array(new CCol($lstWrite, 'read_write'), new CCol($lstRead, 'read_only'), new CCol($lstDeny, 'deny')));
    $table_Rights->addRow(array(array(new CButton('add_read_write', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $frmUserG->getName() . "&permission=" . PERM_READ_WRITE . "',450,450);"), new CButton('del_read_write', S_DELETE_SELECTED)), array(new CButton('add_read_only', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $frmUserG->getName() . "&permission=" . PERM_READ_ONLY . "',450,450);"), new CButton('del_read_only', S_DELETE_SELECTED)), array(new CButton('add_deny', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $frmUserG->getName() . "&permission=" . PERM_DENY . "',450,450);"), new CButton('del_deny', S_DELETE_SELECTED))));
    $frmUserG->addRow(S_RIGHTS, $table_Rights);
    $frmUserG->addVar('perm_details', $perm_details);
    $link = new CSpan($perm_details ? S_HIDE : S_SHOW, 'link');
    $link->onClick("return create_var('" . $frmUserG->getName() . "','perm_details'," . ($perm_details ? 0 : 1) . ", true);");
    $resources_list = array(S_RIGHTS_OF_RESOURCES, SPACE . '(', $link, ')');
    $frmUserG->addSpanRow($resources_list, 'right_header');
    if ($perm_details) {
        $frmUserG->addSpanRow(get_rights_of_elements_table($group_rights));
    }
    $frmUserG->addItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['usrgrpid'])) {
        $frmUserG->addItemToBottomRow(SPACE);
        $frmUserG->addItemToBottomRow(new CButtonDelete('Delete selected group?', url_param('form') . url_param('usrgrpid')));
    }
    $frmUserG->addItemToBottomRow(SPACE);
    $frmUserG->addItemToBottomRow(new CButtonCancel());
    return $frmUserG;
}
Ejemplo n.º 10
0
     $tblOper->addItem(new CVar('new_operation[esc_period]', $new_operation['esc_period']));
     $tblOper->addItem(new CVar('new_operation[esc_step_from]', $new_operation['esc_step_from']));
     $tblOper->addItem(new CVar('new_operation[esc_step_to]', $new_operation['esc_step_to']));
     $tblOper->addItem(new CVar('new_operation[evaltype]', $new_operation['evaltype']));
 }
 $cmbOpType = new CComboBox('new_operation[operationtype]', $new_operation['operationtype'], 'submit()');
 foreach ($allowed_operations as $oper) {
     $cmbOpType->addItem($oper, operation_type2str($oper));
 }
 $tblNewOperation->addRow(array(S_OPERATION_TYPE, $cmbOpType));
 switch ($new_operation['operationtype']) {
     case OPERATION_TYPE_MESSAGE:
         if ($new_operation['object'] == OPERATION_OBJECT_GROUP) {
             $object_srctbl = 'usrgrp';
             $object_srcfld1 = 'usrgrpid';
             $object_name = CUserGroup::get(array('usrgrpids' => $new_operation['objectid'], 'output' => API_OUTPUT_EXTEND));
             $object_name = reset($object_name);
             $display_name = 'name';
         } else {
             $object_srctbl = 'users';
             $object_srcfld1 = 'userid';
             $object_name = CUser::get(array('userids' => $new_operation['objectid'], 'output' => API_OUTPUT_EXTEND));
             $object_name = reset($object_name);
             $display_name = 'alias';
         }
         $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid']));
         if ($object_name) {
             $object_name = $object_name[$display_name];
         }
         $cmbObject = new CComboBox('new_operation[object]', $new_operation['object'], 'submit()');
         $cmbObject->addItem(OPERATION_OBJECT_USER, S_SINGLE_USER);