wiki:PrevTechDoc

Version 6 (modified by Serge Okon, 14 years ago) ( diff )

--

iPeer v2 Technical Documentation

rdAuth Components:

rdAuth components monitors the current user’s information such as id, role, username, fullname. To get the current user’s attribute, we can call: From View: $rdAuth->id From Controller: $this->rdAuth->id

Sys_Parameter Settings:

System Parameters are loaded once the users has login successfully. There are 2 core parameters that control the iPeer integration with UBC CWL:

For General version:

Parameter CodeParameter Value
custom.login_controlipeer
custom.login_page_pathnameLeave it as empty

For UBC CWL customization:

Parameter CodeParameter Value
custom.login_controlUBC_CWL
custom.login_page_pathnamecustom_ubc_cwl_login

To check whether the iPeer is UBC CWL integrated or not:

if (isset($this->rdAuth->customIntegrateCWL) && $this->rdAuth->customIntegrateCWL) {
// ipeer is integrated with CWL
}

Get Sys_Parameter from iPeer:

e.g. Get the parameter code ‘system.upload_dir’:

		$uploadDir = $this->sysContainer->getParamByParamCode('system.upload_dir');
		$uploadFile = APP.$uploadDir['parameter_value'] . $filename;

Some useful functions:

1.Get all accessible courses:

$courseList = $this->sysContainer->getMyCourseList(); 

2.Get no. of members within a group:

$numMembers=$event['Event']['self_eval'] ? 
    $this->GroupsMembers->findCount('group_id='.$groupId) : 
    $this->GroupsMembers->findCount('group_id='.$groupId) - 1; 

Caution: To upgrade CakePHP library for iPeer, please also look into the following files to change for iPeer customization:

  1. replace all thtml -> tpl.php, since iPeer use php extension instead of thtml
  2. change the controller.php in \cake\libs\controller
  3. change html.php helper in \cake\libs\view\helpers
  4. change dbo_source.php in \cake\libs\model\datasources

UBC CWL Integration:

Instead of the Sys_Parameter setting from database, there are two files for CWL integration: ipeer_v2\app\controller\loginout_controller.php ipeer_v2\app\views\loginout\custom_ubc_cwl_login.tpl.php

Note: Remove all the following code when release the iPeer v2 to SourceForge.

From loginout_controller:

function loginByCWL() {

$this->autoRender = false; /

  • the URL of the CWL login page */

$CWLLoginURL = 'https://www.auth.verf.cwl.ubc.ca/auth/login';

CWL XML-RPC interface URLs: https://www.auth.verf.cwl.ubc.ca/auth/rpc (for verification) https://www.auth.cwl.ubc.ca/auth/rpc $CWLRPCURL = "https://www.auth.verf.cwl.ubc.ca"; $CWLRPCPath = "/auth/rpc";

/

  • the name of the function being called through XML-RPC. this is
  • prepended with 'session.' later */

$CWLFunctionName = 'getLoginName'; $CWLFunctionName = 'getIdentities';

/

  • the application's ID/name and password as given by the CWL team */

$applicationID = 'cis_ipeer_vsa'; $applicationPassword = 'p33rl355';

$ticket = $_GETticket; if ($ticket != null) {

now get some info about the session

the parameters passed to the RPC interface. the ticket is the first argument for all functions $params = array( new XML_RPC_Value($ticket, 'string') );

note that the function name is prepended with the string 'session.' $msg = new XML_RPC_Message("session.$CWLFunctionName", $params);

$cli = new XML_RPC_Client($CWLRPCPath, $CWLRPCURL); $cli->setCredentials($applicationID, $applicationPassword); print_r ($cli); $cli->setDebug(1);

$resp = $cli->send($msg); if (!$resp) {

echo 'Communication error: ' . $cli->errstr; exit;

}

print the raw response data

echo "<b>Raw Response:</b><br /><pre>"; print_r($resp); echo "</pre>";

if (!$resp->faultCode()) {

an encoded response value $val = $resp->value();

the actual data we requested $data = XML_RPC_decode($val);

echo "<b>Response Data:</b><br /><pre>"; print_r($data); echo "</pre>"; if (!empty($datastudent_number)) {

$studentNumber = $datastudent_number;

Check is this CWL login student able to use iPeer $this->paramsdata = $this->User->findUserByStudentNo(trim($studentNumber));

if ($this->paramsdataUserid) {

sets up the session vars $this->rdAuth->set($this->paramsdataUser);

sets up the system container for accessible functions $accessFunction = $this->SysFunction->getAllAccessibleFunction($this->paramsdataUserrole); $accessController = $this->SysFunction->getTopAccessibleFunction($this->paramsdataUserrole); $this->sysContainer->setAcesFunctionList($accessFunction); $this->sysContainer->setActionList($accessController);

setup my accessible courses $myCourses = $this->Course->findAccessibleCoursesList($this->paramsdataUser); $this->sysContainer->setMyCourseList($myCourses);

clear up the data parameters $this->paramsdata = array(); $redirect = '/home/index/'; $this->redirect($redirect);

} else {

$this->Session->write('CWLErr', 'NO_PERMISSION'); $redirect = 'loginout/login'; $this->redirect($redirect);

}

} else {

$this->Session->write('CWLErr', 'INVALID_USER'); $redirect = 'loginout/login'; $this->redirect($redirect);

}

} else {

error echo '<b>Fault Code:</b> ' . $resp->faultCode() . "<br />\n"; echo '<b>Fault Reason:</b> ' . $resp->faultString() . "<br />\n";

}

}

}

Delete the view page custom_ubc_cwl_login.tpl.php:

… document.write(' <td width="62">For Students:</td>'); document.write(' <td width="140"><A HREF="https://www.auth.verf.cwl.ubc.ca/auth/login?serviceName=cis_ipeer_vsa&serviceURL=http://ipeer.apsc.ubc.ca<?php echo $this->webroot.$this->themeWeb;?>loginout/loginByCWL">'); document.write(' <IMG SRC="https://www.auth.verf.cwl.ubc.ca/CWL_login_button.gif" WIDTH="76" HEIGHT="25" ALT="CWL Login" BORDER="0">'); document.write(' <IMG SRC="https://www.auth.cwl.ubc.ca/CWL_login_button.gif " WIDTH="76" HEIGHT="25" ALT="CWL Login" BORDER="0">'); document.write(' </A>'); document.write(' </td>'); ….

Note: See TracWiki for help on using the wiki.