Beispiel #1
0
 public function getUsers()
 {
     $userIDs = explode(",", $this->userIDs);
     $users = array();
     foreach ($userIDs as $uID) {
         $user = User::getByUserID(intval($uID));
         if (!is_object($user) || !$user->getUserID()) {
             continue;
         }
         $users[] = $user;
     }
     return $users;
 }
 public static function getSelectedOptions()
 {
     $db = Loader::db();
     $value = $db->GetRow("select avID,userIDs from `atMultiuserPickerValues` where avID = ?", array($avID));
     $userIDs = explode(",", $value['userIDs']);
     $users = array();
     foreach ($userIDs as $fID) {
         $user = User::getByUserID(intval($fID));
         if (!is_object($user) || !$user->getUserID()) {
             continue;
         }
         $users[] = $user;
     }
     return $users;
 }
Beispiel #3
0
 public function remove_friend($fuID = 0, $token = "")
 {
     /** @type ValidationTokenHelper $token_helper */
     $token_helper = Loader::helper('validation/token');
     $user_id = intval($fuID);
     if ($token_helper->validate("profile.remove_friend.{$user_id}", $token)) {
         $user = User::getByUserID($user_id);
         if (!$user->isError()) {
             UsersFriends::removeFriend($user->getUserID());
         } else {
             $this->error->add(t('Invalid User ID'));
         }
     } else {
         $this->error->add('Invalid Token.');
     }
     if ($this->error->has()) {
         $this->set('error', $this->error);
     }
     $this->view();
 }
Beispiel #4
0
 public function testGroups()
 {
     $u = \User::getByUserID(2);
     $g = Group::add('Test Group', 'Test Group');
     $u->enterGroup($g);
     $this->list->filterByGroup($g);
     $this->assertEquals(1, $this->list->getTotalResults());
     $pagination = $this->list->getPagination();
     $this->assertEquals(1, $pagination->getTotalResults());
     $results = $pagination->getCurrentPageResults();
     $this->assertInstanceOf('\\Concrete\\Core\\User\\UserInfo', $results[0]);
     $this->assertEquals('testuser2', $results[0]->getUserName());
     $nl = new UserList();
     $nl->filterByGroup($g, false);
     $nl->sortByUserID();
     $this->assertEquals(2, $nl->getTotalResults());
     $results = $nl->getResults();
     $this->assertEquals('testuser', $results[0]->getUserName());
     $this->assertEquals('andrew', $results[1]->getUserName());
 }
 public function add_users()
 {
     // insert the default groups
     // create the groups our site users
     // have to add these in the right order so their IDs get set
     // starting at 1 w/autoincrement
     $g1 = Group::add(t("Guest"), t("The guest group represents unregistered visitors to your site."));
     $g2 = Group::add(t("Registered Users"), t("The registered users group represents all user accounts."));
     $g3 = Group::add(t("Administrators"), "");
     // insert admin user into the user table
     if (defined('INSTALL_USER_PASSWORD')) {
         $uPassword = INSTALL_USER_PASSWORD;
         $uPasswordEncrypted = User::encryptPassword($uPassword, PASSWORD_SALT);
     } else {
         $uPasswordEncrypted = INSTALL_USER_PASSWORD_HASH;
     }
     $uEmail = INSTALL_USER_EMAIL;
     UserInfo::addSuperUser($uPasswordEncrypted, $uEmail);
     $u = User::getByUserID(USER_SUPER_ID, true, false);
     Loader::library('mail/importer');
     MailImporter::add(array('miHandle' => 'private_message'));
 }
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$ui = UserInfo::getByID($_REQUEST['uID']);
if (!is_object($ui)) {
    die(t("Invalid user provided."));
}
$u = User::getByUserID($_REQUEST['uID']);
$uName = $ui->getUserName();
$uEmail = $ui->getUserEmail();
$attributeList = UserAttributeKey::getList();
$userGroup = $u->getUserGroups();
?>

<div class="ccm-ui">

    <h3><?php 
echo t('Basic Details');
?>
</h3>
    <br>

    <div class="row">
        <div class="col-md-8">
            <p><strong><?php 
