Minahito
minah****@users*****
2006年 7月 4日 (火) 18:49:44 JST
Index: xoops2jp/html/modules/pm/forms/PmliteEditForm.class.php diff -u xoops2jp/html/modules/pm/forms/PmliteEditForm.class.php:1.1.2.6 xoops2jp/html/modules/pm/forms/PmliteEditForm.class.php:1.1.2.7 --- xoops2jp/html/modules/pm/forms/PmliteEditForm.class.php:1.1.2.6 Tue Mar 28 22:30:48 2006 +++ xoops2jp/html/modules/pm/forms/PmliteEditForm.class.php Tue Jul 4 18:49:43 2006 @@ -12,61 +12,61 @@ * @auchor makeActionForm * @abstract */ -class PmliteEditForm extends XCube_ActionForm +class Pm_PmliteEditForm extends XCube_ActionForm { - var $mState=null; + var $mState = null; function getTokenName() { - return "module.user.PmliteEditForm.TOKEN"; + return "module.pm.PmliteEditForm.TOKEN"; } function prepare() { - $this->mFormProperties['subject']=new XCube_StringProperty('subject'); - $this->mFormProperties['message']=new XCube_TextProperty('message'); + $this->mFormProperties['subject'] = new XCube_StringProperty('subject'); + $this->mFormProperties['message'] = new XCube_TextProperty('message'); // set fields - $this->mFieldProperties['subject']=new XCube_FieldProperty($this); - $this->mFieldProperties['subject']->setDependsByArray(array('required')); - $this->mFieldProperties['subject']->addMessage("required",_MD_PM_ERROR_REQUIRED,_PM_SUBJECT); + $this->mFieldProperties['subject'] = new XCube_FieldProperty($this); + $this->mFieldProperties['subject']->setDependsByArray(array('required', 'maxlength')); + $this->mFieldProperties['subject']->addMessage("required", _MD_PM_ERROR_REQUIRED, _PM_SUBJECT); + $this->mFieldProperties['subject']->addMessage('maxlength', _MD_PM_ERROR_MAXLENGTH, _PM_SUBJECT, '255'); + $this->mFieldProperties['subject']->addVar('maxlength', '255'); - $this->mFieldProperties['message']=new XCube_FieldProperty($this); + $this->mFieldProperties['message'] = new XCube_FieldProperty($this); $this->mFieldProperties['message']->setDependsByArray(array('required')); - $this->mFieldProperties['message']->addMessage("required",_MD_PM_ERROR_REQUIRED,_MD_PM_LANG_MESSAGE); + $this->mFieldProperties['message']->addMessage("required", _MD_PM_ERROR_REQUIRED, _MD_PM_LANG_MESSAGE); - if(is_object($this->mState)) + if (is_object($this->mState)) { $this->mState->prepare($this); + } } function fetch() { parent::fetch(); - if(is_object($this->mState)) + if (is_object($this->mState)) { $this->mState->fetch($this); + } } function changeStateReply() { - $this->mState=new PmliteEditFormReplyState(); - } - - function setToUser(&$user) - { + $this->mState =& new Pm_PmliteEditFormReplyState(); } - + function resetToUser() { } } -class PmliteComboEditForm extends PmliteEditForm +class Pm_PmliteComboEditForm extends PmliteEditForm { function prepare() { parent::prepare(); - $this->mFormProperties['to_userid']=new XCube_IntProperty('to_userid'); + $this->mFormProperties['to_userid'] = new XCube_IntProperty('to_userid'); } /** @@ -74,48 +74,38 @@ */ function validateTo_userid() { - if($this->get('to_userid')) { - $userHandler=&xoops_gethandler('user'); - $user=&$userHandler->get($this->get('to_userid')); + if ($this->get('to_userid')) { + $handler =& xoops_gethandler('user'); + $user =& $handler->get($this->get('to_userid')); - if(!(is_object($user)&&$user->isActive())) { - $this->set('to_userid',0); + if (!(is_object($user) && $user->isActive())) { + $this->set('to_userid', 0); $this->addErrorMessage(_PM_USERNOEXIST); } } } - /** - * @param $pm PrivateMessage - */ - function update(&$pm) - { - $userHandler=&xoops_gethandler('user'); - $toUser=&$userHandler->get($this->get('to_userid')); - $pm->setToUsers($toUser); - $pm->setSubject($this->get("subject")); - $pm->setMessage($this->get("message")); - } - - function setToUser(&$user) + function update(&$obj) { - $this->set('to_userid',$user->get('uid')); + $obj->setVar('to_userid', $this->get('to_userid')); + $obj->setVar('subject', $this->get('subject')); + $obj->setVar('msg_text', $this->get('message')); } function resetToUser() { - $this->set('to_userid',0); + $this->set('to_userid', 0); } } -class PmliteDirectEditForm extends PmliteEditForm +class Pm_PmliteDirectEditForm extends PmliteEditForm { - var $mToUser; + var $_mUid; function prepare() { parent::prepare(); - $this->mFormProperties['to_uname']=new XCube_StringProperty('to_uname'); + $this->mFormProperties['to_uname'] = new XCube_StringProperty('to_uname'); } /** @@ -123,51 +113,43 @@ */ function validateTo_uname() { - if($this->get('to_uname')) { - $userHandler=&xoops_gethandler('user'); - $criteria=new Criteria("uname",$this->get("to_uname")); - $users=&$userHandler->getObjects($criteria); + if ($this->get('to_uname')) { + $handler =& xoops_gethandler('user'); + $criteria =& new Criteria("uname", $this->get("to_uname")); + $userArr =& $userHandler->getObjects($criteria); - if(!(count($users)>0 && is_object($users[0]) && $users[0]->isActive())) { + if (!(count($userArr) > 0 && is_object($userArr[0]) && $userArr[0]->isActive())) { $this->addErrorMessage(_PM_USERNOEXIST); } - $this->mToUser=&$users[0]; + $this->_mId = $userArr[0]->get('uid'); } } - /** - * @param $pm PrivateMessage - */ - function update(&$pm) - { - $pm->setToUsers($this->mToUser); - $pm->setSubject($this->get("subject")); - $pm->setMessage($this->get("message")); - } - - function setToUser(&$user) + function update(&$obj) { - $this->set('to_uname',$user->get('uname')); + $obj->setVar('to_userid', $this->_mUid); + $obj->setVar('subject', $this->get('subject')); + $obj->setVar('msg_text', $this->get('message')); } - + function resetToUser() { - $this->set('to_uname',""); + $this->_mUid = 0; } } /** * This shows reply-mode for ActionForm of pmlite. */ -class PmliteEditFormReplyState +class Pm_PmliteEditFormReplyState { /** * @param $form PmliteEditForm */ function prepare(&$form) { - $form->mFormProperties['msg_id']=new XCube_IntProperty('msg_id'); + $form->mFormProperties['msg_id'] = new XCube_IntProperty('msg_id'); } /** @@ -175,27 +157,34 @@ */ function fetch(&$form) { - if($form->get('msg_id')) { - $pmHandler=&xoops_gethandler('privmessage'); - $pm=&$pmHandler->get($form->get('msg_id')); - if(is_object($pm)) { - $root=XCube_Root::getSingleton(); - $currentUser=&$root->mController->getXoopsUser(); - if($pm->get('to_userid')==$currentUser->get('uid')) { - if(!preg_match("/^Re:/",$pm->get('subject'))) - $form->set('subject',"Re: ".$pm->get('subject')); + if ($form->get('msg_id')) { + $handler =& xoops_gethandler('privmessage'); + $pm =& $handler->get($form->get('msg_id')); + if (is_object($pm)) { + $root =& XCube_Root::getSingleton(); + $currentUser =& $root->mController->getXoopsUser(); + if ($pm->get('to_userid') == $currentUser->get('uid')) { + // + // Create subject + // + if (!preg_match("/^Re:/", $pm->get('subject'))) { + $form->set('subject', "Re: " . $pm->get('subject')); + } // TODO Use Active Check - $userHandler=&xoops_gethandler('user'); - $user=&$userHandler->get($pm->get('from_userid')); - - $form->setToUser($user); - $message="[quote]\n"; - $message.=sprintf(_PM_USERWROTE,$user->get('uname')) . "\n"; - $message.=$pm->getProperty("msg_text") . "\n"; - $message.="[/quote]\n"; - $form->set("message",$message); + $handler =& xoops_gethandler('user'); + $user =& $handler->get($pm->get('from_userid')); + if (!(is_object($user) && $user->isActive())) { + $this->addErrorMessage(_PM_USERNOEXIST); + } + else { + $message = "[quote]\n"; + $message .= sprintf(_PM_USERWROTE, $user->get('uname')) . "\n"; + $message .= $pm->get("msg_text") . "\n"; + $message .= "[/quote]\n"; + $form->set('message', $message); + } return; } } @@ -204,7 +193,7 @@ // // Reset // - $form->set('msg_id',0); + $form->set('msg_id', 0); $form->resetToUser(); } }