- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
/**
* Получаем права на объект.
*
* @param string $fullHref
* @param string $method
* @param string $params
* @param string $type
* @return object $this
* @access public
*/
public function getPermsHref( $object, $method = '*', $params = false, $type = 'module', $url = false )
{
$registr = URegistry::getInstance();
$sql = $registr->SQuery->getAcl();
if ( $type == 'url' && $url )
{
$sql['where'] = "`o`.`type` = 'url' and `o`.`href` = '".$url."'";
$ac_type = 'url';
}
elseif ( $type == 'module' )
{
$sql['where'] = "(`o`.`type` = 'module') and `o`.`name` = '".$object."'";
if ( $method != '*' )
$sql['where'] .= ' or `o`.`href` = "'.$object.'/'.$method.'"';
$ac_type = 'module';
}
else
{
//TODO:wtf?
}
$registr->db->build_query($sql)->safe_sql($ac_type, $this->gid)->exec();
$perms = $registr->db->fetch_object();
if ( !$perms || !$perms->permission || !$perms->groupid )
throw new NotFoundObject();
$this->perms = $perms->permission;
$this->groupObject = explode(',', $perms->groupid);
$this->priv_lengh = strlen($perms->permission);
return $this;
}
/**
* Проверка прав на объект
*
* @param mixed $priv
* @return array
* @access public
*/
public function checkPremsObject( $priv = false )
{
$pruf = array();
$priv = empty($priv) ? $this->perms : $priv;
if ( $this->priv_lengh <= 0 or !in_array($this->gid, $this->groupObject) )
return false;
for ( $gi = 0; $gi < $this->priv_lengh; $gi++ )
{
if ( in_array($priv[$gi], $this->privileges['read']) ) $pruf['read'] = true;
if ( in_array($priv[$gi], $this->privileges['write']) ) $pruf['write'] = true;
if ( in_array($priv[$gi], $this->privileges['delete']) ) $pruf['delete'] = true;
}
return $pruf;
}
Проверка прав.
Что скажите?