Index: branches/5.3.x/core/units/helpers/permissions_helper.php =================================================================== diff -u -N -r15483 -r15698 --- branches/5.3.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 15483) +++ branches/5.3.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 15698) @@ -1,6 +1,6 @@ Application->getUnitOption('perm', 'TableName'); + $perm_table = $this->Application->getUnitConfig('perm')->getTableName(); $perm_table = $this->Application->GetTempName($perm_table, 'prefix:'.$prefix); $sql = 'SELECT * FROM '.$perm_table.' @@ -147,19 +147,18 @@ if (is_array($ids)) { $ids = implode(',', $ids); } - $id_field = $this->Application->getUnitOption($prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); - $ci_table = $this->Application->getUnitOption('ci', 'TableName'); + $config = $this->Application->getUnitConfig($prefix); + $id_field = $config->getIDField(); + $table_name = $config->getTableName(); + $ci_table = $this->Application->getUnitConfig('ci')->getTableName(); + if ($temp_mode) { $table_name = $this->Application->GetTempName($table_name, 'prefix:' . $prefix); $ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $prefix); } - $owner_field = $this->Application->getUnitOption($prefix, 'OwnerField'); - if (!$owner_field) { - $owner_field = 'CreatedById'; - } + $owner_field = $config->getOwnerField('CreatedById'); $sql = 'SELECT item_table.'.$id_field.', item_table.'.$owner_field.' AS CreatedById, ci.CategoryId FROM '.$table_name.' item_table @@ -247,7 +246,8 @@ return true; } - $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); + $item_prefix = $this->Application->getUnitConfig($top_prefix)->getPermItemPrefix(); + foreach ($check_perms as $perm_name) { // check if at least one of required permissions is set if ( !isset($perm_mapping[$perm_name]) ) { @@ -456,21 +456,21 @@ */ function getPrimaryCategory($prefix) { - $id_field = $this->Application->getUnitOption($prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); $id = $this->Application->GetVar($prefix.'_id'); if (!$id) { return $this->Application->GetVar('m_cat_id'); } + $config = $this->Application->getUnitConfig($prefix); + $sql = 'SELECT ResourceId - FROM '.$table_name.' - WHERE '.$id_field.' = '.(int)$id; + FROM '. $config->getTableName() .' + WHERE '. $config->getIDField() .' = '.(int)$id; $resource_id = $this->Conn->GetOne($sql); $sql = 'SELECT CategoryId - FROM '.$this->Application->getUnitOption('ci', 'TableName').' + FROM '.$this->Application->getUnitConfig('ci')->getTableName().' WHERE ItemResourceId = '.$resource_id.' AND PrimaryCat = 1'; return $this->Conn->GetOne($sql); } @@ -662,7 +662,7 @@ } else { $sql = 'SELECT ParentPath - FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' + FROM ' . $this->Application->getUnitConfig('c')->getTableName() . ' WHERE CategoryId = ' . $cat_id; $cat_hierarchy = $this->Conn->GetOne($sql); if ( $cat_hierarchy === false ) { @@ -758,7 +758,7 @@ */ function ModifyCheckPermission($owner_id, $category_id, $prefix) { - $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix(); $live_modify = $this->CheckPermission($perm_prefix.'.MODIFY', ptCATEGORY, $category_id); if ($live_modify) { @@ -792,7 +792,7 @@ */ function DeleteCheckPermission($owner_id, $category_id, $prefix) { - $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix(); $live_delete = $this->CheckPermission($perm_prefix.'.DELETE', ptCATEGORY, $category_id); if ($live_delete) { @@ -819,7 +819,7 @@ */ function AddCheckPermission($category_id, $prefix) { - $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix(); $live_add = $this->CheckPermission($perm_prefix.'.ADD', ptCATEGORY, $category_id); if ($live_add) {