_init('aw_hdu3/department_permission', 'id'); } /** * @param Mage_Core_Model_Abstract $object * * @return $this|Mage_Core_Model_Resource_Db_Abstract */ protected function _afterSave(Mage_Core_Model_Abstract $object) { $_result = parent::_afterSave($object); if (strlen($object->getAdminRoleIds()) > 0) { $object->setAdminRoleIds(array_map('intval', explode(',', $object->getAdminRoleIds()))); } else { $object->setAdminRoleIds(array()); } if (strlen($object->getDepartmentIds()) > 0) { $object->setDepartmentIds(array_map('intval', explode(',', $object->getDepartmentIds()))); } else { $object->setDepartmentIds(array()); } return $_result; } /** * @param Mage_Core_Model_Abstract $object * * @return $this|Mage_Core_Model_Resource_Db_Abstract */ protected function _beforeSave(Mage_Core_Model_Abstract $object) { if (is_array($object->getAdminRoleIds())) { $object->setAdminRoleIds(implode(',', $object->getAdminRoleIds())); } if (is_array($object->getDepartmentIds())) { $object->setDepartmentIds(implode(',', $object->getDepartmentIds())); } return parent::_beforeSave($object); } /** * @param Mage_Core_Model_Abstract $object * * @return $this|Mage_Core_Model_Resource_Db_Abstract */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { if (strlen($object->getAdminRoleIds()) > 0) { $object->setAdminRoleIds(array_map('intval', explode(',', $object->getAdminRoleIds()))); } else { $object->setAdminRoleIds(array()); } if (strlen($object->getDepartmentIds()) > 0) { $object->setDepartmentIds(array_map('intval', explode(',', $object->getDepartmentIds()))); } else { $object->setDepartmentIds(array()); } return parent::_afterLoad($object); } }