diff options
Diffstat (limited to 'h-source/Application')
-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 |
5 files changed, 141 insertions, 36 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> |