Example #1
0
 /**
  * Defines a belongs to one relationship between article and user
  *
  * @return  object  \Hubzero\Database\Relationship\BelongsToOne
  */
 public function voter()
 {
     return Hubzero\User\Profile::getInstance($this->get('created_by'));
 }
Example #2
0
            $closeddata = '';
            //$utot = 0;
            if ($user->closed) {
                $c = array();
                foreach ($user->closed as $year => $data) {
                    foreach ($data as $k => $v) {
                        //$utot += $v;
                        $c[] = '[Date.UTC(' . $year . ',  ' . ($k - 1) . ', 1),' . $v . ']';
                    }
                }
                $closeddata = implode(',', $c);
            }
            $anon = 0;
            $profile = \Hubzero\User\Profile::getInstance($user->id);
            if (!$profile) {
                $profile = new \Hubzero\User\Profile();
                $anon = 1;
            }
            ?>
	<div class="breakdown container">
		<div class="entry-head">
			<p class="entry-rank">
				<strong>#<?php 
            echo $j;
            ?>
</strong>
			</p>
			<p class="entry-member-photo">
				<img src="<?php 
            echo $profile->getPicture($anon);
            ?>
Example #3
0
 /**
  * Processes the password set form
  *
  * @return void
  */
 public function settingpasswordTask()
 {
     // Check for request forgeries
     Session::checkToken('post') or exit(Lang::txt('JINVALID_TOKEN'));
     // Get the token and user id from the verification process
     $token = User::getState('com_users.reset.token', null);
     $id = User::getState('com_users.reset.user', null);
     $no_html = Request::getInt('no_html', 0);
     // Check the token and user id
     if (empty($token) || empty($id)) {
         throw new Exception(Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_TOKENS_MISSING'), 403);
     }
     // Get the user object
     $user = \Hubzero\User\User::oneOrFail($id);
     // Check for a user and that the tokens match
     if ($user->tokens()->latest()->token !== $token) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&task=setpassword', false), Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_USER_NOT_FOUND'), 'warning');
         return;
     }
     // Make sure the user isn't blocked
     if ($user->block) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&task=setpassword', false), Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_USER_NOT_FOUND'), 'warning');
         return;
     }
     // Instantiate profile classs
     $profile = new \Hubzero\User\Profile();
     $profile->load($id);
     if (\Hubzero\User\Helper::isXDomainUser($user->id)) {
         throw new Exception(Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_LINKED_ACCOUNT'), 403);
     }
     $password_rules = \Hubzero\Password\Rule::getRules();
     $password1 = trim(Request::getVar('password1', null));
     $password2 = trim(Request::getVar('password2', null));
     if (!empty($password1)) {
         $msg = \Hubzero\Password\Rule::validate($password1, $password_rules, $profile->get('username'));
     } else {
         $msg = array();
     }
     require_once dirname(dirname(__DIR__)) . DS . 'helpers' . DS . 'utility.php';
     $error = false;
     $changing = true;
     if (!$password1 || !$password2) {
         $error = Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_PASSWORD_TWICE');
     } elseif ($password1 != $password2) {
         $error = Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_PASSWORD_DONT_MATCH');
     } elseif (!\Components\Members\Helpers\Utility::validpassword($password1)) {
         $error = Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_PASSWORD_INVALID');
     } elseif (!empty($msg)) {
         $error = Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_PASSWORD_FAILS_REQUIREMENTS');
     }
     // If we're resetting password to the current password, just return true
     // That way you can't reset the counter on your current password, or invalidate it by putting it into history
     if (\Hubzero\User\Password::passwordMatches($profile->get('uidNumber'), $password1)) {
         $error = false;
         $changing = false;
         $result = true;
     }
     if ($error) {
         if ($no_html) {
             $response = array('success' => false, 'message' => $error);
             echo json_encode($response);
             die;
         } else {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&task=setpassword', false), $error, 'warning');
             return;
         }
     }
     if ($changing) {
         // Encrypt the password and update the profile
         $result = \Hubzero\User\Password::changePassword($profile->get('username'), $password1);
     }
     // Save the changes
     if (!$result) {
         if ($no_html) {
             $response = array('success' => false, 'message' => Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_GENERIC'));
             echo json_encode($response);
             die;
         } else {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&task=setpassword', false), Lang::txt('COM_MEMBERS_CREDENTIALS_ERROR_GENERIC'), 'warning');
             return;
         }
     }
     // Flush the user data from the session
     User::setState('com_users.reset.token', null);
     User::setState('com_users.reset.user', null);
     if ($no_html) {
         $response = array('success' => true, 'redirect' => Route::url('index.php?option=com_users&view=login', false));
         echo json_encode($response);
         die;
     } else {
         // Everything went well...go to the login page
         App::redirect(Route::url('index.php?option=com_users&view=login', false), Lang::txt('COM_MEMBERS_CREDENTIALS_PASSWORD_RESET_COMPLETE'), 'passed');
     }
 }
Example #4
0
	<div class="clear share-divider"></div>
<?php 
    if ($this->config->get('shareable', 0)) {
        ?>
	<form name="share" id="app-share" method="post" action="<?php 
        echo Route::url('index.php?option=' . $this->option . '&app=' . $this->toolname . '&task=session&sess=' . $this->app->sess);
        ?>
">
		<div class="grid">
		<?php 
        if (is_object($this->app->owns)) {
            ?>
			<div class="col span8">
				<p class="share-member-photo" id="shareform">
					<?php 
            $jxuser = new \Hubzero\User\Profile();
            $jxuser->load(User::get('id'));
            ?>
					<img src="<?php 
            echo $jxuser->getPicture();
            ?>
" alt="" />
				</p>
				<fieldset>
					<legend><?php 
            echo Lang::txt('COM_TOOLS_SHARE_SESSION');
            ?>
</legend>

					<input type="hidden" name="option" value="<?php 
            echo $this->escape($this->option);
Example #5
0
}
?>
">
	<fieldset>
		<legend><?php 
echo Lang::txt('PLG_GROUPS_MEMBERS_ASSIGN_ROLE');
?>
</legend>

		<label for="uid">
			<input type="hidden" name="uid" value="<?php 
echo $this->escape($this->uid);
?>
" id="uid" />
			<?php 
$u = new \Hubzero\User\Profile();
$u->load($this->uid);
$current_roles = array();
$roles = $u->getGroupMemberRoles($u->get('uidNumber'), $this->group->get('gidNumber'));
if ($roles) {
    foreach ($roles as $role) {
        $current_roles[] = $role['name'];
    }
}
?>
			<strong><?php 
echo Lang::txt('PLG_GROUPS_MEMBERS_MEMBER');
?>
: </strong> <?php 
echo $this->escape($u->get('name'));
?>
Example #6
0
 /**
  * Save one or more authors
  *
  * @param      integer $show       Display author list when done?
  * @param      integer $id         Resource ID
  * @param      array   $authorsNew Authors to add
  * @return     void
  */
 public function saveTask($show = 1, $id = 0, $authorsNew = array())
 {
     // Incoming resource ID
     if (!$id) {
         $id = Request::getInt('pid', 0);
     }
     if (!$id) {
         $this->setError(Lang::txt('COM_TOOLS_CONTRIBUTE_NO_ID'));
         if ($show) {
             $this->displayTask($id);
         }
         return;
     }
     // Incoming authors
     $authid = Request::getInt('authid', 0, 'post');
     $authorsNewstr = trim(Request::getVar('new_authors', '', 'post'));
     $role = Request::getVar('role', '', 'post');
     // Turn the string into an array of usernames
     $authorsNew = empty($authorsNew) ? explode(',', $authorsNewstr) : $authorsNew;
     // Instantiate a resource/contributor association object
     $rc = new \Components\Resources\Tables\Contributor($this->database);
     $rc->subtable = 'resources';
     $rc->subid = $id;
     // Get the last child in the ordering
     $order = $rc->getLastOrder($id, 'resources');
     $order = $order + 1;
     // new items are always last
     // Was there an ID? (this will come from the author <select>)
     if ($authid) {
         // Check if they're already linked to this resource
         $rc->loadAssociation($authid, $id, 'resources');
         if ($rc->authorid) {
             $this->setError(Lang::txt('USER_IS_ALREADY_AUTHOR', $authid));
         } else {
             // Perform a check to see if they have a contributors page. If not, we'll need to make one
             $xprofile = new \Hubzero\User\Profile();
             $xprofile->load($authid);
             if ($xprofile) {
                 $this->_authorCheck($authid);
                 // New record
                 $rc->authorid = $authid;
                 $rc->ordering = $order;
                 $rc->name = addslashes($xprofile->get('name'));
                 $rc->role = addslashes($role);
                 $rc->organization = addslashes($xprofile->get('organization'));
                 $rc->createAssociation();
                 $order++;
             }
         }
     }
     // Do we have new authors?
     if (!empty($authorsNew)) {
         jimport('joomla.user.helper');
         // loop through each one
         for ($i = 0, $n = count($authorsNew); $i < $n; $i++) {
             $cid = trim($authorsNew[$i]);
             if (is_numeric($cid)) {
                 $uid = intval($cid);
             } else {
                 $cid = strtolower($cid);
                 // Find the user's account info
                 $uid = \JUserHelper::getUserId($cid);
                 if (!$uid) {
                     $this->setError(Lang::txt('COM_CONTRIBUTE_UNABLE_TO_FIND_USER_ACCOUNT', $cid));
                     continue;
                 }
             }
             $user = User::getInstance($uid);
             if (!is_object($user)) {
                 $this->setError(Lang::txt('COM_CONTRIBUTE_UNABLE_TO_FIND_USER_ACCOUNT', $cid));
                 continue;
             }
             $uid = $user->get('id');
             if (!$uid) {
                 $this->setError(Lang::txt('COM_CONTRIBUTE_UNABLE_TO_FIND_USER_ACCOUNT', $cid));
                 continue;
             }
             // Check if they're already linked to this resource
             $rcc = new \Components\Resources\Tables\Contributor($this->database);
             $rcc->loadAssociation($uid, $id, 'resources');
             if ($rcc->authorid) {
                 $this->setError(Lang::txt('USER_IS_ALREADY_AUTHOR', $cid));
                 continue;
             }
             $this->_authorCheck($uid);
             $xprofile = \Hubzero\User\Profile::getInstance($user->get('id'));
             $rcc->subtable = 'resources';
             $rcc->subid = $id;
             $rcc->authorid = $uid;
             $rcc->ordering = $order;
             $rcc->name = $xprofile->get('name');
             $rcc->role = $role;
             $rcc->organization = $xprofile->get('organization');
             if (!$rcc->createAssociation()) {
                 $this->setError($rcc->getError());
             }
             $order++;
         }
     }
     if ($show) {
         // Push through to the authors view
         $this->displayTask($id);
     }
 }
Example #7
0
 /**
  * Display a form for registering for an event
  *
  * @return     void
  */
 public function eventregisterTask()
 {
     // Get some needed info
     $offset = $this->offset;
     $year = $this->year;
     $month = $this->month;
     $day = $this->day;
     $option = $this->_option;
     // Incoming
     $id = Request::getInt('id', 0, 'request');
     // Ensure we have an ID
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Load event
     $event = new Event($this->database);
     $event->load($id);
     // Ensure we have an event
     if (!$event->title || $event->registerby == '0000-00-00 00:00:00') {
         App::Redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     $auth = true;
     if ($this->config->getCfg('adminlevel')) {
         $auth = $this->_authorize();
     }
     $bits = explode('-', $event->publish_up);
     $eyear = $bits[0];
     $emonth = $bits[1];
     $edbits = explode(' ', $bits[2]);
     $eday = $edbits[0];
     // Set the page title
     Document::setTitle(Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt('EVENTS_REGISTER') . ': ' . stripslashes($event->title));
     // Set the pathway
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option);
     }
     Pathway::append($eyear, 'index.php?option=' . $this->_option . '&year=' . $eyear);
     Pathway::append($emonth, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth);
     Pathway::append($eday, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth . '&day=' . $eday);
     Pathway::append(stripslashes($event->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $event->id);
     Pathway::append(Lang::txt('EVENTS_REGISTER'), 'index.php?option=' . $this->_option . '&task=details&id=' . $event->id . '&page=register');
     $page = new Page($this->database);
     $page->alias = $this->_task;
     // Get the pages for this workshop
     $pages = $page->loadPages($event->id);
     // Check if registration is still open
     $registerby = strtotime($event->registerby);
     $now = time();
     $register = array();
     if (!User::isGuest()) {
         $profile = new \Hubzero\User\Profile();
         $profile->load(User::get('id'));
         $register['firstname'] = $profile->get('givenName');
         $register['lastname'] = $profile->get('surname');
         $register['affiliation'] = $profile->get('organization');
         $register['email'] = $profile->get('email');
         $register['telephone'] = $profile->get('phone');
         $register['website'] = $profile->get('url');
     }
     // Is the registration open?
     if ($registerby >= $now) {
         // Is the registration restricted?
         if ($event->restricted) {
             $passwrd = Request::getVar('passwrd', '', 'post');
             if ($event->restricted == $passwrd) {
                 // Instantiate a view
                 $this->view->setLayout('default');
                 $this->view->state = 'open';
             } else {
                 // Instantiate a view
                 $this->view->setLayout('restricted');
                 $this->view->state = 'restricted';
             }
         } else {
             // Instantiate a view
             $this->view->setLayout('default');
             $this->view->state = 'open';
         }
     } else {
         // Instantiate a view
         $this->view->setLayout('closed');
         $this->view->state = 'closed';
     }
     // Output HTML
     $this->view->setName('register');
     $this->view->option = $this->_option;
     $this->view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt('EVENTS_REGISTER');
     $this->view->task = $this->_task;
     $this->view->year = $year;
     $this->view->month = $month;
     $this->view->day = $day;
     $this->view->offset = $offset;
     $this->view->event = $event;
     $this->view->authorized = $auth;
     $this->view->page = $page;
     $this->view->pages = $pages;
     $this->view->register = $register;
     $this->view->arrival = null;
     $this->view->departure = null;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }
Example #8
0
 /**
  * Gets the full name of a user from their ID #
  *
  * @return     string
  */
 public function authorTask()
 {
     $this->view->id = Request::getVar('u', '');
     $this->view->role = Request::getVar('role', '');
     $rid = Request::getInt('rid', 0);
     // Get the member's info
     $profile = new \Hubzero\User\Profile();
     $profile->load($this->view->id);
     if (!is_object($profile) || !$profile->get('uidNumber')) {
         $this->database->setQuery("SELECT id FROM `#__users` WHERE `name`=" . $this->database->Quote($this->view->id));
         if ($id = $this->database->loadResult()) {
             $profile->load($id);
         }
     }
     if (is_object($profile) && $profile->get('uidNumber')) {
         if (!$profile->get('name')) {
             $this->view->name = $profile->get('givenName') . ' ';
             $this->view->name .= $profile->get('middleName') ? $profile->get('middleName') . ' ' : '';
             $this->view->name .= $profile->get('surname');
         } else {
             $this->view->name = $profile->get('name');
         }
         $this->view->org = $profile->get('organization');
         $this->view->id = $profile->get('uidNumber');
     } else {
         $this->view->name = null;
         include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'contributor.php';
         $rcc = new Contributor($this->database);
         if (is_numeric($this->view->id)) {
             $this->database->setQuery("SELECT name, organization FROM `#__author_assoc` WHERE authorid=" . $this->database->Quote($this->view->id) . " LIMIT 1");
             $author = $this->database->loadObject();
             if (is_object($author) && $author->name) {
                 $this->view->name = $author->name;
                 $this->view->org = $author->organization;
             }
         }
         if (!$this->view->name) {
             $this->view->org = '';
             $this->view->name = str_replace('_', ' ', $this->view->id);
             $this->view->id = $rcc->getUserId($this->view->name);
         }
     }
     $row = new Resource($this->database);
     $row->load($rid);
     $rt = new Type($this->database);
     $this->view->roles = $rt->getRolesForType($row->type);
     $this->view->display();
 }
Example #9
0
 /**
  * Method is called after user data is stored in the database
  *
  * @param   array    $user     holds the new user data
  * @param   boolean  $isnew    true if a new user is stored
  * @param   boolean  $success  true if user was succesfully stored in the database
  * @param   string   $msg      message
  * @return  void
  */
 public function onAfterStoreUser($user, $isnew, $success, $msg)
 {
     $xprofile = \Hubzero\User\Profile::getInstance($user['id']);
     if (!is_object($xprofile)) {
         $params = Component::params('com_members');
         $hubHomeDir = rtrim($params->get('homedir'), '/');
         if (empty($hubHomeDir)) {
             // try to deduce a viable home directory based on sitename or live_site
             $sitename = strtolower(Config::get('sitename'));
             $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
             $sitename = trim($sitename, '/ ');
             $sitename_e = explode('.', $sitename, 2);
             if (isset($sitename_e[1])) {
                 $sitename = $sitename_e[0];
             }
             if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                 $sitename = '';
             }
             if (empty($sitename)) {
                 $sitename = strtolower(Request::base());
                 $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
                 $sitename = trim($sitename, '/ ');
                 $sitename_e = explode('.', $sitename, 2);
                 if (isset($sitename_e[1])) {
                     $sitename = $sitename_e[0];
                 }
                 if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                     $sitename = '';
                 }
             }
             $hubHomeDir = DS . 'home';
             if (!empty($sitename)) {
                 $hubHomeDir .= DS . $sitename;
             }
             if (!empty($hubHomeDir)) {
                 $db = App::get('db');
                 $component = new JTableExtension($this->database);
                 $component->load($component->find(array('element' => 'com_members', 'type' => 'component')));
                 $params = new \Hubzero\Config\Registry($component->params);
                 $params->set('homedir', $hubHomeDir);
                 $component->params = $params->toString();
                 $component->store();
             }
         }
         $xprofile = new \Hubzero\User\Profile();
         $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
         $xprofile->set('gid', $params->get('gid', 'users'));
         $xprofile->set('uidNumber', $user['id']);
         $xprofile->set('homeDirectory', isset($user['homeDirectory']) ? $user['homeDirectory'] : $hubHomeDir . DS . $user['username']);
         $xprofile->set('loginShell', isset($user['loginShell']) ? $user['loginShell'] : '/bin/bash');
         $xprofile->set('ftpShell', isset($user['ftpShell']) ? $user['ftpShell'] : '/usr/lib/sftp-server');
         $xprofile->set('name', $user['name']);
         $xprofile->set('email', $user['email']);
         $xprofile->set('username', $user['username']);
         $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']);
         //$xprofile->set('emailConfirmed', '3');
         $xprofile->set('emailConfirmed', isset($user['activation']) ? $user['activation'] : -rand(1, pow(2, 31) - 1));
         $xprofile->set('public', $params->get('privacy', 0));
         if (isset($_SERVER['REMOTE_HOST'])) {
             $xprofile->set('regHost', $_SERVER['REMOTE_HOST']);
         }
         $xprofile->set('registerDate', Date::toSql());
         $result = $xprofile->create();
         if (!$result) {
             return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500);
         }
     } else {
         $update = false;
         $params = Component::params('com_members');
         if ($xprofile->get('username') != $user['username']) {
             $xprofile->set('username', $user['username']);
             $update = true;
         }
         if ($xprofile->get('name') != $user['name']) {
             $xprofile->set('name', $user['name']);
             $update = true;
         }
         // Fix missing surname/given name as well
         if ($xprofile->get('name') && (!$xprofile->get('surname') || !$xprofile->get('givenName'))) {
             $firstname = $xprofile->get('givenName');
             $middlename = $xprofile->get('middleName');
             $lastname = $xprofile->get('surname');
             $words = array_map('trim', explode(' ', $xprofile->get('name')));
             $count = count($words);
             if ($count == 1) {
                 $firstname = $words[0];
             } else {
                 if ($count == 2) {
                     $firstname = $words[0];
                     $lastname = $words[1];
                 } else {
                     if ($count == 3) {
                         $firstname = $words[0];
                         $middlename = $words[1];
                         $lastname = $words[2];
                     } else {
                         $firstname = $words[0];
                         $lastname = $words[$count - 1];
                         $middlename = $words[1];
                         for ($i = 2; $i < $count - 1; $i++) {
                             $middlename .= ' ' . $words[$i];
                         }
                     }
                 }
             }
             $firstname = trim($firstname);
             if ($firstname) {
                 $xprofile->set('givenName', $firstname);
             }
             $middlename = trim($middlename);
             if ($middlename) {
                 $xprofile->set('middleName', $middlename);
             }
             $lastname = trim($lastname);
             if ($lastname) {
                 $xprofile->set('surname', $lastname);
             }
             $update = true;
         }
         if ($xprofile->get('email') != $user['email']) {
             $xprofile->set('email', $user['email']);
             $xprofile->set('emailConfirmed', 0);
             $update = true;
         }
         if ($xprofile->get('emailConfirmed') == '') {
             $xprofile->set('emailConfirmed', '3');
             $update = true;
         }
         if ($xprofile->get('gid') == '') {
             $xprofile->set('gid', $params->get('gid', 'users'));
             $update = true;
         }
         if ($xprofile->get('gidNumber') == '') {
             $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
             $update = true;
         }
         if ($xprofile->get('loginShell') == '') {
             $xprofile->set('loginShell', '/bin/bash');
             $update = true;
         }
         if ($xprofile->get('ftpShell') == '') {
             $xprofile->set('ftpShell', '/usr/lib/sftp-server');
             // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy
             $xprofile->set('public', $params->get('privacy', 0));
             $update = true;
         }
         if ($update) {
             $xprofile->update();
         }
     }
     // Check if quota exists for the user
     $params = Component::params('com_members');
     if ($params->get('manage_quotas', false)) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'quota.php';
         $quota = Components\Members\Models\Quota::all()->whereEquals('user_id', $user['id'])->row();
         if (!$quota->get('id')) {
             $class = Components\Members\Models\Quota\Category::defaultEntry();
             if ($class->get('id')) {
                 $quota->set('user_id', $user['id']);
                 $quota->set('class_id', $class->get('id'));
                 $quota->set('soft_blocks', $class->get('soft_blocks'));
                 $quota->set('hard_blocks', $class->get('hard_blocks'));
                 $quota->set('soft_files', $class->get('soft_files'));
                 $quota->set('hard_files', $class->get('hard_files'));
                 $quota->save();
             }
         }
     }
     if ($success) {
         Event::trigger('members.onMemberAfterSave', array($user, $isnew, $success, $msg));
     }
 }
