function perform()
 {
     WorkbenchContext::get()->getApexConnection()->setDebugLevels($this->logCategory, $this->logCategoryLevel);
     $executeAnonymousResultWithDebugLog = WorkbenchContext::get()->getApexConnection()->executeAnonymous($this->executeAnonymousBlock);
     ob_start();
     if ($executeAnonymousResultWithDebugLog->executeAnonymousResult->success) {
         if (isset($executeAnonymousResultWithDebugLog->debugLog) && $executeAnonymousResultWithDebugLog->debugLog != "") {
             print "<pre>" . addLinksToIds(htmlspecialchars($executeAnonymousResultWithDebugLog->debugLog, ENT_QUOTES)) . '</pre>';
         } else {
             displayInfo("Execution was successful, but returned no results. Confirm log category and level.");
         }
     } else {
         $error = null;
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->compileProblem)) {
             $error .= "COMPILE ERROR: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->compileProblem;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionMessage)) {
             $error .= "\nEXCEPTION: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionMessage;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionStackTrace)) {
             $error .= "\nSTACKTRACE: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionStackTrace;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->line)) {
             $error .= "\nLINE: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->line;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->column)) {
             $error .= " COLUMN: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->column;
         }
         displayError($error);
         print '<pre style="color: red;">' . addLinksToIds(htmlspecialchars($executeAnonymousResultWithDebugLog->debugLog, ENT_QUOTES)) . '</pre>';
     }
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
예제 #2
0
파일: common.php 프로젝트: boekkooi/icepay
/**
 * A helper function to catch exception and errors
 *
 * @param $request
 * @param Closure $closure
 */
