Ejemplo n.º 1
0
 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     $email = $user->get($this->getConfig('email_field', 'email'));
     if (empty($email)) {
         return true;
     }
     // add custom fields info
     $fields = array();
     foreach ($this->getConfig('fields', array()) as $fn) {
         $fields['custom_' . $fn] = $user->get($fn);
     }
     foreach ($addLists as $listId) {
         $ret = $this->doRequest(array('first_name' => $user->name_f, 'last_name' => $user->name_l, 'email_address' => $email) + $fields, $listId);
         if (!$ret) {
             return false;
         }
     }
     foreach ($deleteLists as $listId) {
         $list = $this->getDi()->newsletterListTable->findFirstBy(array('plugin_id' => $this->getId(), 'plugin_list_id' => $listId));
         if (!$list) {
             continue;
         }
         $vars = unserialize($list->vars);
         $ret = $this->doRequest(array('first_name' => $user->name_f, 'last_name' => $user->name_l, 'email_address' => $email), @$vars['unsub_list_id']);
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
/**
 * Check whether a user is on probation.
 * @param int $userid
 * @return boolean TRUE if the user is on probation, FALSE if the user is not on probation
 */
function is_probationary_user($userid = null)
{
    global $USER;
    // Check whether a new user threshold is in place or not.
    if (!is_using_probation()) {
        return false;
    }
    // Get the user's information
    if ($userid == null) {
        $user = $USER;
    } else {
        $user = new User();
        $user->find_by_id($userid);
    }
    // Admins and staff get a free pass
    if ($user->get('admin') || $user->get('staff') || $user->is_institutional_admin() || $user->is_institutional_staff()) {
        return false;
    }
    // We actually store new user points in reverse. When your account is created, you get $newuserthreshold points, and
    // we decrease those when you do something good, and when it hits 0 you're no longer a new user.
    $userspoints = get_field('usr', 'probation', 'id', $user->get('id'));
    if ($userspoints > 0) {
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 3
0
Archivo: arp.php Proyecto: grlf/eyedock
 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     $email = $user->get($this->getConfig('email_field', 'email'));
     if (empty($email)) {
         return true;
     }
     // add custom fields info
     $fields = array();
     foreach ($this->getConfig('fields', array()) as $fn) {
         $fields['custom_' . $fn] = $user->get($fn);
     }
     foreach ($addLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E') + $fields);
         if (!$ret) {
             return false;
         }
     }
     foreach ($deleteLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E', 'arp_action' => 'UNS'));
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
 public function check_addUser($arguments)
 {
     $username = $arguments['username'];
     $password = $arguments['password'];
     $User = $arguments['User'];
     if (!in_array($this->node, $_SESSION['PluginsInstalled'])) {
         return;
     }
     foreach ($this->getClass('LDAPManager')->find() as $LDAP) {
         if ($LDAP->authLDAP($username, $password)) {
             $UserByName = current($this->getClass('UserManager')->find(array('name' => $username)));
             if ($UserByName) {
                 $arguments['User'] = $UserByName;
                 break;
             } else {
                 if (!$User || !$User->isValid()) {
                     $tmpUser = new User(array('name' => $username, 'type' => 1, 'password' => md5($password), 'createdBy' => 'fog'));
                     if (!$tmpUser->save()) {
                         throw new Exception('Database update failed');
                     }
                     $this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', _('User created'), $tmpUser->get('id'), $tmpUser->get('name')));
                     $arguments['User'] = $tmpUser;
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Process an authorization request.
  *
  * Operations:
  *     - Auto creates users.
  *     - Sets up user object for linked accounts.
  *
  * @param string $oidcuniqid The OIDC unique identifier received.
  * @param array $tokenparams Received token parameters.
  * @param \auth_oidc\jwt $idtoken Received id token.
  * @return bool Success/Failure.
  */
 public function request_user_authorise($oidcuniqid, $tokenparams, $idtoken)
 {
     global $USER, $SESSION;
     $this->must_be_ready();
     $username = $oidcuniqid;
     $email = $idtoken->claim('email');
     $firstname = $idtoken->claim('given_name');
     $lastname = $idtoken->claim('family_name');
     // Office 365 uses "upn".
     $upn = $idtoken->claim('upn');
     if (!empty($upn)) {
         $username = $upn;
         $email = $upn;
     }
     $create = false;
     try {
         $user = new \User();
         $user->find_by_instanceid_username($this->instanceid, $username, true);
         if ($user->get('suspendedcusr')) {
             die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));
         }
     } catch (\AuthUnknownUserException $e) {
         if ($this->can_auto_create_users() === true) {
             $institution = new \Institution($this->institution);
             if ($institution->isFull()) {
                 throw new \XmlrpcClientException('OpenID Connect login attempt failed because the institution is full.');
             }
             $user = new \User();
             $create = true;
         } else {
             return false;
         }
     }
     if ($create === true) {
         $user->passwordchange = 0;
         $user->active = 1;
         $user->deleted = 0;
         $user->expiry = null;
         $user->expirymailsent = 0;
         $user->lastlogin = time();
         $user->firstname = $firstname;
         $user->lastname = $lastname;
         $user->email = $email;
         $user->authinstance = $this->instanceid;
         db_begin();
         $user->username = get_new_username($username);
         $user->id = create_user($user, array(), $this->institution, $this, $username);
         $userobj = $user->to_stdclass();
         $userarray = (array) $userobj;
         db_commit();
         $user = new User();
         $user->find_by_id($userobj->id);
     }
     $user->commit();
     $USER->reanimate($user->id, $this->instanceid);
     $SESSION->set('authinstance', $this->instanceid);
     return true;
 }
Ejemplo n.º 6
0
 function panel()
 {
     $this->load->model('user');
     $this->load->model('script');
     $this->load->library('facebook');
     if ($signedUp = $this->session->flashdata('signedUp')) {
         $this->session->keep_flashdata('signedUp');
         $viewData['signedUp'] = $signedUp;
     }
     if ($this->input->post('changePassword')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['currentPassword'] = '******';
             $rules['newPassword'] = '******';
             $rules['newPasswordRepeat'] = 'required|matches[newPassword]';
             $fields['currentPassword'] = '******';
             $fields['newPassword'] = '******';
             $fields['newPasswordRepeat'] = 'new password repeated';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $user = new User();
                 $user->setKey($this->_getUser());
                 $user->retrieve();
                 if ($user->get('password') === $user->makePass($this->input->post('currentPassword'))) {
                     $user->set('password', $user->makePass($this->input->post('newPassword')));
                     $viewData['checkpoints'][] = 'You have successfully changed your password.';
                     $user->update();
                 } else {
                     $viewData['errors'][] = 'You did not enter your current password correctly.';
                 }
             }
         }
     }
     $viewData['token'] = $this->_token();
     $user = new User();
     $script = new Script();
     $user->retrieve($this->session->userdata('email'));
     if ($user->getType() === User::FB_CONNECT) {
         $viewData['email'] = false;
         $viewData['UID'] = $user->getKey();
         $viewData['name'] = $user->name();
         $viewData['institution'] = $user->institution();
         if (!($subject = $user->subject())) {
             $subject = 'Not specified on Facebook';
         }
         $viewData['subject'] = $subject;
         $viewData['fbEmail'] = $user->get('fbEmail');
     } else {
         $viewData['email'] = $user->getKey();
         $viewData['name'] = $user->get('name');
         $user->get('subject') ? $viewData['subject'] = $user->get('subject') : ($viewData['subject'] = 'Not specified');
         $viewData['institution'] = $user->get('institution');
     }
     //$viewData['messages'][] = 'We are on day '.ceil((time() - 1229536800)/86400).' of the Exambuff pilot. Thanks for taking part!';
     $this->_template('user/panel', 'Your account', 'my-account', $viewData);
 }
Ejemplo n.º 7
0
 /**
  * Create a log object
  *
  * @access public
  * @param string $action
  * @param object $object
  */
 public static function create($action, $object = null)
 {
     // what class is it
     $classname = '';
     if (!is_null($object)) {
         $classname = strtolower(get_class($object));
     }
     $log = new self();
     try {
         $user = User::get();
         $log->user_id = $user->id;
     } catch (\Exception $e) {
         $log->user_id = 0;
     }
     if ($action == 'add') {
         $content = ucfirst($classname) . ' created';
     } elseif ($action == 'edit') {
         $content = ucfirst($classname) . ' edited';
     } else {
         $content = ucfirst($action);
     }
     $log->classname = $classname;
     $log->object_id = !is_null($object) ? $object->id : 0;
     $log->content = $content;
     $log->save();
     return $log;
 }
Ejemplo n.º 8
0
 function user_id()
 {
     if ($this->users->is_connected()) {
         return User::get()->id;
     }
     return 0;
 }
Ejemplo n.º 9
0
 public function isAuthorized()
 {
     if ($this->userLogged == TRUE && $this->params['prefix'] == User::get('type')) {
         return true;
     }
     return false;
 }
Ejemplo n.º 10
0
 /**
  * Get the parameters given in Url
  * @return string url parameters
  * @access private
  */
 function __getDataForLogs($verbose = 1)
 {
     // build the data for the log entry
     $data = array('user_id' => User::get('id'), 'ip' => $this->Controller->RequestHandler->getClientIP(), 'resource_type' => 'controller', 'get_data_url' => implode(DS, $this->Controller->params['pass']));
     // clean up a bit on cakeerror
     if ($this->Controller->name != "CakeError") {
         $data['error'] = $this->error;
         $data['error_id'] = $this->errorCode;
         //$data['errorCode'] = $this->errorCode,
         $data['resource'] = strtolower($this->Controller->name);
         $data['action'] = $this->Controller->action;
     } else {
         $data['error'] = true;
         $data['resource'] = strtolower($this->Controller->params['controller']);
         $data['action'] = $this->Controller->params['action'];
     }
     // Better to remain silent and be thought a fool
     if (!empty($this->Controller->data)) {
         if ($verbose == 2) {
             $data['post_data'] = print_r($this->Controller->data, true);
         } elseif ($verbose == 1) {
             $data['post_data'] = count($this->Controller->data);
         }
     }
     // than to speak out and remove all doubt - MT
     $data['get_data_url'] = implode(DS, $this->Controller->params['pass']);
     $data['get_data_named'] = '';
     foreach ($this->Controller->params['named'] as $key => $value) {
         $data['get_data_named'] .= $key . ':' . $value . DS;
     }
     return $data;
 }
 /**
  * @group no-saucelabs
  *
  * Scenario:  As an AP going through the setup two times, I should be able to login at the end of the second setup.
  * Given    I create an account as John Doe, and I proceed through the entire setup.
  * When     I register again with another username, and proceed again through the entire setup
  * Then     I should be able to see the login form
  * And      I should be able to login
  */
 public function testPluginShouldStartAfterTwoSetup()
 {
     // Reset database at the end of test.
     $this->resetDatabaseWhenComplete();
     // Register John Doe as a user.
     $john = User::get('john');
     $this->registerUser($john['FirstName'], $john['LastName'], $john['Username']);
     // Go to setup page.
     $this->goToSetup($john['Username']);
     // Wait until I see the setup section domain check.
     $this->waitForSection('domain_check');
     // I should not se any warning.
     $this->assertNotVisible('.plugin-check.warning');
     // Complete registration.
     $this->completeRegistration($john);
     // Switch config to secondary domain.
     $this->switchToSecondaryDomain();
     // Register Curtis Mayfield as a user.
     $curtis = User::get('curtis');
     $this->registerUser($curtis['FirstName'], $curtis['LastName'], $curtis['Username']);
     // Go to setup page.
     $this->goToSetup($curtis['Username'], false);
     // Wait until I see the setup section domain check.
     $this->waitForSection('domain_check');
     // Complete registration.
     $this->completeRegistration($curtis);
     // And I am logged in on the password workspace
     $this->loginAs($curtis);
     // wait for redirection trigger
     sleep(1);
     $this->waitCompletion();
     $this->assertElementContainsText($this->findByCss('.header .user.profile .details .name'), $curtis['FirstName'] . ' ' . $curtis['LastName']);
     // Switch back config to primary domain.
     $this->switchToPrimaryDomain();
 }
Ejemplo n.º 12
0
 /**
  * undocumented function
  *
  * @param string $id
  * @return void
  * @access public
  */
 function edit($id = null, $parentId = null)
 {
     $action = 'add';
     if ($this->action == 'edit') {
         $Comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => $id)));
         Assert::notEmpty($Comment, '404');
         Assert::true($this->Comment->isOwn($Comment, 'Comment'), '403');
         $action = 'edit';
     } else {
         $Comment = $this->Comment->create();
     }
     $referer = $this->referer();
     $parentId = isset($this->params['named']['parent_id']) ? $this->params['named']['parent_id'] : false;
     $foreignId = isset($this->params['named']['foreign_id']) ? $this->params['named']['foreign_id'] : false;
     $this->set(compact('action', 'referer', 'parentId', 'foreignId'));
     $this->action = 'edit';
     if ($this->isGet()) {
         return $this->data = $Comment;
     }
     $this->data['Comment']['user_id'] = User::get('id');
     $this->Comment->set($this->data);
     $result = $this->Comment->save();
     if ($this->Comment->validationErrors) {
         $msg = __('There are problems with the form.', true);
         $this->Message->add($msg, 'error', true, $referer);
     }
     Assert::notEmpty($result);
     $msg = __('Successfully saved!', true);
     $this->Message->add($msg, 'ok', true, $this->data['Comment']['referer']);
 }
Ejemplo n.º 13
0
 public static function format_time($timestamp, $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false)
 {
     if ($timestamp == '') {
         return __('Never');
     }
     $diff = (User::get()->timezone + User::get()->dst) * 3600;
     $timestamp += $diff;
     $now = time();
     if (is_null($date_format)) {
         $date_format = Container::get('forum_date_formats')[User::get()->date_format];
     }
     if (is_null($time_format)) {
         $time_format = Container::get('forum_time_formats')[User::get()->time_format];
     }
     $date = gmdate($date_format, $timestamp);
     $today = gmdate($date_format, $now + $diff);
     $yesterday = gmdate($date_format, $now + $diff - 86400);
     if (!$no_text) {
         if ($date == $today) {
             $date = __('Today');
         } elseif ($date == $yesterday) {
             $date = __('Yesterday');
         }
     }
     if ($date_only) {
         return $date;
     } elseif ($time_only) {
         return gmdate($time_format, $timestamp);
     } else {
         return $date . ' ' . gmdate($time_format, $timestamp);
     }
 }
Ejemplo n.º 14
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     // First, check for presence of subject dn, which is the minimum required field
     if (!isset($_SERVER['SSL_CLIENT_S_DN']) || !$_SERVER['SSL_CLIENT_S_DN']) {
         \App::redirect($this->params->get('failure_location', '/invalidcert.php'));
         return;
     }
     if (\User::isGuest()) {
         // If so, redirect to login
         Request::setVar('option', 'com_users');
         Request::setVar('task', 'user.login');
         Request::setVar('authenticator', 'certificate');
         Request::setVar('return', base64_encode(\Request::current()));
         return;
     }
     // Check if user is registered and if current session is linked to cert identity
     $hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'certificate', $_SERVER['SSL_CLIENT_I_DN_CN']);
     if ($link = \Hubzero\Auth\Link::getInstance($hzad->id, $_SERVER['SSL_CLIENT_S_DN_CN'])) {
         if ($link->user_id == \User::get('id')) {
             // All clear...return nothing
             return;
         }
     }
     // Otherwise, we have a cert-based user that doesn't match the current user
     Request::setVar('option', 'com_users');
     Request::setVar('task', 'user.logout');
     $this->event->stop();
 }