echo t(Username);
?>
</strong></p>
        </div>

        <div class="col-md-2">
 protected function createUser()
 {
     // Make sure that this extractor supports everything we need.
     if (!$this->supportsEmail() && $this->supportsUniqueId()) {
         throw new Exception('Email and unique ID support are required for user creation.');
     }
     // Make sure that email is verified if the extractor supports it.
     if ($this->supportsVerifiedEmail() && !$this->isEmailVerified()) {
         throw new Exception('Please verify your email with this service before attempting to log in.');
     }
     $email = $this->getEmail();
     if (\UserInfo::getByEmail($email)) {
         throw new Exception('Email is already in use.');
     }
     $first_name = "";
     $last_name = "";
     $name_support = array('full' => $this->supportsFullName(), 'first' => $this->supportsFirstName(), 'last' => $this->supportsLastName());
     if ($name_support['first'] && $name_support['last']) {
         $first_name = $this->getFirstName();
         $last_name = $this->getLastName();
     } elseif ($name_support['full']) {
         $reversed_full_name = strrev($this->getFullName());
         list($reversed_last_name, $reversed_first_name) = explode(' ', $reversed_full_name, 2);
         $first_name = strrev($reversed_first_name);
         $last_name = strrev($reversed_last_name);
     }
     $username = null;
     if ($this->supportsUsername()) {
         $username = $this->getUsername();
     }
     if ($username === null) {
         if ($first_name || $last_name) {
             $username = preg_replace('/[^a-z0-9\\_]/', '_', strtolower($first_name . ' ' . $last_name));
             $username = trim(preg_replace('/_{2,}/', '_', $username), '_');
         } else {
             $username = preg_replace('/[^a-zA-Z0-9\\_]/i', '_', strtolower(substr($email, 0, strpos($email, '@'))));
             $username = trim(preg_replace('/_{2,}/', '_', $username), '_');
         }
     }
     $unique_username = $username;
     $append = 1;
     while (\UserInfo::getByUserName($unique_username)) {
         // This is a heavy handed way to do this, but it must be done.
         $unique_username = $username . '_' . $append++;
     }
     $username = $unique_username;
     $data = array();
     $data['uName'] = $username;
     $data['uPassword'] = "";
     $data['uEmail'] = $email;
     $data['uIsValidated'] = 1;
     $user_info = \UserInfo::add($data);
     if (!$user_info) {
         throw new Exception('Unable to create new account.');
     }
     if ($group_id = intval($this->registrationGroupID(), 10)) {
         $group = \Group::getByID($group_id);
         if ($group && is_object($group) && !$group->isError()) {
             $user = \User::getByUserID($user_info->getUserID());
             $user->enterGroup($group);
         }
     }
     $key = \UserAttributeKey::getByHandle('first_name');
     if ($key) {
         $user_info->setAttribute($key, $first_name);
     }
     $key = \UserAttributeKey::getByHandle('last_name');
     if ($key) {
         $user_info->setAttribute($key, $last_name);
     }
     \User::loginByUserID($user_info->getUserID());
     $this->bindUser($user = \User::getByUserID($user_info->getUserID()), $this->getUniqueId());
     return $user;
 }
Beispiel #8
0
 /**
  * @param int $uID
  * @return User
  */
 public function loginByUserID($uID)
 {
     return User::getByUserID($uID, true);
 }
Beispiel #9
0
		public function getUserObject() {
			// returns a full user object - groups and everything - for this userinfo object
			$nu = User::getByUserID($this->uID);
			return $nu;
		}
 public function addEntry($user, ActionDescription $descr, $points = false, $date = null)
 {
     if (!$this->isUserPointActionActive()) {
         return false;
     }
     if (is_object($user)) {
         $user = UserInfo::getByID($user->getUserID());
         $uID = $user->getUserID();
     } else {
         $uID = $user;
     }
     if (!isset($uID) || $uID <= 0) {
         return false;
     }
     $g = $this->getUserPointActionBadgeGroupObject();
     if ($g instanceof Group) {
         if ($user instanceof UserInfo) {
             $user = User::getByUserID($user->getUserID());
         }
         $user->enterGroup($g);
     }
     if ($date == null) {
         $date = date('Y-m-d H:i:s');
     }
     if ($points === false) {
         $points = $this->getUserPointActionDefaultPoints();
     }
     try {
         $upe = new UserPointEntry();
         $upe->upuID = $uID;
         $upe->upaID = $this->upaID;
         $upe->upPoints = $points;
         $upe->timestamp = $date;
         $descr = serialize($descr);
         $upe->object = $descr;
         $upe->save();
         return $upe;
     } catch (Exception $e) {
         Log::addEntry(t("Error saving user point record: %s", $e->getMessage()), 'exceptions');
         return false;
     }
     return true;
 }
