Esempio n. 1
0
	public static function getRules( $userId, $component = 'com_content' )
	{
		$signature	= serialize( array( $userId, $component ) );

		if( empty( self::$rules[$signature] ) )
		{
			$profile = Komento::getProfile( $userId );

			$model	= Komento::getModel( 'acl' );
			$data	= array();

			// check user group specific rules
			$gids = $profile->getUsergroups();

			foreach( $gids as $gid )
			{
				$data[]	= $model->getAclObject( $gid, 'usergroup', $component );
			}

			// check user specific rules
			$data[] = $model->getAclObject( $userId, 'user', $component );

			// remove empty set
			foreach( $data as $key => $value )
			{
				if( empty( $value ) )
				{
					unset( $data[$key] );
				}
			}

			if( count( $data ) < 1 )
			{
				$data[] = KomentoACLHelper::getEmptySet( true );
			}

			self::$rules[$signature] = self::merge( $data );
		}

		return self::$rules[$signature];
	}
Esempio n. 2
0
 public function save($data)
 {
     $component = $data['target_component'];
     unset($data['target_component']);
     $cid = $data['target_id'];
     unset($data['target_id']);
     $type = $data['target_type'];
     unset($data['target_type']);
     Komento::import('helper', 'acl');
     $defaultset = KomentoACLHelper::getEmptySet(true);
     foreach ($defaultset as $key => $value) {
         if (isset($data[$key])) {
             $defaultset->{$key} = $data[$key] ? true : false;
         }
     }
     $table = Komento::getTable('Acl');
     $table->compositeLoad($cid, $type, $component);
     $json = Komento::getJSON();
     $table->rules = $json->encode($defaultset);
     return $table->store();
 }