[xoops-cvslog 5048] CVS update: xoops2jp/html/modules/user/class

Back to archive index

Minahito minah****@users*****
2006年 10月 14日 (土) 23:17:57 JST


Index: xoops2jp/html/modules/user/class/mailjob.php
diff -u xoops2jp/html/modules/user/class/mailjob.php:1.1.2.7 xoops2jp/html/modules/user/class/mailjob.php:1.1.2.7.2.1
--- xoops2jp/html/modules/user/class/mailjob.php:1.1.2.7	Mon Aug  7 20:32:25 2006
+++ xoops2jp/html/modules/user/class/mailjob.php	Sat Oct 14 23:17:57 2006
@@ -65,23 +65,51 @@
 		}
 	}
 	
+	/**
+	 * Gets users who this mailjob will send mail to, with $retry number.
+	 * @param int $retry
+	 */
+	function &getUsers($retry)
+	{
+		$handler =& xoops_getmodulehandler('mailjob_link', 'user');
+		
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('mailjob_id', $this->get('mailjob_id')));
+		$criteria->add(new Criteria('retry', $retry));
+		
+		$arr =& $handler->getObjects($criteria);
+		
+		return $arr;
+	}
+	
 	function send($from_user)
 	{
 		$root =& XCube_Root::getSingleton();
 		
-		$this->loadUser();
+		$userArr =& $this->getUsers($this->getCurrentRetry());
 		$handler =& xoops_getmodulehandler('mailjob_link', 'user');
 
 		$userHandler =& xoops_gethandler('user');
 		
-		foreach ($this->mUsers as $link) {
-			$to_user =& $userHandler->get($link->get('uid'));
+		foreach (array_keys($userArr) as $key) {
+			$to_user =& $userHandler->get($userArr[$key]->get('uid'));
+			
+			$userArr[$key]->set('message', '');
 			
 			if (is_object($to_user)) {
-				$this->mSend->call(new XCube_Ref($this), $to_user, $from_user);
+				$this->mSend->call(new XCube_Ref($userArr[$key]), new XCube_Ref($this), $to_user, $from_user);
+			}
+			else {
+				$userArr[$key]->set('message', 'This user does not exist.');
 			}
 			
-			$handler->delete($link);
+			if ($userArr[$key]->get('message') == '') {
+				$handler->delete($userArr[$key]);
+			}
+			else {
+				$userArr[$key]->set('retry', $userArr[$key]->get('retry') + 1);
+				$handler->insert($userArr[$key]);
+			}
 		}
 	}
 	
@@ -105,6 +133,12 @@
 		
 		return $t_body;
 	}
+	
+	function getCurrentRetry()
+	{
+		$handler =& xoops_getmodulehandler('mailjob_link', 'user');
+		return $handler->getCurrentRetry($this->get('mailjob_id'));
+	}
 }
 
 class UserMailjobHandler extends XoopsObjectGenericHandler
Index: xoops2jp/html/modules/user/class/mailjob_link.php
diff -u xoops2jp/html/modules/user/class/mailjob_link.php:1.1.2.3.2.1 xoops2jp/html/modules/user/class/mailjob_link.php:1.1.2.3.2.2
--- xoops2jp/html/modules/user/class/mailjob_link.php:1.1.2.3.2.1	Sat Oct 14 20:28:34 2006
+++ xoops2jp/html/modules/user/class/mailjob_link.php	Sat Oct 14 23:17:57 2006
@@ -36,6 +36,39 @@
 		return $ret;
 	}
 	
+	function getCurrentRetry($mailjob_id)
+	{
+		$mailjob_id = intval($mailjob_id);
+		$table = $this->mTable;
+		
+		$sql = "SELECT min(retry) AS cretry FROM ${table} where mailjob_id='${mailjob_id}'";
+		
+		$result = $this->db->query($sql);
+		$row = $this->db->fetchArray($result);
+		
+		return $row['cretry'];
+	}
+	
+	function _update(&$obj) {
+		$set_lists=array();
+		$where = "";
+
+		$arr = $this->_makeVars4sql($obj);
+
+		foreach ($arr as $_name => $_value) {
+			if ($_name == 'mailjob_id' || $_name == 'uid') {
+				$where = "${_name}=${_value}";
+			}
+			else {
+				$set_lists[] = "${_name}=${_value}";
+			}
+		}
+
+		$sql = @sprintf("UPDATE " . $this->mTable . " SET %s WHERE %s", implode(",",$set_lists), $where);
+
+		return $sql;
+	}
+	
 	function delete(&$obj, $force = false)
 	{
 		//


xoops-cvslog メーリングリストの案内
Back to archive index