Пример #1
0
 /**
  * Edit form by admin
  */
 public function edit_form_by_admin($id = null)
 {
     //turn access
     $this->ACL->turn(array('users', 'edit_users'));
     $id = (int) $id;
     if ($id < 1) {
         redirect('/users/');
     }
     if (!isset($_SESSION['user'])) {
         redirect('/');
     }
     $statusArray = $this->Register['ACL']->get_group_info();
     if (!empty($statusArray)) {
         unset($statusArray[0]);
     }
     $markers = array();
     // Получаем данные о пользователе из БД
     $user = $this->Model->getById($id);
     if (count($user) == 0) {
         return $this->showInfoMessage(__('Can not find user'), '/users/');
     }
     if (is_object($this->AddFields) && count($user) > 0) {
         $user = $this->AddFields->mergeRecords(array($user), true);
         $user = $user[0];
     }
     // Check for preview or errors
     $data = array('name' => null, 'email' => null, 'timezone' => null, 'icq' => null, 'jabber' => null, 'pol' => null, 'city' => null, 'telephone' => null, 'byear' => null, 'bmonth' => null, 'bday' => null, 'url' => null, 'about' => null, 'signature' => null);
     $data = Validate::getCurrentInputsValues($user, $data);
     $markers['errors'] = $this->Register['Validate']->getErrors();
     if (isset($_SESSION['FpsForm'])) {
         unset($_SESSION['FpsForm']);
     }
     $fpol = $data->getPol() && $data->getPol() === 'f' || $data->getPol() === '2' ? ' checked="checked"' : '';
     $data->setFpol($fpol);
     $mpol = $data->getPol() && $data->getPol() === 'm' || $data->getPol() === '1' ? ' checked="checked"' : '';
     $data->setMpol($mpol);
     $markers['action'] = get_url('/users/update_by_admin/' . $id);
     if ($data->getPol() === 'f') {
         $data->setPol(__('f'));
     } else {
         if ($data->getPol() === 'm') {
             $data->setPol(__('m'));
         } else {
             $data->setPol(__('no gender'));
         }
     }
     if (file_exists(ROOT . '/sys/avatars/' . $data->getId() . '.jpg')) {
         $data->setAvatar(get_url('/sys/avatars/' . $data->getId() . '.jpg'));
     } else {
         $data->setAvatar(get_url('/sys/img/noavatar.png'));
     }
     $options = '';
     for ($i = -12; $i <= 12; $i++) {
         if ($i < 1) {
             $value = $i . __('Hours');
         } else {
             $value = '+' . $i . __('Hours');
         }
         if ($data->getTimezone() && $i == $data->getTimezone() || $i == 0 && !$data->getTimezone()) {
             $options = $options . '<option value="' . $i . '" selected>' . $value . '</option>' . "\n";
         } else {
             $options = $options . '<option value="' . $i . '">' . $value . '</option>' . "\n";
         }
     }
     $markers['options'] = $options;
     $markers['servertime'] = date("d.m.Y H:i:s");
     $data->setByears_selector(createOptionsFromParams(1950, 2008, $data->getByear()));
     $data->setBmonth_selector(createOptionsFromParams(1, 12, $data->getBmonth()));
     $data->setBday_selector(createOptionsFromParams(1, 31, $data->getBday()));
     $unlinkfile = '';
     if (is_file(ROOT . '/sys/avatars/' . $_SESSION['user']['id'] . '.jpg')) {
         $unlinkfile = '<input type="checkbox" name="unlink" value="1" />' . __('Are you want delete file') . "\n";
     }
     $markers['unlinkfile'] = $unlinkfile;
     $userStatus = '<select name="status">' . "\n";
     foreach ($statusArray as $key => $value) {
         if ($key == $data->getStatus()) {
             $userStatus = $userStatus . '<option value="' . $key . '" selected>' . $value['title'] . '</option>' . "\n";
         } else {
             $userStatus = $userStatus . '<option value="' . $key . '">' . $value['title'] . '</option>' . "\n";
         }
     }
     $userStatus = $userStatus . '</select>' . "\n";
     $data->setStatus($userStatus);
     $data->setOldemail(h($user->getEmail()));
     $activation = $user->getActivation() ? __('Activate') . ' <input name="activation" type="checkbox" value="1" >' : __('Active');
     $data->setActivation($activation);
     // Navigation Panel
     $nav = array();
     $nav['navigation'] = get_link(__('Home'), '/') . __('Separator') . get_link(h($this->module_title), '/users/') . __('Separator') . __('Editing');
     $this->_globalize($nav);
     $markers['user'] = $data;
     $source = $this->render('edituserformbyadmin.html', array('context' => $markers));
     return $this->_view($source);
 }
