1: <?php
2:
3: if (!defined('XOOPS_ROOT_PATH')) exit();
4:
5: class Mailjob_ArrayOfInt extends XCube_ObjectArray
6: {
7: function getClassName()
8: {
9: return "int";
10: }
11: }
12:
13: class User_MailjobService extends XCube_Service
14: {
15: var $mServiceName = "User_MailjobService";
16: var $mNameSpace = "User_Mailjob";
17: var $mClassName = "User_MailjobService";
18:
19: 20: 21:
22: function prepare()
23: {
24: $this->addFunction(S_PUBLIC_FUNC('int addMailjob(string title, text body, string from_name, string from_email, bool is_pm, bool is_mail, Mailjob_ArrayOfInt uidArr)'));
25:
26: }
27:
28: 29: 30: 31:
32: function addMailjob()
33: {
34: require_once XOOPS_MODULE_PATH . "/user/admin/forms/MailjobServiceEditForm.class.php";
35:
36: $root =& XCube_Root::getSingleton();
37:
38: $uidArr = $root->mContext->mRequest->getRequest('uidArr');
39:
40:
41: $handler =& xoops_getmodulehandler('mailjob', 'user');
42: $obj = $handler->create();
43: $obj->set('title', $root->mContext->mRequest->getRequest('title'));
44: $obj->set('body', $root->mContext->mRequest->getRequest('body'));
45: $obj->set('from_name', $root->mContext->mRequest->getRequest('from_name'));
46: $obj->set('from_email', $root->mContext->mRequest->getRequest('from_email'));
47: $obj->set('is_pm', $root->mContext->mRequest->getRequest('is_pm'));
48: $obj->set('is_mail', $root->mContext->mRequest->getRequest('is_mail'));
49:
50:
51: $actionForm = new User_MailjobServiceEditForm();
52: $actionForm->prepare();
53: $actionForm->load($obj);
54: $actionForm->validate();
55: if($actionForm->hasError()){
56: return 0;
57: }
58:
59:
60: if(! $handler->insert($obj)){
61: return 0;
62: }
63:
64:
65: $linkHandler =& xoops_getmodulehandler('mailjob_link', 'user');
66: foreach ($uidArr as $uid) {
67: $linkObj =& $linkHandler->create();
68: $linkObj->set('mailjob_id', $obj->get('mailjob_id'));
69: $linkObj->set('uid', $uid);
70: $linkHandler->insert($linkObj);
71: }
72:
73: return $obj->get('mailjob_id');
74: }
75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100:
101: }
102:
103:
104: ?>