Пример #1
0
 function getUsers()
 {
     $snm =& session_get_manager();
     $users = $snm->user->getList(false, false, 'lastname', 'asc');
     if (!$users) {
         return array();
     }
     foreach ($users as $k => $v) {
         if (!empty($v->lastname)) {
             $users[$v->username] = $v->lastname . ', ' . $v->firstname;
         } else {
             $users[$v->username] = $v->username;
         }
         unset($users[$k]);
     }
     return $users;
 }
Пример #2
0
<?php

$types = array('users' => 'user', 'roles' => 'role', 'teams' => 'team', 'resources' => 'resource', 'statuses' => 'status', 'accesslevels' => 'access');
$names = array('users' => 'user', 'roles' => 'role', 'teams' => 'team', 'resources' => 'resource', 'statuses' => 'status', 'accesslevels' => 'access level');
global $cgi;
if (!in_array($cgi->_list, array_keys($types))) {
    header('Location: ' . site_prefix() . '/index/usradm-browse-action');
    exit;
}
$snm =& session_get_manager();
$form =& $snm->{$types[$cgi->_list]}->getAddForm();
if ($form->invalid($cgi)) {
    $form->setValues($cgi);
    echo '<h1>' . intl_get('Adding') . ': ' . $names[$cgi->_list] . '</h1>' . NEWLINEx2;
    echo $form->show();
} else {
    $form->setValues($cgi);
    $vals = $form->getValues();
    unset($vals['_list']);
    unset($vals['submit_button']);
    $res = $snm->{$types[$cgi->_list]}->add($vals);
    if (!$res) {
        die($snm->{$types[$cgi->_list]}->error);
    }
    echo '<h1>' . intl_get('Added') . ' ' . $names[$cgi->_list] . '</h1>' . NEWLINEx2;
    echo template_simple('<p><a href="{site/prefix}/index/usradm-browse-action?list={cgi/_list}">Back</a></p>');
}
exit;
Пример #3
0
    /**
     * Generate a form for editing items in this list.
     *
     * @return object saf.MailForm object
     */
    function &getEditForm($item)
    {
        loader_import('saf.MailForm');
        $form = new MailForm();
        $form->action = site_prefix() . '/index/usradm-edit-user-action';
        $form->error_mode = 'all';
        loader_import('ext.phpsniff');
        $sniffer = new phpSniff();
        $form->_browser = $sniffer->property('browser');
        $user = session_user_get($item);
        $form->addWidget('hidden', '_list');
        page_add_script('
			formhelp_prepend = \'<table border="0" cellpadding="0"><tr><td width="12" valign="top"><img src="' . site_prefix() . '/inc/app/cms/pix/arrow-10px.gif" alt="" border="0" /></td><td valign="top">\';
			formhelp_append = \'</td></tr></table>\';
		');
        $w =& $form->addWidget('tab', 'tab1');
        $w->title = intl_get('Account');
        $w =& $form->addWidget('info', '_key');
        $w->alt = intl_get('Username');
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('password', 'passwd');
        $w->alt = intl_get('Password');
        $w =& $form->addWidget('password', 'password_verify');
        $w->alt = intl_get('Verify Password');
        $w->addRule('equals "passwd"', intl_get('Passwords do not match.'));
        $w->ignoreEmpty = false;
        $w =& $form->addWidget('text', 'firstname');
        $w->alt = intl_get('First Name');
        //$w->addRule ('not empty', intl_get ('First name must not be empty.'));
        $w->setValue($user->firstname);
        $w->extra = 'maxlength="32"';
        $w =& $form->addWidget('text', 'lastname');
        $w->alt = intl_get('Last Name');
        //$w->addRule ('not empty', intl_get ('Last name must not be empty.'));
        $w->setValue($user->lastname);
        $w->extra = 'maxlength="32"';
        $w =& $form->addWidget('text', 'email');
        $w->alt = intl_get('Email');
        //$w->addRule ('not empty', intl_get ('Email must not be empty.'));
        //$w->addRule ('contains "@"', intl_get ('Email does not appear to be valid.'));
        $w->setValue($user->email);
        $w->extra = 'maxlength="42"';
        $snm =& session_get_manager();
        $list = assocify(array_keys($snm->role->getList()));
        unset($list['anonymous']);
        unset($list['']);
        $w =& $form->addWidget('select', 'role');
        $w->alt = intl_get('Role');
        $w->setValues($list);
        $w->setValue($user->role);
        $w->extra = 'id="role"';
        $w =& $form->addWidget('select', 'team');
        $w->alt = intl_get('Team');
        $w->setValues(assocify(array_keys($snm->team->getList())));
        $w->setValue($user->team);
        $w->extra = 'id="team"';
        $w =& $form->addWidget('select', 'disabled');
        $w->alt = intl_get('Disabled');
        $w->setValues(array('yes' => 'Yes', 'no' => 'No'));
        $w->setValue($user->disabled);
        $w->extra = 'id="disabled"';
        $w =& $form->addWidget('select', 'public');
        $w->alt = intl_get('Public');
        $w->setValues(array('yes' => 'Yes', 'no' => 'No'));
        $w->setValue($user->public);
        $w->extra = 'id="public"';
        $w =& $form->addWidget('textarea', 'profile');
        $w->alt = intl_get('Profile');
        $w->setValue($user->profile);
        $w->labelPosition = 'left';
        $w->rows = 5;
        $w->extra = 'id="profile"';
        $w =& $form->addWidget('textarea', 'sig');
        $w->alt = intl_get('Signature (for comments)');
        $w->setValue($user->sig);
        $w->labelPosition = 'left';
        $w->rows = 3;
        $w->extra = 'id="sig"';
        $w =& $form->addWidget('info', 'registered');
        $w->alt = intl_get('Date Registered');
        $w->setValue(loader_call('saf.Date', 'Date::timestamp', $user->registered, 'F jS, Y - g:i A'));
        $w =& $form->addWidget('info', 'modified');
        $w->alt = intl_get('Date Last Modified');
        $w->setValue(loader_call('saf.Date', 'Date::timestamp', $user->modified, 'F jS, Y - g:i A'));
        $w =& $form->addWidget('tab', 'tab2');
        $w->title = intl_get('Contact');
        $w =& $form->addWidget('text', 'company');
        $w->alt = intl_get('Company');
        $w->setValue($user->company);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('text', 'position');
        $w->alt = intl_get('Position');
        $w->setValue($user->position);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('text', 'website');
        $w->alt = intl_get('Web Site');
        if (!empty($user->website)) {
            $w->setValue($user->website);
        } else {
            $w->setValue('http://');
        }
        $w->extra = 'maxlength="72"';
        $w =& $form->addWidget('text', 'phone');
        $w->alt = intl_get('Phone #');
        $w->setValue($user->phone);
        $w->extra = 'maxlength="24"';
        $w =& $form->addWidget('text', 'cell');
        $w->alt = intl_get('Cell #');
        $w->setValue($user->cell);
        $w->extra = 'maxlength="24"';
        $w =& $form->addWidget('text', 'fax');
        $w->alt = intl_get('Fax #');
        $w->setValue($user->fax);
        $w->extra = 'maxlength="24"';
        $w =& $form->addWidget('text', 'sms_address');
        $w->alt = intl_get('SMS #');
        $w->setValue($user->sms_address);
        $w->extra = 'maxlength="72"';
        $w =& $form->addWidget('text', 'jabber_id');
        $w->alt = intl_get('Jabber ID');
        $w->setValue($user->jabber_id);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('text', 'address1');
        $w->alt = intl_get('Address');
        $w->setValue($user->address1);
        $w->extra = 'maxlength="72"';
        $w =& $form->addWidget('text', 'address2');
        $w->alt = intl_get('Address Line 2');
        $w->setValue($user->address2);
        $w->extra = 'maxlength="72"';
        $w =& $form->addWidget('text', 'city');
        $w->alt = intl_get('City');
        $w->setValue($user->city);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('text', 'province');
        $w->alt = intl_get('Province/State');
        $w->setValue($user->province);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('text', 'postal_code');
        $w->alt = intl_get('Postal/Zip Code');
        $w->setValue($user->postal_code);
        $w->extra = 'maxlength="16"';
        $w =& $form->addWidget('text', 'country');
        $w->alt = intl_get('Country');
        $w->setValue($user->country);
        $w->extra = 'maxlength="48"';
        $w =& $form->addWidget('tab', 'tab3');
        $w->title = intl_get('Access');
        $w =& $form->addWidget('usradm.Widget.Allowedbox', 'teams');
        $w->alt = 'Allowed Teams';
        $w->headers[] = '&nbsp;';
        $w->headers[] = intl_get('Read');
        $w->headers[] = intl_get('Write');
        $b =& $w->addButton('all', array('r' => '', 'w' => ''));
        $b->alt = '<strong>All</strong>';
        $teams = unserialize($user->teams);
        if (isset($teams['all'])) {
            $b->setValue(assocify(preg_split('//', $teams['all'], -1, PREG_SPLIT_NO_EMPTY)));
        }
        foreach (session_get_teams() as $value) {
            $b =& $w->addButton($value, array('r' => '', 'w' => ''));
            $b->alt = ucwords(str_replace('_', ' ', $value));
            $b->setValue(assocify(preg_split('//', $teams[$value], -1, PREG_SPLIT_NO_EMPTY)));
        }
        $w =& $form->addWidget('tab', 'tab-end');
        $w =& $form->addWidget('msubmit', 'submit_button');
        $b =& $w->getButton();
        $b->setValues(intl_get('Save'));
        $b =& $w->addButton('cancel_button');
        $b->setValues(intl_get('Cancel'));
        $b->extra = 'onclick="window.location.href = \'' . site_prefix() . '/index/usradm-browse-action?list=users\'; return false"';
        return $form;
    }