function responseWrapper($request, \Closure $closure)
{
    $error = $response = null;
    try {
        $response = $closure($request);
    } catch (\Icepay\Api\Exception\BadResponseException $e) {
        $error = $e->getMessage();
        $response = $e->getResponseObject();
    } catch (\Icepay\Api\Exception\SoapFaultException $e) {
        $error = $e->getMessage();
        $response = $e->getPrevious();
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
    displayInfo($response, $request, $error);
}
예제 #3
0
function handleUserMgmt()
{
    global $urlRequestRoot, $cmsFolder, $moduleFolder, $templateFolder, $sourceFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/viewregistrants.php";
    if (isset($_GET['userid'])) {
        $_GET['userid'] = escape($_GET['userid']);
    }
    if (isset($_POST['editusertype'])) {
        $_POST['editusertype'] = escape($_POST['editusertype']);
    }
    if (isset($_POST['user_selected_activate'])) {
        foreach ($_POST as $key => $var) {
            if (substr($key, 0, 9) == "selected_") {
                if (!mysql_query("UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=1 WHERE user_id='" . substr($key, 9) . "'")) {
                    $result = mysql_query("SELECT `user_fullname` FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id`='" . substr($key, 9) . "'");
                    if ($result) {
                        $row = mysql_fetch_assoc($result);
                        displayerror("Couldn't activate user, {$row['user_fullname']}");
                    }
                }
            }
        }
        return registeredUsersList($_POST['editusertype'], "edit", false);
    }
    if (isset($_POST['user_selected_deactivate'])) {
        foreach ($_POST as $key => $var) {
            if (substr($key, 0, 9) == "selected_") {
                if ((int) substr($key, 9) == ADMIN_USERID) {
                    displayerror("You cannot deactivate administrator!");
                    continue;
                }
                if (!mysql_query("UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=0 WHERE user_id='" . substr($key, 9) . "'")) {
                    $result = mysql_query("SELECT `user_fullname` FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id`='" . substr($key, 9) . "'");
                    if ($result) {
                        $row = mysql_fetch_assoc($result);
                        displayerror("Couldn't deactivate user, {$row['user_fullname']}");
                    }
                }
            }
        }
        return registeredUsersList($_POST['editusertype'], "edit", false);
    }
    if (isset($_POST['user_selected_delete'])) {
        $done = true;
        foreach ($_POST as $key => $var) {
            if (substr($key, 0, 9) == "selected_") {
                if ((int) substr($key, 9) == ADMIN_USERID) {
                    displayerror("You cannot delete administrator!");
                    continue;
                }
                $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id` = '" . substr($key, 9) . "'";
                if (mysql_query($query)) {
                    $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "openid_users` WHERE `user_id` = '" . substr($key, 9) . "'";
                    if (!mysql_query($query)) {
                        $done = false;
                    }
                } else {
                    $done = false;
                }
            }
        }
        if (!$done) {
            displayerror("Some problem in deleting selected users");
        }
        return registeredUsersList($_POST['editusertype'], "edit", false);
    }
    if (isset($_POST['user_activate'])) {
        $query = "UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=1 WHERE user_id='{$_GET['userid']}'";
        if (mysql_query($query)) {
            displayInfo("User Successfully Activated!");
        } else {
            displayerror("User Not Activated!");
        }
        return registeredUsersList($_POST['editusertype'], "edit", false);
    } else {
        if (isset($_POST['activate_all_users'])) {
            $query = "UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=1";
            if (mysql_query($query)) {
                displayInfo("All users activated successfully!");
            } else {
                displayerror("Users Not Deactivated!");
            }
            return;
        } else {
            if (isset($_POST['user_deactivate'])) {
                if ($_GET['userid'] == ADMIN_USERID) {
                    displayError("You cannot deactivate administrator!");
                    return registeredUsersList($_POST['editusertype'], "edit", false);
                }
                $query = "UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=0 WHERE user_id='{$_GET['userid']}'";
                if (mysql_query($query)) {
                    displayInfo("User Successfully Deactivated!");
                } else {
                    displayerror("User Not Deactivated!");
                }
                return registeredUsersList($_POST['editusertype'], "edit", false);
            } else {
                if (isset($_POST['deactivate_all_users'])) {
                    $query = "UPDATE " . MYSQL_DATABASE_PREFIX . "users SET user_activated=0 WHERE user_id != " . ADMIN_USERID;
                    if (mysql_query($query)) {
                        displayInfo("All users deactivated successfully except Administrator!");
                    } else {
                        displayerror("Users Not Deactivated!");
                    }
                    return;
                } else {
                    if (isset($_POST['user_delete'])) {
                        $userId = $_GET['userid'];
                        if ($userId == ADMIN_USERID) {
                            displayError("You cannot delete administrator!");
                            return registeredUsersList($_POST['editusertype'], "edit", false);
                        }
                        $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id` = '{$userId}'";
                        if (mysql_query($query)) {
                            $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "openid_users` WHERE `user_id` = '{$userId}'";
                            if (mysql_query($query)) {
                                displayinfo("User Successfully Deleted!");
                            } else {
                                displayerror("User not deleted from OpenID database!");
                            }
                        } else {
                            displayerror("User Not Deleted!");
                        }
                        return registeredUsersList($_POST['editusertype'], "edit", false);
                    } else {
                        if (isset($_POST['user_info']) || isset($_POST['user_info_update'])) {
                            if (isset($_POST['user_info_update'])) {
                                $updates = array();
                                $userId = $_GET['userid'];
                                $query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id`='{$userId}'";
                                $row = mysql_fetch_assoc(mysql_query($query));
                                $errors = false;
                                if (isset($_POST['user_name']) && $row['user_name'] != $_POST['user_name']) {
                                    $chkquery = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_name`='" . escape($_POST['user_name']) . "'";
                                    $result = mysql_query($chkquery) or die("failed  : {$chkquery}");
                                    if (mysql_num_rows($result) > 0) {
                                        displayerror("User Name already exists in database!");
                                        $errors = true;
                                    }
                                }
                                if (isset($_POST['user_name']) && $_POST['user_name'] != '' && $_POST['user_name'] != $row['user_name']) {
                                    $updates[] = "`user_name` = '" . escape($_POST['user_name']) . "'";
                                }
                                if (isset($_POST['user_email']) && $_POST['user_email'] != '' && $_POST['user_email'] != $row['user_email']) {
                                    $updates[] = "`user_email` = '" . escape($_POST['user_email']) . "'";
                                }
                                if (isset($_POST['user_fullname']) && $_POST['user_fullname'] != '' && $_POST['user_fullname'] != $row['user_fullname']) {
                                    $updates[] = "`user_fullname` = '" . escape($_POST['user_fullname']) . "'";
                                }
                                if ($_POST['user_password'] != '') {
                                    if ($_POST['user_password'] != $_POST['user_password2']) {
                                        displayerror('Error! The New Password you entered does not match the password you typed in the Confirmation Box.');
                                        $errors = true;
                                    } else {
                                        if (md5($_POST['user_password']) != $row['user_password']) {
                                            $updates[] = "`user_password` = MD5('{$_POST['user_password']}')";
                                        }
                                    }
                                }
                                if (isset($_POST['user_regdate']) && $_POST['user_regdate'] != '' && $_POST['user_regdate'] != $row['user_regdate']) {
                                    $updates[] = "`user_regdate` = '" . escape($_POST['user_regdate']) . "'";
                                }
                                if (isset($_POST['user_lastlogin']) && $_POST['user_lastlogin'] != '' && $_POST['user_lastlogin'] != $row['user_lastlogin']) {
                                    $updates[] = "`user_lastlogin` = '" . escape($_POST['user_lastlogin']) . "'";
                                }
                                if ($_GET['userid'] != ADMIN_USERID && (isset($_POST['user_activated']) ? 1 : 0) != $row['user_activated']) {
                                    $checked = isset($_POST['user_activated']) ? 1 : 0;
                                    $updates[] = "`user_activated` = {$checked}";
                                }
                                if (isset($_POST['user_loginmethod']) && $_POST['user_loginmethod'] != '' && $_POST['user_loginmethod'] != $row['user_loginmethod']) {
                                    $updates[] = "`user_loginmethod` = '" . escape($_POST['user_loginmethod']) . "'";
                                    if ($_POST['user_loginmethod'] != 'db') {
                                        displaywarning("Please make sure " . strtoupper(escape($_POST['user_loginmethod'])) . " is configured properly, otherwise the user will not be able to login to the website.");
                                    }
                                }
                                if (!$errors) {
                                    if (count($updates) > 0) {
                                        $profileQuery = 'UPDATE `' . MYSQL_DATABASE_PREFIX . 'users` SET ' . join($updates, ', ') . " WHERE `user_id` = " . escape($_GET['userid']) . "'";
                                        $profileResult = mysql_query($profileQuery);
                                        if (!$profileResult) {
                                            displayerror('An error was encountered while attempting to process your request.' . $profileQuery);
                                            $errors = true;
                                        }
                                    }
                                    global $sourceFolder, $moduleFolder;
                                    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
                                    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php";
                                    if (!$errors && !submitRegistrationForm(0, $userId, true, true)) {
                                        displayerror('An error was encountered while attempting to process your request.' . $profileQuery);
                                        $errors = true;
                                    } else {
                                        displayinfo('All fields updated successfully!');
                                    }
                                }
                            }
                            $userid = $_GET['userid'];
                            $query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id`={$userid}";
                            $columnList = getColumnList(0, false, false, false, false, false);
                            $xcolumnIds = array_keys($columnList);
                            $xcolumnNames = array_values($columnList);
                            $row = mysql_fetch_assoc(mysql_query($query));
                            $userfieldprettynames = array("User ID", "Username", "Email", "Full Name", "Password", "Registration", "Last Login", "Activated", "Login Method");
                            $userinfo = "<fieldset><legend>Edit User Information</legend><form name='user_info_edit' action='./+admin&subaction=useradmin&userid={$userid}' method='post'>";
                            $usertablefields = array_merge(getTableFieldsName('users'), $xcolumnNames);
                            for ($i = 0; $i < count($usertablefields); $i++) {
                                if (isset($_POST[$usertablefields[$i] . '_sel'])) {
                                    $userinfo .= "<input type='hidden' name='{$usertablefields[$i]}_sel' value='checked'/>";
                                }
                            }
                            $userinfo .= "<input type='hidden' name='not_first_time' />";
                            $userinfo .= userProfileForm($userfieldprettynames, $row, false, true);
                            $userinfo .= "<input type='submit' value='Update' name='user_info_update' />\n\t\t<input type='reset' value='Reset' /></form></fieldset>";
                            return $userinfo;
                        } else {
                            if (isset($_POST['view_reg_users']) || isset($_POST['save_reg_users_excel'])) {
                                return registeredUsersList("all", "view", false);
                            } else {
                                if (isset($_POST['edit_reg_users'])) {
                                    return registeredUsersList("all", "edit", false);
                                } else {
                                    if (isset($_POST['view_activated_users']) || isset($_POST['save_activated_users_excel'])) {
                                        return registeredUsersList("activated", "view", false);
                                    } else {
                                        if (isset($_POST['edit_activated_users'])) {
                                            return registeredUsersList("activated", "edit", false);
                                        } else {
                                            if (isset($_POST['view_nonactivated_users']) || isset($_POST['save_nonactivated_users_excel'])) {
                                                return registeredUsersList("nonactivated", "view", false);
                                            } else {
                                                if (isset($_POST['edit_nonactivated_users'])) {
                                                    return registeredUsersList("nonactivated", "edit", false);
                                                } else {
                                                    if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'search') {
                                                        $results = "";
                                                        $userfieldprettynames = array("User ID", "Username", "Email", "Full Name", "Password", "Registration", "Last Login", "Activated", "Login Method");
                                                        $usertablefields = getTableFieldsName('users');
                                                        $first = true;
                                                        $qstring = "";
                                                        foreach ($usertablefields as $field) {
                                                            if (isset($_POST[$field]) && $_POST[$field] != '') {
                                                                if ($first == false) {
                                                                    $qstring .= $_POST['user_search_op'] == 'and' ? " AND " : " OR ";
                                                                }
                                                                $val = escape($_POST[$field]);
                                                                if ($field == 'user_activated') {
                                                                    ${$field . '_lastval'} = $val = isset($_POST[$field]) ? 1 : 0;
                                                                } else {
                                                                    ${$field . '_lastval'} = $val;
                                                                }
                                                                $qstring .= "`{$field}` LIKE CONVERT( _utf8 '%{$val}%'USING latin1 ) ";
                                                                $first = false;
                                                            }
                                                        }
                                                        if ($qstring != "") {
                                                            $query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE {$qstring} ";
                                                            $resultSearch = mysql_query($query);
                                                            if (mysql_num_rows($resultSearch) > 0) {
                                                                $num = mysql_num_rows($resultSearch);
                                                                $userInfo = array();
                                                                while ($row = mysql_fetch_assoc($resultSearch)) {
                                                                    $userInfo['user_id'][] = $row['user_id'];
                                                                    $userInfo['user_name'][] = $row['user_name'];
                                                                    $userInfo['user_email'][] = $row['user_email'];
                                                                    $userInfo['user_fullname'][] = $row['user_fullname'];
                                                                    $userInfo['user_password'][] = $row['user_password'];
                                                                    $userInfo['user_lastlogin'][] = $row['user_lastlogin'];
                                                                    $userInfo['user_regdate'][] = $row['user_regdate'];
                                                                    $userInfo['user_activated'][] = $row['user_activated'];
                                                                    $userInfo['user_loginmethod'][] = $row['user_loginmethod'];
                                                                }
                                                                $results = registeredUsersList("all", "edit", false, $userInfo);
                                                            } else {
                                                                displayerror("No users matched your query!");
                                                            }
                                                        }
                                                        $searchForm = "<form name='user_search_form' action='./+admin&subaction=useradmin&subsubaction=search' method='POST'><h3>Search User</h3>";
                                                        $xcolumnNames = array_keys(getColumnList(0, false, false, false, false, false));
                                                        $usertablefields2 = array_merge($usertablefields, $xcolumnNames);
                                                        for ($i = 0; $i < count($usertablefields2); $i++) {
                                                            if (isset($_POST[$usertablefields2[$i] . '_sel'])) {
                                                                $searchForm .= "<input type='hidden' name='{$usertablefields2[$i]}_sel' value='checked'/>";
                                                            }
                                                        }
                                                        $searchForm .= "<input type='hidden' name='not_first_time' />";
                                                        $infoarray = array();
                                                        foreach ($usertablefields as $field) {
                                                            if (isset(${$field . '_lastval'})) {
                                                                $infoarray[$field] = ${$field . '_lastval'};
                                                            } else {
                                                                $infoarray[$field] = "";
                                                            }
                                                        }
                                                        $searchForm .= userProfileForm($userfieldprettynames, $infoarray, true, false);
                                                        $searchForm .= "Operation : <input type='radio' name='user_search_op' value='and'  />AND  <input type='radio' name='user_search_op' value='or' checked='true' />OR<br/><br/><input type='submit' onclick name='user_search_submit' value='Search' /><input type='reset' value='Clear' /></form>";
                                                        return $results . $searchForm;
                                                    } else {
                                                        if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'create') {
                                                            $userfieldprettynamesarray = array("User ID", "Username", "Email", "Full Name", "Password", "Registration", "Last Login", "Activated", "Login Method");
                                                            $usertablefields = getTableFieldsName('users');
                                                            if (isset($_POST['create_user_submit'])) {
                                                                $incomplete = false;
                                                                foreach ($usertablefields as $field) {
                                                                    if ($field != 'user_regdate' && $field != 'user_lastlogin' && $field != 'user_activated' && (isset($_POST[$field]) && $_POST[$field] == "")) {
                                                                        displayerror("New user could not be created. Some fields are missing!{$field}");
                                                                        $incomplete = true;
                                                                        break;
                                                                    }
                                                                    ${$field} = escape($_POST[$field]);
                                                                }
                                                                if (!$incomplete) {
                                                                    $user_id = $_GET['userid'];
                                                                    $chkquery = "SELECT COUNT(user_id) FROM `" . MYSQL_DATABASE_PREFIX . "users` WHERE `user_id`='{$user_id}' OR `user_name`='{$user_name}' OR `user_email`='{$user_email}'";
                                                                    $result = mysql_query($chkquery);
                                                                    $row = mysql_fetch_row($result);
                                                                    if ($row[0] > 0) {
                                                                        displayerror("Another user with the same name or email already exists!");
                                                                    } else {
                                                                        if ($user_password != $_POST['user_password2']) {
                                                                            displayerror("Passwords mismatch!");
                                                                        } else {
                                                                            if (isset($_POST['user_activated'])) {
                                                                                $user_activated = 1;
                                                                            }
                                                                            $query = "INSERT INTO `" . MYSQL_DATABASE_PREFIX . "users` (`user_id` ,`user_name` ,`user_email` ,`user_fullname` ,`user_password` ,`user_regdate` ,`user_lastlogin` ,`user_activated`,`user_loginmethod`)VALUES ('{$user_id}' ,'{$user_name}' ,'{$user_email}' ,'{$user_fullname}' , MD5('{$user_password}') ,CURRENT_TIMESTAMP , '', '{$user_activated}','{$user_loginmethod}')";
                                                                            $result = mysql_query($query) or die(mysql_error());
                                                                            global $sourceFolder, $moduleFolder;
                                                                            require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
                                                                            require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php";
                                                                            if (mysql_affected_rows() && submitRegistrationForm(0, $user_id, true, true)) {
                                                                                displayinfo("User {$user_fullname} Successfully Created!");
                                                                            } else {
                                                                                displayerror("Failed to create user");
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            $nextUserId = getNextUserId();
                                                            $userForm = "<form name='user_create_form' action='./+admin&subaction=useradmin&subsubaction=create&userid={$nextUserId}' method='POST'><h3>Create New User</h3>";
                                                            $xcolumnNames = array_values(getColumnList(0, false, false, false, false, false));
                                                            $usertablefields2 = array_merge($usertablefields, $xcolumnNames);
                                                            $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}";
                                                            $userForm .= '<link rel="stylesheet" type="text/css" media="all" href="' . $calpath . '/form/calendar/calendar.css" title="Aqua" />' . '<script type="text/javascript" src="' . $calpath . '/form/calendar/calendar.js"></script>';
                                                            for ($i = 0; $i < count($usertablefields2); $i++) {
                                                                if (isset($_POST[$usertablefields2[$i] . '_sel'])) {
                                                                    $userForm .= "<input type='hidden' name='{$usertablefields2[$i]}_sel' value='checked'/>";
                                                                }
                                                            }
                                                            $userForm .= "<input type='hidden' name='not_first_time' />";
                                                            $infoarray = array();
                                                            foreach ($usertablefields as $field) {
                                                                $infoarray[$field] = "";
                                                            }
                                                            $infoarray['user_id'] = $nextUserId;
                                                            $userForm .= userProfileForm($userfieldprettynamesarray, $infoarray, false, true);
                                                            $userForm .= "<input type='submit' onclick name='create_user_submit' value='Create' /><input type='reset' value='Clear' /></form>";
                                                            return $userForm;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
예제 #4
0
파일: index.php 프로젝트: spyre/emiral
} else {
    get_template_part('content', 'none');
}
?>

		</main><!-- .site-main -->
	</div><!-- .content-area -->



<!-- NEW -->
<?php 
// echo 'TITLU: '.getFilmTitle(1).'<br/>';
// echo 'RAND: '; // s.getFilmInfo(1).'<br/>';
// print_r(getFilmInfo(1));
//  print_r(getFilmTitleCol());
$as = getSheetAsArray();
// var_dump($as);
echo '<br/>';
displayInfo();
echo '<br/>';
echo '<br/>';
echo '<br/>';
$titles = getTitles();
print_r($titles);
// getPostIdsByCustomFields();
?>
<!-- END NEW -->

<?php 
get_footer();
예제 #5
0
<?php

require_once 'session.php';
require_once 'shared.php';
require_once 'header.php';
if (isset($cacheCleared)) {
    displayInfo("Cache Cleared Successfully");
    print "<p/>";
}
if (isset($_REQUEST['keyPrefix']) || isset($_REQUEST['id'])) {
    $keyPrefixOrId = isset($_REQUEST['keyPrefix']) ? $_REQUEST['keyPrefix'] : $_REQUEST['id'];
    $specifiedType = WorkbenchContext::get()->getObjectTypeByKeyPrefixOrId(trim($keyPrefixOrId));
    if ($specifiedType == null) {
        displayWarning("Unknown object type");
    }
    WorkbenchContext::get()->setDefaultObject($specifiedType);
}
?>

<p class='instructions'>Choose an object to describe:</p>

<form name='describeForm' method='POST' action='describe.php'>
    <?php 
printObjectSelection(WorkbenchContext::get()->getDefaultObject(), 'default_object', 30, "onChange=\"document.getElementById('loadingMessage').style.visibility='visible'; document.describeForm.submit();\"");
?>

    <span id='loadingMessage' style='visibility:hidden; color:#888;'>
        &nbsp;&nbsp;<img src='<?php 
print getPathToStaticResource('/images/wait16trans.gif');
?>
' align='absmiddle'/> Loading...
        $validationErrors = validateZipFile($_FILES["deployFile"]);
        if ($validationErrors) {
            displayError($validationErrors, true, true);
            exit;
        }
        $deployFileTmpName = $_FILES["deployFile"]["tmp_name"];
        $deployFileContents = file_get_contents($deployFileTmpName);
        if (!isset($deployFileContents) || !$deployFileContents) {
            displayError("Unknown error reading file contents.", true, true);
            exit;
        }
        $_SESSION[$deployFileTmpName] = $deployFileContents;
        $_SESSION[$deployFileTmpName . "_OPTIONS"] = deserializeDeployOptions($_POST);
        require_once 'header.php';
        print "<p/>";
        displayInfo("Successfully staged " . ceil($_FILES["deployFile"]["size"] / 1024) . " KB zip file " . $_FILES["deployFile"]["name"] . " for deployment.", true, false);
        ?>
<p class='instructions'>Confirm the following deployment options:</p>
<form id='deployForm' name='deployForm' method='POST'
    action=''>
    <?php 
        print getCsrfFormTag();
        ?>
    <input type='hidden' name='deployFileTmpName' value='<?php 
        print $deployFileTmpName;
        ?>
' />
<p />
    <?php 
        $tree = new ExpandableTree("deployOptionsTree", $_SESSION[$deployFileTmpName . "_OPTIONS"]);
        $tree->setForceCollapse(true);
 function getMessages()
 {
     $messages = "";
     ob_start();
     if (count($this->errors) > 0) {
         displayError($this->errors);
     }
     if (count($this->infos) > 0) {
         displayInfo($this->infos);
     }
     $messages .= ob_get_clean();
     $messages .= "<div id='partialSavedTopic' style='display:none;'>";
     if (count($this->errors) > 0) {
         $messages .= $this->selectedTopic->toJson();
     }
     $messages .= "</div>";
     return $messages;
 }
예제 #8
0
function drawPageTitle($title, $message = null, $message_type = '')
{
    echo '<div class="HeaderPageTitle">' . $title . '</div>';
    echo '<div class="Content">';
    if ($message != null) {
        if ($message_type == '') {
            $message_type = 'error';
        }
        if (strtolower($message_type) == 'error') {
            displayErrors($message);
        } elseif (strtolower($message_type) == 'system') {
            displayMessage($message);
        } elseif (strtolower($message_type) == 'tip') {
            displayTip($message);
        } else {
            displayInfo($message);
        }
    }
}
예제 #9
0
function displayQueryForm($queryRequest)
{
    registerShortcut("Ctrl+Alt+W", "addFilterRow(document.getElementById('numFilters').value++);" . "toggleFieldDisabled();");
    if ($queryRequest->getObject()) {
        $describeSObjectResult = WorkbenchContext::get()->describeSObjects($queryRequest->getObject());
        $fieldValuesToLabels = array();
        foreach ($describeSObjectResult->fields as $field) {
            $fieldValuesToLabels[$field->name] = $field->name;
        }
    } else {
        displayInfo('First choose an object to use the SOQL builder wizard.');
    }
    print "<script type='text/javascript'>\n";
    print "var field_type_array = new Array();\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " field_type_array[\"{$field->name}\"]=[\"{$field->type}\"];\n";
        }
    }
    $ops = array('=' => '=', '!=' => '&ne;', '<' => '&lt;', '<=' => '&le;', '>' => '&gt;', '>=' => '&ge;', 'starts' => 'starts with', 'ends' => 'ends with', 'contains' => 'contains', 'IN' => 'in', 'NOT IN' => 'not in', 'INCLUDES' => 'includes', 'EXCLUDES' => 'excludes');
    print "var compOper_array = new Array();\n";
    foreach ($ops as $opValue => $opLabel) {
        print " compOper_array[\"{$opValue}\"]=[\"{$opLabel}\"];\n";
    }
    print "</script>\n";
    print "<script src='" . getPathToStaticResource('/script/query.js') . "' type='text/javascript'></script>\n";
    print "<form method='POST' id='query_form' name='query_form' action='query.php'>\n";
    print "<input type='hidden' name='justUpdate' value='0' />";
    print "<input type='hidden' id='numFilters' name='numFilters' value='" . count($queryRequest->getFilters()) . "' />";
    print "<p class='instructions'>Choose the object, fields, and critera to build a SOQL query below:</p>\n";
    print "<table border='0' style='width: 100%;'>\n";
    print "<tr><td valign='top' width='1'>Object:";
    printObjectSelection($queryRequest->getObject(), 'QB_object_sel', "16", "onChange='updateObject();'", "queryable");
    print "<p/>Fields:<select id='QB_field_sel' name='QB_field_sel[]' multiple='mutliple' size='4' style='width: 16em;' onChange='buildQuery();'>\n";
    if (isset($describeSObjectResult)) {
        print " <option value='count()'";
        if ($queryRequest->getFields() != null) {
            //check to make sure something is selected; otherwise warnings will display
            foreach ($queryRequest->getFields() as $selectedField) {
                if ('count()' == $selectedField) {
                    print " selected='selected' ";
                }
            }
        }
        print ">count()</option>\n";
        //print ">$field->name</option>\n";
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getFields() != null) {
                //check to make sure something is selected; otherwise warnings will display
                foreach ($queryRequest->getFields() as $selectedField) {
                    if ($field->name == $selectedField) {
                        print " selected='selected' ";
                    }
                }
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select></td>\n";
    print "<td valign='top'>";
    print "<table border='0' align='right' style='width:100%'>\n";
    print "<tr><td valign='top' colspan=2>View as:<br/>" . "<label><input type='radio' id='export_action_screen' name='export_action' value='screen' ";
    if ($queryRequest->getExportTo() == 'screen') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>List</label>&nbsp;";
    print "<label><input type='radio' id='export_action_matrix' name='export_action' value='matrix' ";
    if ($queryRequest->getExportTo() == 'matrix') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Matrix</label>";
    if (WorkbenchConfig::get()->value("allowQueryCsvExport")) {
        print "<label><input type='radio' id='export_action_csv' name='export_action' value='csv' ";
        if ($queryRequest->getExportTo() == 'csv') {
            print "checked='true'";
        }
        print " onClick='toggleMatrixSortSelectors(true);'>CSV</label>&nbsp;";
    }
    print "<label><input type='radio' id='export_action_async_csv' name='export_action' value='async_CSV' ";
    if ($queryRequest->getExportTo() == 'async_CSV') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk CSV</label>&nbsp;";
    print "<label><input type='radio' id='export_action_async_xml' name='export_action' value='async_XML' ";
    if ($queryRequest->getExportTo() == 'async_XML') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk XML</label>&nbsp;";
    print "<td valign='top' colspan=2>Deleted and archived records:<br/>" . "<label><input type='radio' name='query_action' value='Query' ";
    if ($queryRequest->getQueryAction() == 'Query') {
        print "checked='true'";
    }
    print " >Exclude</label>&nbsp;";
    print "<label><input type='radio' name='query_action' value='QueryAll' ";
    if ($queryRequest->getQueryAction() == 'QueryAll') {
        print "checked='true'";
    }
    print " >Include</label></td></tr></table>\n";
    print "<table id='QB_right_sub_table' border='0' align='right' style='width:100%'>\n";
    print "<tr id='matrix_selection_headers' style='display: none;'><td><br/>Columns:</td> <td><br/>Rows:</td> <td>&nbsp;</td></tr>\n";
    print "<tr id='matrix_selection_row' style='display: none;'><td><select id='matrix_cols' name='matrix_cols' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixCols());
    }
    print "</select></td> <td><select id='matrix_rows' name='matrix_rows' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixRows());
    }
    print "</select></td> <td><img onmouseover=\"Tip('Matrix view groups records into columns and rows of common field values.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/></td></tr>\n";
    print "<tr id='sort_selection_headers'><td colspan='2'><br/>Sort results by:</td> <td><br/>Max Records:</td></tr>\n";
    print "<tr id='sort_selection_row'>";
    print "<td colspan='2'><select id='QB_orderby_field' name='QB_orderby_field' style='width: 16em;' onChange='buildQuery();'>\n";
    print "<option value=''></option>\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getOrderByField() != null && $field->name == $queryRequest->getOrderByField()) {
                print " selected='selected' ";
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select>\n";
    $qBOrderbySortOptions = array('ASC' => 'A to Z', 'DESC' => 'Z to A');
    print "<select id='QB_orderby_sort' name='QB_orderby_sort' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBOrderbySortOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if (isset($_POST['QB_orderby_sort']) && $opKey == $_POST['QB_orderby_sort']) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select>\n";
    $qBNullsOptions = array('FIRST' => 'Nulls First', 'LAST' => 'Nulls Last');
    print "<select id='QB_nulls' name='QB_nulls' style='width: 10em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBNullsOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if ($queryRequest->getOrderByNulls() != null && $opKey == $queryRequest->getOrderByNulls()) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select></td>\n";
    print "<td><input type='text' id='QB_limit_txt' size='10' name='QB_limit_txt' value='" . htmlspecialchars($queryRequest->getLimit() != null ? $queryRequest->getLimit() : null, ENT_QUOTES) . "' onkeyup='buildQuery();' /></td>\n";
    print "</tr>\n";
    print "</table>\n";
    print "</td></tr>\n";
    $filterRowNum = 0;
    foreach ($queryRequest->getFilters() as $filter) {
        print "<script>addFilterRow(" . $filterRowNum++ . ", " . "\"" . $filter->getField() . "\", " . "\"" . $filter->getCompOper() . "\", " . "\"" . htmlspecialchars($filter->getValue(), ENT_QUOTES) . "\"" . ");</script>";
    }
    print "<tr><td valign='top' colspan=5><br/>Enter or modify a SOQL query below:\n" . "<br/><textarea id='soql_query_textarea' type='text' name='soql_query' rows='" . WorkbenchConfig::get()->value("textareaRows") . "' style='width: 99%; overflow: auto; font-family: monospace, courier;'>" . htmlspecialchars($queryRequest->getSoqlQuery(), ENT_QUOTES) . "</textarea>\n" . "</td></tr>\n";
    print "<tr><td colspan=1><input type='submit' name='querySubmit' class='disableWhileAsyncLoading' value='Query' onclick='return parentChildRelationshipQueryBlocker();' /></td>";
    print "<td colspan=4 align='right'>";
    print "&nbsp;&nbsp;" . "<img onmouseover=\"Tip('Where did saved queries go? They have been replaced with bookmarkable and shareable queries! Just run a query and bookmark the URL to save or copy and paste to share.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>";
    print "</td></tr></table><p/>\n";
    print "<script>toggleFieldDisabled();toggleMatrixSortSelectors(false);</script>";
}
예제 #10
0
                    } else {
                        die('Error getting columns of table: ' . $mysqli->error());
                    }
                }
                $time_end = microtime(true);
                $process_time = $time_end - $time_start;
                //Draw success page.
                drawHeader();
                drawPageTitle('Successfully Imported Tables', '<br>Cobalt successfully imported the tables you have chosen.
                               The process took ' . number_format($process_time, 5, '.', ',') . ' seconds.<br><br>
                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                               <input type=submit name=BACK value=BACK>', 'system');
                if ($errMsg != '') {
                    displayInfo('<b>Table Import Notes:</b> <br />' . $errMsg);
                }
                drawFooter();
                die;
            }
        }
    }
}
drawHeader();
if ($errMsg == '') {
    $errMsg = 'Cobalt will import all tables it can find using the database connection you specify.';
    $msgType = 'info';
}
drawPageTitle('Import Tables', $errMsg, $msgType);
?>
예제 #11
0
function displayQueryForm($queryRequest)
{
    registerShortcut("Ctrl+Alt+W", "addFilterRow(document.getElementById('numFilters').value++);" . "toggleFieldDisabled();");
    if ($queryRequest->getObject()) {
        $describeSObjectResult = WorkbenchContext::get()->describeSObjects($queryRequest->getObject());
        $fieldValuesToLabels = array();
        foreach ($describeSObjectResult->fields as $field) {
            $fieldValuesToLabels[$field->name] = $field->name;
        }
    } else {
        displayInfo('First choose an object to use the SOQL builder wizard.');
    }
    print "<script>\n";
    print "var field_type_array = new Array();\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " field_type_array[\"{$field->name}\"]=[\"{$field->type}\"];\n";
        }
    }
    $ops = array('=' => '=', '!=' => '&ne;', '<' => '&lt;', '<=' => '&le;', '>' => '&gt;', '>=' => '&ge;', 'starts' => 'starts with', 'ends' => 'ends with', 'contains' => 'contains', 'IN' => 'in', 'NOT IN' => 'not in', 'INCLUDES' => 'includes', 'EXCLUDES' => 'excludes');
    print "var compOper_array = new Array();\n";
    foreach ($ops as $opValue => $opLabel) {
        print " compOper_array[\"{$opValue}\"]=[\"{$opLabel}\"];\n";
    }
    print <<<QUERY_BUILDER_SCRIPT

function parentChildRelationshipQueryBlocker() {
    var soql = document.getElementById('soql_query_textarea').value.toUpperCase();
    
    if (soql.indexOf('(SELECT') != -1 && soql.indexOf('IN (SELECT') == -1 && document.getElementById('export_action_csv').checked) {
        return confirm ("Export of parent-to-child relationship queries to CSV are not yet supported by Workbench and may give unexpected results. Are you sure you wish to continue?");
    }
    
}

function doesQueryHaveName() {
    var saveQr = document.getElementById('saveQr');
    if (saveQr.value == null || saveQr.value.length == 0) {
        alert('Query must have a name to save.');
        return false;
    }    
    
    return true;
}


function toggleFieldDisabled() {
    var QB_field_sel = document.getElementById('QB_field_sel');

    if (document.getElementById('QB_object_sel').value) {
        QB_field_sel.disabled = false;
    } else {
        QB_field_sel.disabled = true;
    }


    var isFieldSelected = false;
    for (var i = 0; i < QB_field_sel.options.length; i++)
        if (QB_field_sel.options[i].selected)
            isFieldSelected = true;
            
    if (isFieldSelected || (document.getElementById('matrix_rows').value != '' && document.getElementById('matrix_cols').value != '')) {
            document.getElementById('QB_orderby_field').disabled = false;
            document.getElementById('QB_orderby_sort').disabled = false;
            document.getElementById('QB_nulls').disabled = false;
            document.getElementById('QB_limit_txt').disabled = false;
            
            document.getElementById('QB_filter_field_0').disabled = false;
            if (document.getElementById('QB_filter_field_0').value) {
                document.getElementById('QB_filter_value_0').disabled = false;
                document.getElementById('QB_filter_compOper_0').disabled = false;
            } else {
                document.getElementById('QB_filter_value_0').disabled = true;
                document.getElementById('QB_filter_compOper_0').disabled = true;
            }
    } else {
            document.getElementById('QB_filter_field_0').disabled = true;
            document.getElementById('QB_filter_compOper_0').disabled = true;
            document.getElementById('QB_filter_value_0').disabled = true;
            document.getElementById('QB_orderby_field').disabled = true;
            document.getElementById('QB_orderby_sort').disabled = true;
            document.getElementById('QB_nulls').disabled = true;
            document.getElementById('QB_limit_txt').disabled = true;
    }

    var allPreviousRowsUsed = true;
    for (var r = 1; r < document.getElementById('numFilters').value; r++) {
        var lastRow = r-1;
        var thisRow = r;
        
        if (isFieldSelected && allPreviousRowsUsed && document.getElementById('QB_filter_field_' + lastRow).value && document.getElementById('QB_filter_compOper_' + lastRow).value && document.getElementById('QB_filter_value_' + lastRow).value) {
            document.getElementById('QB_filter_field_' + thisRow).disabled = false;
            if (document.getElementById('QB_filter_field_' + thisRow).value) {
                document.getElementById('QB_filter_value_' + thisRow).disabled = false;
                document.getElementById('QB_filter_compOper_' + thisRow).disabled = false;
            } else {
                document.getElementById('QB_filter_value_' + thisRow).disabled = true;
                document.getElementById('QB_filter_compOper_' + thisRow).disabled = true;
            }
        } else {
            allPreviousRowsUsed = false;
            document.getElementById('QB_filter_field_' + thisRow).disabled = true;
            document.getElementById('QB_filter_compOper_' + thisRow).disabled = true;
            document.getElementById('QB_filter_value_' + thisRow).disabled = true;
        }
    }
}

function updateObject() {
  document.query_form.justUpdate.value = 1;
  document.query_form.submit();
}

function exportActionIs(type) {
    var exportActions = document.getElementById('query_form')['export_action'];
    for (var i = 0; i < exportActions.length; i++) {
        if (exportActions[i].checked && exportActions[i].value == type) {
            return true;
        }
    }
    return false;
}

function arrayContains(haystack, needle) {
    for (i in haystack) {
        if (haystack[i] == needle) {
            return true;
        }
    }
    
    return false;
}

function buildQuery() {
    toggleFieldDisabled();
    var QB_object_sel = document.getElementById('QB_object_sel').value;
    var QB_field_sel = document.getElementById('QB_field_sel');
    QB_fields_selected = new Array();
    for (var i = 0; i < QB_field_sel.options.length; i++) {
        if (QB_field_sel.options[i].selected) {
            QB_fields_selected.push(QB_field_sel.options[i].value);
        }
    }
    
    if (exportActionIs('matrix')) {
        var matrix_cols = document.getElementById('matrix_cols');
        var matrix_rows = document.getElementById('matrix_rows');
        
        if (matrix_cols.value != '' && matrix_rows.value != '') {
            if (!arrayContains(QB_fields_selected, matrix_cols.value)) QB_fields_selected.push(matrix_cols.value);
            if (!arrayContains(QB_fields_selected, matrix_rows.value)) QB_fields_selected.push(matrix_rows.value);
        }
    }

    var soql_select = '';
    if (QB_fields_selected.toString().indexOf('count()') != -1 && QB_fields_selected.length > 1) {
        alert('Warning: Choosing count() with other fields will result in a malformed query. Unselect either count() or the other fields to continue.');
    } else    if (QB_fields_selected.length > 0) {
        var soql_select = 'SELECT ' + QB_fields_selected + ' FROM ' + QB_object_sel;
    }

    soql_where = '';
    for (var f = 0; f < document.getElementById('numFilters').value; f++) {
    
        var QB_filter_field = document.getElementById('QB_filter_field_' + f).value;
        var QB_filter_compOper = document.getElementById('QB_filter_compOper_' + f).value;
        var QB_filter_value = document.getElementById('QB_filter_value_' + f).value;
        
        var soql_where_logicOper = '';
        if (f > 0) {
            soql_where_logicOper = ' AND ';
        }    
        
        if (QB_filter_field && QB_filter_compOper && QB_filter_value) {
            if (QB_filter_compOper == 'starts') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = QB_filter_value + '%';
            } else if (QB_filter_compOper == 'ends') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = '%' + QB_filter_value;
            } else if (QB_filter_compOper == 'contains') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = '%' + QB_filter_value + '%';
            }
            
            
            if (QB_filter_compOper == 'IN' || 
                QB_filter_compOper == 'NOT IN' ||
                QB_filter_compOper == 'INCLUDES' || 
                QB_filter_compOper == 'EXCLUDES') {
                    QB_filter_value_q = '(' + QB_filter_value + ')';
            } else if ((QB_filter_value == 'null') ||
                (field_type_array[QB_filter_field] == "datetime") ||
                (field_type_array[QB_filter_field] == "date") ||
                (field_type_array[QB_filter_field] == "currency") ||
                (field_type_array[QB_filter_field] == "percent") ||
                (field_type_array[QB_filter_field] == "double") ||
                (field_type_array[QB_filter_field] == "int") ||
                (field_type_array[QB_filter_field] == "boolean")) {
                    QB_filter_value_q = QB_filter_value;
            } else {
                QB_filter_value_q = '\\'' + QB_filter_value + '\\'';
            }

            soql_where += soql_where_logicOper + QB_filter_field + ' ' + QB_filter_compOper + ' ' + QB_filter_value_q;
        } else {
            break;
        }
    }
    soql_where = soql_where != '' ? ' WHERE ' + soql_where : '';

    var QB_orderby_field = document.getElementById('QB_orderby_field').value;
    var QB_orderby_sort = document.getElementById('QB_orderby_sort').value;
    var QB_nulls = document.getElementById('QB_nulls').value;
    if (QB_orderby_field) {
        var soql_orderby = ' ORDER BY ' + QB_orderby_field + ' ' + QB_orderby_sort;
        if (QB_nulls)
            soql_orderby = soql_orderby + ' NULLS ' + QB_nulls;
    } else
        var soql_orderby = '';


    var QB_limit_txt = document.getElementById('QB_limit_txt').value;
    if (QB_limit_txt)
        var soql_limit = ' LIMIT ' + QB_limit_txt;
    else
        var soql_limit = '';

    if (soql_select)
        document.getElementById('soql_query_textarea').value = soql_select + soql_where + soql_orderby + soql_limit ;

}


function addFilterRow(filterRowNum, defaultField, defaultCompOper, defaultValue) {
    //build the row inner html
    var row = filterRowNum == 0 ? "<br/>Filter results by:<br/>" : "" ;
    row +=     "<select id='QB_filter_field_" + filterRowNum + "' name='QB_filter_field_" + filterRowNum + "' style='width: 16em;' onChange='buildQuery();' onkeyup='buildQuery();'>" +
            "<option value=''></option>";
    
    for (var field in field_type_array) {
        row += "<option value='" + field + "'";
        if (defaultField == field) row += " selected='selected' ";
        row += "'>" + field + "</option>";
    }     
    
    row += "</select>&nbsp;" +
            "" +
            "<select id='QB_filter_compOper_" + filterRowNum + "' name='QB_filter_compOper_" + filterRowNum + "' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>";

    for (var opKey in compOper_array) {
        row += "<option value='" + opKey + "'";
        if (defaultCompOper == opKey) row += " selected='selected' ";
        row += ">" + compOper_array[opKey] + "</option>";
    } 
    
    defaultValue = defaultValue != null ? defaultValue : "";
    row +=  "</select>&nbsp;" +
            "<input type='text' id='QB_filter_value_" + filterRowNum + "' size='31' name='QB_filter_value_" + filterRowNum + "' value='" + defaultValue + "' onkeyup='buildQuery();' />";
            

    //add to the DOM
    var newFilterCell = document.createElement('td');
    newFilterCell.setAttribute('colSpan','4');
    newFilterCell.setAttribute('vAlign','top');
    newFilterCell.setAttribute('nowrap','true');
    newFilterCell.innerHTML = row;

    var newPlusCell = document.createElement('td');
    newPlusCell.setAttribute('id','filter_plus_cell_' + filterRowNum);
    newPlusCell.setAttribute('vAlign','bottom');
    newPlusCell.innerHTML = "<img id='filter_plus_button' src='" + getPathToStaticResource('/images/plus_icon.jpg') + "' onclick='addFilterRow(document.getElementById(\\"numFilters\\").value++);toggleFieldDisabled();' onmouseover='this.style.cursor=\\"pointer\\";'  style='padding-top: 4px;'/>";
    
    var newFilterRow = document.createElement('tr');
    newFilterRow.setAttribute('id','filter_row_' + filterRowNum);
    newFilterRow.appendChild(newFilterCell);
    newFilterRow.appendChild(newPlusCell);
    
    document.getElementById('QB_right_sub_table').getElementsByTagName("TBODY").item(0).appendChild(newFilterRow);
    
    if (filterRowNum > 0) {
        var filter_plus_button = document.getElementById('filter_plus_button');
        filter_plus_button.parentNode.removeChild(filter_plus_button);
    }
    
    //expand the field list so it looks right
    document.getElementById('QB_field_sel').size += 2;
}

function toggleMatrixSortSelectors(hasChanged) {
    if (exportActionIs('matrix')) {
        document.getElementById('matrix_selection_headers').style.display = '';
        document.getElementById('matrix_selection_row').style.display = '';
        document.getElementById('QB_field_sel').size += 4;
        
        if(hasChanged) buildQuery();
    } else if (document.getElementById('matrix_selection_headers').style.display == '') {
        document.getElementById('matrix_selection_headers').style.display = 'none';
        document.getElementById('matrix_selection_row').style.display = 'none';
        document.getElementById('QB_field_sel').size -= 4;
        
        if(hasChanged) buildQuery();
    }
    
    //don't do anything if moving from screen to csv
}

</script>
QUERY_BUILDER_SCRIPT;
    if (WorkbenchConfig::get()->value("autoJumpToResults")) {
        print "<form method='POST' id='query_form' name='query_form' action='#qr'>\n";
    } else {
        print "<form method='POST' id='query_form' name='query_form' action=''>\n";
    }
    print "<input type='hidden' name='justUpdate' value='0' />";
    print "<input type='hidden' id='numFilters' name='numFilters' value='" . count($queryRequest->getFilters()) . "' />";
    print "<p class='instructions'>Choose the object, fields, and critera to build a SOQL query below:</p>\n";
    print "<table border='0' style='width: 100%;'>\n";
    print "<tr><td valign='top' width='1'>Object:";
    printObjectSelection($queryRequest->getObject(), 'QB_object_sel', "16", "onChange='updateObject();'", "queryable");
    print "<p/>Fields:<select id='QB_field_sel' name='QB_field_sel[]' multiple='mutliple' size='4' style='width: 16em;' onChange='buildQuery();'>\n";
    if (isset($describeSObjectResult)) {
        print " <option value='count()'";
        if ($queryRequest->getFields() != null) {
            //check to make sure something is selected; otherwise warnings will display
            foreach ($queryRequest->getFields() as $selectedField) {
                if ('count()' == $selectedField) {
                    print " selected='selected' ";
                }
            }
        }
        print ">count()</option>\n";
        //print ">$field->name</option>\n";
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getFields() != null) {
                //check to make sure something is selected; otherwise warnings will display
                foreach ($queryRequest->getFields() as $selectedField) {
                    if ($field->name == $selectedField) {
                        print " selected='selected' ";
                    }
                }
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select></td>\n";
    print "<td valign='top'>";
    print "<table border='0' align='right' style='width:100%'>\n";
    print "<tr><td valign='top' colspan=2>View as:<br/>" . "<label><input type='radio' id='export_action_screen' name='export_action' value='screen' ";
    if ($queryRequest->getExportTo() == 'screen') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>List</label>&nbsp;";
    print "<label><input type='radio' id='export_action_matrix' name='export_action' value='matrix' ";
    if ($queryRequest->getExportTo() == 'matrix') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Matrix</label>";
    if (WorkbenchConfig::get()->value("allowQueryCsvExport")) {
        print "<label><input type='radio' id='export_action_csv' name='export_action' value='csv' ";
        if ($queryRequest->getExportTo() == 'csv') {
            print "checked='true'";
        }
        print " onClick='toggleMatrixSortSelectors(true);'>CSV</label>&nbsp;";
    }
    print "<label><input type='radio' id='export_action_async_csv' name='export_action' value='async_CSV' ";
    if ($queryRequest->getExportTo() == 'async_CSV') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk CSV</label>&nbsp;";
    print "<label><input type='radio' id='export_action_async_xml' name='export_action' value='async_XML' ";
    if ($queryRequest->getExportTo() == 'async_XML') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk XML</label>&nbsp;";
    print "<td valign='top' colspan=2>Deleted and archived records:<br/>" . "<label><input type='radio' name='query_action' value='Query' ";
    if ($queryRequest->getQueryAction() == 'Query') {
        print "checked='true'";
    }
    print " >Exclude</label>&nbsp;";
    print "<label><input type='radio' name='query_action' value='QueryAll' ";
    if ($queryRequest->getQueryAction() == 'QueryAll') {
        print "checked='true'";
    }
    print " >Include</label></td></tr></table>\n";
    print "<table id='QB_right_sub_table' border='0' align='right' style='width:100%'>\n";
    print "<tr id='matrix_selection_headers' style='display: none;'><td><br/>Columns:</td> <td><br/>Rows:</td> <td>&nbsp;</td></tr>\n";
    print "<tr id='matrix_selection_row' style='display: none;'><td><select id='matrix_cols' name='matrix_cols' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixCols());
    }
    print "</select></td> <td><select id='matrix_rows' name='matrix_rows' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixRows());
    }
    print "</select></td> <td><img onmouseover=\"Tip('Matrix view groups records into columns and rows of common field values.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/></td></tr>\n";
    print "<tr id='sort_selection_headers'><td colspan='2'><br/>Sort results by:</td> <td><br/>Max Records:</td></tr>\n";
    print "<tr id='sort_selection_row'>";
    print "<td colspan='2'><select id='QB_orderby_field' name='QB_orderby_field' style='width: 16em;' onChange='buildQuery();'>\n";
    print "<option value=''></option>\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getOrderByField() != null && $field->name == $queryRequest->getOrderByField()) {
                print " selected='selected' ";
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select>\n";
    $qBOrderbySortOptions = array('ASC' => 'A to Z', 'DESC' => 'Z to A');
    print "<select id='QB_orderby_sort' name='QB_orderby_sort' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBOrderbySortOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if (isset($_POST['QB_orderby_sort']) && $opKey == $_POST['QB_orderby_sort']) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select>\n";
    $qBNullsOptions = array('FIRST' => 'Nulls First', 'LAST' => 'Nulls Last');
    print "<select id='QB_nulls' name='QB_nulls' style='width: 10em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBNullsOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if ($queryRequest->getOrderByNulls() != null && $opKey == $queryRequest->getOrderByNulls()) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select></td>\n";
    print "<td><input type='text' id='QB_limit_txt' size='10' name='QB_limit_txt' value='" . htmlspecialchars($queryRequest->getLimit() != null ? $queryRequest->getLimit() : null, ENT_QUOTES) . "' onkeyup='buildQuery();' /></td>\n";
    print "</tr>\n";
    print "</table>\n";
    print "</td></tr>\n";
    $filterRowNum = 0;
    foreach ($queryRequest->getFilters() as $filter) {
        print "<script>addFilterRow(" . $filterRowNum++ . ", " . "\"" . $filter->getField() . "\", " . "\"" . $filter->getCompOper() . "\", " . "\"" . htmlspecialchars($filter->getValue(), ENT_QUOTES) . "\"" . ");</script>";
    }
    print "<tr><td valign='top' colspan=5><br/>Enter or modify a SOQL query below:\n" . "<br/><textarea id='soql_query_textarea' type='text' name='soql_query' rows='" . WorkbenchConfig::get()->value("textareaRows") . "' style='width: 99%; overflow: auto; font-family: monospace, courier;'>" . htmlspecialchars($queryRequest->getSoqlQuery(), ENT_QUOTES) . "</textarea>\n" . "</td></tr>\n";
    print "<tr><td colspan=1><input type='submit' name='querySubmit' class='disableWhileAsyncLoading' value='Query' onclick='return parentChildRelationshipQueryBlocker();' />\n" . "<input type='reset' value='Reset' class='disableWhileAsyncLoading' />\n" . "</td>";
    //save and retrieve named queries
    print "<td colspan=4 align='right'>";
    print "&nbsp;Run: " . "<select name='getQr' style='width: 10em;' onChange='document.query_form.submit();' class='disableWhileAsyncLoading'>" . "<option value='' selected='selected'></option>";
    if (isset($_SESSION['savedQueryRequests'])) {
        foreach ($_SESSION['savedQueryRequests'] as $qrName => $qr) {
            if ($qrName != null) {
                print "<option value='{$qrName}'>{$qrName}</option>";
            }
        }
    }
    print "</select>";
    print "&nbsp;&nbsp;Save as: <input type='text' id='saveQr' name='saveQr' value='" . htmlspecialchars($queryRequest->getName(), ENT_QUOTES) . "' style='width: 10em;'/>\n";
    print "<input type='submit' name='doSaveQr' value='Save' class='disableWhileAsyncLoading' onclick='return doesQueryHaveName();' />\n";
    print "<input type='submit' name='clearAllQr' value='Clear All' class='disableWhileAsyncLoading' onclick='return confirm(\"Are you sure you would like to clear all saved queries?\");'/>\n";
    print "&nbsp;&nbsp;" . "<img onmouseover=\"Tip('Save a query with a name and run it at a later time during your session. Note, if a query is already saved with the same name, the previous one will be overwritten.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>";
    print "</td></tr></table><p/>\n";
    print "<script>toggleFieldDisabled();toggleMatrixSortSelectors(false);</script>";
}
예제 #12
0
                //for null or non-overriding strings and numbers (remove cookie)
                setcookie($configKey, NULL, time() - 3600);
            }
        }
    }
    if (WorkbenchContext::isEstablished()) {
        WorkbenchContext::get()->clearCache();
    }
    header("Location: " . htmlspecialchars($_SERVER['PHP_SELF']) . "?saved=" . (isset($_POST['restoreDefaults']) ? "D" : "S"));
}
require_once 'header.php';
if (isset($errors)) {
    displayError($errors);
} else {
    if (isset($_GET['saved'])) {
        displayInfo(($_GET['saved'] == "D" ? "Defaults restored" : "Settings saved") . " successfully.");
    }
}
if (isLoggedIn()) {
    $unsupportedConfigs = array();
    foreach (WorkbenchConfig::get()->entries() as $configKey => $configValue) {
        if (isset($configValue['minApiVersion']) && !WorkbenchContext::get()->isApiVersionAtLeast($configValue['minApiVersion'])) {
            $unsupportedConfigs[] = $configValue['label'] . sprintf(" (Requires %01.1f)", $configValue['minApiVersion']);
        }
    }
    if (count($unsupportedConfigs) > 0) {
        print "<p/>";
        displayWarning(array_merge(array("The following settings will be ignored for your current API version " . WorkbenchContext::get()->getApiVersion() . ":"), $unsupportedConfigs));
        print "<p/><em style='color: orange;'>Quick Fix: <a style='color: orange;' href='sessionInfo.php' target='_blank'>Change API Version</a></em>";
    }
}
$cat1->setname("Zoe");
$cat1->setBreed("Siamese");
$myCats[] = $cat1;
$cat2 = new Cat();
$cat2->setColor("orange");
$cat2->setname("Garfield");
$cat2->setBreed("Sphynx");
$myCats[] = $cat2;
$cat3 = new Cat();
$cat3->setColor("tabby");
$cat3->setname("Fluffy");
$cat3->setBreed("Ragdoll");
$myCats[] = $cat3;
displayInfo($cat1);
displayInfo($cat2);
displayInfo($cat3);
CatListFun($myCats, "orange");
function displayInfo(Cat $n)
{
    echo $n->getName() . " is a " . $n->getColor() . " " . $n->getBreed() . " cat.</br> </br>";
}
function CatListFun($catsArray, $selectedColor)
{
    $colorCount = 0;
    for ($i = 0; $i < count($catsArray); $i++) {
        if ($catsArray[$i]->getColor() == $selectedColor) {
            $colorCount++;
        }
    }
    if ($colorCount == 1) {
        echo "There is " . $colorCount . " " . $selectedColor . " cat  .";
예제 #14
0
        if (isset($_SESSION['oauth']['serverUrlPrefix']) && !empty($_SESSION['oauth']['serverUrlPrefix'])) {
            $redirectTime = 5000;
            $uiLogoutIFrame = "<iframe src='" . $_SESSION['oauth']['serverUrlPrefix'] . "/secur/logout.jsp' width='0' height='0' style='display:none;'></iframe>\n";
        }
    } else {
        $apiSessionInvalidated = false;
    }
    session_unset();
    session_destroy();
    require_once 'header.php';
    print "<p/>";
    if (isset($uiLogoutIFrame)) {
        print $uiLogoutIFrame;
    }
    if (isset($_REQUEST['message'])) {
        $redirectTime = 5000;
        displayError("An error has occurred and you have been logged out:\n" . $_REQUEST['message']);
    } else {
        if ($apiSessionInvalidated) {
            displayInfo('You have been successfully logged out of Workbench and Salesforce.');
        } else {
            displayInfo('You have been successfully logged out of Workbench.');
        }
    }
    print "<script type='text/javascript'>setTimeout(\"location.href = 'login.php';\", {$redirectTime});</script>";
    include_once 'footer.php';
} else {
    session_unset();
    session_destroy();
    header('Location: login.php');
}
예제 #15
0
function displayForm($infos = null, $errors = null)
{
    if (isset($infos)) {
        displayInfo($infos);
    }
    if (isset($errors)) {
        displayError($errors);
    }
    ?>

<form name='passwordChange' method='post'
    action=''>
<?php 
    print getCsrfFormTag();
    ?>
<table border='0'>

    <tr>
        <td align='right' colspan='2'>
        <p><label><input type='radio' name='passwordChangeType'
            value='set' onclick="togglePasswordFields('set');"
            checked='checked' /> Set</label> &nbsp; <label><input
            type='radio' name='passwordChangeType' value='reset'
            onclick="togglePasswordFields('reset');" /> Reset</label></p>
        </td>
    </tr>

    <tr>
        <td><label for='userId'>User Id: &nbsp;</label></td>
        <td><input type='text' id='userId' name='userId' size='45' /></td>
    </tr>

    <tr>
        <td><label for='passwordOne'>Password: &nbsp;</label></td>
        <td><input type='password' id='passwordOne' name='passwordOne'
            size='45' onkeyup="doPasswordsMatch(false);" /></td>
    </tr>
    <tr>
        <td><label for='passwordConfirm'>Confirm Password: &nbsp;</label></td>
        <td><input type='password' id='passwordConfirm'
            name='passwordConfirm' size='45'
            onkeyup="doPasswordsMatch(false);" /></td>
    </tr>

    <tr>
        <td colspan='2' align='right'>
        <p><input type='submit' id='changePasswordAction'
            name='changePasswordAction' value='Change Password'
            onclick="return doPasswordsMatch(true);" /> <input
            type='button' value='Clear Form' onclick="clearForm();" /></p>
        </td>
    </tr>

</table>
</form>

<script type="text/javascript">
<!--
 
 function togglePasswordFields(changeType) {
 
     if (changeType == 'set') {
         document.getElementById('passwordOne').disabled = false;
         document.getElementById('passwordConfirm').disabled = false;
      } else if (changeType == 'reset') {
         document.getElementById('passwordOne').value = null;
         document.getElementById('passwordConfirm').value = null;
         
         document.getElementById('passwordOne').disabled = true;
         document.getElementById('passwordConfirm').disabled = true;
         
         document.getElementById('passwordOne').style.background = 'white';
         document.getElementById('passwordConfirm').style.background = 'white';
     }
     
 }
 
 
 function doPasswordsMatch(doAlert) {
      if (document.getElementById('passwordOne').value.length < document.getElementById('passwordConfirm').value.length) {     
          document.getElementById('passwordConfirm').style.background = 'LightPink';
      }
      
      if (doAlert && document.getElementById('passwordOne').value.length == 0 && document.getElementById('passwordOne').disabled == false) {     
           document.getElementById('passwordOne').style.background = 'LightPink';
            alert('Must provide a password if setting password; otherwise, choose reset');
            document.getElementById('passwordOne').focus();
           return false;
      } else {
          document.getElementById('passwordOne').style.background = 'white';
      }
      
 
      if (document.getElementById('passwordOne').value == document.getElementById('passwordConfirm').value) {
          document.getElementById('passwordConfirm').style.background = 'white';
        return true;
      } else {
           if (doAlert) {
               document.getElementById('passwordConfirm').style.background = 'LightPink';
               alert('Passwords do not match');
           }
          
          if (document.getElementById('passwordOne').value.length == document.getElementById('passwordConfirm').value.length) {     
              document.getElementById('passwordConfirm').style.background = 'LightPink';
          }
           
          return false;
      }
 }
 
 function clearForm() {
     document.getElementById('userId').value = null;
     document.getElementById('passwordOne').value = null;
     document.getElementById('passwordConfirm').value = null;
     document.getElementById('passwordOne').style.background = 'white';
     document.getElementById('passwordConfirm').style.background = 'white';
 }


//-->
</script>

<?php 
}
 function getMessages()
 {
     ob_start();
     if (count($this->errors) > 0) {
         displayError($this->errors);
     }
     if (count($this->infos) > 0) {
         displayInfo($this->infos);
     }
     return ob_get_clean();
 }
예제 #17
0
    if ($burnt > 0) {
        $successMessage = "Burnt " . $burnt . " API call";
        $successMessage .= $burnt > 1 ? 's' : '';
        displayInfo($successMessage);
    } else {
        $burnErrors = array_merge(array("No API calls were burnt."), $burnErrors);
    }
    if (is_array($burnErrors) && count($burnErrors) > 0) {
        displayError($burnErrors);
    }
    exit;
}
require_once 'header.php';
registerShortcut("Enter", "ajaxBurn();");
if (isset($infos)) {
    displayInfo($infos);
}
if (isset($errors)) {
    displayError($errors);
}
?>
<p />
<form name='afterburner'>
<table border='0'>


    <tr>
        <td align='right'><label for='burnNumOfCalls'>Number of Calls to
        Burn: &nbsp;</label></td>
        <td colspan='2'><input type='text' id='burnNumOfCalls'
            name='burnNumOfCalls' size='45' /></td>
         //echo "<br/>";
         $currentExam .= showImplementation($record, $exam_length, true);
         $currentExam .= "</td></tr>";
     }
     $currentExam .= "</table>";
     // End Structure
     $currentExam .= print_container_end(true);
     //echo "<div id='info_$record->id'></div><br/>";
     $currentExam .= "<hr/>";
 } else {
     // Exam Over 2
     $record = updateExamStatus($record, "Graded");
     // Page Structure
     $prevExam .= "<table border='0' cellpadding='5' cellspacing='5'>";
     $prevExam .= "<tr><td valign='top'>";
     $prevExam .= displayInfo($record, $exam_length, true);
     $prevExam .= "</td></tr>";
     $prevExam .= "<tr><td>";
     // Print Status - Checks if the exam was taken, via the quiz grade
     if ($record->status == "Graded" || $record->grade1 != null && $record->status == "Implementation") {
         $prevExam .= examStatus($record, array(6), "", true);
     } else {
         $prevExam .= examStatus($record, array(0), "", true);
     }
     $prevExam .= "</td></tr>";
     $prevExam .= "<tr><td>";
     $prevExam .= displayExamInfo($record, $exam_length, true);
     $prevExam .= "</td></tr>";
     $prevExam .= "<tr><td>";
     $prevExam .= showGrades($record, true);
     $prevExam .= "</td></tr>";
예제 #19
0
print WorkbenchConfig::get()->value("textareaRows");
?>
'
            style='overflow: auto; font-family: monospace, courier;'><?php 
echo htmlspecialchars(isset($_SESSION['scriptInput']) ? $_SESSION['scriptInput'] : null, ENT_QUOTES);
?>
</textarea>
        <p />
        <input type='submit' name="execute" value='Execute' class='disableWhileAsyncLoading' /> <input
            type='reset' value='Reset' class='disableWhileAsyncLoading' /></td>
    </tr>
</table>
</form>


<script type="text/javascript">
     document.getElementById('scriptInput').focus();
</script>


<?php 
if (isset($_POST['execute']) && isset($_POST['scriptInput']) && $_POST['scriptInput'] != "") {
    print "<h2>Results</h2>";
    $asyncJob = new ApexExecuteFutureTask($_POST['scriptInput'], $_POST['LogCategory'], $_POST['LogCategoryLevel']);
    echo $asyncJob->enqueueOrPerform();
} else {
    if (isset($_POST['execute']) && isset($_POST['scriptInput']) && $_POST['scriptInput'] == "") {
        displayInfo("Anonymous block must not be blank.");
    }
}
require_once 'footer.php';
예제 #20
0
            $retrieveRequest->unpackaged = parseUnpackagedManifest($_FILES["packageXmlFile"]["tmp_name"]);
        }
        if (isset($_POST['packageNames']) && $_POST['packageNames'] != "") {
            $encodedPackageNames = array();
            foreach (explodeCommaSeparated(htmlspecialchars($_POST['packageNames'])) as $p) {
                if ($p == "unpackaged") {
                    throw new WorkbenchHandledException("Cannot retrieve a package named 'unpackaged' -- to retrieve metadata not in a package, upload an unpackaged manifest file (i.e. 'package.xml').");
                }
                $encodedPackageNames[] = urlencode($p);
            }
            $retrieveRequest->packageNames = $encodedPackageNames;
        }
        $retrieveRequestId = "RR-" . time();
        $_SESSION[$retrieveRequestId] = $retrieveRequest;
        require_once 'header.php';
        displayInfo("Successfully staged retrieve request.");
        ?>
<p class='instructions'>Confirm the following retrieve request:</p>
    <?php 
        $tree = new ExpandableTree("retrieveRequestTree", ExpandableTree::processResults($_SESSION[$retrieveRequestId]));
        $tree->setForceCollapse(true);
        $tree->printTree();
        ?>
<form id='retrieveForm' name='retrieveForm' method='POST'
    action=''><input type='hidden'
    name='retrieveRequestId' value='<?php 
        print $retrieveRequestId;
        ?>
' />
<input type='submit' name='retrievalConfirmed' value='Retrieve' /></form>
    <?php 
예제 #21
0
 print "<p>&nbsp;</p><h3>Results</h3>";
 //if they don't tell us the operation name, let's guess from the deploy-specific checkOnly flag (doesn't work for all api versions).
 $operation = isset($_REQUEST['op']) ? htmlspecialchars($_REQUEST['op']) : (isset($asyncResults->checkOnly) ? "D" : "R");
 $results = $operation == "D" ? WorkbenchContext::get()->getMetadataConnection()->checkDeployStatus($asyncProcessId, $debugInfo) : WorkbenchContext::get()->getMetadataConnection()->checkRetrieveStatus($asyncProcessId, $debugInfo);
 $zipLink = null;
 if (isset($results->zipFile) || isset($results->retrieveResult->zipFile)) {
     if (isset($results->zipFile)) {
         $_SESSION['retrievedZips'][$asyncResults->id] = $results->zipFile;
         unset($results->zipFile);
     } else {
         if (isset($results->retrieveResult->zipFile)) {
             $_SESSION['retrievedZips'][$asyncResults->id] = $results->retrieveResult->zipFile;
             unset($results->retrieveResult->zipFile);
         }
     }
     displayInfo("Retrieve result ZIP file is ready for download.");
     print "<p/>";
     $zipLink = " | <a id='zipLink' href='?asyncProcessId={$asyncResults->id}&downloadZip' onclick='undownloadedZip=false;' style='text-decoration:none;'>" . "<span style='text-decoration:underline;'>Download ZIP File</span> <img src='" . getPathToStaticResource('/images/downloadIconCompleted.gif') . "' border='0'/>" . "</a></p>";
 }
 $tree = new ExpandableTree("metadataStatusResultsTree", ExpandableTree::processResults($results));
 $tree->setForceCollapse(true);
 $tree->setAdditionalMenus($zipLink);
 $tree->setContainsIds(true);
 $tree->setContainsDates(true);
 $tree->printTree();
 if (isset($debugInfo["DebuggingInfo"]->debugLog)) {
     print "<p>&nbsp;</p><h3>Debug Logs</h3>";
     print "<pre>" . addLinksToIds(htmlspecialchars($debugInfo["DebuggingInfo"]->debugLog, ENT_QUOTES)) . '</pre>';
 }
 // if metadata changes were deployed, clear the cache because describe results will probably be different
 if ($operation == "D") {
예제 #22
0
/**
 * Display the PUT results from all synchronous
 * functions.
 *
 * @param $results
 * @param $apiCall
 * @param $csvArray
 * @param $idArray
 */
function displayIdOnlyPutResults($results, $apiCall, $csvArray, $idArray)
{
    //check if only result is returned
    if (!is_array($results)) {
        $results = array($results);
    }
    unset($_SESSION['resultsWithData']);
    $resultsWithData = array();
    //create array to hold results with data for download later
    $_SESSION['resultsWithData'][0] = array("Salesforce Id", "Result", "Status");
    $_SESSION['resultsWithData'][0] = array_merge($_SESSION['resultsWithData'][0], $csvArray[0]);
    $successCount = 0;
    $errorCount = 0;
    ob_start();
    for ($row = 0; $row < count($results); $row++) {
        $excelRow = $row + 1;
        $_SESSION['resultsWithData'][$row + 1] = array();
        //create array for row
        if ($results[$row]->success) {
            $successCount++;
            print "<tr>";
            print "<td>" . $excelRow . "</td>";
            print "<td>" . addLinksToIds($results[$row]->id) . "</td>";
            $_SESSION['resultsWithData'][$row + 1][0] = $results[$row]->id;
            print "<td>Success</td>";
            $_SESSION['resultsWithData'][$row + 1][1] = "Success";
            if ($apiCall == 'upsert' && $results[$row]->created || $apiCall == 'create') {
                print "<td>Created</td>";
                $_SESSION['resultsWithData'][$row + 1][2] = "Created";
            } else {
                if ($apiCall == 'upsert' && !$results[$row]->created || $apiCall == 'update') {
                    print "<td>Updated</td>";
                    $_SESSION['resultsWithData'][$row + 1][2] = "Updated";
                } else {
                    if ($apiCall == 'delete' || $apiCall == 'undelete') {
                        print "<td>" . ucwords($apiCall) . "d </td>";
                        $_SESSION['resultsWithData'][$row + 1][2] = ucwords($apiCall) . "d";
                    } else {
                        if ($apiCall == 'emptyRecycleBin') {
                            print "<td>Purged</td>";
                            $_SESSION['resultsWithData'][$row + 1][2] = "Purged";
                        }
                    }
                }
            }
            print "</tr>\n";
        } else {
            $errorCount++;
            print "<tr style='color: red;'>";
            print "<td>" . $excelRow . "</td>";
            if (!isset($results[$row]->id) && isset($idArray)) {
                $_SESSION['resultsWithData'][$row + 1][0] = $idArray[$row];
                //add id from idArray for id-only calls
                print "<td>" . addLinksToIds(htmlspecialchars($idArray[$row])) . "</td>";
            } else {
                $_SESSION['resultsWithData'][$row + 1][0] = $results[$row]->id;
                //add id from results for everything else
                print "<td>" . addLinksToIds(htmlspecialchars($results[$row]->id)) . "</td>";
            }
            $errMsgs = "";
            $statusCodes = "";
            if (is_array($results[$row]->errors)) {
                $errMsgs = implode("; ", array_map("extractMessage", $results[$row]->errors));
                $statusCodes = implode("; ", array_map("extractStatusCode", $results[$row]->errors));
            } else {
                $errMsgs .= $results[$row]->errors->message;
                $statusCodes .= $results[$row]->errors->statusCode;
            }
            print "<td>" . ucwords($errMsgs) . "</td>";
            $_SESSION['resultsWithData'][$row + 1][1] = ucwords($errMsgs);
            print "<td>" . $statusCodes . "</td>";
            $_SESSION['resultsWithData'][$row + 1][2] = $statusCodes;
            print "</tr>\n";
        }
        $_SESSION['resultsWithData'][$row + 1] = array_merge($_SESSION['resultsWithData'][$row + 1], $csvArray[$row + 1]);
    }
    print "</table><br/>";
    $resultsTable = ob_get_clean();
    displayInfo("There " . ($successCount == 1 ? "was" : "were") . " {$successCount} success" . ($successCount == 1 ? "" : "es") . " and {$errorCount} error" . ($errorCount == 1 ? "" : "s"));
    print "<br/><form action='downloadResultsWithData.php' method='GET'><input type='hidden' name='action' value='{$apiCall}'/><input type='submit' value='Download Full Results'/></form>";
    print "<br/>\n<table class='dataTable'>\n";
    print "<th>&nbsp;</th> <th style='width: 30%'>Salesforce Id</th> <th style='width: 30%'>Result</th> <th style='width: 35%'>Status</th>\n";
    print "<p>{$resultsTable}</p>";
}
예제 #23
0
 function displayQueryResults($records, $queryTimeElapsed, QueryRequest $queryRequest)
 {
     if (is_numeric($records)) {
         $countString = "Query would return {$records} record";
         $countString .= $records == 1 ? "." : "s.";
         displayInfo($countString);
         return;
     }
     if (!$records) {
         displayWarning("Sorry, no records returned.");
         return;
     }
     if (WorkbenchConfig::get()->value("areTablesSortable")) {
         addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/sortable.js') . "></script>");
     }
     print "<a name='qr'></a><div style='clear: both;'><br/><h2>Query Results</h2>\n";
     if (isset($this->queryLocator)) {
         preg_match("/-(\\d+)/", $this->queryLocator, $lastRecord);
         $rowOffset = $lastRecord[1];
     } else {
         $rowOffset = 0;
     }
     $minRowNum = $rowOffset + 1;
     $maxRowNum = $rowOffset + count($records);
     print "<p>Returned records {$minRowNum} - {$maxRowNum} of " . $this->totalQuerySize . " total record" . ($this->totalQuerySize !== 1 ? "s" : "") . " in " . sprintf("%01.3f", $queryTimeElapsed) . " seconds:</p>\n";
     if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) {
         print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n";
         print "<p><input type='submit' name='queryMore' id='queryMoreButtonTop' value='More...' /></p>\n";
     }
     print addLinksToIds($queryRequest->getExportTo() == 'matrix' ? $this->createQueryResultsMatrix($records, $queryRequest->getMatrixCols(), $queryRequest->getMatrixRows()) : $this->createQueryResultTable($records, $minRowNum));
     if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) {
         print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n";
         print "<p><input type='submit' name='queryMore' id='queryMoreButtonBottom' value='More...' /></p>";
     }
     print "</form></div>\n";
 }
예제 #24
0
    $displayResults .= "<tr align=right bgcolor=eeeeee><td>Page</td><td>Render (ms)</td><td>Doc (ms)</td></tr>";
    $displayResults .= displayInfo("HomePageDirect", "HomePageOptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= displayInfo("HLPDirect", "HLPOptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= displayInfo("FLPDirect", "FLPOptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= displayInfo("HSRDirect", "HSROptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= displayInfo("FSRDirect", "FSROptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= displayInfo("PSRDirect", "PSROptimized", $renderTotalWithTTFB, $docLoadedWithTTFB, $count);
    $displayResults .= "</table><p><br><table>";
    $displayResults .= "<h2>Adjusted by subtracting TTFB from both direct and optimized render and doc load times.</h2>\n";
    $displayResults .= "<tr align=right bgcolor=eeeeee><td>Page</td><td>Render (ms)</td><td>Doc (ms)</td></tr>";
    $displayResults .= displayInfo("HomePageDirect", "HomePageOptimized", $renderTotal, $fullyTotal, $count);
    $displayResults .= displayInfo("HLPDirect", "HLPOptimized", $renderTotal, $fullyTotal, $count);
    $displayResults .= displayInfo("FLPDirect", "FLPOptimized", $renderTotal, $fullyTotal, $count);
    $displayResults .= displayInfo("HSRDirect", "HSROptimized", $renderTotal, $fullyTotal, $count);
    $displayResults .= displayInfo("FSRDirect", "FSROptimized", $renderTotal, $fullyTotal, $count);
    $displayResults .= displayInfo("PSRDirect", "PSROptimized", $renderTotal, $fullyTotal, $count);
    echo $displayResults;
}
function displayInfo($keyDirect, $keyOptimized, $renderTotal, $fullyTotal, $count)
{
    //  $renderAvgDirect = number_format($renderTotal[$keyDirect] / $count[$keyDirect]);
    //  $fullyAvgDirect = number_format($fullyTotal[$keyDirect] / $count[$keyDirect]);
    //  $renderAvgOptimized = number_format($renderTotal[$keyOptimized] / $count[$keyOptimized]);
    //  $fullyAvgOptimized = number_format($fullyTotal[$keyOptimized] / $count[$keyOptimized]);
    //
    $lpTarget = 0.2;
    $srTarget = 0.1;
    $rendercolor = "green";
    $doccolor = "green";
    // Avoid div by 0
    if ($count[$keyDirect] < 1 || $count[$keyOptimized] < 1) {
예제 #25
0
    if (stripos($e->getMessage(), 'InvalidVersion') > -1) {
        print "<p/><em>Quick Fix: <a href='sessionInfo.php' target='_blank'>Change API Version</a></em>";
    }
    include_once 'footer.php';
    exit;
}
print "<p class='instructions'>A job has been uploaded to Salesforce via the Bulk API and is being processed asynchronously as resources are available. " . "Refresh this page periodically to view the latest status. Results can be downloaded when batches are complete.</p><p/>";
foreach ($batchInfos as $batchInfo) {
    if ($batchInfo->getState() == "Queued" || $batchInfo->getState() == "InProgress") {
        printAsyncRefreshBlock();
        break;
    }
}
print "<h3>Job: " . $jobInfo->getId() . "</h3>";
if ($jobInfo->getStateMessage() != "") {
    displayInfo($jobInfo->getStateMessage());
    print "<p/>";
}
$timeOnlyFormat = "h:i:s A";
print "<table width='100%' cellpadding='5' class='lightlyBoxed'>";
print "<tr>" . "<td class='dataLabel'>Status</td><td class='dataValue'>" . $jobInfo->getState() . "</td>" . "<td class='dataLabel'>Records Processed</td><td class='dataValue'>" . $jobInfo->getNumberRecordsProcessed() . "</td>" . "<td class='dataLabel'>Batches Queued</td><td class='dataValue'>" . $jobInfo->getNumberBatchesQueued() . "</td>" . "</tr>";
print "<tr>" . "<td class='dataLabel'>Object</td><td class='dataValue'>" . $jobInfo->getObject() . "</td>" . (WorkbenchContext::get()->isApiVersionAtLeast(19.0) ? "<td class='dataLabel'>Records Failed</td><td class='dataValue'>" . $jobInfo->getNumberRecordsFailed() . "</td>" : "<td class='dataLabel'>Content Type</td><td class='dataValue'>" . $jobInfo->getContentType() . "</td>") . "<td class='dataLabel'>Batches In Progress</td><td class='dataValue'>" . $jobInfo->getNumberBatchesInProgress() . "</td>" . "</tr>";
print "<tr>" . "<td class='dataLabel'>Operation</td><td class='dataValue'>" . ucwords($jobInfo->getOpertion()) . "</td>" . "<td class='dataLabel'>Concurrency Mode</td><td class='dataValue'>" . $jobInfo->getConcurrencyMode() . "</td>" . "<td class='dataLabel'>Batches Completed</td><td class='dataValue'>" . $jobInfo->getNumberBatchesCompleted() . "</td>" . "</tr>";
print "<tr>" . "<td class='dataLabel'>External Id</td><td class='dataValue'>" . $jobInfo->getExternalIdFieldName() . "</td>" . "<td class='dataLabel'>API Version</td><td class='dataValue'>" . $jobInfo->getApiVersion() . "</td>" . "<td class='dataLabel'>Batches Failed</td><td class='dataValue'>" . $jobInfo->getNumberBatchesFailed() . "</td>" . "</tr>";
if (WorkbenchContext::get()->isApiVersionAtLeast(19.0)) {
    print "<tr>" . "<td class='dataLabel'>API Processing</td><td class='dataValue'>" . $jobInfo->getApiActiveProcessingTime() . " ms</td>" . "<td class='dataLabel'>Apex Processing</td><td class='dataValue'>" . $jobInfo->getApexProcessingTime() . " ms</td>" . "<td class='dataLabel'>Total Processing</td><td class='dataValue'>" . $jobInfo->getTotalProcessingTime() . " ms</td>" . "</tr>";
}
print "<tr>" . "<td class='dataLabel'>Created</td><td class='dataValue'>" . localizeDateTimes($jobInfo->getCreatedDate(), $timeOnlyFormat) . "</td>" . "<td class='dataLabel'>Last Modified</td><td class='dataValue'>" . localizeDateTimes($jobInfo->getSystemModstamp(), $timeOnlyFormat) . "</td>" . "<td class='dataLabel'>Retries</td><td class='dataValue'>" . $jobInfo->getNumberRetries() . "</td>" . "</tr>";
print "</table>";
print "<p>&nbsp;</p>";
if (count($batchInfos) > 0) {