Example #1
0
 /**
  * Returns the groups the user is part of
  *
  * @return array An array of group id's
  */
 public function getGroups()
 {
     $data = $this->getData();
     $groups = KObjectConfig::unbox($data->groups);
     if (empty($groups)) {
         $this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
     }
     return parent::getGroups();
 }
Example #2
0
 function _process_activation()
 {
     global $FUNCS, $DB, $AUTH;
     $data = $_GET['key'];
     $data = str_replace(' ', '+', $data);
     list($user, $key, $expiry, $hash) = explode('|', $data);
     // check if link has not expired
     if (time() > $expiry) {
         return $FUNCS->raise_error($FUNCS->t('invalid_key'));
     }
     // next verify hash to make sure the data has not been tampered with.
     if ($data !== $AUTH->get_hash($user, $key, $expiry)) {
         return $FUNCS->raise_error($FUNCS->t('invalid_key'));
     }
     // finally check if activation key still exists for the user
     // get the user with this activation key
     $rs = $DB->select(K_TBL_USERS, array('id'), "name='" . $DB->sanitize($user) . "' AND activation_key='" . $DB->sanitize($key) . "'");
     if (!count($rs)) {
         return $FUNCS->raise_error($FUNCS->t('invalid_key'));
     } else {
         $user = new KUser($rs[0]['id'], 1);
         $user->populate_fields();
         $user->fields[4]->store_posted_changes(0);
         // enable user
         $access_level = $AUTH->user->access_level;
         $AUTH->user->access_level = K_ACCESS_LEVEL_AUTHENTICATED + 1;
         // to allow an unlogged visitor activate his account
         $errors = $user->save();
         if ($errors) {
             return $FUNCS->raise_error('Activation failed');
         }
         $AUTH->user->access_level = $access_level;
     }
 }
Example #3
0
            $qs = '?o=users';
            if (isset($_GET['pg'])) {
                $qs .= '&pg=' . intval($_GET['pg']);
            }
            header("Location: " . K_ADMIN_URL . K_ADMIN_PAGE . $qs);
            exit;
        }
    }
} else {
    // Any users marked for deletion?
    if (isset($_POST['user-id'])) {
        $FUNCS->validate_nonce('bulk_action_user');
        foreach ($_POST['user-id'] as $v) {
            if ($FUNCS->is_non_zero_natural($v)) {
                $user_id = intval($v);
                $user = new KUser($user_id, 1);
                // execute action
                $user->delete();
            }
        }
    }
    // list users
    $_p = array();
    $_p['module'] = 'users';
    $_p['title'] = ucwords($FUNCS->t('users'));
    $_p['link'] = K_ADMIN_URL . K_ADMIN_PAGE . '?o=users';
    $_p['buttons'] = '<div id="create_new"><a class="button" href="' . K_ADMIN_URL . K_ADMIN_PAGE . '?o=users&act=create&nonce=' . $FUNCS->create_nonce('create_user') . '" title="' . $FUNCS->t('add_new_user') . '"><span>' . $FUNCS->t('add_new') . '</span></a></div>';
    $_p['subtitle'] = $FUNCS->t('list');
    $_p['show_advanced'] = 0;
    $_p['content'] = k_admin_list_users();
    $FUNCS->render_admin_page_ex($_p);