Skip to content

Commit

Permalink
Code reformatted using editor config
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh Patel committed Sep 23, 2015
1 parent 1f7b049 commit 17049e3
Show file tree
Hide file tree
Showing 38 changed files with 1,621 additions and 1,381 deletions.
33 changes: 21 additions & 12 deletions admin/class-rtbiz-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class Rtbiz_Admin {
*
* @since 1.0.0
*/
public function __construct( ) {
public function __construct() {

}

public function init_admin() {
global $rtbiz_acl_model,
$rtbiz_attributes, $rtbiz_access_control, $rtbiz_p2p,
$rtbiz_contact, $rtbiz_company, $rtbiz_team,
$rtbiz_settings, $rtbiz_dashboard, $rt_migration,
$rtbiz_reports, $rtbiz_help;
global $rtbiz_acl_model,
$rtbiz_attributes, $rtbiz_access_control, $rtbiz_p2p,
$rtbiz_contact, $rtbiz_company, $rtbiz_team,
$rtbiz_settings, $rtbiz_dashboard, $rt_migration,
$rtbiz_reports, $rtbiz_help;

$rtbiz_acl_model = new Rtbiz_ACL_Model();

Expand Down Expand Up @@ -184,7 +184,8 @@ public function get_custom_menu_order() {

public function plugin_action_links( $links ) {
$links['get-started'] = '<a href="' . admin_url( 'admin.php?page=' . Rtbiz_Dashboard::$page_slug ) . '">' . __( 'Get Started', RTBIZ_TEXT_DOMAIN ) . '</a>';
$links['settings'] = '<a href="' . admin_url( 'admin.php?page=' . Rtbiz_Dashboard::$page_slug ) . '">' . __( 'Settings', RTBIZ_TEXT_DOMAIN ) . '</a>';
$links['settings'] = '<a href="' . admin_url( 'admin.php?page=' . Rtbiz_Dashboard::$page_slug ) . '">' . __( 'Settings', RTBIZ_TEXT_DOMAIN ) . '</a>';

return $links;
}

Expand All @@ -194,6 +195,7 @@ public function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $stat
//$plugin_meta[] = '<a href="' . 'https://rtcamp.com/rtbiz/faq' . '">' . __( 'FAQ', RTBIZ_TEXT_DOMAIN ) . '</a>';
$plugin_meta[] = '<a href="' . 'https://rtcamp.com/premium-support/' . '">' . __( 'Support', RTBIZ_TEXT_DOMAIN ) . '</a>';
}

return $plugin_meta;
}

Expand Down Expand Up @@ -225,8 +227,8 @@ public function module_register( $modules ) {
$modules[ rtbiz_sanitize_module_key( RTBIZ_TEXT_DOMAIN ) ] = array(
'label' => $menu_label,
'post_types' => array( $rtbiz_contact->post_type, $rtbiz_company->post_type ),
'team_support' => array( $rtbiz_contact->post_type ),
'product_support' => array( $rtbiz_contact->post_type, $rtbiz_company->post_type ),
'team_support' => array( $rtbiz_contact->post_type ),
'product_support' => array( $rtbiz_contact->post_type, $rtbiz_company->post_type ),
'setting_option_name' => Rtbiz_Setting::$biz_opt,
// Use For ACL
'setting_page_url' => admin_url( 'admin.php?page=' . Rtbiz_Setting::$page_slug ),
Expand Down Expand Up @@ -259,7 +261,7 @@ public function init_product() {
);

$settings = rtbiz_get_product_selection_setting();
$product_plugin = ! empty( $settings ) ? $settings : array();
$product_plugin = ! empty( $settings ) ? $settings : array();
$to_register_posttype = array();
foreach ( Rtbiz_Access_Control::$modules as $key => $value ) {
if ( ! empty( $value['product_support'] ) ) {
Expand Down Expand Up @@ -315,12 +317,19 @@ public function enqueue_scripts() {
global $post;

// Taxonomy menu hack for rtBiz
if ( isset( $_REQUEST['taxonomy'] ) && isset( $_REQUEST['post_type'] ) && in_array( $_REQUEST['post_type'], array( rtbiz_get_contact_post_type(), rtbiz_get_company_post_type() ) ) ) {
if ( isset( $_REQUEST['taxonomy'] ) && isset( $_REQUEST['post_type'] ) && in_array( $_REQUEST['post_type'], array(
rtbiz_get_contact_post_type(),
rtbiz_get_company_post_type()
) )
) {
wp_localize_script( RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_dashboard_screen', Rtbiz_Dashboard::$page_slug );
wp_localize_script( RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_menu_url', admin_url( 'edit-tags.php?taxonomy=' . $_REQUEST['taxonomy'] . '&post_type=' . $_REQUEST['post_type'] ) );
}

wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.9.2', true );
wp_enqueue_script( 'jquery-ui-autocomplete', '', array(
'jquery-ui-widget',
'jquery-ui-position'
), '1.9.2', true );
wp_enqueue_script( RTBIZ_TEXT_DOMAIN . 'admin-js', RTBIZ_URL . 'admin/js/admin.js', array( 'jquery' ), RTBIZ_VERSION, true );
wp_localize_script( RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_ajax_url_admin', admin_url( 'admin-ajax.php' ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public static function ui( $post ) {
$user = rtbiz_get_wp_user_for_contact( $post->ID );
if ( isset( $user[0]->roles ) && in_array( 'administrator', $user[0]->roles ) ) {
_e( "Admin have full access for all plugins. You can't change it", RTBIZ_TEXT_DOMAIN );

return;
} ?>
<div>
<?php $selected = ( ( isset( $is_staff_member ) && 'yes' == $is_staff_member ) || ( ! empty( $_GET['contact_group'] ) && 'staff' == $_GET['contact_group'] ) ) ? 'Checked="Checked"' : ''; ?>
<?php $selected = ( ( isset( $is_staff_member ) && 'yes' == $is_staff_member ) || ( ! empty( $_GET['contact_group'] ) && 'staff' == $_GET['contact_group'] ) ) ? 'Checked="Checked"' : ''; ?>
<label><input type="checkbox" id="rtbiz_is_staff_member" <?php echo $selected; ?>
name="rtbiz_is_staff_member" value="yes"><span
class="checkbox-title"><?php _e( 'Staff Member ', RTBIZ_TEXT_DOMAIN ) ?></span></label>
Expand All @@ -42,15 +43,15 @@ class="checkbox-title"><?php _e( 'Staff Member ', RTBIZ_TEXT_DOMAIN ) ?></span><
<th><?php echo $m['label']; ?></th>
<td>
<select name="rtbiz_profile_permissions[<?php echo $mkey ?>]"><?php
if ( ! is_plugin_active( 'rtbiz-helpdesk/rtbiz-helpdesk.php' ) ) { ?>
<option title="<?php _e( 'No Profile Access Override' ); ?>"
value=""><?php _e( 'Use Group Access' ); ?></option><?php
}
foreach ( $permissions as $pkey => $p ) {
$selected = ( isset( $user_permissions[ $mkey ] ) && intval( $user_permissions[ $mkey ] ) == $p['value'] && 0 != strlen( $user_permissions[ $mkey ] ) ) ? 'selected="selected"' : ''; ?>
<option title="<?php echo $p['tooltip']; ?>"
value="<?php echo $p['value']; ?>" <?php echo $selected; ?>><?php echo $p['name']; ?></option><?php
} ?>
if ( ! is_plugin_active( 'rtbiz-helpdesk/rtbiz-helpdesk.php' ) ) { ?>
<option title="<?php _e( 'No Profile Access Override' ); ?>"
value=""><?php _e( 'Use Group Access' ); ?></option><?php
}
foreach ( $permissions as $pkey => $p ) {
$selected = ( isset( $user_permissions[ $mkey ] ) && intval( $user_permissions[ $mkey ] ) == $p['value'] && 0 != strlen( $user_permissions[ $mkey ] ) ) ? 'selected="selected"' : ''; ?>
<option title="<?php echo $p['tooltip']; ?>"
value="<?php echo $p['value']; ?>" <?php echo $selected; ?>><?php echo $p['name']; ?></option><?php
} ?>
</select>
</td>
</tr>
Expand All @@ -68,18 +69,18 @@ public static function save( $contact_id, $post ) {
return;
}
$profile_permissions = array();
if ( ! empty( $_REQUEST['rtbiz_is_staff_member'] ) && 'yes' == $_REQUEST['rtbiz_is_staff_member'] ) {
if ( ! empty( $_REQUEST['rtbiz_is_staff_member'] ) && 'yes' == $_REQUEST['rtbiz_is_staff_member'] ) {
if ( isset( $_REQUEST['rtbiz_profile_permissions'] ) && is_array( $_REQUEST['rtbiz_profile_permissions'] ) ) {
$teams = wp_get_post_terms( $contact_id, Rtbiz_Teams::$slug );
$teams = wp_get_post_terms( $contact_id, Rtbiz_Teams::$slug );
$module_permissions = get_site_option( 'rtbiz_acl_module_permissions' );

$profile_permissions = $_REQUEST['rtbiz_profile_permissions'];
$profile_permissions = $_REQUEST['rtbiz_profile_permissions'];
$old_profile_permissions = get_post_meta( $contact_id, 'rtbiz_profile_permissions', true );

//if helpdesk exist rtbiz & helpdesk permission are same and rtbiz acl is hidden
if ( is_plugin_active( 'rtbiz-helpdesk/rtbiz-helpdesk.php' ) ) {
$profile_permissions[ RTBIZ_TEXT_DOMAIN ] = $profile_permissions[ RTBIZ_HD_TEXT_DOMAIN ];
$_REQUEST['rtbiz_profile_permissions'][ RTBIZ_TEXT_DOMAIN ] = $profile_permissions[ RTBIZ_TEXT_DOMAIN ] ;
$profile_permissions[ RTBIZ_TEXT_DOMAIN ] = $profile_permissions[ RTBIZ_HD_TEXT_DOMAIN ];
$_REQUEST['rtbiz_profile_permissions'][ RTBIZ_TEXT_DOMAIN ] = $profile_permissions[ RTBIZ_TEXT_DOMAIN ];
}

foreach ( $profile_permissions as $module_Key => $module_permission ) {
Expand All @@ -88,7 +89,7 @@ public static function save( $contact_id, $post ) {
$old_profile_permissions[ $module_Key ] = '';
}
$old_permission_len = strlen( $old_profile_permissions[ $module_Key ] );
$isOldPermission = isset( $old_profile_permissions[ $module_Key ] );
$isOldPermission = isset( $old_profile_permissions[ $module_Key ] );
switch ( $module_permission ) {
case 0:
if ( 0 == strlen( $module_permission ) ) {
Expand All @@ -98,17 +99,17 @@ public static function save( $contact_id, $post ) {
if ( $isOldPermission && 0 == $old_permission_len ) {

//get old group and its old permission from custom table
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
);
$old_group_permission = $rtbiz_acl_model->get_acl( $where );

if ( ! empty( $old_group_permission ) ) {
$old_group = array_unique( wp_list_pluck( $old_group_permission, 'groupid' ) );
$old_group = array_unique( wp_list_pluck( $old_group_permission, 'groupid' ) );
$old_group_permission = array_unique( wp_list_pluck( $old_group_permission, 'permission' ) );
} else {
$old_group = array();
$old_group = array();
$old_group_permission = array();
}

Expand All @@ -120,13 +121,13 @@ public static function save( $contact_id, $post ) {
// check id group permission update or not
if ( $module_permission[ $team->term_id ] != $old_group_permission[ $position ] ) {
// update group level permission
$data = array(
$data = array(
'permission' => $module_permission[ $team->term_id ],
);
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
'groupid' => $team->term_id,
'userid' => $user[0]->ID,
'module' => $module_Key,
'groupid' => $team->term_id,
);
$rtbiz_acl_model->update_acl( $data, $where );
}
Expand All @@ -153,9 +154,9 @@ public static function save( $contact_id, $post ) {
// remove group level acl
foreach ( $group_removed as $group ) {
$where = array(
'userid' => $user[0]->ID,
'groupid' => $group,
'module' => $module_Key,
'userid' => $user[0]->ID,
'groupid' => $group,
'module' => $module_Key,
);
$rtbiz_acl_model->remove_acl( $where );
}
Expand All @@ -165,8 +166,8 @@ public static function save( $contact_id, $post ) {
if ( $isOldPermission && 0 != $old_permission_len ) {
// remove old profile level permission
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
'userid' => $user[0]->ID,
'module' => $module_Key,
);
$rtbiz_acl_model->remove_acl( $where );
}
Expand All @@ -187,8 +188,8 @@ public static function save( $contact_id, $post ) {
//remove all permission
if ( $isOldPermission ) {
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
'userid' => $user[0]->ID,
'module' => $module_Key,
);
$rtbiz_acl_model->remove_acl( $where );
}
Expand All @@ -201,22 +202,22 @@ public static function save( $contact_id, $post ) {
if ( $isOldPermission && 0 != $old_permission_len && 0 != $old_profile_permissions[ $module_Key ] ) {
//check if profile level permission changed
if ( $module_permission != $old_profile_permissions[ $module_Key ] ) {
$data = array(
$data = array(
'permission' => $module_permission,
);
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
'groupid' => 0,
'userid' => $user[0]->ID,
'module' => $module_Key,
'groupid' => 0,
);
$rtbiz_acl_model->update_acl( $data, $where );
}
} else {
// remove old group level permission if already set
if ( $isOldPermission && 0 == $old_permission_len ) {
$where = array(
'userid' => $user[0]->ID,
'module' => $module_Key,
'userid' => $user[0]->ID,
'module' => $module_Key,
);
$rtbiz_acl_model->remove_acl( $where );
}
Expand All @@ -235,7 +236,7 @@ public static function save( $contact_id, $post ) {
}
} else {
$where = array(
'userid' => $user[0]->ID,
'userid' => $user[0]->ID,
);
$rtbiz_acl_model->remove_acl( $where );
}
Expand Down
Loading

0 comments on commit 17049e3

Please sign in to comment.