Example #10
0
    ?>
														<?php 
    echo $group->description;
    ?>
													</td>
												</tr>
												<tr>
													<td>
														<?php 
    foreach ($posts as $post) {
        ?>
															<table id="course-discussions" width="650" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;">
																<tr>
																	<td width="75" style="padding: 10px 0;">
																		<?php 
        $path = Hubzero\User\Profile::getInstance($post->created_by)->getPicture(0, true, false);
        ?>
																		<img width="50" src="<?php 
        echo Request::root() . $path;
        ?>
" />
																	</td>
																	<td style="padding: 10px 0;">
																		<div style="position: relative; border: 1px solid #CCCCCC; padding: 12px; -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px;">
																			<div style="background: #FFFFFF; border: 1px solid #CCCCCC; width: 15px; height: 15px;
																				position: absolute; top: 50%; left: -10px; margin-top: -7px;
																				transform:rotate(45deg); -ms-transform:rotate(45deg); -webkit-transform:rotate(45deg);"></div>
																			<div style="background: #FFFFFF; width: 11px; height: 23px; position: absolute; top: 50%; left: -1px; margin-top: -10px;"></div>
																			<div style="color: #AAAAAA; font-size: 11px;">
																				<?php 
        echo User::getInstance($post->created_by)->get('name');
Example #11
0
    ?>
			<?php 
    echo Lang::txt('COM_FORUM_NEW_DISCUSSION');
    ?>
		<?php 
}
?>
		</h3>
		<form action="<?php 
