| 
					
				 | 
			
			
				@@ -7,7 +7,7 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_sketch_search': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','read')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -34,6 +34,9 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			foreach($sketchs as $sketch){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(!$sketch->state &&  $sketch->creator != $myUser->login) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$row = $sketch->toArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$row['picture'] = $sketch->picture(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$row['created'] = relative_time($row['created']); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -113,9 +116,12 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_resource_search': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','read')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = Sketch::provide('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(!$sketch->state &&  $sketch->creator != $myUser->login) throw new Exception("Sketch privé", 403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			foreach(Resource::loadAll(array('sketch'=>$_['sketch']),array('sort')) as $resource){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$row = $resource->toArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$type = $resource->type(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -128,10 +134,15 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_resource_edit': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','read')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$item = Resource::provide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::provide('id',1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(!$sketch->state &&  $sketch->creator != $myUser->login) throw new Exception("Sketch privé", 403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$response = $item->toHtml(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$response['resourceType'] = $item->type; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -139,9 +150,12 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_resource_save_content': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','edit')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$item = Resource::provide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::provide('id',1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$item->content = $_['content']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$item->save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -152,9 +166,13 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if(!$myUser->can('hackpoint','edit')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'ResourceType.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$item = Resource::provide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::provide('id',1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if(!isset($_['type']) && $item->id!=0) $_['type'] = $item->type; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$type = ResourceType::types($_['type']); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -177,10 +195,15 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if(!$myUser->can('hackpoint','edit')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'ResourceType.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			foreach($_['sort'] as $sort=>$id){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$resource =  Resource::getById($id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$resource =  Resource::getById($id,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$sketch = $resource->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if($sketch->creator != $myUser->login) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$resource->sort = $sort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$resource->save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -191,8 +214,13 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_resource_delete': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','delete')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::getById($_['id'],1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Resource::deleteById($_['id']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -261,11 +289,15 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_part_search': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','read')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Part.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'ResourcePart.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::provide('resource',1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(!$sketch->state && $sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			foreach(ResourcePart::loadAll(array('resource'=>$_['resource']),  null, null, array('*'),1) as $resourcepart){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$part = $resourcepart->join('part'); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -282,10 +314,16 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_part_save': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','edit')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'Part.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'ResourcePart.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$item = Resource::provide('resource',1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $item->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$part = Part::provide('part'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$part->label = $_['label']; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -316,8 +354,15 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_resource_part_delete': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(!$myUser->can('hackpoint','delete')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//if(!$myUser->can('hackpoint','delete')) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			require_once(__DIR__.SLASH.'ResourcePart.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			require_once(__DIR__.SLASH.'Part.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$resourcePart = ResourcePart::getById($_['id'],2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$resource = $resourcePart->join('resource'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$sketch = $resource->join('sketch'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($sketch->creator!=$myUser->login) throw new Exception("Permissions insuffisantes",403); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ResourcePart::deleteById($_['id']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -334,7 +379,7 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	//Suppression d'élement part 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//Download d'un fichier 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	case 'hackpoint_download_file': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			global $myUser,$_; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -392,16 +437,19 @@ switch($_['action']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	    case 'get_part_by_id': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	    Action::write(function(&$response){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        global $myUser,$_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        	if (!$myUser->connected()) throw new Exception("Vous devez être connecté!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	require_once(__DIR__.SLASH.'Sketch.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	require_once(__DIR__.SLASH.'Resource.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         	require_once(__DIR__.SLASH.'Part.class.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	        $part = Part::getById($_['id']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	        $part = Part::getById($_['id'],1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        $part = !$part ? new Part() : Part::getById($_['id']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	        $row = $part->toArray(); 
			 |