public function testConvertUserEntryToAndFromString() { $this->entry->transferFromXML($this->entryText); $entryXml = $this->entry->saveXML(); $newUserEntry = new Zend_Gdata_Gapps_UserEntry(); $newUserEntry->transferFromXML($entryXml); $this->verifyAllSamplePropertiesAreCorrect($newUserEntry); $newUserEntryXml = $newUserEntry->saveXML(); $this->assertEquals($entryXml, $newUserEntryXml); }
/** * Update a user in Google Apps * * @param Zend_Gdata_Gapps_UserEntry $gappsuser User entry from Google Apps * @param object $moodleuser Object from {@link moodle_get_user} or {@link moodle_get_users} * @return void * @throws blocks_gdata_exception **/ public function gapps_update_user($gappsuser, $moodleuser) { $save = false; if ($gappsuser->name->givenName != $moodleuser->firstname) { $gappsuser->name->givenName = $moodleuser->firstname; $save = true; } if ($gappsuser->name->familyName != $moodleuser->lastname) { $gappsuser->name->familyName = $moodleuser->lastname; $save = true; } if ($moodleuser->oldpassword != $moodleuser->password) { $gappsuser->login->password = $moodleuser->password; $gappsuser->login->hashFunctionName = self::PASSWORD_HASH_FUNCTION; $save = true; } // By using save flag we hopefully reduce // the number of saves actually called if ($save) { try { $gappsuser->save(); } catch (Zend_Gdata_App_Exception $e) { throw new blocks_gdata_exception('gappserror', 'block_gdata', $e->getMessage()); } $this->counts['updated']++; } }