Exemple #1
0
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
$employee = new MM_Employee($p->id);
$disableRole = "";
global $current_user;
// employees can't edit their own role
if ($current_user->ID == $employee->getUserId()) {
    $disableRole = "disabled='disabled'";
}
?>
<div id="mm-form-container">
	<table cellspacing="10">
		<tr>
			<td colspan="2">
			<span style="font-size:11px;">
			Employee accounts are used to grant access to additional members of your team. Once the 
			account has been created, the employee can login with the email address and password associated with the account.</span>
			</td>
		</tr>
		<tr>
			<td>Role</td>
			<td>
				<select id='mm-role-id' <?php 
echo $disableRole;
?>
 onchange="mmjs.toggleAccessRestrictions();">
 $actions = MM_Utils::getEditIcon("Edit Push Notification", '', $editActionUrl);
 $actions .= MM_Utils::getDeleteIcon("Delete Push Notification", 'margin-left:5px;', $deleteActionUrl);
 if ($item->status == "1") {
     $actions .= '<a title="Send Test Notification" style="margin-left: 5px; cursor:pointer" onclick="mmjs.sendTestNotification(\'' . $item->id . '\');">' . MM_Utils::getIcon('flask', 'green', '1.3em', '2px') . '</a>';
 } else {
     $actions .= '<a title="Activate this push notification in order to send a test" style="margin-left: 5px;">' . MM_Utils::getIcon('flask', 'grey', '1.3em', '2px') . '</a>';
 }
 $description = "";
 $actionValue = unserialize($item->action_value);
 if ($item->action_type == MM_Action::$MM_ACTION_SEND_EMAIL) {
     $description .= MM_Utils::getIcon('paper-plane-o', 'green', '1.3em', '2px', '', 'margin-right:4px;');
     $description .= " Send an email to ";
     if ($actionValue["emailToId"] == "-1") {
         $description .= "the current member";
     } else {
         $employee = new MM_Employee($actionValue["emailToId"]);
         $description .= "<span style='font-family:courier;'>" . $employee->getEmail() . "</span>";
     }
     if (!empty($actionValue["emailCC"])) {
         $ccEmails = explode(",", $actionValue["emailCC"]);
         if (count($ccEmails) > 0) {
             if (count($ccEmails) == 1) {
                 $description .= ", CC <span style='font-family:courier;'>" . $ccEmails[0] . "</span>";
             } else {
                 $description .= ", CC " . count($ccEmails) . " others";
             }
         }
     }
 } else {
     if ($item->action_type == MM_Action::$MM_ACTION_CALL_SCRIPT) {
         $description .= MM_Utils::getIcon('file-code-o', 'turq', '1.3em', '2px', '', 'margin-right:4px;');
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
if (isset($_REQUEST[MM_Session::$PARAM_USER_ID])) {
    $user = new MM_User($_REQUEST[MM_Session::$PARAM_USER_ID]);
    if ($user->isValid()) {
        // check to make sure current employee has access to manage this member
        global $current_user;
        $employee = MM_Employee::findByUserId($current_user->ID);
        $allowAccess = true;
        if ($employee->isValid()) {
            $allowAccess = $employee->canManageMember($user);
        }
        if ($allowAccess) {
            include_once MM_MODULES . "/details.header.php";
            // prepare data grid
            $view = new MM_SubscriptionsView();
            $dataGrid = new MM_DataGrid($_REQUEST, "date_added", "desc", 10);
            $data = $view->getViewData($user->getId(), $dataGrid);
            $rows = $view->generateRows($data, true);
            $dataGrid->setTotalRecords($data);
            $dataGrid->recordName = "subscription";
            $nextRebillDateInfo = "Next rebill date is only available for subscriptions billed with a card-on-file payment service (i.e. Stripe, Braintree, Authorize.net CIM). When non-card-on-file payment services are used (i.e. PayPal, Authorize.net), the billing schedule is managed on their end so MemberMouse doesn't have access to the next rebill date.";
            $headers = array('date_added' => array('content' => '<a onclick="mmjs.sort(\'date_added\');" href="#">Start Date</a>', "attr" => "style='width:100px;'"), 'order_item_status' => array('content' => 'Status', "attr" => "style='width:50px;'"), 'access_type_name' => array('content' => 'Associated Access'), 'product_id' => array('content' => 'Product Name'), 'billing_description' => array('content' => 'Billing Description'), 'rebill_date' => array('content' => 'Next Rebill Date' . MM_Utils::getInfoIcon($nextRebillDateInfo), "attr" => "style='width:140px;'"), 'actions' => array('content' => 'Actions', "attr" => "style='width:90px;'"));
            $dataGrid->setHeaders($headers);
            $dataGrid->setRows($rows);
            $dgHtml = $dataGrid->generateHtml();
Exemple #4
0
 function loginRedirect($redirectTo, $request, $user)
 {
     // clear login form session parameters
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USER_ID);
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USERNAME);
     $newRedirectTo = "";
     $allowUserOverride = true;
     if (class_exists("MM_CorePageEngine")) {
         if ($user instanceof WP_User && isset($user->data->ID) && intval($user->data->ID) > 0) {
             // check if this is an employee
             $employee = MM_Employee::findByUserId($user->data->ID);
             if ($employee->isValid()) {
                 MM_Preview::clearPreviewMode();
                 MM_Preview::getData();
                 $newRedirectTo = $employee->getHomepage();
             }
             if (empty($newRedirectTo)) {
                 $mmUser = new MM_User($user->data->ID);
                 if ($mmUser->getStatus() == MM_Status::$EXPIRED) {
                     $allowUserOverride = false;
                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_EXPIRED, $mmUser);
                     wp_logout();
                 } else {
                     if ($mmUser->getStatus() == MM_Status::$CANCELED) {
                         $allowUserOverride = false;
                         $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_CANCELED, $mmUser);
                         wp_logout();
                     } else {
                         if ($mmUser->getStatus() == MM_Status::$LOCKED) {
                             $allowUserOverride = false;
                             $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                             wp_logout();
                         } else {
                             if ($mmUser->getStatus() == MM_Status::$OVERDUE) {
                                 $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MY_ACCOUNT, "", $mmUser);
                             } else {
                                 MM_Preview::clearPreviewMode();
                                 $setting = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_ON_LOGIN_USE_WP_FRONTPAGE);
                                 if ($setting == "1") {
                                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                                 } else {
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, "", $mmUser);
                                 }
                                 $lastAccessDeniedPageID = MM_Session::value(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 // check if current member has access to the last access denied page
                                 $pce = new MM_ProtectedContentEngine();
                                 if (intval($lastAccessDeniedPageID) > 0 && $pce->canAccessPost($lastAccessDeniedPageID, $mmUser->getId())) {
                                     $corePageEngine = new MM_CorePageEngine();
                                     if (!$corePageEngine->arePermalinksUsed()) {
                                         $newRedirectTo = get_page_link($lastAccessDeniedPageID);
                                     } else {
                                         $newRedirectTo = get_permalink($lastAccessDeniedPageID);
                                     }
                                 }
                                 MM_Session::clear(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 MM_ActivityLog::log($mmUser, MM_ActivityLog::$EVENT_TYPE_LOGIN);
                                 if ($mmUser->hasReachedMaxIPCount()) {
                                     global $current_user, $user;
                                     $mmUser->setStatus(MM_Status::$LOCKED);
                                     $mmUser->commitData();
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                                     wp_logout();
                                 }
                             }
                         }
                     }
                 }
                 if (empty($newRedirectTo)) {
                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                 }
             }
         }
         // give customer an opportunity to redirect the user
         if ($allowUserOverride) {
             $currentUrl = !empty($newRedirectTo) ? $newRedirectTo : $redirectTo;
             $infoObj = new stdClass();
             $infoObj->currentUrl = $currentUrl;
             $infoObj->user = $user;
             $redirectOverride = apply_filters(MM_Filters::$LOGIN_REDIRECT, $infoObj);
             if (is_string($redirectOverride) && !empty($redirectOverride) && $redirectOverride != $currentUrl) {
                 if (!defined("DOING_AJAX") || !DOING_AJAX) {
                     wp_redirect($redirectOverride);
                     exit;
                 } else {
                     return $redirectOverride;
                 }
             }
         }
         if (!empty($newRedirectTo)) {
             return $newRedirectTo;
         }
         return $redirectTo;
     }
 }
