Beispiel #1
0
                <?php 
echo _('Group');
?>
:
            </td>
            <td>
                <input type="hidden" name="mac" value="<?php 
echo $user['mac'];
?>
">
                <select name="group_id">
                <option value="0">--------</option>
                <?php 
$stb_groups = new StbGroup();
$all_groups = $stb_groups->getAll();
$member = $stb_groups->getMemberByUid(intval($_GET['id']));
foreach ($all_groups as $group) {
    $selected = '';
    if (!empty($member) && $member['stb_group_id'] == $group['id']) {
        $selected = 'selected';
    }
    echo '<option value="' . $group['id'] . '" ' . $selected . '>' . $group['name'] . '</option>';
}
?>
            </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="submit" name="account" />
 private function saveUsersData(&$form, $edit = FALSE)
 {
     if (!empty($this->method) && $this->method == 'POST') {
         $form->handleRequest($this->request);
         $data = $form->getData();
         $action = isset($this->user) ? 'updateUserById' : 'insertUsers';
         if (array_key_exists('password', $data) && $edit && empty($data['password'])) {
             unset($data['password']);
         }
         if ($form->isValid()) {
             $stb_groups = new \StbGroup();
             $member = $stb_groups->getMemberByUid(intval($data['id']));
             $id = $data['id'];
             if (empty($member)) {
                 $stb_groups->addMember(array('mac' => \Middleware::normalizeMac($data['mac']), 'uid' => \Middleware::getUidByMac($data['mac']), 'stb_group_id' => $data['group_id']));
             } else {
                 $stb_groups->setMember(array('stb_group_id' => $data['group_id']), $member['id']);
             }
             $curr_fields = $this->db->getTableFields('users');
             $curr_fields = $this->getFieldFromArray($curr_fields, 'Field');
             $curr_fields = array_flip($curr_fields);
             $data = array_intersect_key($data, $curr_fields);
             $match = array();
             if (!empty($data['expire_billing_date']) && preg_match("/(0[1-9]|[12][0-9]|3[01])([- \\/\\.])(0[1-9]|1[012])[- \\/\\.](19|20)\\d\\d/im", $data['expire_billing_date'], $match)) {
                 $data['expire_billing_date'] = implode('-', array_reverse(explode($match[2], $data['expire_billing_date'])));
             } else {
                 $data['expire_billing_date'] = 0;
             }
             if ($data['reseller_id'] == '-') {
                 $data['reseller_id'] = NULL;
             }
             if (!empty($this->user) && array_key_exists('status', $this->user) && (int) $this->user['status'] != (int) $data['status']) {
                 $data['last_change_status'] = FALSE;
                 $event = new \SysEvent();
                 $event->setUserListById($data['id']);
                 if ((int) $data['status'] == 0) {
                     $event->sendCutOn();
                 } else {
                     $event->sendCutOff();
                 }
             } else {
                 unset($data['last_change_status']);
             }
             unset($data['version']);
             $result = call_user_func_array(array($this->db, $action), array($data, $data['id']));
             if (!empty($this->postData['tariff_plan_packages'])) {
                 $this->changeUserPlanPackages($id, $this->postData['tariff_plan_packages']);
             }
             return TRUE;
         }
     }
     return FALSE;
 }