Пример #2
0
function editAnk(&$page_title)
{
    $Register = Register::getInstance();
    $FpsDB = $Register['DB'];
    $ACL = $Register['ACL'];
    if (!is_numeric($_GET['id'])) {
        redirect('/admin/users_list.php');
    }
    $page_title = __('Edit user');
    $content = '';
    $statuses = $ACL->get_group_info();
    $query = $FpsDB->select('users', DB_FIRST, array('cond' => array('id' => $_GET['id'])));
    if (empty($query)) {
        return '<span style="color:red;">' . __('Can not find user') . '</span>';
    }
    foreach ($query[0] as $key => $value) {
        ${$key} = !empty($_SESSION['edit_ank'][$key]) ? $_SESSION['edit_ank'][$key] : $value;
    }
    $telephone = empty($telephone) ? '' : intval($telephone);
    $mpol = !empty($query[0]['pol']) && $query[0]['pol'] === 'm' ? 'checked="checked"' : '';
    $fpol = !empty($query[0]['pol']) && $query[0]['pol'] === 'f' ? 'checked="checked"' : '';
    if (!empty($_SESSION['edit_ank']['errors'])) {
        $content .= '<script type="text/javascript">showHelpWin(\'' . $_SESSION['edit_ank']['errors'] . '\', \'Ошибки\');</script>';
    }
    unset($_SESSION['edit_ank']);
    $_SESSION['adm_form_key'] = md5(rand() . rand());
    $content .= '<form action="users_list.php?ac=save&id=' . $_GET['id'] . '" method="POST"><div class="list">
			<div class="title">' . __('Edit user') . ' (' . h($name) . ')</div>
			<div class="level1">
				<div class="items">
					<div class="setting-item">
						<div class="left">
							' . __('Name') . '
						</div>
						<div class="right">
							<input type="hidden" value="' . $_SESSION['adm_form_key'] . '" name="adm_form_key" />
							<input type="text" name="login" value="' . h($name) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Rank') . '
						</div>
						<div class="right">
							<input type="text" name="state" value="' . h($state) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Password') . '
						</div>
						<div class="right">
							<input type="text" name="passw" value="" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Email') . '
						</div>
						<div class="right">
							<input type="text" name="email" value="' . h($email) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Site') . '
						</div>
						<div class="right">
							<input type="text" name="url" value="' . h($url) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							ICQ
						</div>
						<div class="right">
							<input type="text" name="icq" value="' . h($icq) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							Jabber
						</div>
						<div class="right">
							<input type="text" name="jabber" value="' . h($jabber) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('City') . '
						</div>
						<div class="right">
							<input type="text" name="city" value="' . h($city) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Telephone') . '
						</div>
						<div class="right">
							<input type="text" name="telephone" value="' . h($telephone) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Gender') . '
						</div>
						<div class="right">
							<input type="radio" name="pol" value="m" ' . $mpol . ' id="polm" /><label for="polm">М</label><br /><br />
							<input type="radio" name="pol" value="f" ' . $fpol . ' id="polj" /><label for="polj">Ж</label>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Birth date') . '
						</div>
						<div class="right">
							<select style="width:80px;" name="byear">' . createOptionsFromParams(1970, 2008, $byear) . '</select>
							<select style="width:50px;" name="bmonth">' . createOptionsFromParams(1, 12, $bmonth) . '</select>
							<select style="width:50px;" name="bday">' . createOptionsFromParams(1, 31, $bday) . '</select>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Interests') . '
						</div>
						<div class="right">
							<textarea name="about" style="height:100px;">' . h($about) . '</textarea>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Signature') . '
						</div>
						<div class="right">
							<textarea  style="height:100px;" name="signature" />' . h($signature) . '</textarea>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							Бан
						</div>
						<div class="right">
							<select name="locked">';
    if ($locked == 0) {
        $content .= '<option value="1">' . __('Banned') . '</option>
											<option value="0" selected="selected">' . __('Unbanned') . '</option>';
    } else {
        $content .= '<option value="1" selected="selected">' . __('Banned') . '</option>
											<option value="0">' . __('Unbanned') . '</option>';
    }
    $content .= '</select>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Group') . '
						</div>
						<div class="right">
							<select name="status">';
    foreach ($statuses as $key => $value) {
        if ($key == 0) {
            continue;
        }
        $content .= $status == $key ? '<option value="' . $key . '" selected="selected">' . $value['title'] . '</option>' : '<option value="' . $key . '">' . $value['title'] . '</option>';
    }
    $activation = !empty($activation) ? '<input id="activation" name="activation" type="checkbox" value="1" ><label for="activation">' . __('Activate') . '</label>' : '<span style="color:blue;">' . __('Active') . '</span>';
    $content .= '</select>
						</div>
						<div class="clear"></div>
					</div>
					<div class="setting-item">
						<div class="left">
							' . __('Activation') . '
						</div>
						<div class="right">
							' . $activation . '
						</div>
						<div class="clear"></div>
					</div>

					<div class="setting-item">
						<div class="left">
						</div>
						<div class="right">
							<input class="save-button" type="submit" name="send" value="' . __('Save') . '" />
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</div></form>';
    return $content;
}