00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Admin_Model_Mysql4_Acl_Role
00035 {
00036 protected $_roleTable;
00037 protected $_read;
00038 protected $_write;
00039
00040 public function __construct()
00041 {
00042 $this->_roleTable = Mage::getSingleton('core/resource')->getTableName('admin/role');
00043 $this->_read = Mage::getSingleton('core/resource')->getConnection('admin_read');
00044 $this->_write = Mage::getSingleton('core/resource')->getConnection('admin_write');
00045 }
00046
00047 public function load($roleId)
00048 {
00049 $select = $this->_read->select()->from($this->_roleTable)
00050 ->where("role_id=?", $roleId);
00051 return $this->_read->fetchRow($select);
00052 }
00053
00054 public function save(Mage_Admin_Model_Acl_Role $role)
00055 {
00056 $data = $role->getData();
00057
00058 $this->_write->beginTransaction();
00059
00060 try {
00061 if ($role->getId()) {
00062 $condition = $this->_write->quoteInto('role_id=?', $role->getRoleId());
00063 $this->_write->update($this->_roleTable, $data, $condition);
00064 } else {
00065 $data['created'] = now();
00066 $this->_write->insert($this->_roleTable, $data);
00067 $role->setRoleId($this->_write->lastInsertId());
00068 }
00069
00070 $this->_write->commit();
00071 }
00072 catch (Mage_Core_Exception $e)
00073 {
00074 $this->_write->rollback();
00075 throw $e;
00076 }
00077
00078 return $role;
00079 }
00080
00081 public function delete()
00082 {
00083
00084 }
00085 }