Example #1
0
 public function testGetAttributes()
 {
     $this->object = new Accessor(new ExtendingObj());
     $this->assertEquals(3, count($this->object->getAttributes()));
     $this->assertTrue(in_array('myProp', $this->object->getAttributes()));
     $this->assertTrue(in_array('test', $this->object->getAttributes()));
 }
Example #2
0
 public function setUp()
 {
     if (self::$db_needed && !self::$db_has_transactions) {
         $this->markTestSkipped('Database transactions are needed to test these features, but your "options" and "usermeta" tables are not using the InnoDB engine.');
     }
     self::$location_actual = null;
     self::$location_expected = null;
     self::$mail_file = null;
     self::$mail_file_basename = null;
     self::$lss->set_sleep(null);
     self::$lss->is_xmlrpc = false;
     self::$lss->skip_wp_login_failed = false;
     self::$lss->user_pass = null;
     self::$lss->xmlrpc_enabled = false;
     $_SERVER['SERVER_PROTOCOL'] = 'http';
     $this->user = new WP_User();
     $this->user->data = new StdClass();
     $this->user->ID = 9999999;
     $this->user->user_login = '******';
     $this->user->user_email = 'bbbb';
     $this->user->user_url = 'cccc';
     $this->user->first_name = 'dddd';
     $this->user->last_name = 'aaaa';
     $this->user->nickname = 'fff@1F*8ffff';
     $this->user->display_name = '简化字';
     $this->user->aim = 'hhhhhhhh';
     $this->user->yim = 'iiiiiiii';
     $this->user->jabber = 'jjjjjjjj';
     $this->user->user_pass = self::USER_PASS;
 }
 private static function add(Accessor $accessor)
 {
     self::$ACCESSORS[Hasher::hashObject($accessor->getTargetType())] = $accessor;
 }
Example #4
0
 public function SetEntityType($EntityType)
 {
     parent::SetEntityType($EntityType);
     $this->PropertyGetter->SetEntityType($EntityType);
     $this->PropertySetter->SetEntityType($EntityType);
 }
		/**
		   * Check, whether an accessor is allowed to perform a special operation on the Object.
		   * @param integer GUID of the user or group
		   * @param string Title of the action to check for.
		   */
		function checkAccessToFunction2($guid, $action) {
			global $db, $auth;		
			if ($auth->user == "Administrator") 
			  return true;

			$action = strtoupper($action);
			$result = false;
			$accessor = new Accessor($guid);
			
			// determine accessors the user is in.
			$accessorGroups = $accessor->isInGroups();			
			$accessorGroupsStr = implode(',', $accessorGroups);
						
			// check for owner
			if (in_array($this->owner, $accessorGroups)) {				
				if ($accessor->canDoInGroup($action, $this->owner))				
					return true;
			}
				
			// determine roles, the function is in.			
			$actionRoles = createDBCArray("role_sys_functions", "ROLE_ID", "UPPER(FUNCTION_ID) = '$action'");
			if (! is_array($actionRoles)) {
			  $actionRoles = array();
			 }
			array_push($actionRoles, 1); // Administrator Role
			$actionRolesStr = implode(",", $actionRoles);	
			
			$resourceGroups = array();
			for ($i=0; $i < count($this->accessors); $i++) {
			  if (in_array($this->accessors[$i]["ROLE"], $actionRoles)) {
			    array_push($resourceGroups, $this->accessors[$i]["ACCESSOR"]);	
			  }	
			}
			
								
			$bothGroups = array();
			if (is_array($resourceGroups)) 
			  $bothGroups = array_intersect($resourceGroups, $accessorGroups);
			  if (is_array($bothGroups)) {
			  foreach ($bothGroups as $group) {				
				$sql = "SELECT up.USER_ID FROM user_permissions up, acl_relations r WHERE up.USER_ID = $guid AND up.GROUP_ID = ".$group." AND up.ROLE_ID IN ($actionRolesStr) AND r.ROLE_ID IN ($actionRolesStr) AND r.ACCESSOR_GUID IN ($accessorGroupsStr) AND r.GUID= ".$this->effectiveACLGuid;			
				$query = new query($db, $sql);				
				if ($query->getrow()) {
				  return true;				   
				 } else {				   
				}
				$query->free();
			  }
			}			
			/**
			
			// check for foreign relations....
			if ($accessorGroupsStr != "") {		
				$accessorRolesOnResource = createDBCArray("acl_relations", "ROLE_ID", "GUID = $this->guid AND ACCESSOR_GUID IN ($accessorGroupsStr)");				
				if (in_array(1, $accessorRolesOnResource))  // Admin Rechte
				  $result = true;
				if (is_array($accessorRolesOnResource)) {
					$accessorRolesOnResourceStr = implode(',', $accessorRolesOnResource);										
					$accessorFunctionsOnResource = createDBCArray("role_sys_functions", "FUNCTION_ID", "ROLE_ID IN ($accessorRolesOnResourceStr)");															
					if (is_array($accessorFunctionsOnResource)) {
						if (in_array(strtoupper($action), $accessorFunctionsOnResource)) 
					  		$result = true;				
					}
				}
			}*/
			return false;
		}