Skip to content

Commit

Permalink
Normalized spaces before/after parenthesis and other symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Sep 1, 2014
1 parent e65de49 commit 1e7bf70
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 159 deletions.
48 changes: 24 additions & 24 deletions CommentingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public function hookInitialize()
public function setUp()
{

if(plugin_is_active('SimplePages')) {
if (plugin_is_active('SimplePages')) {
$this->_filters[] = 'api_extend_simple_pages';
}
if(plugin_is_active('ExhibitBuilder')) {
if (plugin_is_active('ExhibitBuilder')) {
$this->_filters[] = 'api_extend_exhibit_pages';
}
parent::setUp();
Expand Down Expand Up @@ -130,32 +130,32 @@ public function hookUpgrade($args)
$old = $args['old_version'];
$new = $args['new_version'];

if(version_compare($old, '1.0', '<')) {
if(!get_option('commenting_comment_roles')) {
if (version_compare($old, '1.0', '<')) {
if (!get_option('commenting_comment_roles')) {
$commentRoles = array('super');
set_option('commenting_comment_roles', serialize($commentRoles));
}

if(!get_option('commenting_moderate_roles')) {
if (!get_option('commenting_moderate_roles')) {
$moderateRoles = array('super');
set_option('commenting_moderate_roles', serialize($moderateRoles));
}

if(!get_option('commenting_noapp_comment_roles')) {
if (!get_option('commenting_noapp_comment_roles')) {
set_option('commenting_noapp_comment_roles', serialize(array()));
}

if(!get_option('commenting_view_roles')) {
if (!get_option('commenting_view_roles')) {
set_option('commenting_view_roles', serialize(array()));
}
}

if(version_compare($old, '2.0', '<')) {
if (version_compare($old, '2.0', '<')) {
$sql = "ALTER TABLE `$db->Comment` ADD `flagged` BOOLEAN NOT NULL DEFAULT '0' AFTER `approved` ";
$db->query($sql);
}

if(version_compare($old, '2.1', '<')) {
if (version_compare($old, '2.1', '<')) {
delete_option('commenting_noapp_comment_roles');
set_option('commenting_reqapp_comment_roles', serialize(array()));
$sql = "ALTER TABLE `$db->Comment` CHANGE `flagged` `flagged` TINYINT( 1 ) NOT NULL DEFAULT '0'";
Expand Down Expand Up @@ -197,8 +197,8 @@ public function hookAfterDeleteRecord($args)
{
$record = $args['record'];
$type = get_class($record);
$comments = get_db()->getTable('Comment')->findBy(array('record_type'=>$type, 'record_id'=>$record->id));
foreach($comments as $comment) {
$comments = get_db()->getTable('Comment')->findBy(array('record_type' => $type, 'record_id' => $record->id));
foreach ($comments as $comment) {
$comment->delete();
}
}
Expand All @@ -210,7 +210,7 @@ public static function showComments($args = array())
{
$view = isset($args['view']) ? $args['view'] : get_view();
echo "<div id='comments-container'>";
if( (get_option('commenting_allow_public') == 1)
if ((get_option('commenting_allow_public') == 1)
|| (get_option('commenting_allow_public_view') == 1)
|| is_allowed('Commenting_Comment', 'show')
) {
Expand All @@ -226,8 +226,8 @@ public static function showComments($args = array())
));
}

if( (get_option('commenting_allow_public') == 1)
|| is_allowed('Commenting_Comment', 'add') ) {
if ((get_option('commenting_allow_public') == 1)
|| is_allowed('Commenting_Comment', 'add')) {
echo "<div id='comment-main-container'>";
echo $view->getCommentForm();
echo "</div>";
Expand Down Expand Up @@ -278,22 +278,22 @@ public function hookDefineAcl($args)
$moderateRoles = unserialize(get_option('commenting_moderate_roles'));
$viewRoles = unserialize(get_option('commenting_view_roles'));
$acl->allow(null, 'Commenting_Comment', array('flag'));
if($viewRoles !== false) {
foreach($viewRoles as $role) {
if ($viewRoles !== false) {
foreach ($viewRoles as $role) {
//check that all the roles exist, in case a plugin-added role has been removed (e.g. GuestUser)
if($acl->hasRole($role)) {
if ($acl->hasRole($role)) {
$acl->allow($role, 'Commenting_Comment', 'show');
}
}

foreach($commentRoles as $role) {
if($acl->hasRole($role)) {
foreach ($commentRoles as $role) {
if ($acl->hasRole($role)) {
$acl->allow($role, 'Commenting_Comment', 'add');
}
}

foreach($moderateRoles as $role) {
if($acl->hasRole($role)) {
foreach ($moderateRoles as $role) {
if ($acl->hasRole($role)) {
$acl->allow($role, 'Commenting_Comment', array(
'update-approved',
'update-spam',
Expand All @@ -305,16 +305,16 @@ public function hookDefineAcl($args)
}
}

if(get_option('commenting_allow_public')) {
if (get_option('commenting_allow_public')) {
$acl->allow(null, 'Commenting_Comment', array('show', 'add'));
}
}
}

public function filterAdminNavigationMain($tabs)
{
if(is_allowed('Commenting_Comment', 'update-approved') ) {
$tabs[] = array('uri'=> url('commenting/comment/browse'), 'label'=>__('Comments') );
if (is_allowed('Commenting_Comment', 'update-approved')) {
$tabs[] = array('uri' => url('commenting/comment/browse'), 'label' => __('Comments'));
}

return $tabs;
Expand Down
52 changes: 26 additions & 26 deletions controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public function init()

public function browseAction()
{
if(!$this->_hasParam('sort_field')) {
if (!$this->_hasParam('sort_field')) {
$this->_setParam('sort_field', 'added');
}

if(!$this->_hasParam('sort_dir')) {
if (!$this->_hasParam('sort_dir')) {
$this->_setParam('sort_dir', 'd');
}
parent::browseAction();
Expand All @@ -27,11 +27,11 @@ public function browseAction()
public function batchDeleteAction()
{
$ids = $_POST['ids'];
foreach($ids as $id) {
foreach ($ids as $id) {
$record = $this->_helper->db->findById($id);
$record->delete();
}
$response = array('status'=>'ok');
$response = array('status' => 'ok');
$this->_helper->json($response);
}

Expand All @@ -41,19 +41,19 @@ public function addAction()
$module = isset($_POST['module']) ? Inflector::camelize($_POST['module']) : '';
$destArray = array(
'module' => $module,
'controller'=> strtolower(Inflector::pluralize($_POST['record_type'])),
'controller' => strtolower(Inflector::pluralize($_POST['record_type'])),
'action' => 'show',
'id' => $_POST['record_id']
);

$comment = new Comment();
if($user = current_user()) {
if ($user = current_user()) {
$comment->user_id = $user->id;
}
$comment->flagged = 0;
$form = $this->_getForm();
$valid = $form->isValid($this->getRequest()->getPost());
if(!$valid) {
if (!$valid) {
$destination .= "#comment-form";
$commentSession = new Zend_Session_Namespace('commenting');
$commentSession->post = serialize($_POST);
Expand All @@ -67,7 +67,7 @@ public function addAction()
$reqAppPublicComment = (bool) get_option('commenting_require_public_moderation');
$requiresApproval = $requiresApproval || (!is_object(current_user()) && $reqAppPublicComment);
//end Daniel Lind contribution
if($requiresApproval) {
if ($requiresApproval) {
$this->_helper->flashMessenger(__("Your comment is awaiting moderation"), 'success');
}

Expand All @@ -91,11 +91,11 @@ public function updateSpamAction()
$table = $this->_helper->db->getTable();
$wordPressAPIKey = get_option('commenting_wpapi_key');
$ak = new Zend_Service_Akismet($wordPressAPIKey, WEB_ROOT );
$response = array('errors'=> array());
foreach($commentIds as $commentId) {
$response = array('errors' => array());
foreach ($commentIds as $commentId) {
$comment = $table->find($commentId);
$data = $comment->getAkismetData();
if($spam) {
if ($spam) {
$submitMethod = 'submitSpam';
} else {
$submitMethod = 'submitHam';
Expand All @@ -108,7 +108,7 @@ public function updateSpamAction()
$response['status'] = 'ok';
} catch (Exception $e){
$response['status'] = 'fail';
$response['errors'][] = array('id'=>$comment->id);
$response['errors'][] = array('id' => $comment->id);
$response['message'] = $e->getMessage();
_log($e);
}
Expand All @@ -122,32 +122,32 @@ public function updateApprovedAction()
$commentIds = $_POST['ids'];
$status = $_POST['approved'];
$table = $this->_helper->db->getTable();
if(! $commentIds) {
if (! $commentIds) {
return;
}
foreach($commentIds as $commentId) {
foreach ($commentIds as $commentId) {
$comment = $table->find($commentId);
$comment->approved = $status;
//if approved, it isn't spam
if( ($status == 1) && ($comment->is_spam == 1) ) {
if (($status == 1) && ($comment->is_spam == 1)) {
$comment->is_spam = 0;
$ak = new Zend_Service_Akismet($wordPressAPIKey, WEB_ROOT );
$data = $comment->getAkismetData();
try {
$ak->submitHam($data);
$response = array('status'=>'ok');
$response = array('status' => 'ok');
$comment->save();
} catch (Exception $e) {
_log($e->getMessage());
$response = array('status'=>'fail', 'message'=>$e->getMessage());
$response = array('status' => 'fail', 'message' => $e->getMessage());
}

} else {
try {
$comment->save();
$response = array('status'=>'ok');
$response = array('status' => 'ok');
} catch(Exception $e) {
$response = array('status'=>'fail', 'message'=>$e->getMessage());
$response = array('status' => 'fail', 'message' => $e->getMessage());
_log($e->getMessage());
}
}
Expand All @@ -162,21 +162,21 @@ public function updateFlaggedAction()
$commentIds = $_POST['ids'];
$flagged = $_POST['flagged'];

if($commentIds) {
foreach($commentIds as $id) {
if ($commentIds) {
foreach ($commentIds as $id) {
$comment = $this->_helper->db->getTable('Comment')->find($id);
$comment->flagged = $flagged;
$comment->save();
}
} else {
$response = array('status'=>'empty', 'message'=>'No Comments Found');
$response = array('status' => 'empty', 'message' => 'No Comments Found');
}
if($flagged) {
if ($flagged) {
$action = 'flagged';
} else {
$action = 'unflagged';
}
$response = array('status'=>'ok', 'action'=>$action, 'ids'=>$commentIds);
$response = array('status' => 'ok', 'action' => $action, 'ids' => $commentIds);
$this->_helper->json($response);
}

Expand All @@ -187,7 +187,7 @@ public function flagAction()
$comment->flagged = true;
$comment->save();
$this->emailFlagged($comment);
$response = array('status'=>'ok', 'id'=>$commentId, 'action'=>'flagged');
$response = array('status' => 'ok', 'id' => $commentId, 'action' => 'flagged');
$this->_helper->json($response);
}

Expand All @@ -197,7 +197,7 @@ public function unflagAction()
$comment = $this->_helper->db->getTable('Comment')->find($commentId);
$comment->flagged = 0;
$comment->save();
$response = array('status'=>'ok', 'id'=>$commentId, 'action'=>'unflagged');
$response = array('status' => 'ok', 'id' => $commentId, 'action' => 'unflagged');
$this->_helper->json($response);
}

Expand Down
Loading

0 comments on commit 1e7bf70

Please sign in to comment.