Zend_Gdata_Gapps_Extension_Login

Represents the apps:login element used by the Apps data API.

Defined (1)

The class is defined in the following location(s).

/inc/VideoUploader/includes/Zend/Gdata/Gapps/Extension/Login.php  
  1. class Zend_Gdata_Gapps_Extension_Login extends Zend_Gdata_Extension 
  2.  
  3. protected $_rootNamespace = 'apps'; 
  4. protected $_rootElement = 'login'; 
  5.  
  6. /** 
  7. * The username for this user. This is used as the user's email address 
  8. * and when logging in to Google Apps-hosted services. 
  9. * @var string 
  10. */ 
  11. protected $_username = null; 
  12.  
  13. /** 
  14. * The password for the user. May be in cleartext or as an SHA-1 
  15. * digest, depending on the value of _hashFunctionName. 
  16. * @var string 
  17. */ 
  18. protected $_password = null; 
  19.  
  20. /** 
  21. * Specifies whether the password stored in _password is in cleartext 
  22. * or is an SHA-1 digest of a password. If the password is cleartext,  
  23. * then this should be null. If the password is an SHA-1 digest, then 
  24. * this should be set to 'SHA-1'. 
  25. * At the time of writing, no other hash functions are supported 
  26. * @var string 
  27. */ 
  28. protected $_hashFunctionName = null; 
  29.  
  30. /** 
  31. * True if the user has administrative rights for this domain, false 
  32. * otherwise. 
  33. * @var boolean 
  34. */ 
  35. protected $_admin = null; 
  36.  
  37. /** 
  38. * True if the user has agreed to the terms of service for Google Apps,  
  39. * false otherwise. 
  40. * @var boolean. 
  41. */ 
  42. protected $_agreedToTerms = null; 
  43.  
  44. /** 
  45. * True if this user has been suspended, false otherwise. 
  46. * @var boolean 
  47. */ 
  48. protected $_suspended = null; 
  49.  
  50. /** 
  51. * True if the user will be required to change their password at 
  52. * their next login, false otherwise. 
  53. * @var boolean 
  54. */ 
  55. protected $_changePasswordAtNextLogin = null; 
  56.  
  57. /** 
  58. * Constructs a new Zend_Gdata_Gapps_Extension_Login object. 
  59. * @param string $username (optional) The username to be used for this 
  60. * login. 
  61. * @param string $password (optional) The password to be used for this 
  62. * login. 
  63. * @param string $hashFunctionName (optional) The name of the hash 
  64. * function used to protect the password, or null if no 
  65. * has function has been applied. As of this writing,  
  66. * the only valid values are 'SHA-1' or null. 
  67. * @param boolean $admin (optional) Whether the user is an administrator 
  68. * or not. 
  69. * @param boolean $suspended (optional) Whether this login is suspended or not. 
  70. * @param boolean $changePasswordAtNextLogin (optional) Whether 
  71. * the user is required to change their password at their 
  72. * next login. 
  73. * @param boolean $agreedToTerms (optional) Whether the user has 
  74. * agreed to the terms of service. 
  75. */ 
  76. public function __construct($username = null, $password = null,  
  77. $hashFunctionName = null, $admin = null, $suspended = null,  
  78. $changePasswordAtNextLogin = null, $agreedToTerms = null) 
  79. $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); 
  80. parent::__construct(); 
  81. $this->_username = $username; 
  82. $this->_password = $password; 
  83. $this->_hashFunctionName = $hashFunctionName; 
  84. $this->_admin = $admin; 
  85. $this->_agreedToTerms = $agreedToTerms; 
  86. $this->_suspended = $suspended; 
  87. $this->_changePasswordAtNextLogin = $changePasswordAtNextLogin; 
  88.  
  89. /** 
  90. * Retrieves a DOMElement which corresponds to this element and all 
  91. * child properties. This is used to build an entry back into a DOM 
  92. * and eventually XML text for sending to the server upon updates, or 
  93. * for application storage/persistence. 
  94. * @param DOMDocument $doc The DOMDocument used to construct DOMElements 
  95. * @return DOMElement The DOMElement representing this element and all 
  96. * child properties. 
  97. */ 
  98. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 
  99. $element = parent::getDOM($doc, $majorVersion, $minorVersion); 
  100. if ($this->_username !== null) { 
  101. $element->setAttribute('userName', $this->_username); 
  102. if ($this->_password !== null) { 
  103. $element->setAttribute('password', $this->_password); 
  104. if ($this->_hashFunctionName !== null) { 
  105. $element->setAttribute('hashFunctionName', $this->_hashFunctionName); 
  106. if ($this->_admin !== null) { 
  107. $element->setAttribute('admin', ($this->_admin ? "true" : "false")); 
  108. if ($this->_agreedToTerms !== null) { 
  109. $element->setAttribute('agreedToTerms', ($this->_agreedToTerms ? "true" : "false")); 
  110. if ($this->_suspended !== null) { 
  111. $element->setAttribute('suspended', ($this->_suspended ? "true" : "false")); 
  112. if ($this->_changePasswordAtNextLogin !== null) { 
  113. $element->setAttribute('changePasswordAtNextLogin', ($this->_changePasswordAtNextLogin ? "true" : "false")); 
  114.  
  115. return $element; 
  116.  
  117. /** 
  118. * Given a DOMNode representing an attribute, tries to map the data into 
  119. * instance members. If no mapping is defined, the name and value are 
  120. * stored in an array. 
  121. * @param DOMNode $attribute The DOMNode attribute needed to be handled 
  122. * @throws Zend_Gdata_App_InvalidArgumentException 
  123. */ 
  124. protected function takeAttributeFromDOM($attribute) 
  125. switch ($attribute->localName) { 
  126. case 'userName': 
  127. $this->_username = $attribute->nodeValue; 
  128. break; 
  129. case 'password': 
  130. $this->_password = $attribute->nodeValue; 
  131. break; 
  132. case 'hashFunctionName': 
  133. $this->_hashFunctionName = $attribute->nodeValue; 
  134. break; 
  135. case 'admin': 
  136. if ($attribute->nodeValue == "true") { 
  137. $this->_admin = true; 
  138. else if ($attribute->nodeValue == "false") { 
  139. $this->_admin = false; 
  140. else { 
  141. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  142. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#admin."); 
  143. break; 
  144. case 'agreedToTerms': 
  145. if ($attribute->nodeValue == "true") { 
  146. $this->_agreedToTerms = true; 
  147. else if ($attribute->nodeValue == "false") { 
  148. $this->_agreedToTerms = false; 
  149. else { 
  150. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  151. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#agreedToTerms."); 
  152. break; 
  153. case 'suspended': 
  154. if ($attribute->nodeValue == "true") { 
  155. $this->_suspended = true; 
  156. else if ($attribute->nodeValue == "false") { 
  157. $this->_suspended = false; 
  158. else { 
  159. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  160. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#suspended."); 
  161. break; 
  162. case 'changePasswordAtNextLogin': 
  163. if ($attribute->nodeValue == "true") { 
  164. $this->_changePasswordAtNextLogin = true; 
  165. else if ($attribute->nodeValue == "false") { 
  166. $this->_changePasswordAtNextLogin = false; 
  167. else { 
  168. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  169. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#changePasswordAtNextLogin."); 
  170. break; 
  171. default: 
  172. parent::takeAttributeFromDOM($attribute); 
  173.  
  174. /** 
  175. * Get the value for this element's username attribute. 
  176. * @see setUsername 
  177. * @return string The attribute being modified. 
  178. */ 
  179. public function getUsername() 
  180. return $this->_username; 
  181.  
  182. /** 
  183. * Set the value for this element's username attribute. This string 
  184. * is used to uniquely identify the user in this domian and is used 
  185. * to form this user's email address. 
  186. * @param string $value The desired value for this attribute. 
  187. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  188. */ 
  189. public function setUsername($value) 
  190. $this->_username = $value; 
  191. return $this; 
  192.  
  193. /** 
  194. * Get the value for this element's password attribute. 
  195. * @see setPassword 
  196. * @return string The requested attribute. 
  197. */ 
  198. public function getPassword() 
  199. return $this->_password; 
  200.  
  201. /** 
  202. * Set the value for this element's password attribute. As of this 
  203. * writing, this can be either be provided as plaintext or hashed using 
  204. * the SHA-1 algorithm for protection. If using a hash function,  
  205. * this must be indicated by calling setHashFunctionName(). 
  206. * @param string $value The desired value for this attribute. 
  207. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  208. */ 
  209. public function setPassword($value) 
  210. $this->_password = $value; 
  211. return $this; 
  212.  
  213. /** 
  214. * Get the value for this element's hashFunctionName attribute. 
  215. * @see setHashFunctionName 
  216. * @return string The requested attribute. 
  217. */ 
  218. public function getHashFunctionName() 
  219. return $this->_hashFunctionName; 
  220.  
  221. /** 
  222. * Set the value for this element's hashFunctionName attribute. This 
  223. * indicates whether the password supplied with setPassword() is in 
  224. * plaintext or has had a hash function applied to it. If null,  
  225. * plaintext is assumed. As of this writing, the only valid hash 
  226. * function is 'SHA-1'. 
  227. * @param string $value The desired value for this attribute. 
  228. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  229. */ 
  230. public function setHashFunctionName($value) 
  231. $this->_hashFunctionName = $value; 
  232. return $this; 
  233.  
  234. /** 
  235. * Get the value for this element's admin attribute. 
  236. * @see setAdmin 
  237. * @return boolean The requested attribute. 
  238. * @throws Zend_Gdata_App_InvalidArgumentException 
  239. */ 
  240. public function getAdmin() 
  241. if (!(is_bool($this->_admin))) { 
  242. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  243. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for admin.'); 
  244. return $this->_admin; 
  245.  
  246. /** 
  247. * Set the value for this element's admin attribute. This indicates 
  248. * whether this user is an administrator for this domain. 
  249. * @param boolean $value The desired value for this attribute. 
  250. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  251. * @throws Zend_Gdata_App_InvalidArgumentException 
  252. */ 
  253. public function setAdmin($value) 
  254. if (!(is_bool($value))) { 
  255. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  256. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); 
  257. $this->_admin = $value; 
  258. return $this; 
  259.  
  260. /** 
  261. * Get the value for this element's agreedToTerms attribute. 
  262. * @see setAgreedToTerms 
  263. * @return boolean The requested attribute. 
  264. * @throws Zend_Gdata_App_InvalidArgumentException 
  265. */ 
  266. public function getAgreedToTerms() 
  267. if (!(is_bool($this->_agreedToTerms))) { 
  268. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  269. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for agreedToTerms.'); 
  270. return $this->_agreedToTerms; 
  271.  
  272. /** 
  273. * Set the value for this element's agreedToTerms attribute. This 
  274. * indicates whether this user has agreed to the terms of service. 
  275. * @param boolean $value The desired value for this attribute. 
  276. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  277. * @throws Zend_Gdata_App_InvalidArgumentException 
  278. */ 
  279. public function setAgreedToTerms($value) 
  280. if (!(is_bool($value))) { 
  281. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  282. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); 
  283. $this->_agreedToTerms = $value; 
  284. return $this; 
  285.  
  286. /** 
  287. * Get the value for this element's suspended attribute. 
  288. * @see setSuspended 
  289. * @return boolean The requested attribute. 
  290. * @throws Zend_Gdata_App_InvalidArgumentException 
  291. */ 
  292. public function getSuspended() 
  293. if (!(is_bool($this->_suspended))) { 
  294. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  295. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for suspended.'); 
  296. return $this->_suspended; 
  297.  
  298. /** 
  299. * Set the value for this element's suspended attribute. If true, the 
  300. * user will not be able to login to this domain until unsuspended. 
  301. * @param boolean $value The desired value for this attribute. 
  302. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  303. * @throws Zend_Gdata_App_InvalidArgumentException 
  304. */ 
  305. public function setSuspended($value) 
  306. if (!(is_bool($value))) { 
  307. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  308. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); 
  309. $this->_suspended = $value; 
  310. return $this; 
  311.  
  312. /** 
  313. * Get the value for this element's changePasswordAtNextLogin attribute. 
  314. * @see setChangePasswordAtNextLogin 
  315. * @return boolean The requested attribute. 
  316. * @throws Zend_Gdata_App_InvalidArgumentException 
  317. */ 
  318. public function getChangePasswordAtNextLogin() 
  319. if (!(is_bool($this->_changePasswordAtNextLogin))) { 
  320. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  321. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for changePasswordAtNextLogin.'); 
  322. return $this->_changePasswordAtNextLogin; 
  323.  
  324. /** 
  325. * Set the value for this element's changePasswordAtNextLogin attribute. 
  326. * If true, the user will be forced to set a new password the next 
  327. * time they login. 
  328. * @param boolean $value The desired value for this attribute. 
  329. * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. 
  330. * @throws Zend_Gdata_App_InvalidArgumentException 
  331. */ 
  332. public function setChangePasswordAtNextLogin($value) 
  333. if (!(is_bool($value))) { 
  334. require_once('Zend/Gdata/App/InvalidArgumentException.php'); 
  335. throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); 
  336. $this->_changePasswordAtNextLogin = $value; 
  337. return $this; 
  338.  
  339. /** 
  340. * Magic toString method allows using this directly via echo 
  341. * Works best in PHP >= 4.2.0 
  342. */ 
  343. public function __toString() 
  344. return "Username: " . $this->getUsername() . 
  345. "\nPassword: " . (($this->getPassword() === null) ? "NOT SET" : "SET") . 
  346. "\nPassword Hash Function: " . $this->getHashFunctionName() . 
  347. "\nAdministrator: " . ($this->getAdmin() ? "Yes" : "No") . 
  348. "\nAgreed To Terms: " . ($this->getAgreedToTerms() ? "Yes" : "No") . 
  349. "\nSuspended: " . ($this->getSuspended() ? "Yes" : "No");