XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
mailjob_link.php
1<?php
2
3if (!defined('XOOPS_ROOT_PATH')) {
4 exit();
5}
6
8{
9 public function __construct()
10 {
11 static $initVars;
12 if (isset($initVars)) {
13 $this->mVars = $initVars;
14 return;
15 }
16 $this->initVar('mailjob_id', XOBJ_DTYPE_INT, '0', true);
17 $this->initVar('uid', XOBJ_DTYPE_INT, '0', true);
18 $this->initVar('retry', XOBJ_DTYPE_INT, '0', true);
19 $this->initVar('message', XOBJ_DTYPE_STRING, '', false, 191);
20 $initVars = $this->mVars;
21 }
22}
23
24// @todo @gigamasterWARNING:
25// Declaration of & UserMailjob_linkHandler::get($mailjob_id, $uid)
26// should be compatible with & XoopsObjectGenericHandler::get($id)
27
29{
30 public $mTable = 'user_mailjob_link';
31 public $mPrimary = 'mailjob_id';
32 public $mClass = 'UserMailjob_linkObject';
33
34 public function &get( $id, $mailjob_id = '', $uid = '' )
35 {
36
37 $ret = null;
38
39 $criteria = new CriteriaCompo();
40 $criteria->add(new Criteria('mailjob_id', $mailjob_id));
41 $criteria->add(new Criteria('uid', $uid));
42
43 $objArr = &$this->getObjects($criteria);
44
45 if (1 == (is_countable($objArr) ? count($objArr) : 0)) {
46 $ret = &$objArr[0];
47 }
48
49 return $ret;
50 }
51
52 public function getCurrentRetry($mailjob_id)
53 {
54 $mailjob_id = (int)$mailjob_id;
55 $table = $this->mTable;
56
57 $sql = "SELECT min(retry) AS cretry FROM {$table} where mailjob_id='{$mailjob_id}'";
58
59 $result = $this->db->query($sql);
60 $row = $this->db->fetchArray($result);
61
62 return $row['cretry'];
63 }
64
65 public function _update(&$obj)
66 {
67 $set_lists = [];
68 $where = '';
69
70 $arr = $this->_makeVars4sql($obj);
71
72 foreach ($arr as $_name => $_value) {
73 if ('mailjob_id' == $_name || 'uid' == $_name) {
74 $where = "{$_name}={$_value}";
75 } else {
76 $set_lists[] = "{$_name}={$_value}";
77 }
78 }
79
80 $sql = @sprintf('UPDATE ' . $this->mTable . ' SET %s WHERE %s', implode(',', $set_lists), $where);
81
82 return $sql;
83 }
84
85 public function delete(&$obj, $force = false)
86 {
87 //
88 // Because Criteria can generate the most appropriate sentence, use
89 // criteria even if this approach is few slow.
90 //
91 $criteria = new CriteriaCompo();
92 $criteria->add(new Criteria('mailjob_id', $obj->get('mailjob_id')));
93 $criteria->add(new Criteria('uid', $obj->get('uid')));
94 $sql = 'DELETE FROM ' . $this->mTable . ' WHERE ' . $this->_makeCriteriaElement4sql($criteria, $obj);
95
96 return $force ? $this->db->queryF($sql) : $this->db->query($sql);
97 }
98}
& getObjects($criteria=null, $limit=null, $start=null, $id_as_key=false)
Definition handler.php:83
_makeCriteriaElement4sql($criteria, &$obj)
Definition handler.php:359