Beispiel #11
0
//causes dispatcher to skip the page rendering
define('C5_ENVIRONMENT_ONLY', true);
//prevents dispatcher from causing redirection to the base_url
define('REDIRECT_TO_BASE_URL', false);
//let's enable timezones
define('ENABLE_USER_TIMEZONES', true);
//since we can't define/redefine this for individual tests, we set to a value that's most likely to cause errors (vs '')
define('DIR_REL', '/blog');
// Force tests to start in en_US
define('SITE_LOCALE', 'en_US');
define('ACTIVE_LOCALE', 'en_US');
//this is where the magic happens
require DIR_BASE . '/concrete/dispatcher.php';
//add a user with Europe/Rome timezone
$uTest = UserInfo::getByUserName('testuser_it');
if (!is_object($uTest)) {
    $uTest = UserInfo::add(array('uName' => 'testuser_it', 'uEmail' => '*****@*****.**', 'uPassword' => 'testpassword'));
}
$uTest->update(array('uTimezone' => 'Europe/Rome'));
define('TESTUSER_IT_ID', $uTest->getUserID());
$uTest = UserInfo::getByUserName('testuser_jp');
if (!is_object($uTest)) {
    $uTest = UserInfo::add(array('uName' => 'testuser_jp', 'uEmail' => '*****@*****.**', 'uPassword' => 'testpassword'));
}
$uTest->update(array('uTimezone' => 'Asia/Tokyo'));
define('TESTUSER_JP_ID', $uTest->getUserID());
// login the admin
User::getByUserID(USER_SUPER_ID, true);
Log::addEntry('bootsrapped', 'unit tests');
// include adodb-lib to avoid a PHPUnit problem with globals
include ADODB_DIR . '/adodb-lib.inc.php';
 public function testSpecialFormats()
 {
     Localization::changeLocale('en_US');
     $activeUser = User::isLoggedIn() ? new User() : null;
     if ($activeUser) {
         $activeUser->logout();
     }
     $timestamp = time();
     foreach (array('FILENAME', 'FILE_PROPERTIES', 'FILE_VERSIONS', 'FILE_DOWNLOAD', 'PAGE_VERSIONS', 'DASHBOARD_SEARCH_RESULTS_USERS', 'DASHBOARD_SEARCH_RESULTS_FILES', 'DASHBOARD_SEARCH_RESULTS_PAGES', 'DATE_ATTRIBUTE_TYPE_MDY', 'DATE_ATTRIBUTE_TYPE_T') as $formatName) {
         $this->assertEquals($this->object->date(constant("DATE_APP_{$formatName}"), $timestamp), $this->object->formatSpecial($formatName, $timestamp));
     }
     if ($activeUser) {
         User::getByUserID($activeUser->getUserID(), true);
     }
 }
Beispiel #13
0
<?php

/**
 * @author jshannon
 */