Ejemplo n.º 15
0
 /**
  * Gets the request filters and returns them
  *
  * @param  string $namespace the application state variable namespace
  * @return array
  **/
 public static function getFilters($namespace)
 {
     // Process query filters
     $q = User::getState("{$namespace}.query");
     if ($incoming = Request::getVar('q', false)) {
         $q[] = $incoming;
     }
     // Set some defaults for the filters, if not set otherwise
     if (!is_array($q)) {
         $q[0]['column'] = $namespace == 'com_time.tasks' ? 'assignee_id' : 'user_id';
         $q[0]['operator'] = 'e';
         $q[0]['value'] = User::get('id');
     }
     // Translate operators and augment query filters with human-friendly text
     $query = self::filtersMap($q);
     // Turn search into array of results, if not already
     $search = Request::getVar('search', User::getState("{$namespace}.search", ''));
     // If we have a search and it's not an array (i.e. it's coming in fresh with this request)
     if ($search && !is_array($search)) {
         // Explode multiple words into array
         $search = explode(" ", $search);
         // Only allow alphabetical characters for search
         $search = preg_replace("/[^a-zA-Z]/", "", $search);
     }
     // Set some values in the session
     User::setState("{$namespace}.search", $search);
     User::setState("{$namespace}.query", $query);
     return array('search' => $search, 'q' => $query);
 }
