/** * Get the submitter of this entry * * Accepts an optional property name. If provided * it will return that property value. Otherwise, * it returns the entire user object * * @param string $property User property to look up * @param mixed $default Value to return if property not found * @return mixed */ public function submitter($property = null, $default = null) { if (!$this->_data->get('submitter.profile') instanceof Member) { $user = Member::oneByUsername($this->get('login')); $user->set('name', $this->get('name')); $user->set('username', $this->get('login')); $user->set('email', $this->get('email')); $this->_data->set('submitter.profile', $user); } if ($property) { $property = $property == 'uidNumber' ? 'id' : $property; return $this->_data->get('submitter.profile')->get($property, $default); } return $this->_data->get('submitter.profile'); }
/** * Check if a username exists * * @return integer */ private function _usernameExists($username) { return Member::oneByUsername($username)->get('id'); }
/** * Display a user profile * * @return void */ public function viewTask() { // Incoming $id = Request::getVar('id', 0); $tab = Request::getVar('active', 'dashboard'); // The active tab (section) // Get the member's info if (is_numeric($id)) { $profile = Member::oneOrNew(intval($id)); } else { $profile = Member::oneByUsername((string) $id); } // Ensure we have a member if (!$profile->get('id')) { App::abort(404, Lang::txt('COM_MEMBERS_NOT_FOUND')); } // Check subscription to Employer Services // NOTE: This must occur after the initial plugins import and // do not specifically call Plugin::import('members', 'resume'); // Doing so can have negative affects. /*if ($this->config->get('employeraccess') && $tab == 'resume') { $checkemp = Event::trigger('members.isEmployer', array()); $emp = is_array($checkemp) ? $checkemp[0] : 0; $this->view->authorized = $emp ? 1 : $this->view->authorized; }*/ // Check if the profile is public/private and the user has access if (User::get('id') != $profile->get('id') && !in_array($profile->get('access'), User::getAuthorisedViewLevels())) { // Check if they're logged in if (User::isGuest()) { $rtrn = Request::getVar('REQUEST_URI', Route::url($profile->link()), 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn))); } App::abort(403, Lang::txt('COM_MEMBERS_NOT_PUBLIC')); } // Check if unconfirmed if ($profile->get('activation') < 1 && !User::authorise('core.manage', $this->_option)) { //App::abort(403, Lang::txt('COM_MEMBERS_NOT_CONFIRMED')); $rtrn = Request::getVar('REQUEST_URI', Route::url($profile->link()), 'server'); /* App::redirect( Route::url('index.php?option=com_members&controller=member&task=unconfirmed&return=' . base64_encode($rtrn)) ); */ // Prep vars for unconfirmed page $return = Request::getVar('return', urlencode('/')); // Offer explaination and eternal redemption to the user, instead of leaving them high and dry $this->view->set('title', Lang::txt('COM_MEMBERS_REGISTER_UNCONFIRMED'))->set('email', $profile->get('email'))->set('sitename', Config::get('sitename'))->set('return', urlencode($rtrn))->setErrors($this->getErrors())->setName('register')->setLayout('unconfirmed')->display(); return; } // Check for name if (!$profile->get('name')) { $name = $profile->get('givenName') . ' '; $name .= $profile->get('middleName') ? $profile->get('middleName') . ' ' : ''; $name .= $profile->get('surname'); $profile->set('name', $name); } // Trigger the functions that return the areas we'll be using $cats = Event::trigger('members.onMembersAreas', array(User::getInstance(), $profile)); $available = array(); foreach ($cats as $cat) { $name = key($cat); if ($name != '') { $available[] = $name; } } //if ($tab != 'profile' && !in_array($tab, $available)) if (!in_array($tab, $available) && isset($available[0])) { //$tab = 'profile'; $tab = $available[0]; } // Get the sections $sections = Event::trigger('members.onMembers', array(User::getInstance(), $profile, $this->_option, array($tab))); // Build the page title $title = Lang::txt(strtoupper($this->_option)); $title .= $this->_task ? ': ' . Lang::txt(strtoupper($this->_task)) : ''; // Set the page title Document::setTitle($title . ': ' . stripslashes($profile->get('name'))); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option); } Pathway::append(stripslashes($profile->get('name')), 'index.php?option=' . $this->_option . '&id=' . $profile->get('id')); // Output HTML $this->view->set('config', $this->config)->set('active', $tab)->set('profile', $profile)->set('title', $title)->set('cats', $cats)->set('sections', $sections)->set('overwrite_content', '')->setErrors($this->getErrors())->setLayout('view')->display(); }
/** * Edit an entry * * @param object $row * @return void */ public function editTask($row = null) { if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } Request::setVar('hidemainmenu', 1); if (!is_object($row)) { // Incoming ID $id = Request::getVar('id', array(0)); $id = is_array($id) ? $id[0] : $id; // Initiate database class and load info $row = Quote::oneOrNew($id); } if (!$row->get('id')) { if ($username = Request::getVar('username', '')) { $profile = Member::oneByUsername($username); $row->set('fullname', $profile->get('name')); $row->set('org', $profile->get('organization')); $row->set('user_id', $profile->get('uidNumber')); } } // Output the HTML $this->view->set('row', $row)->setLayout('edit')->display(); }