| | 1 | == iPeer v2 Technical Documentation == |
| | 2 | |
| | 3 | === rdAuth Components: === |
| | 4 | rdAuth components monitors the current user’s information such as id, role, username, fullname. To get the current user’s attribute, we can call: |
| | 5 | From View: $rdAuth->id |
| | 6 | From Controller: $this->rdAuth->id |
| | 7 | === Sys_Parameter Settings: === |
| | 8 | System Parameters are loaded once the users has login successfully. There are 2 core parameters that control the iPeer integration with UBC CWL: |
| | 9 | |
| | 10 | For General version: |
| | 11 | |
| | 12 | ||Parameter Code||Parameter Value |
| | 13 | custom.login_control||ipeer |
| | 14 | custom.login_page_pathname||Leave it as empty |
| | 15 | |
| | 16 | For UBC CWL customization: |
| | 17 | |
| | 18 | Parameter Code |
| | 19 | Parameter Value |
| | 20 | custom.login_control |
| | 21 | UBC_CWL |
| | 22 | custom.login_page_pathname |
| | 23 | custom_ubc_cwl_login |
| | 24 | |
| | 25 | To check whether the iPeer is UBC CWL integrated or not: |
| | 26 | if (isset($this->rdAuth->customIntegrateCWL) && $this->rdAuth->customIntegrateCWL) { |
| | 27 | // ipeer is integrated with CWL |
| | 28 | } |
| | 29 | Get Sys_Parameter from iPeer: |
| | 30 | e.g. Get the parameter code ‘system.upload_dir’: |
| | 31 | $uploadDir = $this->sysContainer->getParamByParamCode('system.upload_dir'); |
| | 32 | $uploadFile = APP.$uploadDir['parameter_value'] . $filename; |
| | 33 | |
| | 34 | |
| | 35 | Some useful functions: |
| | 36 | 1.Get all accessible courses: |
| | 37 | $courseList = $this->sysContainer->getMyCourseList(); |
| | 38 | |
| | 39 | 2.Get no. of members within a group: |
| | 40 | $numMembers=$event['Event']['self_eval'] ? $this->GroupsMembers->findCount('group_id='.$groupId) : |
| | 41 | $this->GroupsMembers->findCount('group_id='.$groupId) - 1; |
| | 42 | Caution: To upgrade CakePHP library for iPeer, please also look into the following files to change for iPeer customization: |
| | 43 | 1.replace all thtml -> tpl.php, since iPeer use php extension instead of thtml |
| | 44 | 2.change the controller.php in \cake\libs\controller |
| | 45 | 3.change html.php helper in \cake\libs\view\helpers |
| | 46 | 4.change dbo_source.php in \cake\libs\model\datasources |
| | 47 | |
| | 48 | UBC CWL Integration: |
| | 49 | Instead of the Sys_Parameter setting from database, there are two files for CWL integration: |
| | 50 | ipeer_v2\app\controller\loginout_controller.php |
| | 51 | ipeer_v2\app\views\loginout\custom_ubc_cwl_login.tpl.php |
| | 52 | |
| | 53 | Note: Remove all the following code when release the iPeer v2 to SourceForge. |
| | 54 | |
| | 55 | From loginout_controller: |
| | 56 | |
| | 57 | function loginByCWL() { |
| | 58 | $this->autoRender = false; |
| | 59 | /** |
| | 60 | * the URL of the CWL login page |
| | 61 | */ |
| | 62 | $CWLLoginURL = 'https://www.auth.verf.cwl.ubc.ca/auth/login'; |
| | 63 | |
| | 64 | // CWL XML-RPC interface URLs: https://www.auth.verf.cwl.ubc.ca/auth/rpc (for verification) |
| | 65 | // https://www.auth.cwl.ubc.ca/auth/rpc |
| | 66 | $CWLRPCURL = "https://www.auth.verf.cwl.ubc.ca"; |
| | 67 | $CWLRPCPath = "/auth/rpc"; |
| | 68 | |
| | 69 | /** |
| | 70 | * the name of the function being called through XML-RPC. this is |
| | 71 | * prepended with 'session.' later |
| | 72 | */ |
| | 73 | //$CWLFunctionName = 'getLoginName'; |
| | 74 | $CWLFunctionName = 'getIdentities'; |
| | 75 | |
| | 76 | /** |
| | 77 | * the application's ID/name and password as given by the CWL team |
| | 78 | */ |
| | 79 | $applicationID = 'cis_ipeer_vsa'; |
| | 80 | $applicationPassword = 'p33rl355'; |
| | 81 | |
| | 82 | $ticket = $_GET['ticket']; |
| | 83 | if ($ticket != null) { |
| | 84 | // now get some info about the session |
| | 85 | |
| | 86 | // the parameters passed to the RPC interface. the ticket is the |
| | 87 | // first argument for all functions |
| | 88 | $params = array( new XML_RPC_Value($ticket, 'string') ); |
| | 89 | |
| | 90 | // note that the function name is prepended with the string 'session.' |
| | 91 | $msg = new XML_RPC_Message("session.$CWLFunctionName", $params); |
| | 92 | |
| | 93 | $cli = new XML_RPC_Client($CWLRPCPath, $CWLRPCURL); |
| | 94 | $cli->setCredentials($applicationID, $applicationPassword); |
| | 95 | //print_r ($cli); |
| | 96 | //$cli->setDebug(1); |
| | 97 | |
| | 98 | $resp = $cli->send($msg); |
| | 99 | if (!$resp) |
| | 100 | { |
| | 101 | echo 'Communication error: ' . $cli->errstr; |
| | 102 | exit; |
| | 103 | } |
| | 104 | |
| | 105 | // print the raw response data |
| | 106 | |
| | 107 | //echo "<b>Raw Response:</b><br /><pre>"; |
| | 108 | //print_r($resp); |
| | 109 | //echo "</pre>"; |
| | 110 | |
| | 111 | if (!$resp->faultCode()) |
| | 112 | { |
| | 113 | // an encoded response value |
| | 114 | $val = $resp->value(); |
| | 115 | |
| | 116 | // the actual data we requested |
| | 117 | $data = XML_RPC_decode($val); |
| | 118 | |
| | 119 | //echo "<b>Response Data:</b><br /><pre>"; |
| | 120 | //print_r($data); |
| | 121 | //echo "</pre>"; |
| | 122 | if (!empty($data['student_number'])) { |
| | 123 | $studentNumber = $data['student_number']; |
| | 124 | |
| | 125 | //Check is this CWL login student able to use iPeer |
| | 126 | $this->params['data'] = $this->User->findUserByStudentNo(trim($studentNumber)); |
| | 127 | |
| | 128 | if ($this->params['data']['User']['id']) |
| | 129 | { |
| | 130 | //sets up the session vars |
| | 131 | $this->rdAuth->set($this->params['data']['User']); |
| | 132 | |
| | 133 | //sets up the system container for accessible functions |
| | 134 | $accessFunction = $this->SysFunction->getAllAccessibleFunction($this->params['data']['User']['role']); |
| | 135 | $accessController = $this->SysFunction->getTopAccessibleFunction($this->params['data']['User']['role']); |
| | 136 | $this->sysContainer->setAcesFunctionList($accessFunction); |
| | 137 | $this->sysContainer->setActionList($accessController); |
| | 138 | |
| | 139 | //setup my accessible courses |
| | 140 | $myCourses = $this->Course->findAccessibleCoursesList($this->params['data']['User']); |
| | 141 | $this->sysContainer->setMyCourseList($myCourses); |
| | 142 | |
| | 143 | //clear up the data parameters |
| | 144 | $this->params['data'] = array(); |
| | 145 | $redirect = '/home/index/'; |
| | 146 | $this->redirect($redirect); |
| | 147 | } |
| | 148 | else |
| | 149 | { |
| | 150 | $this->Session->write('CWLErr', 'NO_PERMISSION'); |
| | 151 | $redirect = 'loginout/login'; |
| | 152 | $this->redirect($redirect); |
| | 153 | } |
| | 154 | } else { |
| | 155 | $this->Session->write('CWLErr', 'INVALID_USER'); |
| | 156 | $redirect = 'loginout/login'; |
| | 157 | $this->redirect($redirect); |
| | 158 | } |
| | 159 | |
| | 160 | } |
| | 161 | else |
| | 162 | { |
| | 163 | // error |
| | 164 | echo '<b>Fault Code:</b> ' . $resp->faultCode() . "<br />\n"; |
| | 165 | echo '<b>Fault Reason:</b> ' . $resp->faultString() . "<br />\n"; |
| | 166 | } |
| | 167 | |
| | 168 | } |
| | 169 | |
| | 170 | } |
| | 171 | |
| | 172 | Delete the view page custom_ubc_cwl_login.tpl.php: |
| | 173 | |
| | 174 | … |
| | 175 | document.write(' <td width="62">For Students:</td>'); |
| | 176 | 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">'); |
| | 177 | document.write(' <IMG SRC="https://www.auth.verf.cwl.ubc.ca/CWL_login_button.gif" WIDTH="76" HEIGHT="25" ALT="CWL Login" BORDER="0">'); |
| | 178 | //document.write(' <IMG SRC="https://www.auth.cwl.ubc.ca/CWL_login_button.gif " WIDTH="76" HEIGHT="25" ALT="CWL Login" BORDER="0">'); |
| | 179 | document.write(' </A>'); |
| | 180 | document.write(' </td>'); |
| | 181 | …. |