Ejemplo n.º 16
0
 /**
  * undocumented function
  *
  * @return void
  */
 function index()
 {
     $this->set('disableNav', true);
     Router::connectNamed(array('type', 'page'));
     if (empty($this->passedArgs['type'])) {
         $this->passedArgs['type'] = 'public';
         $projects = $this->Project->User->groups($this->Auth->user('id'));
         if (!empty($projects)) {
             $this->Session->write('Auth.User.ProjectPermission', $projects);
             $this->passedArgs['type'] = null;
             $this->paginate['conditions'] = array('Project.id' => array_keys($projects));
             $this->paginate['order'] = 'Project.private DESC, Project.url ASC';
         }
     }
     if (!empty($this->passedArgs['type'])) {
         $this->paginate['conditions'] = array('Project.private' => 0, 'Project.active' => 1, 'Project.approved' => 1);
         if ($this->passedArgs['type'] == 'forks') {
             $this->paginate['conditions']['Project.fork !='] = null;
             $this->paginate['order'] = 'Project.url ASC';
         } else {
             if ($this->passedArgs['type'] == 'public') {
                 $this->paginate['conditions']['Project.fork ='] = null;
                 $this->paginate['order'] = 'Project.url ASC';
             }
         }
     }
     if (User::get('id') == 1) {
         unset($this->paginate['conditions']);
         $this->paginate['order'] = 'Project.private ASC, Project.url ASC';
     }
     $this->Project->recursive = 0;
     $projects = $this->paginate();
     $this->set('projects', $projects);
     $this->set('rssFeed', array('controller' => 'projects'));
 }
