static function process($request)
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         TestCode_Controller::doLayout();
         TestCode_Controller::doLayoutCode();
     } else {
         echo "<div class='alert alert-danger'>ERROR: Login failure!</div>";
     }
 }
 static function process()
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         echo "<div class='alert alert-info'>Many of these queries are specific to the coreBOS application they were created for and will fail on your install. You should just need to tweek the IDs and conditions to get them working.</div>";
         foreach (QueryExamples_Controller::$queries as $query) {
             echo '<b>' . $query . '</b><br>';
             $result = $client->doQuery($query);
             QueryExamples_Controller::showresult($result);
         }
     } else {
         echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
     }
 }
示例#3
0
 static function process($request)
 {
     if (isset($request['q'])) {
         $query = $request['q'];
     } else {
         $query = '';
     }
     $escapedQuery = $query;
     echo "\n\t\t<form method='POST' action='index.php' onsubmit='return validateForm(this);'>\n\t\t\t<table cellpadding='0' cellspacing='1'>\n\t\t\t\t<tr valign=top>\n\t\t\t\t\t<td>Try a query like: select firstname, lastname from Leads order by firstname desc limit 0,2; or <a href='index.php?action=queryExamples'>have a look at our tests and examples.</a><br/><textarea name='q' rows='5' cols='80'>{$escapedQuery}</textarea></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type='submit' value='Execute &raquo;' name='__submitButton' class='btn btn-primary btn-large'></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</form>";
     if (!empty($query)) {
         $loginModel = Session_Controller::getLoginContext();
         $client = new Vtiger_WSClient($loginModel->getURL());
         $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
         if ($login) {
             $result = $client->doQuery($query);
             if (is_array($result)) {
                 if (count($result) == 0) {
                     echo "<div class='alert alert-info'><strong>No results found!</strong></div>";
                 } else {
                     echo "<table cellpadding='3' cellspacing='0' class='table table-striped small'>";
                     $columns = $client->getResultColumns($result);
                     echo "<tr>";
                     foreach ($columns as $column) {
                         echo sprintf("<th nowrap='nowrap'>%s</th>", $column);
                     }
                     echo "</tr>";
                     foreach ($result as $row) {
                         echo "<tr>";
                         foreach ($row as $k => $v) {
                             if ($v === '') {
                                 $v = '&nbsp;';
                             }
                             echo sprintf("<td nowrap='nowrap'>%s</td>", $v);
                         }
                         echo "</tr>";
                     }
                     echo "</table>";
                 }
             } else {
                 $lastError = $client->lastError();
                 echo "<div class='alert alert-danger'><strong>ERROR:</strong> " . $lastError['message'] . "</div>";
             }
         } else {
             echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
         }
     }
 }
示例#4
0
    static function getMenu()
    {
        $rdo = '<header role="banner" id="top">
	<nav role="navigation" class="navbar navbar-default" style="margin-bottom: 0;">
	  <div class="navbar-header">
	    <button data-target=".navbar-ex1-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
	      <span class="sr-only">Toggle navigation</span>
	      <span class="icon-bar"></span>
	      <span class="icon-bar"></span>
	      <span class="icon-bar"></span>
	    </button>
        <a href="http://corebos.org" class="navbar-brand"><img src="assets/app-logo.png" style="max-height: 50px;top:0;position:absolute;"></a>
	  </div>
	  <!-- /.navbar-header -->
	  <div class="collapse navbar-collapse navbar-ex1-collapse">
	    <ul class="nav navbar-nav navbar-right">';
        if (Session_Controller::hasLoginContext()) {
            $rdo .= '<li><a href="index.php?action=vql">Query</a></li>';
            $rdo .= '<li><a href="index.php?action=ListTypes">List Types</a></li>';
            $rdo .= '<li><a href="index.php?action=TestCode">Test Code PHP</a></li>';
            $rdo .= '<li><a href="index.php?action=TestCodeJS">Test Code JS</a></li>';
            $rdo .= '<li style="margin-left:40px;">&nbsp;</li>';
        }
        $rdo .= '<li><a href="http://corebos.org/documentation" target="_blank">Documentation</a></li>
			<li><a href="http://corebos.org/page/corebos-participate" target="_blank">Participate</a></li>
			<li><a href="http://discussions.corebos.org" target="_blank">Forum</a></li>
			<li><a href="http://corebos.org/blog" target="_blank">Blog</a></li>
			<li><a href="http://corebos.org/page/contact" target="_blank">Contact</a></li>';
        if (Session_Controller::hasLoginContext()) {
            $loginModel = Session_Controller::getLoginContext();
            $title = 'URL: ' . $loginModel->getURL() . "          \n";
            $title .= 'User: '******' (' . $loginModel->getUserId() . ")\n";
            $title .= 'Key: ' . $loginModel->getAccessKey();
            $rdo .= sprintf("<li><a href='#'><small><abbr title='%s'>Welcome <b>%s</b></abbr></small></a></li>", $title, $loginModel->getUsername());
            $rdo .= "<li><a href='index.php?action=Logout'>Logout</a></li>";
        }
        $rdo .= '<li style="margin-left:30px;">&nbsp;</li>
	    </ul>
	  </div>
	  <!-- /.navbar-collapse -->
	</nav>
	<div class="row span12 pull-right small"><a href="http://corebos.org" style="color: #04579b;margin-right: 40px;">Proud member of the coreBOS Family</a></div>
</header>';
        return $rdo;
    }
