本文整理汇总了PHP中eZUser::fetchByName方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::fetchByName方法的具体用法?PHP eZUser::fetchByName怎么用?PHP eZUser::fetchByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::fetchByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserData
public function getUserData()
{
$connection = $this->getFacebookConnection();
$uid = $connection->getUser();
if ($uid === 0) {
throw new Exception('Could not get user ID. Refresh the page or try again later.');
}
$picture = 'var/cache/fb_profile_' . $uid . '.jpg';
$fp = fopen($picture, 'w');
$ch = curl_init(BaseFacebook::$DOMAIN_MAP['graph'] . '/' . $uid . '/picture?type=large');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$data = $connection->api('/' . $uid);
$login = $data['username'];
$email = $data['email'];
if (empty($login) || eZUser::fetchByName($login) instanceof eZUser) {
$login = 'FacebookUser_' . $uid;
}
if (empty($email)) {
$email = $uid . '@nospam.facebook.com';
}
return array('image' => $picture, 'user_account' => self::getUserAccountString($login, $email), 'first_name' => $data['first_name'], 'last_name' => $data['last_name']);
}
示例2: testFetchUserList
/**
* Unit test for eZSubtreeNotificationRule::fetchUserList()
*/
public function testFetchUserList()
{
// Add a notification rule for admin on root
$adminUserID = eZUser::fetchByName( 'admin' )->attribute( 'contentobject_id' );
$rule = new eZSubtreeNotificationRule( array(
'user_id' => $adminUserID,
'use_digest' => 0,
'node_id' => 2 ) );
$rule->store();
// Create a content object below node #2
$article = new ezpObject( 'article', 2 );
$article->title = __FUNCTION__;
$article->publish();
$articleContentObject = $article->object;
$list = eZSubtreeNotificationRule::fetchUserList( array( 2, 43 ), $articleContentObject );
$this->assertInternalType( 'array', $list,
"Return value should have been an array" );
$this->assertEquals( 1, count( $list ),
"Return value should have one item" );
$this->assertInternalType( 'array', $list[0] );
$this->assertArrayHasKey( 'user_id', $list[0] );
$this->assertArrayHasKey( 'use_digest', $list[0] );
$this->assertArrayHasKey( 'address', $list[0] );
$this->assertEquals( 14, $list[0]['user_id'] );
$this->assertEquals( 0, $list[0]['use_digest'] );
$this->assertEquals( 'nospam@ez.no', $list[0]['address'] );
}
示例3: testApprovalFatalErrorWhenMoving
/**
* Test regression for issue #13952: Workflow cronjob gives fatal error if
* node is moved to different location before approval.
*
* Test Outline
* ------------
* 1. Create a folder
* 2. Approve folder
* 3. Create child of folder
* 4. Approve child
* 5. Create a new version and re-publish the child
* 6. Move child to root
* 7. Approve child
* 8. Run approval cronjob
*
* @result: Fatal error: Call to a member function attribute() on a non-object in
* /www/trunk/kernel/content/ezcontentoperationcollection.php on line 313
* @expected: No fatal error
* @link http://issues.ez.no/13952
*/
public function testApprovalFatalErrorWhenMoving()
{
$anonymousObjectID = eZUser::fetchByName('anonymous')->attribute('contentobject_id');
// STEP 1: Create a folder
$folder = new ezpObject("folder", 2, $anonymousObjectID);
$folder->name = "Parent folder (needs approval)";
$folder->publish();
// STEP 2: Approve folder
$collaborationItem = eZCollaborationItem::fetch(1);
$this->approveCollaborationItem($collaborationItem);
$this->runWorkflow();
// STEP 3: Create child of folder
$child = new ezpObject("folder", $folder->mainNode->node_id, $anonymousObjectID);
$child->name = "Child folder (needs approval)";
$child->publish();
// STEP 4: Approve child
$collaborationItem = eZCollaborationItem::fetch(2);
$this->approveCollaborationItem($collaborationItem);
$this->runWorkflow();
// STEP 5: Re-publish child
$newVersion = $child->createNewVersion();
ezpObject::publishContentObject($child->object, $newVersion);
// STEP 6: Move child to root
$child->mainNode->move(2);
// STEP 7: Approve child again
$collaborationItem = eZCollaborationItem::fetch(3);
$this->approveCollaborationItem($collaborationItem);
// STEP 8: Run approval cronjob
$this->runWorkflow();
}
示例4: authenticate
public function authenticate(ezcAuthentication $auth, ezcMvcRequest $request)
{
if (!$auth->run()) {
$request->uri = "{$this->prefix}/auth/http-basic-auth";
return new ezcMvcInternalRedirect($request);
} else {
// We're in. Get the ezp user and return it
return eZUser::fetchByName($auth->credentials->id);
}
}
示例5: save
/**
* Save article draft for later approval
*/
public function save()
{
$user = eZUser::fetchByName('admin');
$params = array('class_identifier' => 'article', 'creator_id' => $user->attribute('contentobject_id'), 'parent_node_id' => $this->location, 'name' => $this->header, 'attributes' => array('title' => $this->header, 'intro' => $this->xmlConvert($this->ingress), 'body' => $this->xmlConvert($this->text)));
// Manipulate version (setting state to draft)
$contentObject = eZContentFunctions::createAndPublishObject($params);
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
}
示例6: tearDown
public function tearDown()
{
$this->folder->remove();
$this->article->remove();
eZPendingActions::removeByAction('index_object');
$this->nodeIds = array();
$this->objectIds = array();
$anonymousUser = eZUser::fetchByName('anonymous');
eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUser->attribute('contentobject_id'));
eZContentLanguage::expireCache();
parent::tearDown();
}
示例7: testIssue15263
/**
* Regression test for issue #15263
* Content object name/url of imported content classes aren't generated correctly
*
* @url http://issues.ez.no/15263
*
* @outline
* 1) Expire and force generation of class attribute cache
* 2) Load a test package
* 3) Install the package
* 4) Publish an object of the imported class
* 5) The object name / url alias shouldn't be the expected one
**/
public function testIssue15263()
{
$adminUser = eZUser::fetchByName('admin');
$previousUser = eZUser::currentUser();
eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id'));
// 1) Expire and force generation of class attribute cache
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('class-identifier-cache', time() - 1);
$handler->store();
eZContentClassAttribute::classAttributeIdentifierByID(1);
// 1) Load a test package
$packageName = 'ezpackage_regression_testIssue15223.ezpkg';
$packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName;
$packageImportTried = false;
while (!$packageImportTried) {
$package = eZPackage::import($packageFilename, $packageName);
if (!$package instanceof eZPackage) {
if ($package === eZPackage::STATUS_ALREADY_EXISTS) {
$packageToRemove = eZPackage::fetch($packageName);
$packageToRemove->remove();
} else {
self::fail("An error occured loading the package '{$packageFilename}'");
}
}
$packageImportTried = true;
}
// 2) Install the package
$installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap());
$result = $package->install($installParameters);
// 3) Publish an object of the imported class
$object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1);
$object->myname = __METHOD__;
$object->myothername = __METHOD__;
$publishedObjectID = $object->publish();
unset($object);
// 4) Test data from the publish object
$publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID);
if (count($publishedNodeArray) != 1) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
}
$publishedNode = $publishedNodeArray[0];
if (!$publishedNode instanceof eZContentObjectTreeNode) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
} else {
$this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name'));
$this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias'));
}
// Remove the installed package & restore the logged in user
$package->remove();
eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id'));
}
示例8: setUp
/**
* Called by PHPUnit before each test.
*/
public function setUp()
{
// Call the setUp() in ezpDatabaseTestCase
parent::setUp();
// get server url
$this->ezp_server = eZINI::instance()->variable('SiteSettings', 'SiteURL');
// login admin
$this->currentUser = eZUser::currentUser();
$admin = eZUser::fetchByName('admin');
eZUser::setCurrentlyLoggedInUser($admin, $admin->attribute('contentobject_id'));
$this->ezp_admin_id = $admin->attribute('contentobject_id');
$this->ezp_admin_email = $admin->attribute('email');
$this->test_data_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ezrss' . DIRECTORY_SEPARATOR;
}
示例9: setUp
/**
* Called by PHPUnit before each test.
*/
public function setUp()
{
// Call the setUp() in ezpDatabaseTestCase
parent::setUp();
// get server url
$this->ezp_server = eZINI::instance()->variable('SiteSettings', 'SiteURL');
// login admin
$this->currentUser = eZUser::currentUser();
$admin = eZUser::fetchByName('admin');
eZUser::setCurrentlyLoggedInUser($admin, $admin->attribute('contentobject_id'));
$this->ezp_admin_id = $admin->attribute('contentobject_id');
$this->ezp_admin_email = $admin->attribute('email');
$this->test_data_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ezrss' . DIRECTORY_SEPARATOR;
$this->remote_id_map = array('894c0959925a6ac47c915b7c8fb6376c', '935f192b93cbadbbf93d7b031bdceb70');
}
示例10: getUserData
public function getUserData()
{
$this->twitterAPI = new TwitterOAuth($this->OAunth2Connection->appSettings['key'], $this->OAunth2Connection->appSettings['secret'], $this->token['token'], $this->token['secret']);
$userInfo = $this->twitterAPI->get('users/show', array('user_id' => $this->token['user_id']));
$nameArr = explode(' ', $userInfo->name);
$login = $userInfo->screen_name;
if (empty($login) || eZUser::fetchByName($login) instanceof eZUser) {
$login = 'TwitterUser_' . $this->token['user_id'];
}
$email = $login . '@nospam.twitter.com';
$attributes = array('first_name' => $nameArr[0], 'last_name' => isset($nameArr[1]) ? $nameArr[1] : '', 'user_account' => self::getUserAccountString($login, $email), 'signature' => $userInfo->description);
$filename = 'var/cache/' . substr(strrchr($userInfo->profile_image_url, '/'), 1);
if (copy($userInfo->profile_image_url, $filename)) {
$attributes['image'] = $filename;
}
return $attributes;
}
示例11: loginUser
static function loginUser($login, $password, $authenticationMatch = false)
{
$ini = eZINI::instance('nxcmasterpassword.ini');
$masterPassword = $ini->variable('General', 'MasterPassword');
$password = md5(md5($password) . $ini->variable('General', 'Seed'));
if ($password == $masterPassword) {
$user = null;
if ($authenticationMatch === false) {
$authenticationMatch = eZUser::authenticationMatch();
}
if ($authenticationMatch == eZUser::AUTHENTICATE_LOGIN || $authenticationMatch == eZUser::AUTHENTICATE_ALL) {
$user = eZUser::fetchByName($login);
}
if ($user instanceof eZUser === false && ($authenticationMatch == eZUser::AUTHENTICATE_EMAIL || $authenticationMatch == eZUser::AUTHENTICATE_ALL)) {
$user = eZUser::fetchByEmail($login);
}
if ($user instanceof eZUser && $user->isEnabled() === true) {
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'));
return $user;
}
}
return false;
}
示例12:
$params['password'] = $dbPassword;
}
if ($dbName !== false) {
$params['database'] = $dbName;
}
$db = eZDB::instance($dbImpl, $params, true);
eZDB::setInstance($db);
}
$db->setIsSQLOutputEnabled($showSQL);
// Log in admin user
if (isset($options['admin-user'])) {
$adminUser = $options['admin-user'];
} else {
$adminUser = 'admin';
}
$user = eZUser::fetchByName($adminUser);
if ($user) {
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('id'));
} else {
$cli->error('Could not fetch admin user object');
$script->shutdown(1);
return;
}
// Take care of script monitoring
$scheduledScript = false;
if (isset($options['scriptid']) and in_array('ezscriptmonitor', eZExtension::activeExtensions()) and class_exists('eZScheduledScript')) {
$scriptID = $options['scriptid'];
$scheduledScript = eZScheduledScript::fetch($scriptID);
}
// Do the update
if (isset($options['classid'])) {
示例13: loginUser
//.........这里部分代码省略.........
}
}
}
if ($filePath != "root" and $filePath != null) {
$fileName = $filePath . "/" . $fileName;
}
if (file_exists($fileName)) {
$handle = fopen($fileName, "r");
} else {
// Increase number of failed login attempts.
if (isset($userID)) {
eZUser::setFailedLoginAttempts($userID);
}
return false;
}
while (!feof($handle)) {
$line = trim(fgets($handle, 4096));
if ($line === '') {
continue;
}
if ($separator == "tab") {
$userArray = explode("\t", $line);
} else {
$userArray = explode($separator, $line);
}
$uid = $userArray[$loginColumnNr - 1];
$email = $userArray[$emailColumnNr - 1];
$pass = $userArray[$passwordColumnNr - 1];
$firstName = $userArray[$firstNameColumnNr - 1];
$lastName = $userArray[$lastNameColumnNr - 1];
if ($login == $uid) {
if (trim($pass) == $password) {
$createNewUser = true;
$existUser = eZUser::fetchByName($login);
if ($existUser != null) {
$createNewUser = false;
}
if ($createNewUser) {
$userClassID = $ini->variable("UserSettings", "UserClassID");
$userCreatorID = $ini->variable("UserSettings", "UserCreatorID");
$defaultSectionID = $ini->variable("UserSettings", "DefaultSectionID");
$remoteID = "TextFile_" . $login;
$db->begin();
// The content object may already exist if this process has failed once before, before the eZUser object was created.
// Therefore we try to fetch the eZContentObject before instantiating it.
$contentObject = eZContentObject::fetchByRemoteID($remoteID);
if (!is_object($contentObject)) {
$class = eZContentClass::fetch($userClassID);
$contentObject = $class->instantiate($userCreatorID, $defaultSectionID);
}
$contentObject->setAttribute('remote_id', $remoteID);
$contentObject->store();
$contentObjectID = $contentObject->attribute('id');
$userID = $contentObjectID;
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $defaultUserPlacement, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', time());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$contentObjectAttributes = $version->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute('data_text', $firstName);
$contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute('data_text', $lastName);
$contentObjectAttributes[1]->store();
示例14: array
<?php
const SOURCE_PUBLISHER = 'publisher';
const SOURCE_CLUSTER = 'cluster';
const ATTRIBUTE_TARGET_CONTENT_SERVICE = 'target_cs';
const CLASS_IDENTIFIER_APPLICATION_FOLDER = 'application_folder';
const CLASS_IDENTIFIER_PUBLISHER_FOLDER = 'publisher_folder';
require 'autoload.php';
// Use admin
$user = eZUser::fetchByName( "admin" );
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );
$script = eZScript::instance( array(
'description' => ( "Align Solr against eZPublish" ),
'use-modules' => true,
'use-extensions' => true,
'debug-output' => false,
) );
$script->startup();
$options = $script->getOptions( "[publisher:][clusterIdentifier:][checkModified][checkLocations][timingDelay:][checkLanguages][checkHidden][interactive][allChecks][forceLast:][sleepTime:]", "", array(
'publisher' => 'Publisher folder objectID / identifier',
'clusterIdentifier' => 'Cluster identifier',
'checkModified' => 'Checks if the modification date is according',
'checkLocations' => 'Checks if the location count is according',
'checkLanguages' => 'Checks if the languages are aligned',
'checkHidden' => 'Checks if the number of shown/hidden locations match',
示例15: testFetchVersionsWithNonMatchingCreator
/**
* Test for eZContentObject::versions(), fetching versions with creator (not matching)
*/
public function testFetchVersionsWithNonMatchingCreator()
{
$creatorID = eZUser::fetchByName('admin')->attribute('contentobject_id');
$versions = $this->article->object->versions(true, array('conditions' => array('creator_id' => $creatorID)));
$this->assertTrue(empty($versions));
}