Ejemplo n.º 17
0
 public function checkSecurity($authToken = true, $userToken = false, $mustBeOfficial = false)
 {
     if ($authToken) {
         if (empty($this->authToken)) {
             return $this->replyError('Missing authToken');
         }
         $tokenClass = new AuthToken();
         try {
             $app = $tokenClass->validate($this->authToken);
         } catch (Exception $e) {
             return $this->replyError('Invalid authToken');
         }
         $this->app = $app;
         if ($mustBeOfficial && !$this->app->isOfficial()) {
             return $this->replyError('Permission denied');
         }
     }
     if ($userToken) {
         if (empty($this->authToken)) {
             return $this->replyError('Missing userToken');
         }
         $token = new UserToken();
         $tokenData = $token->get($this->userToken);
         if (!$tokenData || $tokenData->app != $this->app->id) {
             return $this->replyError('Invalid userToken');
         }
         $userClass = new User();
         $user = $userClass->get($tokenData->uid);
         $this->user = $user;
     }
     return true;
 }
Ejemplo n.º 18
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param   object  $resource  Current resource
  * @param   string  $option    Name of the component
  * @param   array   $areas     Active area(s)
  * @param   string  $rtrn      Data to be returned
  * @return  array
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     if (!$model->type->params->get('plg_share')) {
         return;
     }
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     $resource = $model->resource;
     $sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id));
     $url = Request::base() . ltrim($sef, '/');
     // Incoming action
     $sharewith = Request::getVar('sharewith', '');
     if ($sharewith) {
         // Log the activity
         if (!User::isGuest()) {
             Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]);
         }
         // Email form
         if ($sharewith == 'email') {
             // Instantiate a view
             $view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
             // Return the output
             $view->display();
             exit;
         }
         return $this->share($sharewith, $url, $resource);
     }
     // Build the HTML meant for the "about" tab's metadata overview
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         // Instantiate a view
         $view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
         // Return the output
         $arr['metadata'] = $view->loadTemplate();
     }
     return $arr;
 }