示例#5
0
 static function process($request)
 {
     Session_Controller::destroy();
     header('Location: index.php');
 }
示例#6
0
 ************************************************************************************/
//error_reporting(E_ALL); // Debug
//ini_set('display_errors','on');
include_once 'models/Login.php';
include_once 'controllers/Session.php';
include_once 'vtwsclib/WSClient.php';
Session_Controller::start();
header('Content-type: text/html; charset=utf8');
include_once 'controllers/Header.php';
include_once 'controllers/Footer.php';
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
} else {
    $action = '';
}
if (Session_Controller::hasLoginContext()) {
    switch ($action) {
        case 'Logout':
            include_once 'controllers/Logout.php';
            Logout_Controller::process($_REQUEST);
            Footer_Controller::process($_REQUEST);
            break;
        case 'ListTypes':
            Header_Controller::process($_REQUEST);
            include_once 'controllers/ListTypes.php';
            ListTypes_Controller::process($_REQUEST);
            Footer_Controller::process($_REQUEST);
            break;
        case 'TestCode':
            Header_Controller::process($_REQUEST);
            include_once 'controllers/TestCode.php';
示例#7
0
    static function process($request)
    {
        if (isset($request['url'])) {
            $url = $request['url'];
        } else {
            $url = 'http://localhost/';
        }
        if (isset($request['username'])) {
            $username = $request['username'];
        } else {
            $username = '******';
        }
        if (isset($request['accesskey'])) {
            $accesskey = $request['accesskey'];
        } else {
            $accesskey = '';
        }
        if (!empty($url) && !empty($username) && !empty($accesskey)) {
            $loginModel = new Login_Model($url, $username, $accesskey);
            $client = new Vtiger_WSClient($loginModel->getURL());
            $checkLogin = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
            if ($checkLogin) {
                Session_Controller::setLoginContext($loginModel);
                $loginModel->setUserId($client->_userid);
                $loginModel->setSessionId($client->_sessionid);
                header('Location: index.php');
                exit;
                //return;
            }
        }
        Header_Controller::process($request);
        ?>
		<form method='POST' action='index.php' onsubmit='$("#wserrmsg").hide();this.__submitButton.value="Verifying"; this.__submitButton.disabled=true;'>
		<div class='form-group'>
			<label for='url'>URL</label>
			<input type='text' name='url' value='<?php 
        echo $url;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='username'>Username</label>
			<input type='text' name='username' value='<?php 
        echo $username;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='accesskey'>Access key</label>
			<input type='text' name='accesskey' value='<?php 
        echo $accesskey;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<input class='btn btn-primary btn-large' type='submit' value='Login &raquo;' name='__submitButton'>
		</div>
		</form>
<?php 
        if (!empty($url) && !empty($username) && !empty($accesskey) && !$checkLogin) {
            echo '<div class="alert alert-danger" id="wserrmsg">There is an error with the validation data given, please review and try again.</div>';
        }
        Footer_Controller::process($request);
    }
 static function process($request)
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         $modules = $client->doListTypes();
         asort($modules);
         if ($modules) {
             $modOptions = '';
             foreach ($modules as $module) {
                 $modOptions .= "<option value='" . $module['name'] . "'>" . $module['name'] . "</option>";
             }
             foreach ($modules as $module) {
                 echo "<div class='row' id='" . $module['name'] . "' style='vertical-align:bottom;'><span class='span5 pull-left'><h3>" . $module['name'] . "</h3></span>";
                 echo "<span class='span1 pull-right' style='margin-left:10px;margin-right:60px;margin-top: 30px;'>";
                 echo "<a href='#top'><img src='assets/go_top.png'></a>";
                 echo "</span>";
                 echo "<span class='span4 pull-right' style='margin-top: 30px;'>";
                 echo "<select onchange=\"\$('.modqaselect').val(this.value);document.location='#'+this.value\" class='small modqaselect'>" . $modOptions . "</select>";
                 echo "</span>";
                 echo "</div>";
                 echo "<table class='table table-striped small table-condensed'>";
                 echo "<tr><th>REST ID</th><th>Can Create</th><th>Can Update</th><th>Can Delete</th><th>Can Retrieve</th></tr>";
                 echo "<tr>";
                 $desc = $client->doDescribe($module['name']);
                 if (is_array($desc)) {
                     echo sprintf("<td nowrap='nowrap'>%s</td>", $desc['idPrefix'] . 'x');
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['createable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['updateable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['deleteable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['retrieveable']);
                     echo "</tr></table>";
                     echo "<table class='table table-striped small table-condensed'>";
                     echo "<tr><th>Field</th><th>Information</th><th>Block</th><th>Type</th><th width='30%'>Reference/Values</th></tr>";
                     foreach ($desc['fields'] as $field) {
                         $fieldname = $field['label'];
                         echo "<tr><td nowrap='nowrap'><b>" . $fieldname . '</b><br>' . $field['name'] . '</td>';
                         echo "<td>";
                         $fielddesc = "Mandatory: ";
                         $fielddesc .= ($field['mandatory'] ? 'yes' : 'no') . "<br>Null: " . ($field['nullable'] ? 'yes' : 'no');
                         $fielddesc .= "<br>Editable: " . ($field['editable'] ? 'yes' : 'no');
                         if (isset($field['sequence'])) {
                             $fielddesc .= "<br>Sequence: " . $field['sequence'];
                         }
                         echo $fielddesc . "</td><td>";
                         if (isset($field['block'])) {
                             $blockddesc = "ID: " . $field['block']['blockid'] . '<br>';
                             $blockddesc .= 'Sequence: ' . $field['block']['blocksequence'] . '<br>';
                             $blockddesc .= 'Label: ' . $field['block']['blocklabel'] . '<br>';
                             $blockddesc .= 'Name: ' . $field['block']['blockname'];
                             echo $blockddesc;
                         }
                         echo "</td><td>";
                         $fielddesc = "Type: " . $field['type']['name'];
                         if (isset($field['typeofdata'])) {
                             $fielddesc .= "&nbsp;(" . $field['typeofdata'] . ')';
                         }
                         if (isset($field['uitype'])) {
                             $fielddesc .= "<br>UIType: " . $field['uitype'];
                         }
                         if (isset($field['type']['format'])) {
                             $fielddesc .= "<br>Format: " . $field['type']['format'];
                         }
                         if (isset($field['default'])) {
                             $fielddesc .= "<br>Default: " . $field['default'];
                         }
                         echo $fielddesc . '</td><td>';
                         $addinfo = '';
                         if (isset($field['type']['refersTo'])) {
                             foreach ($field['type']['refersTo'] as $capts) {
                                 $addinfo .= "{$capts}, ";
                             }
                         }
                         if (isset($field['type']['picklistValues'])) {
                             foreach ($field['type']['picklistValues'] as $plvs => $plvn) {
                                 $addinfo .= $plvn['value'] . ", ";
                             }
                         }
                         echo $addinfo . '</td>';
                         echo "</tr>";
                     }
                 }
                 echo "</table>";
             }
         } else {
             $lastError = $client->lastError();
             echo "<div class='alert alert-danger'>ERROR: " . $lastError['message'] . "</div>";
         }
     } else {
         echo "<div class='alert alert-danger'>ERROR: Login failure!</div>";
     }
 }