[xoops-cvslog 2651] CVS update: xoops2jp/html/modules/base/class

Back to archive index

Minahito minah****@users*****
2006年 4月 6日 (木) 15:00:25 JST


Index: xoops2jp/html/modules/base/class/newblocks.php
diff -u xoops2jp/html/modules/base/class/newblocks.php:1.1.2.2 xoops2jp/html/modules/base/class/newblocks.php:1.1.2.3
--- xoops2jp/html/modules/base/class/newblocks.php:1.1.2.2	Thu Apr  6 12:37:37 2006
+++ xoops2jp/html/modules/base/class/newblocks.php	Thu Apr  6 15:00:25 2006
@@ -10,8 +10,14 @@
 	 * Array of group objects who can access this object.
 	 * It need lazy loading to access.
 	 */
-	var $mGroup = null;
+	var $mGroup = array();
 	
+	var $mBmodule = array();
+	
+	var $mColumn = null;
+	
+	var $mCachetime = null;
+
 	function BaseNewblocksObject()
 	{
 		$this->initVar('bid', XOBJ_DTYPE_INT, '', true);
@@ -62,6 +68,26 @@
 			$this->mGroup[] =& $handler->get($gperm->get('gperm_groupid'));
 		}
 	}
+	
+	function loadBmodule()
+	{
+		$handler =& xoops_getmodulehandler('block_module_link', 'base');
+		$criteria =& new Criteria('block_id', $this->get('bid'));
+		
+		$this->mBmodule =& $handler->getObjects($criteria);
+	}
+	
+	function loadColumn()
+	{
+		$handler =& xoops_getmodulehandler('columnside', 'base');
+		$this->mColumn =& $handler->get($this->get('side'));
+	}
+	
+	function loadCachetime()
+	{
+		$handler =& xoops_gethandler('cachetime');
+		$this->mCachetime =& $handler->get($this->get('bcachetime'));
+	}
 }
 
 class BaseNewblocksHandler extends XoopsObjectGenericHandler
@@ -69,6 +95,61 @@
 	var $mTable = "newblocks";
 	var $mPrimary = "bid";
 	var $mClass = "BaseNewblocksObject";
+	
+	function insert(&$obj, $force=false)
+	{
+		if (parent::insert($obj, $force)) {
+			$handler =& xoops_getmodulehandler('block_module_link', 'base');
+			$handler->deleteAll(new Criteria('block_id', $obj->get('bid')));
+			foreach ($obj->mBmodule as $bmodule) {
+				$handler->insert($bmodule);
+			}
+
+			//
+			// Insert group permissions.
+			//
+			$currentGroupid = array();
+			foreach ($obj->mGroup as $group) {
+				$currentGroupid[] = $group->get('groupid');
+			}
+			
+			$permHandler =& xoops_gethandler('groupperm');
+			$criteria =& new CriteriaCompo();
+			$criteria->add(new Criteria('gperm_modid', 1));
+			$criteria->add(new Criteria('gperm_itemid', $obj->get('bid')));
+			$criteria->add(new Criteria('gperm_name', 'block_read'));
+			
+			$gpermArr =&  $permHandler->getObjects($criteria);
+			foreach ($gpermArr as $gperm) {
+				if (!in_array($gperm->get('gperm_groupid', $currentGroupid))) {
+					$permHandler->delete($gperm, $force);
+				}
+			}
+			
+			foreach ($obj->mGroup as $group) {
+				$insertFlag = true;
+				foreach ($gpermArr as $gperm) {
+					if ($gperm->get('gperm_groupid') == $group->get('group_id')) {
+						$insertFlag = false;
+					}
+				}
+				
+				if ($insertFlag) {
+					$gperm =& $permHandler->create();
+					$gperm->set('gperm_modid', 1);
+					$gperm->set('gperm_groupid', $group->get('groupid'));
+					$gperm->set('gperm_itemid', $obj->get('bid'));
+					$gperm->set('gperm_name', 'block_read');
+					
+					$permHandler->insert($gperm, $force);
+				}
+			}
+			
+			return true;
+		}
+		
+		return false;
+	}
 }
 
 ?>


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