Ejemplo n.º 19
0
 /**
  * Renders the user listing page.
  *
  * This page renders a table of users, with dropdown menus for admin actions for each user.
  * Actions typically include: edit user details, activate user, enable/disable user, delete user.
  * This page requires authentication.
  * Request type: GET
  * @param string $primary_group_name optional.  If specified, will only display users in that particular primary group.
  * @param bool $paginate_server_side optional.  Set to true if you want UF to load each page of results via AJAX on demand, rather than all at once.
  * @todo implement interface to modify user-assigned authorization hooks and permissions
  */
 public function pageUsers($primary_group_name = null, $paginate_server_side = true)
 {
     // Optional filtering by primary group
     if ($primary_group_name) {
         $primary_group = Group::where('name', $primary_group_name)->first();
         if (!$primary_group) {
             $this->_app->notFound();
         }
         // Access-controlled page
         if (!$this->_app->user->checkAccess('uri_group_users', ['primary_group_id' => $primary_group->id])) {
             $this->_app->notFound();
         }
         if (!$paginate_server_side) {
             $user_collection = User::where('primary_group_id', $primary_group->id)->get();
             $user_collection->getRecentEvents('sign_in');
             $user_collection->getRecentEvents('sign_up', 'sign_up_time');
         }
         $name = $primary_group->name;
         $icon = $primary_group->icon;
     } else {
         // Access-controlled page
         if (!$this->_app->user->checkAccess('uri_users')) {
             $this->_app->notFound();
         }
         if (!$paginate_server_side) {
             $user_collection = User::get();
             $user_collection->getRecentEvents('sign_in');
             $user_collection->getRecentEvents('sign_up', 'sign_up_time');
         }
         $name = "Users";
         $icon = "fa fa-users";
     }
     $this->_app->render('users/users.twig', ["box_title" => $name, "icon" => $icon, "primary_group_name" => $primary_group_name, "paginate_server_side" => $paginate_server_side, "users" => isset($user_collection) ? $user_collection->toArray() : []]);
 }
 /**
  * Scenario :   The contextual menu should disappear after changing workspace
  * Given        I am logged in as Ada on the password workspace
  * And          I right click on a password
  * Then         I should see the contextual menu
  * When         I go to user workspace
  * Then         I should not see the contextual menu anymore
  * When         I right click on a user
  * Then         I should see the contextual menu
  * When         I go to password workspace
  * Then         I should not see the contextual menu
  * When         I right click again on the previous password where I had clicked.
  * Then         I should see again the contextual menu
  */
 public function testContextualMenuDisappearAfterChangingWorkspace()
 {
     // Given I am Ada
     $user = User::get('ada');
     // And I am logged in on the password workspace
     $this->setClientConfig($user);
     $this->loginAs($user);
     // When I right click on a password I own
     $resource = Resource::get(array('user' => 'ada', 'permission' => 'owner'));
     $this->rightClickPassword($resource['id']);
     // Then I can see the contextual menu
     $this->assertVisible('js_contextual_menu');
     // When I change workspace
     $this->gotoWorkspace('user');
     // Then I shouldn't see the contextual menu anymore
     $this->assertNotVisible('js_contextual_menu');
     // And I right click on user betty
     $betty = User::get(array('user' => 'betty'));
     $this->rightClickUser($betty['id']);
     // Then I can see the contextual menu
     $this->assertVisible('js_contextual_menu');
     // When I change workspace
     $this->gotoWorkspace('password');
     // Then I shouldn't see the contextual menu anymore
     $this->assertNotVisible('js_contextual_menu');
     // And I right click on the password I clicked before.
     $this->rightClickPassword($resource['id']);
     // Then I can see the contextual menu
     $this->assertVisible('js_contextual_menu');
 }
