public function deployRelease($rest)
 {
     $post = $rest->getRequest()->getPost();
     MM_LogApi::logRequest(json_encode($post), "/deployRelease");
     if (!isset($post["version"])) {
         return new Response($rest, "Major version number is required", RESPONSE_ERROR_MESSAGE_MISSING_PARAMS . " : version", RESPONSE_ERROR_CODE_MISSING_PARAMS, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     $majorVersion = $post["version"];
     $minorVersion = isset($post["minor_version"]) ? $post["minor_version"] : MM_MemberMouseService::$DEFAULT_MINOR_VERSION;
     $crntVersion = MemberMouse::getPluginVersion();
     if ($crntVersion != $majorVersion) {
         MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_UPGRADE_NOTICE, $majorVersion);
         return new Response($rest, "Major version do not match. A notification will be displayed to the customer informing them an update is available.", "Major version do not match. A notification will be displayed to the customer informing them an update is available.", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     // if major versions match, update cache with the latest files from central
     $writeableDir = MM_Utils::getCacheDir();
     // delete existing cache
     if (is_dir($writeableDir)) {
         if (is_writeable($writeableDir)) {
             if ($handle = opendir($writeableDir)) {
                 while (false !== ($file = readdir($handle))) {
                     if (!is_dir($file)) {
                         @unlink($writeableDir . "/" . $file);
                     }
                 }
                 closedir($handle);
             }
         }
     }
     // get updated classes from central
     MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_MINOR_VERSION, $minorVersion);
     $ret = MM_MemberMouseService::authorize(true);
     if (MM_Response::isError($ret)) {
         return new Response($rest, "Could not find classes associated with version {$majorVersion}.{$minorVersion}", "Invalid major/minor version combination", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     if (defined("DB_NAME")) {
         global $wpdb;
         if (file_exists($writeableDir . "/membermouse_schema.sql")) {
             $phpObj = new MM_PhpObj($wpdb, DB_NAME);
             if (!$phpObj->importFile($writeableDir . "/membermouse_schema.sql", true)) {
                 return new Response($rest, "Could not update MemberMouse database", "Could not update MemberMouse database", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
             }
         }
     } else {
         return new Response($rest, "DB_NAME not defined", "DB_NAME not defined", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     $version = $majorVersion;
     if (!empty($minorVersion)) {
         $version .= "-" . $minorVersion;
     }
     $versionRelease = MM_VersionRelease::findByVersion($version);
     $versionRelease->setVersion($version);
     $versionRelease->commitData();
     return new Response($rest);
 }
 public function getBundles($rest)
 {
     $post = $rest->getRequest()->getPost();
     MM_LogApi::logRequest(json_encode($post), "/getBundles");
     if (!Utils::isAuthenticated($post)) {
         return new Response($rest, null, RESPONSE_ERROR_MESSAGE_AUTH, RESPONSE_ERROR_CODE_AUTH, RESPONSE_ERROR_MESSAGE_AUTH);
     }
     $result = MM_APIService::getBundles();
     if (MM_Response::isError($result)) {
         return new Response($rest, null, $result->message, RESPONSE_ERROR_CODE_CONFLICT, RESPONSE_ERROR_MESSAGE_CONFLICT);
     }
     return new Response($rest, $result->message);
 }
Example #3
0
            }
        }
    }
    $rows[] = array(array('content' => "<span title='ID [" . $coupon->getId() . "]'>" . $coupon->getCouponName() . "</span>"), array('content' => "<span style='font-family:courier;'>" . strtoupper($coupon->getCouponCode()) . "</span>"), array('content' => $description), array('content' => $quantityDescription), array('content' => $availableDates), array('content' => empty($item->product_restrictions) ? MM_NO_DATA : $item->product_restrictions), array('content' => $actions), array('content' => $archiveActions));
}
$headers = array('name' => array('content' => '<a onclick="mmjs.sort(\'c.coupon_name\');" href="#">Name</a>'), 'coupon_code' => array('content' => '<a onclick="mmjs.sort(\'c.coupon_code\');" href="#">Coupon Code</a>'), 'description' => array('content' => 'Description'), 'quantity_used' => array('content' => '<a onclick="mmjs.sort(\'quantity_used\');" href="#"># Used</a>'), 'start_date_end_date' => array('content' => '<a onclick="mmjs.sort(\'c.start_date\');" href="#">Valid Dates</a>'), 'product_restrictions' => array('content' => 'Product Restrictions'), 'actions' => array('content' => 'Actions', "attr" => "style='width:50px;'"), 'archive' => array('content' => 'Archive', "attr" => "style='width:20px;'"));
$dataGrid->setHeaders($headers);
$dataGrid->setRows($rows);
$dgHtml = $dataGrid->generateHtml();
if ($dgHtml == "") {
    $dgHtml = "<p><i>No coupons.</i></p>";
}
?>
<div class="mm-wrap">
	<?php 
if (MM_Response::isError($couponsSupported)) {
    ?>
	<div class="error">
		<p><?php 
    echo $couponsSupported->message;
    ?>
</p>
	</div>
	<?php 
}
?>
	
	<div class="mm-button-container">
		<a onclick="mmjs.create('mm-coupons-dialog', 620, 615)" class="mm-ui-button green"><?php 
echo MM_Utils::getIcon('plus-circle', '', '1.2em', '1px');
?>
Example #4
0
} else {
    $notAvailable = true;
}
//release the lock
$wpdb->query("SELECT RELEASE_LOCK('{$lockName}')");
if ($notAvailable) {
    error_log("Requested cache entry is already being processed or is not available for processing");
    exit;
}
//now route the query to the correct handler, and retrieve the data
try {
    //clean expired from the cache first
    MM_ReportDataRetriever::clearDataCache(true);
    $queryTarget = $cacheRow->query_target;
    $queryIdentifier = $cacheRow->query_token;
    $params = MM_ReportDataRetriever::decodeParams($cacheRow->query_params);
    $dataResponse = MM_ReportDataRetriever::generateData($queryTarget, $queryIdentifier, $params, MM_ReportDataRetriever::$DEFAULT_CACHE_TIMEOUT);
    if (MM_Response::isError($dataResponse)) {
        $wpdb->update(MM_TABLE_REPORT_DATA_CACHE, array("status" => MM_ReportDataRetriever::$DATA_ERROR_STATUS), array("id" => $cacheId));
        error_log("Error generating data for query referenced by cache id {$cacheId}:{$dataResponse->message}");
        exit;
    }
    //data has been retrieved, update cache table
    $wpdb->update(MM_TABLE_REPORT_DATA_CACHE, array("status" => MM_ReportDataRetriever::$DATA_READY_STATUS), array("id" => $cacheId));
    //processing complete, terminate disconnected process
    exit;
} catch (Exception $e) {
    $wpdb->update(MM_TABLE_REPORT_DATA_CACHE, array("status" => MM_ReportDataRetriever::$DATA_ERROR_STATUS), array("id" => $cacheId));
    $error = $e->getMessage();
    error_log("Error generating data for query referenced by cache id {$cacheId}" . (empty($error) ? "" : ": {$error}"));
}
        $lastParams = json_decode($p->lastActionParams);
        $user = new MM_User();
        $user->setStatus(MM_Status::$PENDING_ACTIVATION);
        $user->setStatusMessage("Customer account created by administrator using the Create Member tool but not completed.");
        $user->setMembershipId($lastParams->mm_new_membership);
        $user->setEmail($lastParams->mm_new_email);
        $user->setFirstName($lastParams->mm_new_first_name);
        $user->setLastName($lastParams->mm_new_last_name);
        if (isset($lastParams->mm_new_phone)) {
            $user->setPhone($lastParams->mm_new_phone);
        }
        if (isset($lastParams->mm_new_password)) {
            $user->setPassword($lastParams->mm_new_password);
        }
        $result = $user->commitData();
        if (MM_Response::isError($result)) {
            echo "Payment Options Dialog:  Error creating pending account for new member: {$result->message}";
            exit;
        }
    }
    if (!$user->isValid()) {
        echo "Payment Options Dialog: Invalid user ID '{$p->userId}'.";
        exit;
    }
}
$membership = null;
$bundle = null;
$products = array();
if ($p->accessType == MM_AccessControlEngine::$ACCESS_TYPE_MEMBERSHIP) {
    $membership = new MM_MembershipLevel($p->accessTypeId);
    if ($membership->isValid()) {
Example #6
0
 $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";
     $message = "";
     if (isset($_POST["custom_submit"])) {
         foreach ($_POST as $k => $v) {
             if (preg_match("/(mm_custom_field_)/", $k)) {
                 // bypass radio button and checkbox helper fields
                 if (strpos($k, 'helper') === false) {
                     $fieldId = preg_replace("/[^0-9]+/", "", $k);
                     $response = $user->setCustomData($fieldId, $v);
                     if (MM_Response::isError($response)) {
                         if (!empty($v)) {
                             $message = $response->message;
                         }
                     }
                 }
             }
         }
         // does account update event need to be dispatched?
         $fields = MM_CustomField::getCustomFieldsList();
         foreach ($fields as $id => $val) {
             if (MM_CustomFieldData::wasRecentlyUpdated($id, $user->getId())) {
                 do_action(MM_Event::$MEMBER_ACCOUNT_UPDATE, MM_Event::packageMemberData($user->getId()));
                 break;
             }
         }