diff options
| author | Antonio Gallo <tonicucoz@gmail.com> | 2010-11-01 20:42:44 +0000 | 
|---|---|---|
| committer | Antonio Gallo <tonicucoz@gmail.com> | 2010-11-01 20:42:44 +0000 | 
| commit | 049e37619a1ea7de4eed2695139645d6d6b9f397 (patch) | |
| tree | aac510dfdcc9e771cd3448cc0f45e7a6fdfc0665 | |
| parent | b006de42300a5671544e6fd3ea20ae7ce96da933 (diff) | |
moderators can now block/unblock users - part 1
| -rw-r--r-- | h-source/Application/Controllers/HistoryController.php | 117 | ||||
| -rw-r--r-- | h-source/Application/Controllers/MeetController.php | 11 | ||||
| -rwxr-xr-x | h-source/Application/Models/UsersModel.php | 16 | ||||
| -rw-r--r-- | h-source/Application/Views/History/viewall.php | 8 | ||||
| -rw-r--r-- | h-source/Application/Views/Meet/meet.php | 25 | ||||
| -rw-r--r-- | h-source/Config/Route.php | 2 | ||||
| -rwxr-xr-x | h-source/Public/Css/website.css | 25 | ||||
| -rwxr-xr-x | h-source/Public/Img/H2O/im-ban-user.png | bin | 0 -> 1258 bytes | |||
| -rwxr-xr-x | h-source/Public/Img/H2O/im-user.png | bin | 0 -> 1109 bytes | |||
| -rw-r--r-- | h-source/tables.sql | 1 | 
10 files changed, 166 insertions, 39 deletions
diff --git a/h-source/Application/Controllers/HistoryController.php b/h-source/Application/Controllers/HistoryController.php index 7250fb0..7702ac9 100644 --- a/h-source/Application/Controllers/HistoryController.php +++ b/h-source/Application/Controllers/HistoryController.php @@ -45,6 +45,26 @@ class HistoryController extends BaseController  		), +		'block'	=>	array( +			 +			'action' 		=>	'block', +			'check_status'	=>	'no', +			'to_status'		=>	'yes', +			'exec_string'	=>	'The user has been blocked. Just reload the page', +			'error_string'	=>	'Error: the user is already blocked', +		 +		), +		 +		'unblock'	=>	array( +		 +			'action'		=>	'unblock', +			'check_status'	=>	'yes', +			'to_status'		=>	'no', +			'exec_string'	=>	'The user is no more blocked. Just reload the page', +			'error_string'	=>	'Error: the user is already un-blocked', +			 +		), +		  	);  	protected $types = array( @@ -54,6 +74,8 @@ class HistoryController extends BaseController  			'clean_type'	=>	'message',  			'model_name'	=>	'MessagesModel',  			'id_name'		=>	'id_mes', +			'field_name'	=>	'deleted', +			'actions'		=>	array('hide','show'),  		), @@ -62,6 +84,18 @@ class HistoryController extends BaseController  			'clean_type'	=>	'talk',  			'model_name'	=>	'TalkModel',  			'id_name'		=>	'id_talk', +			'field_name'	=>	'deleted', +			'actions'		=>	array('hide','show'), +		 +		), +		 +		'user'	=>	array( +		 +			'clean_type'	=>	'user', +			'model_name'	=>	'UsersModel', +			'id_name'		=>	'id_user', +			'field_name'	=>	'blocked', +			'actions'		=>	array('block','unblock'),  		), @@ -85,6 +119,16 @@ class HistoryController extends BaseController  		$this->generic($lang, $token, 'show');  	} +	public function block($lang = 'en', $token = '') +	{ +		$this->generic($lang, $token, 'block'); +	} +	 +	public function unblock($lang = 'en', $token = '') +	{ +		$this->generic($lang, $token, 'unblock'); +	} +	  	protected function generic($lang = 'en', $token = '', $action = 'hide')  	{  		header('Content-type: text/html; charset=UTF-8'); @@ -110,47 +154,51 @@ class HistoryController extends BaseController  				if (array_key_exists($type,$this->types))  				{ -					$modelName = $this->types[$type]['model_name']; -					$clean['type'] = $this->types[$type]['clean_type']; -					$clean['id_name'] = $this->types[$type]['id_name']; - -					//load the right model -					$this->model($modelName); -					$model = $this->m[$modelName]; +					if (in_array($action,$this->types[$type]['actions'])) +					{ +						$modelName = $this->types[$type]['model_name']; +						$clean['type'] = $this->types[$type]['clean_type']; +						$clean['id_name'] = $this->types[$type]['id_name']; +						$clean['field_name'] = $this->types[$type]['field_name']; +						 +						//load the right model +						$this->model($modelName); +						$model = $this->m[$modelName]; -					$count = $model->select()->where(array($clean['id_name'] => $clean['id'],'deleted' => $this->strings[$action]['check_status']))->rowNumber(); +						$count = $model->select()->where(array($clean['id_name'] => $clean['id'],$clean['field_name'] => $this->strings[$action]['check_status']))->rowNumber(); -					if ($count > 0) -					{ -						if (eg_strlen($message) < 500) +						if ($count > 0)  						{ -							//hide the message -							$model->values = array('deleted' => $this->strings[$action]['to_status']); -							$model->update($clean['id']); -							 -							if ($model->queryResult) +							if (eg_strlen($message) < 500)  							{ -								$this->m['HistoryModel']->setFields('id:forceInt,type,message','sanitizeAll'); -								$this->m['HistoryModel']->values['created_by'] = $clean['id_user']; -								$this->m['HistoryModel']->values['action'] = $this->strings[$action]['action']; -								$this->m['HistoryModel']->updateTable('insert'); +								//hide the message +								$model->values = array($clean['field_name'] => $this->strings[$action]['to_status']); +								$model->update($clean['id']); -								echo $this->strings[$action]['exec_string']; +								if ($model->queryResult) +								{ +									$this->m['HistoryModel']->setFields('id:forceInt,type,message','sanitizeAll'); +									$this->m['HistoryModel']->values['created_by'] = $clean['id_user']; +									$this->m['HistoryModel']->values['action'] = $this->strings[$action]['action']; +									$this->m['HistoryModel']->updateTable('insert'); +									 +									echo $this->strings[$action]['exec_string']; +								} +								else +								{ +									echo "error: one error occurred, please retry later"; +								}  							}  							else  							{ -								echo "error: one error occurred, please retry later"; +								echo "error: the message has too many characters or wrong type";  							}  						}  						else  						{ -							echo "error: the message has too many characters or wrong type"; +							echo $this->strings[$action]['error_string'];  						}  					} -					else -					{ -						echo $this->strings[$action]['error_string']; -					}  				}  			}  		} @@ -173,10 +221,21 @@ class HistoryController extends BaseController  				{  					$clean['type'] = $this->types[$type]['clean_type']; -					$data['res'] = $this->m['HistoryModel']->select()->where(array('id'=>$clean['id'],'type'=>$clean['type']))->send(); +					switch ($clean['type']) { +						case 'user': +							$data['object'] = 'user'; +							$data['box_class'] = 'details_of_actions_inner_user'; +							break; +						default: +							$data['object'] = 'message'; +							$data['box_class'] = 'details_of_actions_inner'; +							break; +					} -					$data['md_action'] = array('hide'=>'hidden','show'=>'restored'); +					$data['res'] = $this->m['HistoryModel']->select()->where(array('id'=>$clean['id'],'type'=>$clean['type']))->send(); +					$data['md_action'] = array('hide'=>'hidden','show'=>'restored','block'=>'blocked','unblock'=>'un-blocked'); +										  					$this->append($data);  					$this->load('viewall');  				} diff --git a/h-source/Application/Controllers/MeetController.php b/h-source/Application/Controllers/MeetController.php index 416b5dd..72e9006 100644 --- a/h-source/Application/Controllers/MeetController.php +++ b/h-source/Application/Controllers/MeetController.php @@ -75,14 +75,23 @@ class MeetController extends BaseController  		if ($this->userExists($clean['user']))  		{ +			$clean['id_user'] = (int)$this->m['UsersModel']->getUserId($clean['user']); +			$data['meet_id_user'] = $clean['id_user']; +			 +			$data['isBlocked'] = $this->m['UsersModel']->isBlocked($clean['id_user']); +			  			$this->whereArray['username'] = $clean['user'];  			$data['table'] = $this->m['ProfileModel']->select('regusers.e_mail,regusers.username,profile.*')->from('regusers inner join profile')->on('regusers.id_user = profile.created_by')->where($this->whereArray)->send();  			$data['meet_username'] = $clean['user']; -						 +			 +// 			javascript for moderator +			$data['md_javascript'] = "moderator_dialog(\"block\",\"user\");moderator_dialog(\"unblock\",\"user\");"; +		  			$this->append($data);  			$this->load('meet'); +			$this->load('moderator_dialog');  			$this->right();  		} diff --git a/h-source/Application/Models/UsersModel.php b/h-source/Application/Models/UsersModel.php index 27fc02a..a7c3845 100755 --- a/h-source/Application/Models/UsersModel.php +++ b/h-source/Application/Models/UsersModel.php @@ -89,7 +89,7 @@ class UsersModel extends Model_Map  	}  	//get the user id from the username -	public function getUserId($username) +	public function getUserId($username = '')  	{  		$clean['username'] = ctype_alnum($username) ? sanitizeAll($username) : ''; @@ -104,6 +104,20 @@ class UsersModel extends Model_Map  		}  	} +	public function isBlocked($idUser) +	{ +		$clean['id_user'] = (int)$idUser; +		 +		$res = $this->select('blocked')->where(array('id_user'=>$clean['id_user'],'has_confirmed'=>0,'deleted'=>'no'))->toList('blocked')->send(); +		 +		if (count($res) > 0) +		{ +			return strcmp($res[0],'yes') === 0 ? true : false; +		} +		 +		return true; +	} +	  	public function insert()  	{  		//create the token diff --git a/h-source/Application/Views/History/viewall.php b/h-source/Application/Views/History/viewall.php index 948a63d..9dc27c6 100644 --- a/h-source/Application/Views/History/viewall.php +++ b/h-source/Application/Views/History/viewall.php @@ -26,15 +26,15 @@  	foreach ($res as $row) {  	$mess_count++;  ?> -<div class="details_of_actions_inner"> -	<div class="talk_message_item_date">this message has been <?php echo $md_action[$row['history']['action']];?> by <?php echo getLinkToUser($u->getUser($row['history']['created_by']));?> at <?php echo smartDate($row['history']['creation_date']);?> with the following motivation: +<div class="<?php echo $box_class;?>"> +	<div class="talk_message_item_date">this <?php echo $object;?> has been <?php echo $md_action[$row['history']['action']];?> by <?php echo getLinkToUser($u->getUser($row['history']['created_by']));?> at <?php echo smartDate($row['history']['creation_date']);?> with the following motivation:  	</div> -	<div class="deleted_message_show"><?php echo$row['history']['message'];?></div> +	<div class="deleted_message_show"><?php echo $row['history']['message'];?></div>  </div>  <?php } ?>  <?php if ($mess_count === 0) { ?> -	<div class="details_of_actions_inner"> +	<div class="<?php echo $box_class;?>">  		there are no details..  	</div>  <?php } ?>
\ No newline at end of file diff --git a/h-source/Application/Views/Meet/meet.php b/h-source/Application/Views/Meet/meet.php index 127fe86..82b3d90 100644 --- a/h-source/Application/Views/Meet/meet.php +++ b/h-source/Application/Views/Meet/meet.php @@ -25,7 +25,30 @@  		<div class="position_tree_box">  			<a href="<?php echo $this->baseUrl."/home/index/$lang";?>">Home</a> » meet <b><?php echo $meet_username;?></b>  		</div> -	 +		 +		<?php if ($ismoderator) { ?> +		<div class="moderator_box"> +			<?php if ($isBlocked) { ?> +				This user has been blocked +				 +				<a id="<?php echo $meet_id_user;?>" class="unblock_user block_general" href="<?php echo $this->baseUrl."/home/index/$lang";?>"><img src="<?php echo $this->baseUrl;?>/Public/Img/H2O/im-user.png">unblock the user</a> +				 +			<?php } else {	?> +			 +				<a id="<?php echo $meet_id_user;?>" class="block_user block_general" href="<?php echo $this->baseUrl."/home/index/$lang";?>"><img src="<?php echo $this->baseUrl;?>/Public/Img/H2O/im-ban-user.png">block the user</a> +				 +			<?php } ?> +			 +			<!--view details--> +			<div class="show_hidden_box_ext"> +				<div class="md_type">user</div> +				<a id="<?php echo $meet_id_user;?>" class="hidden_message_view_details" href="<?php echo $this->baseUrl."/home/index/$lang";?>">view details</a> +				<div class="moderation_details_box"></div> +			</div> +			 +		</div> +		<?php } ?> +		  		<div class="meet_contrib_link">  			<u>Public profile of <?php echo $meet_username;?></u>. See all <a href="<?php echo $this->baseUrl."/meet/contributions/$lang/$meet_username";?>"><b><?php echo $meet_username;?></b> contributions</a>  		</div> diff --git a/h-source/Config/Route.php b/h-source/Config/Route.php index 3cde053..145947e 100644 --- a/h-source/Config/Route.php +++ b/h-source/Config/Route.php @@ -97,6 +97,8 @@ class Route  		'download,threegcards',  		'history,hide',  		'history,show', +		'history,block', +		'history,unblock',  		'history,viewall',  		'threegcards,catalogue',  		'threegcards,view', diff --git a/h-source/Public/Css/website.css b/h-source/Public/Css/website.css index 01e35c9..0f50c7d 100755 --- a/h-source/Public/Css/website.css +++ b/h-source/Public/Css/website.css @@ -1325,7 +1325,7 @@ ins  	width:500px;  } -.hide_general +.hide_general, .block_general  {  	float:right;  	margin-left:10px; @@ -1338,6 +1338,11 @@ ins  	margin-right:5px;  	margin-bottom:-2px;  } +.block_general img +{ +	margin-right:5px; +	margin-bottom:-5px; +}  .language_links_box ul  {  	overflow:hidden; @@ -1394,7 +1399,7 @@ ins  {  	display:none;  } -.details_of_hidden_message_inner, .details_of_actions_inner +.details_of_hidden_message_inner, .details_of_actions_inner, .details_of_actions_inner_user  {  	margin:10px 0px;  	background:#fbfbfb; @@ -1406,7 +1411,11 @@ ins  	background:#ecfffe;  	border:1px solid #7ed0cb;  } - +.details_of_actions_inner_user +{ +/* 	background:#F6EA99; */ +/* 	border:1px solid #F65637; */ +}  .md_type  {  	display:none; @@ -1445,4 +1454,14 @@ ins  	background:#F1D8D8;  	border-bottom:1px solid #DC143C;  	border-top:1px solid #DC143C; +} + +.moderator_box +{ +	overflow:hidden; +/* 	height:20px; */ +	padding:10px; +	margin:5px 5px 25px 5px; +	background:#fbd59a; +	border:1px solid #f65637;  }
\ No newline at end of file diff --git a/h-source/Public/Img/H2O/im-ban-user.png b/h-source/Public/Img/H2O/im-ban-user.png Binary files differnew file mode 100755 index 0000000..3771291 --- /dev/null +++ b/h-source/Public/Img/H2O/im-ban-user.png diff --git a/h-source/Public/Img/H2O/im-user.png b/h-source/Public/Img/H2O/im-user.png Binary files differnew file mode 100755 index 0000000..69de2e4 --- /dev/null +++ b/h-source/Public/Img/H2O/im-user.png diff --git a/h-source/tables.sql b/h-source/tables.sql index 4489477..ae0d1c1 100644 --- a/h-source/tables.sql +++ b/h-source/tables.sql @@ -28,6 +28,7 @@ create table regusers (  	creation_time INT UNSIGNED NOT NULL,  	temp_field CHAR(32) NOT NULL,  	deleted CHAR(4) NOT NULL default 'no', +	blocked CHAR(4) NOT NULL default 'no',  	forgot_token CHAR(32) NOT NULL,  	forgot_time INT UNSIGNED NOT NULL,    	unique(username),  | 