Exemple #5
0
     }
 }
 // Phone
 if ($item->phone != "") {
     $phone = $item->phone;
 } else {
     $phone = MM_NO_DATA;
 }
 // Role Name
 $item->role_name = MM_Role::getRoleName($item->role_id);
 if (empty($item->role_name)) {
     $item->role_name = MM_NO_DATA;
 }
 // Access Restrictions
 if (MM_MemberMouseService::hasPermission(MM_MemberMouseService::$FEATURE_EMPLOYEE_ACCOUNTS)) {
     $employee = new MM_Employee($item->id);
     $hasRestrictions = false;
     if ($employee->isValid()) {
         $membershipRestrictions = $employee->getAccessRescrictions(MM_Employee::$ACCESS_TYPE_MEMBERSHIP);
         if (count($membershipRestrictions) > 0) {
             $hasRestrictions = true;
         }
     }
     if ($hasRestrictions) {
         $item->role_name .= MM_Utils::getIcon('lock', 'yellow', '1.3em', '2px', 'This employee has additional access restrictions', 'margin-left:5px;');
     }
 }
 // Actions
 $editActionUrl = 'onclick="mmjs.edit(\'mm-employee-accounts-dialog\', \'' . $item->id . '\', 540, 450)"';
 $deleteActionUrl = 'onclick="mmjs.removeAccount(\'' . $item->id . '\')"';
 $actions = MM_Utils::getEditIcon("Edit Employee", '', $editActionUrl);
Exemple #6
0
 /**
  * This function returns a user object based on if a member is logged in or an admin. If an 
  * admin is logged in, a user object will be returned based on the current preview bar settings
  */
 public static function getCurrentUser()
 {
     global $user, $current_user;
     $user_obj = null;
     if (MM_Employee::isEmployee()) {
         $previewObj = MM_Preview::getData();
         if ($previewObj !== false) {
             return $previewObj->getUser();
         }
     }
     if (isset($user->ID) && intval($user->ID) > 0) {
         $user_obj = MM_User::create($user->ID);
     } else {
         if (isset($user->data->ID) && intval($user->data->ID) > 0) {
             $user_obj = MM_User::create($user->data->ID);
         } else {
             if (isset($current_user->ID) && intval($current_user->ID) > 0) {
                 $user_obj = MM_User::create($current_user->ID);
             }
         }
     }
     return $user_obj;
 }
Exemple #7
0
 public function buildAdminMenu()
 {
     if (!isset($_GET[MM_Session::$PARAM_COMMAND_DEACTIVATE])) {
         global $current_user;
         $crntModule = MM_ModuleUtils::getPage();
         if ($crntModule == MM_MODULE_GENERAL_SETTINGS) {
             add_thickbox();
         }
         if (class_exists("MM_Employee")) {
             $employee = MM_Employee::findByUserId($current_user->ID);
             $employee->buildMenu();
         }
     }
 }