echo Route::url($action);
?>
" method="post" id="commentform" enctype="multipart/form-data">
			<p class="comment-member-photo">
				<a class="comment-anchor" name="commentform"></a>
				<?php 
$jxuser = new \Hubzero\User\Profile();
$jxuser->load($this->post->get('created_by', User::get('id')));
?>
				<img src="<?php 
echo $jxuser->getPicture();
?>
" alt="" />
			</p>

			<fieldset>
			<?php 
if ($this->config->get('access-manage-thread') && !$this->post->get('parent')) {
    ?>
				<div class="grid">
					<div class="col span-half">
						<label for="field-sticky">
Example #12
0
 public function uploadcsvTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // See if we have a file
     $csvFile = Request::getVar('csvFile', false, 'files', 'array');
     $sId = Request::getVar('sId', '');
     if (isset($csvFile['name']) && $csvFile['name'] && $csvFile['type'] == 'text/csv') {
         if (($handle = fopen($csvFile['tmp_name'], "r")) !== FALSE) {
             $inserted = 0;
             $skipped = array();
             $ignored = array();
             while (($line = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if (!empty($line[0])) {
                     $usr = new \Hubzero\User\Profile(trim($line[0]));
                     $uId = $usr->get('uidNumber');
                     if ($uId) {
                         $res = RestrictionsHelper::addSkuUser($uId, $sId);
                         if ($res) {
                             $inserted++;
                         } else {
                             $skipped[] = $usr;
                         }
                     } else {
                         $ignored[] = $line[0];
                     }
                 }
             }
             fclose($handle);
         } else {
             $this->view->setError('Could not read the file.');
         }
     } else {
         $this->view->setError('No file or bad file was uploaded. Please make sure you upload the CSV formated file.');
     }
     // Output the HTML
     $this->view->sId = $sId;
     $this->view->inserted = $inserted;
     $this->view->skipped = $skipped;
     $this->view->ignored = $ignored;
     $this->view->display();
 }
Example #13
0
 /**
  * Display host entries for a member
  *
  * @param   object  $profile  \Hubzero\User\Profile
  * @return  void
  */
 public function displayTask($profile = null)
 {
     // Incoming
     if (!$profile) {
         $id = Request::getInt('id', 0, 'get');
         $profile = new \Hubzero\User\Profile();
         $profile->load($id);
     }
     // Get a list of all hosts
     $this->view->rows = $profile->get('host');
     $this->view->id = $profile->get('uidNumber');
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Output the HTML
     $this->view->setLayout('display')->display();
 }
Example #14
0
 /**
  * Set local password
  *
  * @return void - redirect to members account page
  */
 private function setlocalpass()
 {
     // Logged in?
     if ($this->user->get('guest')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->option . '&task=myaccount&active=account&action=setlocalpass'))), Lang::txt('You must be a logged in to access this area.'), 'warning');
         return;
     }
     // Get the token from the user state variable
     $token = User::getState($this->option . 'token');
     // First check to make sure they're not trying to jump to this page without first verifying their token
     if (is_null($token)) {
         // Tsk tsk, no sneaky business
         App::redirect(Route::url('index.php?option=' . $this->option . '&id=' . $this->user->get('id') . '&active=account&task=sendtoken'), Lang::txt('You must first verify your email address by inputting the token.'), 'error');
         return;
     }
     // Get the password input
     $password1 = Request::getVar('password1', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $password2 = Request::getVar('password2', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $change = Request::getVar('change', '', 'post');
     // Create the view
     $view = new \Hubzero\Plugin\View(array('folder' => 'members', 'element' => 'account', 'name' => 'setlocalpassword', 'layout' => 'setlocalpass'));
     // Add a few more variables to the view
     $view->option = $this->option;
     $view->id = $this->user->get('id');
     // Get the password rules
     $password_rules = \Hubzero\Password\Rule::getRules();
     // Get the password rule descriptions
     $view->password_rules = array();
     foreach ($password_rules as $rule) {
         if (!empty($rule['description'])) {
             $view->password_rules[] = $rule['description'];
         }
     }
     // Blank form request (no data submitted)
     if (empty($change)) {
         $view->notifications = $this->getPluginMessage() ? $this->getPluginMessage() : array();
         return $view->loadTemplate();
     }
     // Check for request forgeries
     Request::checkToken();
     // Load some needed libraries
     jimport('joomla.user.helper');
     // Initiate profile classs
     $profile = new \Hubzero\User\Profile();
     $profile->load($this->user->get('id'));
     // Fire the onBeforeStoreUser trigger
     Event::trigger('user.onBeforeStoreUser', array($this->user->getProperties(), false));
     // Validate the password against password rules
     if (!empty($password1)) {
         $msg = \Hubzero\Password\Rule::validate($password1, $password_rules, $profile->get('username'));
     } else {
         $msg = array();
     }
     // Verify password
     $passrules = false;
     if (!$password1 || !$password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_MUST_BE_ENTERED_TWICE'));
     } elseif ($password1 != $password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_NEW_CONFIRMATION_MISMATCH'));
     } elseif (!empty($msg)) {
         $this->setError(Lang::txt('Password does not meet site password requirements. Please choose a password meeting all the requirements listed.'));
         $passrules = true;
     }
     // Were there any errors?
     if ($this->getError()) {
         $change = array();
         $change['_missing']['password'] = $this->getError();
         if (!empty($msg) && $passrules) {
             //$change = $msg;
         }
         if (Request::getInt('no_html', 0)) {
             echo json_encode($change);
             exit;
         } else {
             $view->setError($this->getError());
             return $view->loadTemplate();
         }
     }
     // No errors, so let's move on - encrypt the password and update the profile
     $result = \Hubzero\User\Password::changePassword($profile->get('uidNumber'), $password1);
     // Save the changes
     if (!$result) {
         $view->setError(Lang::txt('MEMBERS_PASS_CHANGE_FAILED'));
         return $view->loadTemplate();
     }
     // Fire the onAfterStoreUser trigger
     Event::trigger('user.onAfterStoreUser', array($this->user->getProperties(), false, null, $this->getError()));
     // Flush the variables from the session
     User::setState($this->option . 'token', null);
     // Redirect
     if (Request::getInt('no_html', 0)) {
         echo json_encode(array("success" => true, "redirect" => Route::url($this->member->getLink() . '&active=account')));
         exit;
     } else {
         // Redirect user to confirm view page
         App::redirect(Route::url($this->member->getLink() . '&active=account'), Lang::txt('Password reset successful'), 'passed');
     }
     return;
 }
Example #15
0
            ?>
		<?php 
        }
        ?>
		</h3>

			<form method="post" action="<?php 
        echo Route::url($this->url);
        ?>