Ejemplo n.º 21
0
 function do_index()
 {
     $users = new User();
     $users->order_by('name');
     $users->get();
     $this->render(null, array('users' => $users));
 }
Ejemplo n.º 22
0
 public function editUser()
 {
     $u = new User();
     $user = $u->get($_GET['id']);
     $user->set($_POST);
     $user->save();
 }
Ejemplo n.º 23
0
 /**
  * Grab activities(only Linkedin) for every users
  * 
  * 
  * @throws Exception
  */
 public function grabber()
 {
     $this->load->library('activitioner');
     try {
         $user = new User();
         $users = $user->get()->all;
         $socials = array();
         if (empty($socials)) {
             return;
         }
         $aac = $this->getAAC();
         foreach ($users as $u) {
             $aac->setUser($u);
             if (!$aac->isGrantedPlan('social_activity')) {
                 continue;
             }
             $act = Activitioner::factory($u->id);
             foreach ($socials as $social) {
                 if ($social == 'linkedin') {
                     $act->getLinkedinUpdates();
                 }
                 log_message('TASK_SUCCESS', __FUNCTION__ . ' > ' . 'Activities for ' . $social . ' mkwid: grabbed');
             }
         }
     } catch (Exception $e) {
         log_message('TASK_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
     }
 }
Ejemplo n.º 24
0
 public function get()
 {
     $uid = (int) $_REQUEST['uid'];
     if ($uid == 0) {
         $uid = $this->user->id;
     }
     $user = new User();
     $user->get($uid);
     $userData = $user->getRaw();
     //region data
     $region = new Region();
     $regionData = $region->getRaw($userData['region']);
     $userData['region'] = array('id' => $regionData['id'], 'name' => $regionData['name']);
     //counrry data
     $country = new Country();
     $countryData = $country->getRaw($userData['country']);
     $userData['country'] = array('id' => $countryData['id'], 'name' => $countryData['name']);
     // myself
     if ($uid == $this->user->id) {
         $currencyQuantity = $user->getCurrency($userData['currency']);
         $userData['currencyName'] = $userData['currency'];
         $userData['currency'] = $currencyQuantity;
     } else {
         unset($userData['gold']);
         unset($userData['currency']);
     }
     unset($userData['password']);
     return $userData;
 }
Ejemplo n.º 25
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.userlist.display');
     if (User::get()->g_view_users == '0') {
         throw new Error(__('No permission'), 403);
     }
     // Determine if we are allowed to view post counts
     $show_post_count = ForumSettings::get('o_show_post_count') == '1' || User::get()->is_admmod ? true : false;
     $username = Input::query('username') && User::get()->g_search_users == '1' ? Utils::trim(Input::query('username')) : '';
     $show_group = Input::query('show_group') ? intval(Input::query('show_group')) : -1;
     $sort_by = Input::query('sort_by') && (in_array(Input::query('sort_by'), array('username', 'registered')) || Input::query('sort_by') == 'num_posts' && $show_post_count) ? Input::query('sort_by') : 'username';
     $sort_dir = Input::query('sort_dir') && Input::query('sort_dir') == 'DESC' ? 'DESC' : 'ASC';
     $num_users = $this->model->fetch_user_count($username, $show_group);
     // Determine the user offset (based on $page)
     $num_pages = ceil($num_users / 50);
     $p = !Input::query('p') || $page <= 1 || $page > $num_pages ? 1 : intval($page);
     $start_from = 50 * ($p - 1);
     if (User::get()->g_search_users == '1') {
         $focus_element = array('userlist', 'username');
     } else {
         $focus_element = array();
     }
     // Generate paging links
     $paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?username='******'&amp;show_group=' . $show_group . '&amp;sort_by=' . $sort_by . '&amp;sort_dir=' . $sort_dir);
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('User list')), 'active_page' => 'userlist', 'page_number' => $p, 'paging_links' => $paging_links, 'focus_element' => $focus_element, 'is_indexed' => true, 'username' => $username, 'show_group' => $show_group, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_post_count' => $show_post_count, 'dropdown_menu' => $this->model->generate_dropdown_menu($show_group), 'userlist_data' => $this->model->print_users($username, $start_from, $sort_by, $sort_dir, $show_group)))->addTemplate('userlist.php')->display();
 }
