== iPeer v2 Technical Documentation == Based on file: `iPeer-v2-Technical-Documentation.doc` === 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 Code||Parameter Value|| ||custom.login_control||ipeer ||custom.login_page_pathname||Leave it as empty For UBC CWL customization: ||Parameter Code||Parameter Value ||custom.login_control||UBC_CWL ||custom.login_page_pathname||custom_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 {{{#!comment === 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 = $_GET['ticket']; 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 "Raw Response:
";
			//print_r($resp);
			//echo "
"; if (!$resp->faultCode()) { // an encoded response value $val = $resp->value(); // the actual data we requested $data = XML_RPC_decode($val); //echo "Response Data:
";
				//print_r($data);
				//echo "
"; if (!empty($data['student_number'])) { $studentNumber = $data['student_number']; //Check is this CWL login student able to use iPeer $this->params['data'] = $this->User->findUserByStudentNo(trim($studentNumber)); if ($this->params['data']['User']['id']) { //sets up the session vars $this->rdAuth->set($this->params['data']['User']); //sets up the system container for accessible functions $accessFunction = $this->SysFunction->getAllAccessibleFunction($this->params['data']['User']['role']); $accessController = $this->SysFunction->getTopAccessibleFunction($this->params['data']['User']['role']); $this->sysContainer->setAcesFunctionList($accessFunction); $this->sysContainer->setActionList($accessController); //setup my accessible courses $myCourses = $this->Course->findAccessibleCoursesList($this->params['data']['User']); $this->sysContainer->setMyCourseList($myCourses); //clear up the data parameters $this->params['data'] = 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 'Fault Code: ' . $resp->faultCode() . "
\n"; echo 'Fault Reason: ' . $resp->faultString() . "
\n"; } } } }}} ==== Delete the view page custom_ubc_cwl_login.tpl.php: ==== {{{ … document.write('For Students:'); document.write(''); document.write('CWL Login'); //document.write('CWL Login'); document.write(''); document.write(''); …. }}} }}}