" id="commentform">
				<p class="comment-member-photo">
					<span class="comment-anchor"></span>
					<?php 
        $anonymous = 1;
        if (!User::isGuest()) {
            $jxuser = new \Hubzero\User\Profile();
            $jxuser->load(User::get('id'));
            $anonymous = 0;
        }
        ?>
					<img src="<?php 
        echo $jxuser->getPicture($anonymous);
        ?>
" alt="" />
				</p>
				<fieldset>
				<?php 
        if (!User::isGuest()) {
            if ($replyto = Request::getInt('replyto', 0)) {
                $reply = new \Hubzero\Item\Comment($this->database);
                $reply->load($replyto);
Example #16
0
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$user = new \Hubzero\User\Profile();
$user->load(User::get('id'));
$unknown = true;
$name = '';
$usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
$notify = array();
if ($this->row->get('login')) {
    if ($this->row->get('name')) {
        jimport('joomla.user.helper');
        $usertype = implode(', ', JUserHelper::getUserGroups($this->row->submitter('id')));
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&task=edit&id=' . $this->row->submitter('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = false;
        $notify[] = $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')';
    }
}
if (!$name) {
Example #17
0
            echo Lang::txt('COM_MEMBERS_IMPORT_DISPLAY_ON');
            ?>
</strong>
								<time datetime="<?php 
            echo $import->get('ran_at');
            ?>
"><?php 
            echo Date::of($lastRun->get('ran_at'))->toLocal('m/d/Y @ g:i a');
            ?>
</time><br />
								<strong><?php 
            echo Lang::txt('COM_MEMBERS_IMPORT_DISPLAY_BY');
            ?>
</strong>
								<?php 
            if ($created_by = Hubzero\User\Profile::getInstance($lastRun->get('ran_by'))) {
                echo $created_by->get('name');
            }
            ?>
							<?php 
        } else {
            ?>
								n/a
							<?php 
        }
        ?>
						</td>
						<td class="priority-4">
							<?php 
        $runs = $import->runs('list', array('import' => $import->get('id'), 'dry_run' => 0));
        echo $runs->count();
Example #18
0
 /**
  * @since	1.6
  */
 function processResetComplete($data)
 {
     // Get the form.
     $form = $this->getResetCompleteForm();
     // Check for an error.
     if ($form instanceof Exception) {
         return $form;
     }
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data);
     // Check for an error.
     if ($return instanceof Exception) {
         return $return;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             $this->setError($message);
         }
         return false;
     }
     // Get the token and user id from the confirmation process.
     $app = JFactory::getApplication();
     $token = $app->getUserState('com_users.reset.token', null);
     $id = $app->getUserState('com_users.reset.user', null);
     // Check the token and user id.
     if (empty($token) || empty($id)) {
         return new Exception(Lang::txt('COM_USERS_RESET_COMPLETE_TOKENS_MISSING'), 403);
     }
     // Get the user object.
     $user = User::getInstance($id);
     // Check for a user and that the tokens match.
     if (empty($user) || $user->activation !== $token) {
         $this->setError(Lang::txt('COM_USERS_USER_NOT_FOUND'));
         return false;
     }
     // Make sure the user isn't blocked.
     if ($user->block) {
         $this->setError(Lang::txt('COM_USERS_USER_BLOCKED'));
         return false;
     }
     // Initiate profile classs
     $profile = new \Hubzero\User\Profile();
     $profile->load($id);
     if (\Hubzero\User\Helper::isXDomainUser($user->get('id'))) {
         App::abort(403, Lang::txt('This is a linked account. To change your password you must change it using the procedures available where the account you are linked to is managed.'));
         return;
     }
     $password_rules = \Hubzero\Password\Rule::getRules();
     $password1 = $data['password1'];
     $password2 = $data['password2'];
     if (!empty($password1)) {
         $msg = \Hubzero\Password\Rule::validate($password1, $password_rules, $profile->get('username'));
     } else {
         $msg = array();
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'helpers' . DS . 'utility.php';
     if (!$password1 || !$password2) {
         $this->setError(Lang::txt('you must enter your new password twice to ensure we have it correct'));
     } elseif ($password1 != $password2) {
         $this->setError(Lang::txt('the new password and confirmation you entered do not match. Please try again'));
     } elseif (!\Components\Members\Helpers\Utility::validpassword($password1)) {
         $this->setError(Lang::txt('the password you entered was invalid password. You may be using characters that are not allowed'));
     } elseif (!empty($msg)) {
         $this->setError(Lang::txt('the password does not meet site password requirements. Please choose a password meeting all the requirements listed below.'));
     }
     if ($this->getError()) {
         $this->setError($this->getError());
         return false;
     }
     // Encrypt the password and update the profile
     $result = \Hubzero\User\Password::changePassword($profile->get('username'), $password1);
     // Save the changes
     if (!$result) {
         $this->setError(Lang::txt('There was an error changing your password.'));
         return false;
     }
     // Flush the user data from the session.
     $app->setUserState('com_users.reset.token', null);
     $app->setUserState('com_users.reset.user', null);
     return true;
 }
Example #19
0
         $row->givenName = array_shift($bits);
     }
     if (count($bits) >= 1) {
         $row->middleName = implode(' ', $bits);
     }
 }
 $name = $row->surname ? stripslashes($row->surname) : '';
 if ($row->givenName) {
     $name .= $row->surname ? ', ' : '';
     $name .= stripslashes($row->givenName);
     $name .= $row->middleName ? ' ' . stripslashes($row->middleName) : '';
 }
 if (!trim($name)) {
     $name = Lang::txt('COM_MEMBERS_UNKNOWN') . ' (' . $row->username . ')';
 }
 $profile = new \Hubzero\User\Profile();
 $profile->set('uidNumber', $row->uidNumber);
 $profile->set('email', $row->email);
 $profile->set('picture', $row->picture);
 $p = \Hubzero\User\Profile\Helper::getMemberPhoto($profile);
 // User messaging
 $messageuser = false;
 if ($messaging && $row->uidNumber > 0 && $row->uidNumber != User::get('id')) {
     switch ($this->config->get('user_messaging')) {
         case 1:
             // Get the groups of the profile
             $pgroups = \Hubzero\User\Helper::getGroups($row->uidNumber, 'all');
             // Get the groups the user has access to
             $profilesgroups = array();
             if (!empty($pgroups)) {
                 foreach ($pgroups as $group) {
Example #20
0
 /**
  * Conform user's registration code
  *
  * @return     void
  */
 public function confirmTask()
 {
     // Incoming
     $code = Request::getVar('confirm', false);
     if (!$code) {
         $code = Request::getVar('code', false);
     }
     // Check if the user is logged in
     if (User::isGuest()) {
         $return = base64_encode(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=' . $this->_task . '&confirm=' . $code, false, true));
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return, false), Lang::txt('Please login in so we can confirm your account.'), 'warning');
         return;
     }
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     $xprofile = \Hubzero\User\Profile::getInstance(User::get('id'));
     $email_confirmed = $xprofile->get('emailConfirmed');
     if ($email_confirmed == 1 || $email_confirmed == 3) {
         // The current user is confirmed - check to see if the incoming code is valid at all
         if (\Components\Members\Helpers\Utility::isActiveCode($code)) {
             $this->setError('login mismatch');
             // Build logout/login/confirm redirect flow
             $login_return = base64_encode(Route::url('index.php?option=' . $this->option . '&controller=' . $this->_controller . '&task=' . $this->_task . '&confirm=' . $code));
             $logout_return = base64_encode(Route::url('index.php?option=com_users&view=login&return=' . $login_return));
             $redirect = Route::url('index.php?option=com_users&view=logout&return=' . $logout_return);
         }
     } elseif ($email_confirmed < 0 && $email_confirmed == -$code) {
         //var to hold return path
         $return = '';
         // get return path
         $cReturn = $this->config->get('ConfirmationReturn');
         if ($cReturn) {
             $return = $cReturn;
         }
         //load user profile
         $profile = new \Hubzero\User\Profile();
         $profile->load($xprofile->get('username'));
         //check to see if we have a return param
         $pReturn = base64_decode(urldecode($profile->getParam('return')));
         if ($pReturn) {
             $return = $pReturn;
             $profile->setParam('return', '');
         }
         // make as confirmed
         $profile->set('emailConfirmed', 1);
         // set public setting
         $profile->set('public', $this->config->get('privacy', '0'));
         // upload profile
         if (!$profile->update()) {
             $this->setError(Lang::txt('COM_MEMBERS_REGISTER_ERROR_CONFIRMING'));
         }
         // if the user just changed their email & confirmed
         // reset 'userchangedemail' key
         if (Session::get('userchangedemail', 0) == 1) {
             Session::set('userchangedemail', 0);
         }
         // Redirect
         if (empty($return)) {
             $r = $this->config->get('ConfirmationReturn');
             $return = $r ? $r : Route::url('index.php?option=com_members&task=myaccount');
             // consume cookie (yum) if available to return to whatever action prompted registration
             if (isset($_COOKIE['return'])) {
                 $return = $_COOKIE['return'];
                 setcookie('return', '', time() - 3600);
             }
         }
         App::redirect($return, '', 'message', true);
     } else {
         $this->setError(Lang::txt('COM_MEMBERS_REGISTER_ERROR_INVALID_CONFIRMATION'));
     }
     // Instantiate a new view
     $this->view->title = Lang::txt('COM_MEMBERS_REGISTER_CONFIRM');
     $this->view->login = $xprofile->get('username');
     $this->view->email = $xprofile->get('email');
     $this->view->code = $code;
     $this->view->redirect = isset($return) ? $return : '';
     $this->view->sitename = Config::get('sitename');
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     $this->view->display();
 }
Example #21
0
		</div>
	<?php 
}
?>
</div>

<?php 
if ($displayComments && $this->page->get('id') > 0) {
    ?>
	<div id="page-comments">
		<?php 
    // get experts
    $experts = array();
    foreach ($this->group->get('members') as $member) {
        // get each members roles
        $roles = Hubzero\User\Profile::getGroupMemberRoles($member, $this->group->get('gidNumber'));
        // make sure roles match pattern "Expert: ..."
        $roles = array_map(function ($role) {
            if (preg_match('/Expert:(.*)/', $role['name'])) {
                return $role['name'];
            }
        }, $roles);
        // if we are in any expert role mark as expert
        if (count($roles) > 0) {
            $experts[] = $member;
        }
    }
    // mark comments for experts
    $params = new \Hubzero\Config\Registry();
    $params->set('onCommentMark', function ($comment) use($experts) {
        if (in_array($comment->creator('id'), $experts)) {
Example #22
0
					<?php 
echo Lang::txt('COM_DEVELOPER_API_APPLICATION_TOKENS_REVOKE_ALL_TOKEN');
?>
				</a>
			</h3>
			<ul class="entries-list tokens access-tokens">
				<?php 
if ($total > 0) {
    ?>
					<?php 
    foreach ($this->application->accessTokens($filters) as $token) {
        ?>
						<li>
							<h4>
								<?php 
        echo Hubzero\User\Profile::getInstance($token->get('uidNumber'))->get('name');
        ?>
							</h4>

							<a class="btn btn-secondary revoke confirm" data-txt-confirm="<?php 
        echo Lang::txt('COM_DEVELOPER_API_APPLICATION_TOKENS_REVOKE_TOKEN_CONFIRM');
        ?>
" href="<?php 
        echo Route::url($this->application->link('revoke') . '&token=' . $token->get('id') . '&return=tokens');
        ?>
">
								<?php 
        echo Lang::txt('COM_DEVELOPER_API_APPLICATION_TOKENS_REVOKE_TOKEN');
        ?>
							</a>
Example #23
0
 /**
  * Add/edit job form
  *
  * @return     void
  */
 public function editjobTask()
 {
     $live_site = rtrim(Request::base(), '/');
     // Incoming
     $code = Request::getVar('code', '');
     $empid = $this->_admin ? 1 : User::get('id');
     $code = !$code && $this->_jobCode ? $this->_jobCode : $code;
     // Login required
     if (User::isGuest()) {
         \Notify::warning(Lang::txt('COM_JOBS_PLEASE_LOGIN_ACCESS_EMPLOYER'));
         $this->login();
         return;
     }
     $job = new Job($this->database);
     $jobadmin = new JobAdmin($this->database);
     $employer = new Employer($this->database);
     if (!$this->_emp && !$this->_admin) {
         // need to subscribe first
         $employer = new Employer($this->database);
         if ($employer->loadEmployer($empid)) {
             //do we have a pending subscription?
             $subscription = new Subscription($this->database);
             if ($subscription->loadSubscription($employer->subscriptionid, User::get('id'), '', $status = array(0))) {
                 App::redirect(Route::url('index.php?option=com_jobs&task=dashboard'), Lang::txt('COM_JOBS_WARNING_SUBSCRIPTION_PENDING'), 'warning');
                 return;
             }
         }
         // send to subscription page
         App::redirect(Route::url('index.php?option=com_jobs&task=subscribe'));
         return;
     }
     if ($code) {
         if (!$job->loadJob($code)) {
             App::abort(404, Lang::txt('COM_JOBS_ERROR_JOB_NOT_FOUND'));
         }
         // check if user is authorized to edit
         if ($this->_admin or $jobadmin->isAdmin(User::get('id'), $job->id) or User::get('id') == $job->employerid) {
             // we are editing
             $code = $job->code;
         } else {
             App::abort(403, Lang::txt('COM_JOBS_ALERTNOTAUTH'));
         }
     }
     // display with errors
     if ($this->_job) {
         $job = $this->_job;
     }
     $uid = $code ? $job->employerid : User::get('id');
     $job->admins = $code ? $jobadmin->getAdmins($job->id) : array(User::get('id'));
     // Get the member's info
     $profile = new \Hubzero\User\Profile();
     $profile->load($uid);
     // load Employer
     if (!$employer->loadEmployer($uid) && !$this->_admin) {
         App::abort(404, Lang::txt('COM_JOBS_ERROR_EMPLOYER_NOT_FOUND'));
     } else {
         if (!$employer->id && $this->_admin) {
             $employer->uid = 1;
             $employer->subscriptionid = 1;
             $employer->companyName = Config::get('sitename');
             $employer->companyLocation = '';
             $employer->companyWebsite = $live_site;
             $uid = 1;
             // site admin
         }
     }
     // Push some styles to the template
     $this->css();
     // Push some scripts to the template
     $this->js();
     // Push some styles to the tmeplate
     $this->css('calendar.css');
     $jt = new JobType($this->database);
     $jc = new JobCategory($this->database);
     // get job types
     $types = $jt->getTypes();
     $types[0] = Lang::txt('COM_JOBS_TYPE_ANY');
     // get job categories
     $cats = $jc->getCats();
     $cats[0] = Lang::txt('COM_JOBS_CATEGORY_NO_SPECIFIC');
     // Set page title
     $this->_buildTitle();
     // Set the pathway
     $this->_jobid = $job->id;
     $this->_jobtitle = $job->title;
     $this->_buildPathway();
     // Output HTML
     $this->view->title = $this->_title;
     $this->view->config = $this->config;
     $this->view->uid = $uid;
     $this->view->profile = $profile;
     $this->view->emp = $this->_emp;
     $this->view->job = $job;
     $this->view->jobid = $job->id;
     $this->view->types = $types;
     $this->view->cats = $cats;
     $this->view->employer = $employer;
     $this->view->admin = $this->_admin;
     $this->view->task = $this->_task;
     $this->view->option = $this->_option;
     // Set any errors
     if ($this->getError()) {
         \Notify::error($this->getError());
     }
     $this->view->setName('editjob')->setLayout('default')->display();
 }
Example #24
0
 /**
  * Register View for Event
  *
  * @return     string
  */
 private function register()
 {
     //create the view
     $view = $this->view('register', 'calendar');
     //get request varse
     $eventId = Request::getVar('event_id', '');
     //load event data
     $view->event = new \Components\Events\Models\Event($eventId);
     //get registrants count
     $eventsRespondent = new \Components\Events\Tables\Respondent(array('id' => $eventId));
     $view->registrants = $eventsRespondent->getCount();
     //do we have a registration deadline
     if ($view->event->get('registerby') == '' || $view->event->get('registerby') == '0000-00-00 00:00:00') {
         App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=details&event_id=' . $view->event->get('id')), Lang::txt('This event does not have registration.'), 'warning');
         return;
     }
     //make sure registration is open
     $now = Date::toUnix();
     $registerby = Date::of($view->event->get('registerby'))->toUnix();
     if ($registerby >= $now) {
         //get the password
         $password = Request::getVar('passwrd', '', 'post');
         //is the event restricted
         if ($view->event->get('restricted') != '' && $view->event->get('restricted') != $password && !isset($this->register)) {
             //if we entered a password and it was bad lets tell the user
             if (isset($password) && $password != '') {
                 $this->setError('The password entered is incorrect.');
             }
             $view->setLayout('register_restricted');
         }
     } else {
         $view->setLayout('register_closed');
     }
     //push some vars to the view
     $view->month = $this->month;
     $view->year = $this->year;
     $view->group = $this->group;
     $view->option = $this->option;
     $view->authorized = $this->authorized;
     $view->user = $this->user;
     $view->register = isset($this->register) ? $this->register : null;
     $view->arrival = isset($this->arrival) ? $this->arrival : null;
     $view->departure = isset($this->departure) ? $this->departure : null;
     $view->dietary = isset($this->dietary) ? $this->dietary : null;
     $view->dinner = isset($this->dinner) ? $this->dinner : null;
     $view->disability = isset($this->disability) ? $this->disability : null;
     $view->race = isset($this->race) ? $this->race : null;
     //add params to view
     $view->params = new \Hubzero\Config\Registry($view->event->get('params'));
     if (!$this->user->get('guest')) {
         $profile = new \Hubzero\User\Profile();
         $profile->load($this->user->get('id'));
         $view->register['first_name'] = $profile->get('givenName');
         $view->register['last_name'] = $profile->get('surname');
         $view->register['affiliation'] = $profile->get('organization');
         $view->register['email'] = $profile->get('email');
         $view->register['telephone'] = $profile->get('phone');
         $view->register['website'] = $profile->get('url');
     }
     //get any errors if there are any
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     //load the view
     return $view->loadTemplate();
 }
Example #25
0
    echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_ID');
    ?>
</th>
							<td><?php 
    echo $this->import->get('id');
    ?>
</td>
						</tr>
						<tr>
							<th><?php 
    echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_CREATEDBY');
    ?>
</th>
							<td>
								<?php 
    if ($created_by = Hubzero\User\Profile::getInstance($this->import->get('created_by'))) {
        echo $created_by->get('name');
    }
    ?>
							</td>
						</tr>
						<tr>
							<th><?php 
    echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_CREATEDON');
    ?>
</th>
							<td>
								<?php 
    echo Date::of($this->import->get('created_at'))->toLocal('m/d/Y @ g:i a');
    ?>
							</td>
Example #26
0
 /**
  * Method is called after user data is stored in the database
  *
  * @param   array    $user     holds the new user data
  * @param   boolean  $isnew    true if a new user is stored
  * @param   boolean  $success  true if user was succesfully stored in the database
  * @param   string   $msg      message
  * @return  void
  */
 public function onAfterStoreUser($user, $isnew, $succes, $msg)
 {
     $xprofile = \Hubzero\User\Profile::getInstance($user['id']);
     if (!is_object($xprofile)) {
         $params = Component::params('com_members');
         $hubHomeDir = rtrim($params->get('homedir'), '/');
         if (empty($hubHomeDir)) {
             // try to deduce a viable home directory based on sitename or live_site
             $sitename = strtolower(Config::get('sitename'));
             $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
             $sitename = trim($sitename, '/ ');
             $sitename_e = explode('.', $sitename, 2);
             if (isset($sitename_e[1])) {
                 $sitename = $sitename_e[0];
             }
             if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                 $sitename = '';
             }
             if (empty($sitename)) {
                 $sitename = strtolower(Request::base());
                 $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
                 $sitename = trim($sitename, '/ ');
                 $sitename_e = explode('.', $sitename, 2);
                 if (isset($sitename_e[1])) {
                     $sitename = $sitename_e[0];
                 }
                 if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                     $sitename = '';
                 }
             }
             $hubHomeDir = DS . 'home';
             if (!empty($sitename)) {
                 $hubHomeDir .= DS . $sitename;
             }
             if (!empty($hubHomeDir)) {
                 $db = App::get('db');
                 $component = new JTableExtension($this->database);
                 $component->load($component->find(array('element' => 'com_members', 'type' => 'component')));
                 $params = new \Hubzero\Config\Registry($component->params);
                 $params->set('homedir', $hubHomeDir);
                 $component->params = $params->toString();
                 $component->store();
             }
         }
         $xprofile = new \Hubzero\User\Profile();
         $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
         $xprofile->set('gid', $params->get('gid', 'users'));
         $xprofile->set('uidNumber', $user['id']);
         $xprofile->set('homeDirectory', $hubHomeDir . DS . $user['username']);
         $xprofile->set('loginShell', '/bin/bash');
         $xprofile->set('ftpShell', '/usr/lib/sftp-server');
         $xprofile->set('name', $user['name']);
         $xprofile->set('email', $user['email']);
         $xprofile->set('emailConfirmed', '3');
         $xprofile->set('username', $user['username']);
         $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']);
         $xprofile->set('emailConfirmed', -rand(1, pow(2, 31) - 1));
         $xprofile->set('public', $params->get('privacy', 0));
         if (isset($_SERVER['REMOTE_HOST'])) {
             $xprofile->set('regHost', $_SERVER['REMOTE_HOST']);
         }
         $xprofile->set('registerDate', Date::toSql());
         $result = $xprofile->create();
         if (!$result) {
             return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500);
         }
     } else {
         $update = false;
         $params = Component::params('com_members');
         if ($xprofile->get('username') != $user['username']) {
             $xprofile->set('username', $user['username']);
             $update = true;
         }
         if ($xprofile->get('name') != $user['name']) {
             $xprofile->set('name', $user['name']);
             $update = true;
         }
         if ($xprofile->get('email') != $user['email']) {
             $xprofile->set('email', $user['email']);
             $xprofile->set('emailConfirmed', 0);
             $update = true;
         }
         if ($xprofile->get('emailConfirmed') == '') {
             $xprofile->set('emailConfirmed', '3');
             $update = true;
         }
         if ($xprofile->get('gid') == '') {
             $xprofile->set('gid', $params->get('gid', 'users'));
             $update = true;
         }
         if ($xprofile->get('gidNumber') == '') {
             $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
             $update = true;
         }
         if ($xprofile->get('loginShell') == '') {
             $xprofile->set('loginShell', '/bin/bash');
             $update = true;
         }
         if ($xprofile->get('ftpShell') == '') {
             $xprofile->set('ftpShell', '/usr/lib/sftp-server');
             // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy
             $xprofile->set('public', $params->get('privacy', 0));
             $update = true;
         }
         if ($update) {
             $xprofile->update();
         }
     }
     // Check if quota exists for the user
     $params = Component::params('com_members');
     if ($params->get('manage_quotas', false)) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'quotas_classes.php';
         $quota = new \Components\Members\Tables\UsersQuotas($this->database);
         $quota->load(array('user_id' => $user['id']));
         if (!$quota->id) {
             $class = new \Components\Members\Tables\QuotasClasses($this->database);
             $class->load(array('alias' => 'default'));
             if ($class->id) {
                 $quota->set('user_id', $user['id']);
                 $quota->set('class_id', $class->id);
                 $quota->set('soft_blocks', $class->soft_blocks);
                 $quota->set('hard_blocks', $class->hard_blocks);
                 $quota->set('soft_files', $class->soft_files);
                 $quota->set('hard_files', $class->hard_files);
                 $quota->store();
             }
         }
     }
 }
Example #27
0
 /**
  * [sortAlphabetically description]
  * @param  [type] $userIds [description]
  * @return [type]          [description]
  */
 private function sortAlphabetically($userIds)
 {
     // get each users name
     $users = array();
     $emails = array();
     foreach ($userIds as $k => $userid) {
         $profile = Hubzero\User\Profile::getInstance($userid);
         if ($profile) {
             $users[$profile->get('uidNumber')] = $profile->get('surname');
         } elseif (preg_match("/^[_\\.\\%0-9a-zA-Z-]+@([0-9a-zA-Z-]+\\.)+[a-zA-Z]{2,6}\$/i", $userid)) {
             $emails[] = $userid;
         }
     }
     // sort by last name
     natcasesort($users);
     // return sorted member ids
     return array_merge(array_keys($users), $emails);
 }