public static function handleRedirectReturn($data = false) { $connections = CASHSystem::getSystemSettings('system_connections'); if (isset($connections['com.amazon'])) { $s3_default_email = $connections['com.amazon']['email']; } else { $s3_default_email = false; } $success = S3Seed::connectAndAuthorize($data['key'], $data['secret'], $data['bucket'], $s3_default_email); if ($success) { // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth // calls would only happen in the admin. If this changes we can f**k around with it later. $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $connection_name = $data['bucket'] . ' (Amazon S3)'; if (substr($connection_name, 0, 10) == 'cashmusic.') { $connection_name = 'Amazon S3 (created ' . date("M j, Y") . ')'; } $result = $new_connection->setSettings($connection_name, 'com.amazon', array('bucket' => $data['bucket'])); if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.'); } } else { //$return_markup = '<h4>Error</h4>' // . '<p>We couldn\'t connect with your S3 account. Please check the key and secret.</p>'; AdminHelper::formFailure('We couldn\'t connect your S3 account. Please check the key and secret.'); } return $return_markup; }
/** * Tell it what you need. It makes dropdowns. It's a dropdown robot travelling * at the speed of light — it'll make a supersonic nerd of you. Don't stop it. * * @return array */ public static function echoFormOptions($base_type, $selected = 0, $range = false, $return = false) { switch ($base_type) { case 'assets': $plant_name = 'asset'; $action_name = 'getassetsforuser'; $display_information = 'title'; if ($range) { if (!in_array($selected, $range)) { $range[] = $selected; } } break; case 'people_lists': $plant_name = 'people'; $action_name = 'getlistsforuser'; $display_information = 'name'; break; case 'venues': $plant_name = 'calendar'; $action_name = 'getallvenues'; $display_information = 'name'; break; case 'items': $plant_name = 'commerce'; $action_name = 'getitemsforuser'; $display_information = 'name'; break; } $echoformoptions_cash_request = new CASHRequest(array('cash_request_type' => $plant_name, 'cash_action' => $action_name, 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); $all_options = ''; if (is_array($echoformoptions_cash_request->response['payload']) && $echoformoptions_cash_request->response['status_code'] == 200) { foreach ($echoformoptions_cash_request->response['payload'] as $item) { $doloop = true; if ($range) { if (!in_array($item['id'], $range)) { $doloop = false; } } if ($doloop) { $selected_string = ''; if ($item['id'] == $selected) { $selected_string = ' selected="selected"'; } $all_options .= '<option value="' . $item['id'] . '"' . $selected_string . '>' . $item[$display_information] . '</option>'; } } } if ($return) { return $all_options; } else { echo $all_options; } unset($echoformoptions_cash_request); }
/** * Tell it what you need. It makes dropdowns. It's a dropdown robot travelling * at the speed of light — it'll make a supersonic nerd of you. Don't stop it. * * @return array */ public static function echoFormOptions($base_type, $selected = 0) { switch ($base_type) { case 'assets': $plant_name = 'asset'; $action_name = 'getassetsforuser'; $display_information = 'title'; break; case 'people_lists': $plant_name = 'people'; $action_name = 'getlistsforuser'; $display_information = 'name'; break; case 'venues': $plant_name = 'calendar'; $action_name = 'getallvenues'; $display_information = 'name'; break; } $echoformoptions_cash_request = new CASHRequest(array('cash_request_type' => $plant_name, 'cash_action' => $action_name, 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); if (is_array($echoformoptions_cash_request->response['payload']) && $echoformoptions_cash_request->response['status_code'] == 200) { foreach ($echoformoptions_cash_request->response['payload'] as $item) { $selected_string = ''; if ($item['id'] == $selected) { $selected_string = ' selected="selected"'; } echo '<option value="' . $item['id'] . '"' . $selected_string . '>' . $item[$display_information] . '</option>'; } } unset($echoformoptions_cash_request); }
<?php // add unique page settings: $page_title = 'Elements: Your Elements'; $page_tips = 'This page lists all your defined elements. Click any of them to see embed details, make edits, or delete them.'; $elements_data = AdminHelper::getElementsData(); $effective_user = AdminHelper::getPersistentData('cash_effective_user'); if ($request_parameters) { $page_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getelement', 'id' => $request_parameters[0])); if ($page_request->response['payload']['user_id'] == $effective_user) { $page_title = 'Elements: View “' . $page_request->response['payload']['name'] . '”'; $element_type = $page_request->response['payload']['type']; if (@file_exists(CASH_PLATFORM_ROOT . '/elements' . '/' . $element_type . '/help.php')) { $page_tips = file_get_contents(CASH_PLATFORM_ROOT . '/elements' . '/' . $element_type . '/help.php'); } $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'elementbylocation', 'element_id' => $request_parameters[0], 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'elementbylocation'); $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'elementbymethod', 'element_id' => $request_parameters[0], 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'elementbymethod'); } else { // var_dump($page_request->response); header('Location: ' . ADMIN_WWW_BASE_PATH . '/elements/view/'); } } else { $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getelementsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'getelementsforuser'); }
<?php $all_order_details = false; $raw_orders = new CASHRequest(array('cash_request_type' => 'commerce', 'cash_action' => 'getordersforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); if (is_array($raw_orders->response['payload'])) { $all_order_details = array(); foreach ($raw_orders->response['payload'] as $order) { if ($order['canceled'] == 0) { $order_details_request = new CASHRequest(array('cash_request_type' => 'commerce', 'cash_action' => 'getorder', 'id' => $order['id'], 'deep' => true)); $order_details = $order_details_request->response['payload']; if ($order_details['successful']) { $order_date = $order_details['creation_date']; if ($order_details['creation_date']) { $order_date = $order_details['modification_date']; } $all_order_details[] = array('id' => '#' . str_pad($order_details['id'], 6, 0, STR_PAD_LEFT), 'date' => CASHSystem::formatTimeAgo((int) $order_date) . '<br /><a href="' . ADMIN_WWW_BASE_PATH . '/commerce/orders/view/' . $order_details['id'] . '">details</a>', 'customer' => $order_details['customer_details']['display_name'] . '<br /><a href="mailto:' . $order_details['customer_details']['email_address'] . '">' . $order_details['customer_details']['email_address'] . '</a>', 'items' => str_replace('\\n', '<br />', $order_details['order_totals']['description']), 'gross' => '$' . sprintf("%01.2f", $order_details['gross_price']), 'net' => '$' . sprintf("%01.2f", $order_details['gross_price'] - $order_details['service_fee'])); } } } if (count($all_order_details) == 0) { $all_order_details = false; } }
public static function handleRedirectReturn($data = false) { if (!isset($data['state'])) { return "Please start the Dropbox authentication flow from the beginning."; } $connections = CASHSystem::getSystemSettings('system_connections'); if (!isset($connections['com.dropbox'])) { return 'Please add default Dropbox credentials.'; } $auth_client = DropboxSeed::getWebAuthClient($connections['com.dropbox']['redirect_uri']); try { list($token, $user_id) = $auth_client->finish($data); } catch (Exception $e) { $token = false; } if (!$token) { return "The Dropbox authentication flow failed - please try again."; } $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $result = $new_connection->setSettings($user_id . ' (Dropbox)', 'com.dropbox', array('access_token' => $token, 'user_id' => $user_id)); if (!$result) { $settings_for_user = $new_connection->getAllConnectionsforUser(); if (is_array($settings_for_user)) { foreach ($settings_for_user as $key => $connection_data) { if ($connection_data['name'] == $user_id . ' (Dropbox)') { $result = $connection_data['id']; break; } } } } if (isset($data['return_result_directly'])) { return $result; } else { if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.', '/settings/connections/'); } } }
<?php // add unique page settings: $page_title = 'Calendar: Venues'; $page_tips = ''; $cash_admin->requestAndStore(array('cash_request_type' => 'calendar', 'cash_action' => 'getallvenues', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'visible_event_types' => 'upcoming'), 'getallvenues'); $cash_admin->requestAndStore(array('cash_request_type' => 'system', 'cash_action' => 'setapicredentials', 'user_id' => 1), 'apishit');
<?php if (!$request_parameters) { header('Location: ' . ADMIN_WWW_BASE_PATH . '/elements/view/'); } $current_element = $cash_admin->setCurrentElement($request_parameters[0]); if ($current_element) { $cash_admin->page_data['form_state_action'] = 'doelementedit'; $elements_data = AdminHelper::getElementsData(); $effective_user = AdminHelper::getPersistentData('cash_effective_user'); if ($current_element['user_id'] == $effective_user) { $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'elementbylocation', 'element_id' => $request_parameters[0], 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'elementbylocation'); $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'elementbymethod', 'element_id' => $request_parameters[0], 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'elementbymethod'); if (@file_exists(CASH_PLATFORM_ROOT . '/elements' . '/' . $current_element['type'] . '/admin.php')) { include CASH_PLATFORM_ROOT . '/elements' . '/' . $current_element['type'] . '/admin.php'; $cash_admin->page_data['title'] = 'Elements: “' . $current_element['name'] . '”'; $cash_admin->page_data['element_button_text'] = 'Edit the element'; $element_rendered_content = $cash_admin->mustache_groomer->render(file_get_contents(CASH_PLATFORM_ROOT . '/elements' . '/' . $current_element['type'] . '/templates/admin.mustache'), $cash_admin->page_data); } else { $element_rendered_content = "Could not find the admin.php file for this ."; } } else { header('Location: ' . ADMIN_WWW_BASE_PATH . '/elements/view/'); } } else { header('Location: ' . ADMIN_WWW_BASE_PATH . '/elements/view/'); }
public static function handleRedirectReturn($data = false) { if (isset($data['error'])) { return 'There was an error. (general) Please try again.'; } else { $connections = CASHSystem::getSystemSettings('system_connections'); require_once CASH_PLATFORM_ROOT . '/lib/twitter/OAuth.php'; require_once CASH_PLATFORM_ROOT . '/lib/twitter/twitteroauth.php'; $temporary_credentials = AdminHelper::getPersistentData('twitter_temporary_credentials'); $twitter = new TwitterOAuth($connections['com.twitter']['client_id'], $connections['com.teitter']['client_secret'], $temporary_credentials['oauth_token'], $temporary_credentials['oauth_token_secret']); $access_token = $twitter->getAccessToken($_REQUEST['oauth_verifier']); if ($twitter->http_code == 200) { // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth // calls would only happen in the admin. If this changes we can f**k around with it later. $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $result = $new_connection->setSettings('@' . $access_token['screen_name'] . ' (Twitter)', 'com.twitter', array('token' => $access_token)); if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Could not save connection.', '/settings/connections/'); } } else { AdminHelper::formFailure('Error. Problem communicating with Twitter', '/settings/connections/'); } } }
<?php $items_response = $cash_admin->requestAndStore(array('cash_request_type' => 'commerce', 'cash_action' => 'getitemsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'all_items'); // banner stuff $settings = $cash_admin->getUserSettings(); if ($settings['banners'][BASE_PAGENAME]) { $cash_admin->page_data['banner_title_content'] = '<h2>Commerce</h2><b>sell</b> your music<br />review and <b>fulfill</b> orders'; $cash_admin->page_data['banner_main_content'] = 'Here’s where you’ll define products and special offers, check on orders, manage fulfillment, and tracks overall sales. Connect to your Paypal account and off you go.'; } if (is_array($items_response['payload'])) { $cash_admin->page_data['items_all'] = new ArrayIterator($items_response['payload']); } $cash_admin->setPageContentTemplate('commerce');
public static function handleRedirectReturn($data = false) { if (isset($data['code'])) { $connections = CASHSystem::getSystemSettings('system_connections'); if (isset($connections['com.google.drive'])) { $credentials = GoogleDriveSeed::exchangeCode($data['code'], $connections['com.google.drive']['client_id'], $connections['com.google.drive']['client_secret'], $connections['com.google.drive']['redirect_uri']); $user_info = GoogleDriveSeed::getUserInfo($credentials, $connections['com.google.drive']['client_id'], $connections['com.google.drive']['client_secret']); if ($user_info) { $email_address = $user_info['email']; $user_id = $user_info['id']; } else { $email_address = false; $user_id = false; } $credentials_array = json_decode($credentials, true); if (isset($credentials_array['refresh_token'])) { // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth // calls would only happen in the admin. If this changes we can f**k around with it later. $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $result = $new_connection->setSettings($email_address . ' (Google Drive)', 'com.google.drive', array('user_id' => $user_id, 'email_address' => $email_address, 'access_token' => $credentials, 'access_expires' => $credentials_array['created'] + $credentials_array['expires_in'], 'refresh_token' => $credentials_array['refresh_token'])); if (!$result) { $settings_for_user = $new_connection->getAllConnectionsforUser(); if (is_array($settings_for_user)) { foreach ($settings_for_user as $key => $connection_data) { if ($connection_data['name'] == $email_address . ' (Google Drive)') { $result = $connection_data['id']; break; } } } } if (isset($data['return_result_directly'])) { return $result; } else { if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.', '/settings/connections/'); } } } else { return 'Could not find a refresh token from google'; } } else { return 'Please add default google drive app credentials.'; } } else { return 'There was an error. (session) Please try again.'; } }
<?php $page_data_object = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $settings_types_data = $page_data_object->getConnectionTypes(); $settings_for_user = $page_data_object->getAllConnectionsforUser(); if ($request_parameters) { $settings_action = $request_parameters[0]; }
/** * Tell it what you need. It makes dropdowns. It's a dropdown robot travelling * at the speed of light — it'll make a supersonic nerd of you. Don't stop it. * * @return array */ public static function echoFormOptions($base_type, $selected = 0, $range = false, $return = false, $shownone = true) { global $admin_primary_cash_request; $available_options = false; $all_options = ''; if ($shownone) { $all_options = '<option value="0">None</option>'; } if (is_array($base_type)) { $available_options = array(); foreach ($base_type as $key => $value) { $available_options[] = array('id' => $key, 'display' => $value); } $display_information = 'display'; } else { // fix for an old style. we prefer '/' in app.json but use '_' in other calls $base_type = str_replace('/', '_', $base_type); if (substr($base_type, 0, 7) == 'connect') { $scope = explode('_', $base_type); return AdminHelper::echoConnectionsOptions($scope[1], $selected, true); } switch ($base_type) { case 'assets': $plant_name = 'asset'; $action_name = 'getassetsforuser'; $display_information = 'title'; if ($range) { if (!in_array($selected, $range)) { $range[] = $selected; } } break; case 'people_lists': $plant_name = 'people'; $action_name = 'getlistsforuser'; $display_information = 'name'; break; case 'venues': case 'calendar_venues': $plant_name = 'calendar'; $action_name = 'getallvenues'; $display_information = 'name'; break; case 'items': case 'commerce_items': $plant_name = 'commerce'; $action_name = 'getitemsforuser'; $display_information = 'name'; break; } global $admin_primary_cash_request; $admin_primary_cash_request->processRequest(array('cash_request_type' => $plant_name, 'cash_action' => $action_name, 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'parent_id' => 0)); if (is_array($admin_primary_cash_request->response['payload']) && $admin_primary_cash_request->response['status_code'] == 200) { $available_options = $admin_primary_cash_request->response['payload']; } } if (is_array($available_options)) { foreach ($available_options as $item) { $doloop = true; if ($range) { if (!in_array($item['id'], $range)) { $doloop = false; } } if ($doloop) { $selected_string = ''; if ($item['id'] == $selected) { $selected_string = ' selected="selected"'; } $all_options .= '<option value="' . $item['id'] . '"' . $selected_string . '>' . $item[$display_information] . '</option>'; } } } else { $all_options = false; } if ($return) { return $all_options; } else { echo $all_options; } }
<?php if (!$request_parameters) { header('Location: ' . ADMIN_WWW_BASE_PATH . '/people/lists/'); } $page_request = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'getlist', 'list_id' => $request_parameters[0]), 'getlist'); //var_dump($page_request); if ($page_request['status_uid'] == 'people_getlist_200') { $elements_data = AdminHelper::getElementsData(); $effective_user = AdminHelper::getPersistentData('cash_effective_user'); if ($page_request['payload']['user_id'] == $effective_user) { if (isset($_POST['dodelete']) || isset($_GET['modalconfirm'])) { $list_delete_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'deletelist', 'list_id' => $request_parameters[0])); if ($list_delete_request->response['status_uid'] == 'people_deletelist_200') { header('Location: ' . ADMIN_WWW_BASE_PATH . '/people/lists/'); } } $cash_admin->page_data['title'] = 'People: Delete “' . $page_request->response['payload']['name'] . '”'; } else { header('Location: ' . ADMIN_WWW_BASE_PATH . '/people/lists/'); } } else { header('Location: ' . ADMIN_WWW_BASE_PATH . '/people/lists/delete/' . $request_parameters[0]); } $cash_admin->setPageContentTemplate('delete_confirm');
} // format date for viewing $event['formatted_date'] = date('d M', $event['date']); // format location if (strtolower($event['venue_country']) == 'usa' || strtolower($event['venue_country']) == 'canada') { $event['event_location'] = $event['venue_city'] . ', ' . $event['venue_region']; } else { $event['event_location'] = $event['venue_city'] . ', ' . $event['venue_country']; } if ($event['event_location'] == ', ') { $event['event_location'] = ''; } } } $thisweek_response = $cash_admin->requestAndStore(array('cash_request_type' => 'calendar', 'cash_action' => 'geteventsbetween', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'cutoff_date_low' => 'now', 'cutoff_date_high' => time() + 60 * 60 * 24 * 7), 'events_thisweek'); $unpublished_response = $cash_admin->requestAndStore(array('cash_request_type' => 'calendar', 'cash_action' => 'getevents', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'visible_event_types' => 'upcoming', 'published_status' => 0), 'events_unpublished'); // banner stuff $settings = $cash_admin->getUserSettings(); if ($settings['banners'][BASE_PAGENAME]) { $cash_admin->page_data['banner_title_content'] = '<h2>Calendar</h2>enter your <b>shows</b><br />manage <b>guestlists</b><br />check <b>venue</b> details'; $cash_admin->page_data['banner_main_content'] = 'Enter all your shows, manage your calendar and your guest lists, and use all of it to feed elements like show listings, tour archives, and even guest list slot giveaways.'; } // this week if (is_array($thisweek_response['payload'])) { formatEventOutput($thisweek_response); $cash_admin->page_data['events_thisweek'] = new ArrayIterator($thisweek_response['payload']); } // unpublished // most accessed if (is_array($unpublished_response['payload'])) { formatEventOutput($unpublished_response);
$html_content = str_replace('{{subject}}', strip_tags($_POST['mail_subject']), $html_content); } else { if ($_POST['template_id'] == 'none') { $html_content = $_POST['html_content']; } else { $html_content = Markdown($_POST['html_content']); } } // make sure we include an unsubscribe link if (!stripos($html_content, '{{{unsubscribe_link}}}')) { if (stripos($html_content, '</body>')) { $html_content = str_ireplace('</body>', '<br /><br />{{{unsubscribe_link}}}</body>', $html_content); } else { $html_content = $html_content . '<br /><br />{{{unsubscribe_link}}}'; } } $mailing_response = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'addmailing', 'user_id' => $cash_admin->effective_user_id, 'list_id' => $_POST['email_list_id'], 'connection_id' => $_POST['connection_id'], 'subject' => $_POST['mail_subject'], 'from_name' => $_POST['mail_from'], 'html_content' => $html_content)); $mailing_result = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'sendmailing', 'mailing_id' => $mailing_response['payload'])); if ($mailing_result) { AdminHelper::formSuccess('Success. The mail is sent, just kick back and watch.', '/people/mailings/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.', '/people/mailings/'); } } $settings_test_object = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $settings_test_array = $settings_test_object->getConnectionsByScope('mass_email'); if ($settings_test_array) { $cash_admin->page_data['options_people_lists'] = AdminHelper::echoFormOptions('people_lists', 0, false, true); $cash_admin->page_data['connection_options'] = AdminHelper::echoConnectionsOptions('mass_email', 0, true); } $cash_admin->setPageContentTemplate('people_mailings');
$eval_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getanalytics', 'analtyics_type' => 'mostaccessed', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'asset_mostaccessed'); // recently added assets $eval_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getanalytics', 'analtyics_type' => 'recentlyadded', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'asset_recentlyadded'); // next week of events $cash_admin->requestAndStore(array('cash_request_type' => 'calendar', 'cash_action' => 'geteventsbetween', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'cutoff_date_low' => 'now', 'cutoff_date_high' => time() + 60 * 60 * 24 * 7), 'events_thisweek'); // most active elements $eval_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'mostactive', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'element_mostactive'); // recently added elements $eval_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'recentlyadded', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'element_recentlyadded'); // get all elements $eval_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getelementsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'element_allelements'); $lists_response = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getlistsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); $lists_array = array(); $lists_count = 1; foreach ($lists_response->response['payload'] as $list) { $analytics_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getanalytics', 'analtyics_type' => 'listmembership', 'list_id' => $list['id'], 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); $lists_array[] = array('id' => $list['id'], 'name' => $list['name'], 'total' => $analytics_request->response['payload']['active'], 'lastweek' => $analytics_request->response['payload']['last_week']); unset($analytics_request); $lists_count++; if ($lists_count > 3) { break; } } // count the active elements if ($cash_admin->getStoredResponse('element_mostactive', true)) { $cash_admin->storeData(count($cash_admin->getStoredResponse('element_mostactive', true)), 'element_active_count'); } // if active elements are found, subtract them from the total to get inactive elements if ($cash_admin->getStoredData('element_active_count')) { $cash_admin->storeData(count($cash_admin->getStoredResponse('element_allelements', true)) - $cash_admin->getStoredData('element_active_count'), 'element_inactive_count'); }
<?php // add unique page settings: $page_title = 'People: Main'; $page_tips = ''; $page_memu = array('People' => array('people/contacts/' => array('Contacts', 'user'), 'people/lists/' => array('Lists', 'list'), 'people/social/' => array('Social', 'chat'))); $current_response = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'getlistsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'getlistsforuser');
<?php // add unique page settings: $page_title = 'Elements: Main'; $page_tips = 'This is where specific functionalities will be deployed, pages installed, and widgets set up. It is really the heart of the public-facing tools — the other tabs are more aimed at management, lightweight CRM, and fulfillment.'; $page_memu = array('Elements' => array('elements/add/' => array('Add Element', 'plus_alt'), 'elements/view/' => array('Your Elements', 'heart_fill'))); $element_page_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'mostactive', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); if ($element_page_request->response['status_code'] == 200) { $page_data['element_mostactive'] = $element_page_request->response['payload']; } else { $page_data['element_mostactive'] = false; } $element_page_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'recentlyadded', 'user_id' => AdminHelper::getPersistentData('cash_effective_user'))); if ($element_page_request->response['status_code'] == 200) { $page_data['element_recentlyadded'] = $element_page_request->response['payload']; } else { $page_data['element_recentlyadded'] = false; }
<?php // most accessed assets $mostaccessed_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getanalytics', 'analtyics_type' => 'mostaccessed', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'asset_mostaccessed'); // banner stuff $settings = $cash_admin->getUserSettings(); if ($settings['banners'][BASE_PAGENAME]) { $cash_admin->page_data['banner_title_content'] = '<h2>Assets</h2><b>upload</b> files<br /><b>organize</b> assets for use<br />add <b>tags</b> and <b>metadata</b>'; $cash_admin->page_data['banner_main_content'] = 'Enter details about all the files that matter to you, either on a connected S3 account or simple URLs. These assets will be used in the elements you define.'; } // most accessed if (is_array($mostaccessed_response['payload'])) { $cash_admin->page_data['mostaccessed_assets'] = new ArrayIterator(array_slice($mostaccessed_response['payload'], 0, 5)); } $cash_admin->setPageContentTemplate('assets');
<?php if ($request_parameters) { $request_list_id = $request_parameters[0]; $current_response = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'getlist', 'list_id' => $request_list_id), 'listdetails'); $cash_admin->page_data['title'] = 'People: View "' . $current_response['payload']['name'] . '"'; if ($current_response['payload']) { $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'viewlist', 'list_id' => $request_list_id), 'listmembers'); $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'getanalytics', 'analtyics_type' => 'listmembership', 'list_id' => $request_list_id, 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'listanalytics'); } } else { header('Location: ' . ADMIN_WWW_BASE_PATH . '/people/lists/'); }
if (count($cash_admin->page_data['metadata']['private'])) { $private_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getfulfillmentassets', 'asset_details' => $asset_response['payload'], 'type' => 'private')); if ($private_response['payload']) { $cash_admin->page_data['private_files'] = new ArrayIterator($private_response['payload']); } } } $cash_admin->page_data['cover_url'] = ADMIN_WWW_BASE_PATH . '/assets/images/release.jpg'; if (isset($cash_admin->page_data['metadata']['cover'])) { if ($cash_admin->page_data['metadata']['cover']) { // effectively non-zero $cover_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getasset', 'id' => $cash_admin->page_data['metadata']['cover'])); if ($cover_response['payload']) { $cover_asset = $cover_response['payload']; if (strpos(CASHSystem::getMimeTypeFor($cover_asset['location']), 'image') !== false) { $cover_url_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getasseturl', 'connection_id' => $cover_asset['connection_id'], 'user_id' => AdminHelper::getPersistentData('cash_effective_user'), 'asset_location' => $cover_asset['location'], 'inline' => true)); if ($cover_url_response['payload']) { $cash_admin->page_data['cover_url'] = $cover_url_response['payload']; $cash_admin->page_data['cover_asset_id'] = $cash_admin->page_data['metadata']['cover']; } } } } } // set the view $cash_admin->setPageContentTemplate('assets_details_release'); } else { // default back to the most basic view: $cash_admin->page_data['form_state_action'] = 'doassetedit'; $cash_admin->page_data['asset_button_text'] = 'Edit the asset'; $cash_admin->setPageContentTemplate('assets_details');
public static function handleRedirectReturn($data = false) { if (!isset($data['key'])) { return 'There was an error. (general) Please try again.'; } else { require_once CASH_PLATFORM_ROOT . '/lib/mandrill/Mandrill.php'; $m = new Mandrill($data['key']); $user_info = $m->getUserInfo(); $username = $user_info['username']; // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth // calls would only happen in the admin. If this changes we can f**k around with it later. $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $result = $new_connection->setSettings($username . ' (Mandrill)', 'com.mandrillapp', array('key' => $data['key'])); if (!$result) { return 'There was an error. (adding the connection) Please try again.'; } // set up webhooks $api_credentials = CASHSystem::getAPICredentials(); $webhook_api_url = CASH_API_URL . '/verbose/people/processwebhook/origin/com.mandrillapp/api_key/' . $api_credentials['api_key']; //$m->webhooksDelete($webhook_api_url); // remove duplicate webhooks //$m->webhooksAdd($webhook_api_url,array('send','hard_bounce','soft_bounce','open','click','spam','unsub','reject')); // add it, all events $m->call('webhooks/add', array("url" => $webhook_api_url, "events" => array('hard_bounce', 'soft_bounce', 'open', 'click', 'spam', 'unsub', 'reject'))); if (isset($data['return_result_directly'])) { return $result; } else { if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.'); } } } }