XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
AvatarSelectForm.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
13
15{
16 public $mSelectedId = null;
17
18 public function getTokenName()
19 {
20 return 'module.user.AvatarSelectForm.TOKEN' . $this->get('uid');
21 }
22
23 public function prepare()
24 {
25 $this->mFormProperties['uid'] =new XCube_IntProperty('uid');
26 $this->mFormProperties['avatar_id'] =new XCube_IntArrayProperty('avatar_id');
27 }
28
29 public function validateAvatar_id()
30 {
31 $ids = $this->get('avatar_id');
32
33 if (1 != (is_countable($ids) ? count($ids) : 0)) {
34 $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SELECT);
35 }
36
37 foreach ($ids as $avatar_id => $dmy_value) {
38 $this->mSelectedId = $avatar_id;
39 }
40
41 if (0 == $this->mSelectedId) {
42 return;
43 }
44
45 //
46 // Check whether specified avatar_id exists.
47 //
48 $handler =& xoops_getmodulehandler('avatar', 'user');
49 $obj =& $handler->get($this->mSelectedId);
50
51 if (!is_object($obj)) {
52 $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SELECT);
53 }
54 }
55
56 public function load(&$obj)
57 {
58 $this->set('uid', $obj->get('uid'));
59 }
60
61 public function update(&$obj)
62 {
63 $handler =& xoops_getmodulehandler('avatar', 'user');
64
65 if (0 == $this->mSelectedId) {
66 $obj->set('user_avatar', 'blank.gif');
67 } else {
68 $avatar =& $handler->get($this->mSelectedId);
69 $obj->set('user_avatar', $avatar->get('avatar_file'));
70 }
71 }
72}
update(&$obj)
[Abstract] Updates an object with properties values.
getTokenName()
Gets the token name of this actionform's token.
prepare()
[Abstract] Set up form properties and field properties.
load(&$obj)
[Abstract] Initializes properties' values from an object.
addErrorMessage( $message)
Adds a message to the form's error message buffer.
Represents int[] property. XCube_GenericArrayProperty<XCube_IntProperty>.
Represents int property.