// TODO: check include path
//ini_set('include_path', ini_get('include_path'));
error_reporting(E_ERROR | E_WARNING | E_USER_ERROR);
define('C5_EXECUTE', true);
define('DIR_BASE', dirname(__FILE__) . '/../web');
//causes dispatcher to skip the page rendering
define('C5_ENVIRONMENT_ONLY', true);
//prevents dispatcher from causing redirection to the base_url
define('REDIRECT_TO_BASE_URL', false);
//since we can't define/redefine this for individual tests, we set to a value that's most likely to cause errors (vs '')
define('DIR_REL', '/blog');
//this is where the magic happens
require DIR_BASE . '/concrete/dispatcher.php';
// login the admin
User::getByUserID(1, true);
?>

 public function add_users()
 {
     // insert the default groups
     // create the groups our site users
     // specify the ID's since auto increment may not always be +1
     $g1 = Group::add(tc("GroupName", "Guest"), tc("GroupDescription", "The guest group represents unregistered visitors to your site."), GUEST_GROUP_ID);
     $g2 = Group::add(tc("GroupName", "Registered Users"), tc("GroupDescription", "The registered users group represents all user accounts."), REGISTERED_GROUP_ID);
     $g3 = Group::add(tc("GroupName", "Administrators"), "", ADMIN_GROUP_ID);
     // insert admin user into the user table
     if (defined('INSTALL_USER_PASSWORD')) {
         Loader::library('3rdparty/phpass/PasswordHash');
         $hasher = new PasswordHash(PASSWORD_HASH_COST_LOG2, PASSWORD_HASH_PORTABLE);
         $uPassword = INSTALL_USER_PASSWORD;
         $uPasswordEncrypted = $hasher->HashPassword($uPassword);
     } else {
         $uPasswordEncrypted = INSTALL_USER_PASSWORD_HASH;
     }
     $uEmail = INSTALL_USER_EMAIL;
     UserInfo::addSuperUser($uPasswordEncrypted, $uEmail);
     $u = User::getByUserID(USER_SUPER_ID, true, false);
     Loader::library('mail/importer');
     MailImporter::add(array('miHandle' => 'private_message'));
 }
 protected function createUser($username, $email, $first_name = '', $last_name = '')
 {
     $data = array();
     $data['uName'] = $username;
     $data['uPassword'] = \Illuminate\Support\Str::random(256);
     $data['uEmail'] = $email;
     $data['uIsValidated'] = 1;
     $user_info = \UserInfo::add($data);
     if (!$user_info) {
         throw new Exception('Unable to create new account.');
     }
     if ($group_id = intval($this->registrationGroupID(), 10)) {
         $group = \Group::getByID($group_id);
         if ($group && is_object($group) && !$group->isError()) {
             $user = \User::getByUserID($user_info->getUserID());
             $user->enterGroup($group);
         }
     }
     $key = \UserAttributeKey::getByHandle('first_name');
     if ($key) {
         $user_info->setAttribute($key, $first_name);
     }
     $key = \UserAttributeKey::getByHandle('last_name');
     if ($key) {
         $user_info->setAttribute($key, $last_name);
     }
     $user = \User::loginByUserID($user_info->getUserID());
     $this->mapUserByLdapUser($username, $user_info->getUserID());
     return $user;
 }
Beispiel #16
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
if (is_array($image)) {
    $image = $image[0];
}
$ownerID = $this->page->vObj->cvAuthorUID;
$u = User::getByUserID($ownerID);
$ownerName = $u->getUserName();
?>
<div class="ccm-gathering-image-byline-description-center ccm-gathering-centered-content ccm-gathering-scaled-image">
	<a href="#" data-overlay="gathering-item">
		<img src="<?php 
echo $image->getSrc();
?>
" alt="<?php 
echo t('Preview Image');
?>
" />
	</a>
	<div class="ccm-gathering-tile-title-description">
		<div class="ccm-gathering-tile-byline"><?php 
echo tc('Authored', 'By %s', '<span class="author-name">' . $ownerName . '</span>');
?>
</div>
		<div class="ccm-gathering-tile-description">
		<?php 
echo $description;
?>
		</div>
	</div>
Beispiel #17
0
    ?>
</td>
                    <td valign="top" style="text-align: center"><?php 
    echo $ent->getLevelIcon();
    ?>
</td>
                    <td valign="top" style="white-space: nowrap"><?php 
    echo $ent->getChannelDisplayName();
    ?>
</td>
                    <td valign="top"><strong><?php 
    $uID = $ent->getUserID();
    if (empty($uID)) {
        echo t("Guest");
    } else {
        $u = User::getByUserID($uID);
        if (is_object($u)) {
            echo $u->getUserName();
        } else {
            echo tc('Deleted user', 'Deleted (id: %s)', $uID);
        }
    }
    ?>
</strong></td>
                    <td style="width: 100%"><?php 
    echo $th->makenice($ent->getMessage());
    ?>
</td>
                </tr>
                <?php 
}
            echo t(' at ');
            echo date(DATE_APP_GENERIC_MDY, strtotime($ent->getTimestamp('user')));
            ?>
                    <?php 
        }
        ?>
</td>
                    <td valign="top"><strong><?php 
        echo $ent->getType();
        ?>
</strong></td>
                    <td valign="top"><strong><?php 
        if ($ent->getUserID() == NULL) {
            echo t("Guest");
        } else {
            $u = User::getByUserID($ent->getUserID());
            echo $u->getUserName();
        }
        ?>
</strong></td>
                    <td style="width: 100%"><?php 
        echo $th->makenice($ent->getText());
        ?>
</td>
                </tr>
                <?php 
    }
    ?>
			</tbody>
		</table>