Ejemplo n.º 26
0
 public function getUser()
 {
     if (!$user) {
         $user = User::get($this->user_id);
     }
     return $user;
 }
Ejemplo n.º 27
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     // check if we can render
     if (!parent::canRender()) {
         return \Lang::txt('[This macro is designed for Groups only]');
     }
     // get args
     $args = $this->getArgs();
     //array of filters
     $filters = array('limit' => count($args) == 1 && is_numeric($args[0]) ? $args[0] : 12);
     // get members
     $members = $this->getGroupMembers($this->group, $filters);
     //are we a group member
     $isMember = in_array(\User::get('id'), $this->group->get('members')) ? true : false;
     //get the members plugin access for this group
     $memberAccess = \Hubzero\User\Group\Helper::getPluginAccess($this->group, 'members');
     // make sure we can actually display for the current user
     if ($memberAccess == 'anyone' || $memberAccess == 'registered' && !\User::isGuest() || $memberAccess == 'members' && $isMember) {
         $html = $this->renderMembers($this->group, $members);
     } else {
         $html = '';
     }
     //return rendered events
     return $html;
 }
Ejemplo n.º 28
0
/**
 * Populate a Plans page with all the usual stuff
 *
 * Fills up the PlansPage object with all the elements that are found on every page:
 * the main panel (which holds the links, autoreads, finger form, etc), legal footer,
 * and so on
 *
 * @param PlansPage $page The PlansPage object
 * @param resource $dbh The database connection
 * @param int $idcookie The user's id
 */
function populate_page(PlansPage $page, $dbh, $idcookie)
{
    $user = User::get();
    // get the global stylesheet
    $page->stylesheets[] = 'styles/global.css';
    // get user stylesheet
    $page->stylesheets[] = $user->stylesheet;
    $myprivl = get_myprivl();
    $page->autoreadpriority = $myprivl;
    $mp = new MainPanel();
    $page->mainpanel = $mp;
    $mp->fingerbox = get_fingerbox();
    $mp->linkhome = get_linkhome();
    $mp->links = new WidgetList('linkslist', false);
    foreach (get_all_user_links($idcookie) as $link) {
        $mp->links->append($link);
    }
    $mp->autoreads = new WidgetList('autoread', true);
    foreach ($user->getAutofinger() as $p => $autoreadlist) {
        $ar = new AutoRead($p, "setpriv.php?myprivl={$p}");
        foreach ($autoreadlist as $autoreadlink) {
            $ar->append(new PlanLink($autoreadlink));
        }
        $mp->autoreads->append($ar);
    }
    $footer = new Footer();
    $footer->doyouread = get_just_updated();
    $footer->powered_by = get_powered_by();
    $footer->legal = new RegularText(get_disclaimer());
    $page->footer = $footer;
}
Ejemplo n.º 29
0
 function setup()
 {
     $oRootFolder =& Folder::get(1);
     $this->oUser = User::get(1);
     $sName = 'PermissionsTrest' . strftime('%Y%m%d%H%M%S');
     $this->oFolder =& KTFolderUtil::add($oRootFolder, $sName, $this->oUser);
 }
Ejemplo n.º 30
0
 public function filter_post_staff($staff, $post)
 {
     if (intval($post->info->staff) != 0) {
         $staff = User::get($post->info->staff);
     }
     return $staff;
 }