@@ -447,7 +447,7 @@ |
||
| 447 | 447 | * |
| 448 | 448 | * @param array $headers The HTTP headers |
| 449 | 449 | * @param string $data unprocessed request data from client |
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 450 | + * @return false|null value of the message, decoded into a PHP type |
|
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | */ |
| 88 | 88 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 89 | - if (! $cid) {
|
|
| 89 | + if (!$cid) {
|
|
| 90 | 90 | $cid = md5(uniqid(time())); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @access private |
| 222 | 222 | */ |
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 224 | + $this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 225 | 225 | $this->responseAttachments = array(); |
| 226 | 226 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 227 | 227 | $this->debug('Decode multipart/related');
|
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | foreach ($headers as $k => $v) {
|
| 230 | 230 | $input .= "$k: $v\r\n"; |
| 231 | 231 | } |
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 232 | + $params['input'] = $input."\r\n".$data; |
|
| 233 | 233 | $params['include_bodies'] = true; |
| 234 | 234 | $params['decode_bodies'] = true; |
| 235 | 235 | $params['decode_headers'] = true; |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | foreach ($structure->parts as $part) {
|
| 240 | 240 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 241 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 242 | 242 | $root = $part->body; |
| 243 | 243 | $return = parent::parseResponse($part->headers, $part->body); |
| 244 | 244 | } else {
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 245 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 246 | 246 | $info['data'] = $part->body; |
| 247 | 247 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 248 | 248 | $info['contenttype'] = $part->headers['content-type']; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @access public |
| 317 | 317 | */ |
| 318 | 318 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 319 | - if (! $cid) {
|
|
| 319 | + if (!$cid) {
|
|
| 320 | 320 | $cid = md5(uniqid(time())); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 454 | + $this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 455 | 455 | $this->requestAttachments = array(); |
| 456 | 456 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 457 | 457 | $this->debug('Decode multipart/related');
|
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | foreach ($headers as $k => $v) {
|
| 460 | 460 | $input .= "$k: $v\r\n"; |
| 461 | 461 | } |
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 462 | + $params['input'] = $input."\r\n".$data; |
|
| 463 | 463 | $params['include_bodies'] = true; |
| 464 | 464 | $params['decode_bodies'] = true; |
| 465 | 465 | $params['decode_headers'] = true; |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | foreach ($structure->parts as $part) {
|
| 470 | 470 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 471 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 472 | 472 | $return = parent::parseRequest($part->headers, $part->body); |
| 473 | 473 | } else {
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 474 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 475 | 475 | $info['data'] = $part->body; |
| 476 | 476 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 477 | 477 | $info['contenttype'] = $part->headers['content-type']; |
@@ -52,224 +52,224 @@ discard block |
||
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | 54 | class nusoap_client_mime extends nusoap_client {
|
| 55 | - /** |
|
| 56 | - * @var array Each array element in the return is an associative array with keys |
|
| 57 | - * data, filename, contenttype, cid |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $requestAttachments = array(); |
|
| 61 | - /** |
|
| 62 | - * @var array Each array element in the return is an associative array with keys |
|
| 63 | - * data, filename, contenttype, cid |
|
| 64 | - * @access private |
|
| 65 | - */ |
|
| 66 | - var $responseAttachments; |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $mimeContentType; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * adds a MIME attachment to the current request. |
|
| 75 | - * |
|
| 76 | - * If the $data parameter contains an empty string, this method will read |
|
| 77 | - * the contents of the file named by the $filename parameter. |
|
| 78 | - * |
|
| 79 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | - * |
|
| 81 | - * @param string $data The data of the attachment |
|
| 82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | - * @return string The content-id (cid) of the attachment |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 88 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | - if (! $cid) {
|
|
| 90 | - $cid = md5(uniqid(time())); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $info['data'] = $data; |
|
| 94 | - $info['filename'] = $filename; |
|
| 95 | - $info['contenttype'] = $contenttype; |
|
| 96 | - $info['cid'] = $cid; |
|
| 97 | - |
|
| 98 | - $this->requestAttachments[] = $info; |
|
| 99 | - |
|
| 100 | - return $cid; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * clears the MIME attachments for the current request. |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - */ |
|
| 108 | - function clearAttachments() {
|
|
| 109 | - $this->requestAttachments = array(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * gets the MIME attachments from the current response. |
|
| 114 | - * |
|
| 115 | - * Each array element in the return is an associative array with keys |
|
| 116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | - * for addAttachment. |
|
| 118 | - * |
|
| 119 | - * @return array The attachments. |
|
| 120 | - * @access public |
|
| 121 | - */ |
|
| 122 | - function getAttachments() {
|
|
| 123 | - return $this->responseAttachments; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * gets the HTTP body for the current request. |
|
| 128 | - * |
|
| 129 | - * @param string $soapmsg The SOAP payload |
|
| 130 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | - * @access private |
|
| 132 | - */ |
|
| 133 | - function getHTTPBody($soapmsg) {
|
|
| 134 | - if (count($this->requestAttachments) > 0) {
|
|
| 135 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | - unset($params); |
|
| 138 | - |
|
| 139 | - $params['content_type'] = 'text/xml'; |
|
| 140 | - $params['encoding'] = '8bit'; |
|
| 141 | - $params['charset'] = $this->soap_defencoding; |
|
| 142 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 143 | - |
|
| 144 | - foreach ($this->requestAttachments as $att) {
|
|
| 145 | - unset($params); |
|
| 146 | - |
|
| 147 | - $params['content_type'] = $att['contenttype']; |
|
| 148 | - $params['encoding'] = 'base64'; |
|
| 149 | - $params['disposition'] = 'attachment'; |
|
| 150 | - $params['dfilename'] = $att['filename']; |
|
| 151 | - $params['cid'] = $att['cid']; |
|
| 152 | - |
|
| 153 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | - $data = fread($fd, filesize($att['filename'])); |
|
| 156 | - fclose($fd); |
|
| 157 | - } else {
|
|
| 158 | - $data = ''; |
|
| 159 | - } |
|
| 160 | - $mimeMessage->addSubpart($data, $params); |
|
| 161 | - } else {
|
|
| 162 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $output = $mimeMessage->encode(); |
|
| 167 | - $mimeHeaders = $output['headers']; |
|
| 168 | - |
|
| 169 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | - $this->debug("MIME header $k: $v");
|
|
| 171 | - if (strtolower($k) == 'content-type') {
|
|
| 172 | - // PHP header() seems to strip leading whitespace starting |
|
| 173 | - // the second line, so force everything to one line |
|
| 174 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return $output['body']; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return parent::getHTTPBody($soapmsg); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * gets the HTTP content type for the current request. |
|
| 186 | - * |
|
| 187 | - * Note: getHTTPBody must be called before this. |
|
| 188 | - * |
|
| 189 | - * @return string the HTTP content type for the current request. |
|
| 190 | - * @access private |
|
| 191 | - */ |
|
| 192 | - function getHTTPContentType() {
|
|
| 193 | - if (count($this->requestAttachments) > 0) {
|
|
| 194 | - return $this->mimeContentType; |
|
| 195 | - } |
|
| 196 | - return parent::getHTTPContentType(); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * gets the HTTP content type charset for the current request. |
|
| 201 | - * returns false for non-text content types. |
|
| 202 | - * |
|
| 203 | - * Note: getHTTPBody must be called before this. |
|
| 204 | - * |
|
| 205 | - * @return string the HTTP content type charset for the current request. |
|
| 206 | - * @access private |
|
| 207 | - */ |
|
| 208 | - function getHTTPContentTypeCharset() {
|
|
| 209 | - if (count($this->requestAttachments) > 0) {
|
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - return parent::getHTTPContentTypeCharset(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * processes SOAP message returned from server |
|
| 217 | - * |
|
| 218 | - * @param array $headers The HTTP headers |
|
| 219 | - * @param string $data unprocessed response data from server |
|
| 220 | - * @return mixed value of the message, decoded into a PHP type |
|
| 221 | - * @access private |
|
| 222 | - */ |
|
| 55 | + /** |
|
| 56 | + * @var array Each array element in the return is an associative array with keys |
|
| 57 | + * data, filename, contenttype, cid |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $requestAttachments = array(); |
|
| 61 | + /** |
|
| 62 | + * @var array Each array element in the return is an associative array with keys |
|
| 63 | + * data, filename, contenttype, cid |
|
| 64 | + * @access private |
|
| 65 | + */ |
|
| 66 | + var $responseAttachments; |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $mimeContentType; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * adds a MIME attachment to the current request. |
|
| 75 | + * |
|
| 76 | + * If the $data parameter contains an empty string, this method will read |
|
| 77 | + * the contents of the file named by the $filename parameter. |
|
| 78 | + * |
|
| 79 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | + * |
|
| 81 | + * @param string $data The data of the attachment |
|
| 82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | + * @return string The content-id (cid) of the attachment |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | + if (! $cid) {
|
|
| 90 | + $cid = md5(uniqid(time())); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $info['data'] = $data; |
|
| 94 | + $info['filename'] = $filename; |
|
| 95 | + $info['contenttype'] = $contenttype; |
|
| 96 | + $info['cid'] = $cid; |
|
| 97 | + |
|
| 98 | + $this->requestAttachments[] = $info; |
|
| 99 | + |
|
| 100 | + return $cid; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * clears the MIME attachments for the current request. |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + */ |
|
| 108 | + function clearAttachments() {
|
|
| 109 | + $this->requestAttachments = array(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * gets the MIME attachments from the current response. |
|
| 114 | + * |
|
| 115 | + * Each array element in the return is an associative array with keys |
|
| 116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | + * for addAttachment. |
|
| 118 | + * |
|
| 119 | + * @return array The attachments. |
|
| 120 | + * @access public |
|
| 121 | + */ |
|
| 122 | + function getAttachments() {
|
|
| 123 | + return $this->responseAttachments; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * gets the HTTP body for the current request. |
|
| 128 | + * |
|
| 129 | + * @param string $soapmsg The SOAP payload |
|
| 130 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | + * @access private |
|
| 132 | + */ |
|
| 133 | + function getHTTPBody($soapmsg) {
|
|
| 134 | + if (count($this->requestAttachments) > 0) {
|
|
| 135 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | + unset($params); |
|
| 138 | + |
|
| 139 | + $params['content_type'] = 'text/xml'; |
|
| 140 | + $params['encoding'] = '8bit'; |
|
| 141 | + $params['charset'] = $this->soap_defencoding; |
|
| 142 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 143 | + |
|
| 144 | + foreach ($this->requestAttachments as $att) {
|
|
| 145 | + unset($params); |
|
| 146 | + |
|
| 147 | + $params['content_type'] = $att['contenttype']; |
|
| 148 | + $params['encoding'] = 'base64'; |
|
| 149 | + $params['disposition'] = 'attachment'; |
|
| 150 | + $params['dfilename'] = $att['filename']; |
|
| 151 | + $params['cid'] = $att['cid']; |
|
| 152 | + |
|
| 153 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | + $data = fread($fd, filesize($att['filename'])); |
|
| 156 | + fclose($fd); |
|
| 157 | + } else {
|
|
| 158 | + $data = ''; |
|
| 159 | + } |
|
| 160 | + $mimeMessage->addSubpart($data, $params); |
|
| 161 | + } else {
|
|
| 162 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $output = $mimeMessage->encode(); |
|
| 167 | + $mimeHeaders = $output['headers']; |
|
| 168 | + |
|
| 169 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | + $this->debug("MIME header $k: $v");
|
|
| 171 | + if (strtolower($k) == 'content-type') {
|
|
| 172 | + // PHP header() seems to strip leading whitespace starting |
|
| 173 | + // the second line, so force everything to one line |
|
| 174 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return $output['body']; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return parent::getHTTPBody($soapmsg); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * gets the HTTP content type for the current request. |
|
| 186 | + * |
|
| 187 | + * Note: getHTTPBody must be called before this. |
|
| 188 | + * |
|
| 189 | + * @return string the HTTP content type for the current request. |
|
| 190 | + * @access private |
|
| 191 | + */ |
|
| 192 | + function getHTTPContentType() {
|
|
| 193 | + if (count($this->requestAttachments) > 0) {
|
|
| 194 | + return $this->mimeContentType; |
|
| 195 | + } |
|
| 196 | + return parent::getHTTPContentType(); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * gets the HTTP content type charset for the current request. |
|
| 201 | + * returns false for non-text content types. |
|
| 202 | + * |
|
| 203 | + * Note: getHTTPBody must be called before this. |
|
| 204 | + * |
|
| 205 | + * @return string the HTTP content type charset for the current request. |
|
| 206 | + * @access private |
|
| 207 | + */ |
|
| 208 | + function getHTTPContentTypeCharset() {
|
|
| 209 | + if (count($this->requestAttachments) > 0) {
|
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + return parent::getHTTPContentTypeCharset(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * processes SOAP message returned from server |
|
| 217 | + * |
|
| 218 | + * @param array $headers The HTTP headers |
|
| 219 | + * @param string $data unprocessed response data from server |
|
| 220 | + * @return mixed value of the message, decoded into a PHP type |
|
| 221 | + * @access private |
|
| 222 | + */ |
|
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | - $this->responseAttachments = array(); |
|
| 226 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | - $this->debug('Decode multipart/related');
|
|
| 228 | - $input = ''; |
|
| 229 | - foreach ($headers as $k => $v) {
|
|
| 230 | - $input .= "$k: $v\r\n"; |
|
| 231 | - } |
|
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 233 | - $params['include_bodies'] = true; |
|
| 234 | - $params['decode_bodies'] = true; |
|
| 235 | - $params['decode_headers'] = true; |
|
| 236 | - |
|
| 237 | - $structure = Mail_mimeDecode::decode($params); |
|
| 238 | - |
|
| 239 | - foreach ($structure->parts as $part) {
|
|
| 240 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | - $root = $part->body; |
|
| 243 | - $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | - } else {
|
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | - $info['data'] = $part->body; |
|
| 247 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | - $info['cid'] = $part->headers['content-id']; |
|
| 250 | - $this->responseAttachments[] = $info; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - if (isset($return)) {
|
|
| 255 | - $this->responseData = $root; |
|
| 256 | - return $return; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - $this->setError('No root part found in multipart/related content');
|
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - $this->debug('Not multipart/related');
|
|
| 263 | - return parent::parseResponse($headers, $data); |
|
| 264 | - } |
|
| 224 | + $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | + $this->responseAttachments = array(); |
|
| 226 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | + $this->debug('Decode multipart/related');
|
|
| 228 | + $input = ''; |
|
| 229 | + foreach ($headers as $k => $v) {
|
|
| 230 | + $input .= "$k: $v\r\n"; |
|
| 231 | + } |
|
| 232 | + $params['input'] = $input . "\r\n" . $data; |
|
| 233 | + $params['include_bodies'] = true; |
|
| 234 | + $params['decode_bodies'] = true; |
|
| 235 | + $params['decode_headers'] = true; |
|
| 236 | + |
|
| 237 | + $structure = Mail_mimeDecode::decode($params); |
|
| 238 | + |
|
| 239 | + foreach ($structure->parts as $part) {
|
|
| 240 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | + $root = $part->body; |
|
| 243 | + $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | + } else {
|
|
| 245 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | + $info['data'] = $part->body; |
|
| 247 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | + $info['cid'] = $part->headers['content-id']; |
|
| 250 | + $this->responseAttachments[] = $info; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + if (isset($return)) {
|
|
| 255 | + $this->responseData = $root; |
|
| 256 | + return $return; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + $this->setError('No root part found in multipart/related content');
|
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + $this->debug('Not multipart/related');
|
|
| 263 | + return parent::parseResponse($headers, $data); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /* |
| 268 | 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. |
| 269 | 269 | */ |
| 270 | 270 | if (!extension_loaded('soap')) {
|
| 271 | - class soapclientmime extends nusoap_client_mime {
|
|
| 272 | - } |
|
| 271 | + class soapclientmime extends nusoap_client_mime {
|
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,214 +282,214 @@ discard block |
||
| 282 | 282 | * @access public |
| 283 | 283 | */ |
| 284 | 284 | class nusoap_server_mime extends nusoap_server {
|
| 285 | - /** |
|
| 286 | - * @var array Each array element in the return is an associative array with keys |
|
| 287 | - * data, filename, contenttype, cid |
|
| 288 | - * @access private |
|
| 289 | - */ |
|
| 290 | - var $requestAttachments = array(); |
|
| 291 | - /** |
|
| 292 | - * @var array Each array element in the return is an associative array with keys |
|
| 293 | - * data, filename, contenttype, cid |
|
| 294 | - * @access private |
|
| 295 | - */ |
|
| 296 | - var $responseAttachments; |
|
| 297 | - /** |
|
| 298 | - * @var string |
|
| 299 | - * @access private |
|
| 300 | - */ |
|
| 301 | - var $mimeContentType; |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * adds a MIME attachment to the current response. |
|
| 305 | - * |
|
| 306 | - * If the $data parameter contains an empty string, this method will read |
|
| 307 | - * the contents of the file named by the $filename parameter. |
|
| 308 | - * |
|
| 309 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | - * |
|
| 311 | - * @param string $data The data of the attachment |
|
| 312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | - * @return string The content-id (cid) of the attachment |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 318 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | - if (! $cid) {
|
|
| 320 | - $cid = md5(uniqid(time())); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $info['data'] = $data; |
|
| 324 | - $info['filename'] = $filename; |
|
| 325 | - $info['contenttype'] = $contenttype; |
|
| 326 | - $info['cid'] = $cid; |
|
| 327 | - |
|
| 328 | - $this->responseAttachments[] = $info; |
|
| 329 | - |
|
| 330 | - return $cid; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * clears the MIME attachments for the current response. |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - */ |
|
| 338 | - function clearAttachments() {
|
|
| 339 | - $this->responseAttachments = array(); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * gets the MIME attachments from the current request. |
|
| 344 | - * |
|
| 345 | - * Each array element in the return is an associative array with keys |
|
| 346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | - * for addAttachment. |
|
| 348 | - * |
|
| 349 | - * @return array The attachments. |
|
| 350 | - * @access public |
|
| 351 | - */ |
|
| 352 | - function getAttachments() {
|
|
| 353 | - return $this->requestAttachments; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * gets the HTTP body for the current response. |
|
| 358 | - * |
|
| 359 | - * @param string $soapmsg The SOAP payload |
|
| 360 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | - * @access private |
|
| 362 | - */ |
|
| 363 | - function getHTTPBody($soapmsg) {
|
|
| 364 | - if (count($this->responseAttachments) > 0) {
|
|
| 365 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | - unset($params); |
|
| 368 | - |
|
| 369 | - $params['content_type'] = 'text/xml'; |
|
| 370 | - $params['encoding'] = '8bit'; |
|
| 371 | - $params['charset'] = $this->soap_defencoding; |
|
| 372 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 373 | - |
|
| 374 | - foreach ($this->responseAttachments as $att) {
|
|
| 375 | - unset($params); |
|
| 376 | - |
|
| 377 | - $params['content_type'] = $att['contenttype']; |
|
| 378 | - $params['encoding'] = 'base64'; |
|
| 379 | - $params['disposition'] = 'attachment'; |
|
| 380 | - $params['dfilename'] = $att['filename']; |
|
| 381 | - $params['cid'] = $att['cid']; |
|
| 382 | - |
|
| 383 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | - $data = fread($fd, filesize($att['filename'])); |
|
| 386 | - fclose($fd); |
|
| 387 | - } else {
|
|
| 388 | - $data = ''; |
|
| 389 | - } |
|
| 390 | - $mimeMessage->addSubpart($data, $params); |
|
| 391 | - } else {
|
|
| 392 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $output = $mimeMessage->encode(); |
|
| 397 | - $mimeHeaders = $output['headers']; |
|
| 398 | - |
|
| 399 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | - $this->debug("MIME header $k: $v");
|
|
| 401 | - if (strtolower($k) == 'content-type') {
|
|
| 402 | - // PHP header() seems to strip leading whitespace starting |
|
| 403 | - // the second line, so force everything to one line |
|
| 404 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - return $output['body']; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return parent::getHTTPBody($soapmsg); |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * gets the HTTP content type for the current response. |
|
| 416 | - * |
|
| 417 | - * Note: getHTTPBody must be called before this. |
|
| 418 | - * |
|
| 419 | - * @return string the HTTP content type for the current response. |
|
| 420 | - * @access private |
|
| 421 | - */ |
|
| 422 | - function getHTTPContentType() {
|
|
| 423 | - if (count($this->responseAttachments) > 0) {
|
|
| 424 | - return $this->mimeContentType; |
|
| 425 | - } |
|
| 426 | - return parent::getHTTPContentType(); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * gets the HTTP content type charset for the current response. |
|
| 431 | - * returns false for non-text content types. |
|
| 432 | - * |
|
| 433 | - * Note: getHTTPBody must be called before this. |
|
| 434 | - * |
|
| 435 | - * @return string the HTTP content type charset for the current response. |
|
| 436 | - * @access private |
|
| 437 | - */ |
|
| 438 | - function getHTTPContentTypeCharset() {
|
|
| 439 | - if (count($this->responseAttachments) > 0) {
|
|
| 440 | - return false; |
|
| 441 | - } |
|
| 442 | - return parent::getHTTPContentTypeCharset(); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * processes SOAP message received from client |
|
| 447 | - * |
|
| 448 | - * @param array $headers The HTTP headers |
|
| 449 | - * @param string $data unprocessed request data from client |
|
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 451 | - * @access private |
|
| 452 | - */ |
|
| 285 | + /** |
|
| 286 | + * @var array Each array element in the return is an associative array with keys |
|
| 287 | + * data, filename, contenttype, cid |
|
| 288 | + * @access private |
|
| 289 | + */ |
|
| 290 | + var $requestAttachments = array(); |
|
| 291 | + /** |
|
| 292 | + * @var array Each array element in the return is an associative array with keys |
|
| 293 | + * data, filename, contenttype, cid |
|
| 294 | + * @access private |
|
| 295 | + */ |
|
| 296 | + var $responseAttachments; |
|
| 297 | + /** |
|
| 298 | + * @var string |
|
| 299 | + * @access private |
|
| 300 | + */ |
|
| 301 | + var $mimeContentType; |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * adds a MIME attachment to the current response. |
|
| 305 | + * |
|
| 306 | + * If the $data parameter contains an empty string, this method will read |
|
| 307 | + * the contents of the file named by the $filename parameter. |
|
| 308 | + * |
|
| 309 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | + * |
|
| 311 | + * @param string $data The data of the attachment |
|
| 312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | + * @return string The content-id (cid) of the attachment |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | + if (! $cid) {
|
|
| 320 | + $cid = md5(uniqid(time())); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $info['data'] = $data; |
|
| 324 | + $info['filename'] = $filename; |
|
| 325 | + $info['contenttype'] = $contenttype; |
|
| 326 | + $info['cid'] = $cid; |
|
| 327 | + |
|
| 328 | + $this->responseAttachments[] = $info; |
|
| 329 | + |
|
| 330 | + return $cid; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * clears the MIME attachments for the current response. |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + */ |
|
| 338 | + function clearAttachments() {
|
|
| 339 | + $this->responseAttachments = array(); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * gets the MIME attachments from the current request. |
|
| 344 | + * |
|
| 345 | + * Each array element in the return is an associative array with keys |
|
| 346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | + * for addAttachment. |
|
| 348 | + * |
|
| 349 | + * @return array The attachments. |
|
| 350 | + * @access public |
|
| 351 | + */ |
|
| 352 | + function getAttachments() {
|
|
| 353 | + return $this->requestAttachments; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * gets the HTTP body for the current response. |
|
| 358 | + * |
|
| 359 | + * @param string $soapmsg The SOAP payload |
|
| 360 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | + * @access private |
|
| 362 | + */ |
|
| 363 | + function getHTTPBody($soapmsg) {
|
|
| 364 | + if (count($this->responseAttachments) > 0) {
|
|
| 365 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | + unset($params); |
|
| 368 | + |
|
| 369 | + $params['content_type'] = 'text/xml'; |
|
| 370 | + $params['encoding'] = '8bit'; |
|
| 371 | + $params['charset'] = $this->soap_defencoding; |
|
| 372 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 373 | + |
|
| 374 | + foreach ($this->responseAttachments as $att) {
|
|
| 375 | + unset($params); |
|
| 376 | + |
|
| 377 | + $params['content_type'] = $att['contenttype']; |
|
| 378 | + $params['encoding'] = 'base64'; |
|
| 379 | + $params['disposition'] = 'attachment'; |
|
| 380 | + $params['dfilename'] = $att['filename']; |
|
| 381 | + $params['cid'] = $att['cid']; |
|
| 382 | + |
|
| 383 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | + $data = fread($fd, filesize($att['filename'])); |
|
| 386 | + fclose($fd); |
|
| 387 | + } else {
|
|
| 388 | + $data = ''; |
|
| 389 | + } |
|
| 390 | + $mimeMessage->addSubpart($data, $params); |
|
| 391 | + } else {
|
|
| 392 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $output = $mimeMessage->encode(); |
|
| 397 | + $mimeHeaders = $output['headers']; |
|
| 398 | + |
|
| 399 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | + $this->debug("MIME header $k: $v");
|
|
| 401 | + if (strtolower($k) == 'content-type') {
|
|
| 402 | + // PHP header() seems to strip leading whitespace starting |
|
| 403 | + // the second line, so force everything to one line |
|
| 404 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + return $output['body']; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return parent::getHTTPBody($soapmsg); |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * gets the HTTP content type for the current response. |
|
| 416 | + * |
|
| 417 | + * Note: getHTTPBody must be called before this. |
|
| 418 | + * |
|
| 419 | + * @return string the HTTP content type for the current response. |
|
| 420 | + * @access private |
|
| 421 | + */ |
|
| 422 | + function getHTTPContentType() {
|
|
| 423 | + if (count($this->responseAttachments) > 0) {
|
|
| 424 | + return $this->mimeContentType; |
|
| 425 | + } |
|
| 426 | + return parent::getHTTPContentType(); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * gets the HTTP content type charset for the current response. |
|
| 431 | + * returns false for non-text content types. |
|
| 432 | + * |
|
| 433 | + * Note: getHTTPBody must be called before this. |
|
| 434 | + * |
|
| 435 | + * @return string the HTTP content type charset for the current response. |
|
| 436 | + * @access private |
|
| 437 | + */ |
|
| 438 | + function getHTTPContentTypeCharset() {
|
|
| 439 | + if (count($this->responseAttachments) > 0) {
|
|
| 440 | + return false; |
|
| 441 | + } |
|
| 442 | + return parent::getHTTPContentTypeCharset(); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * processes SOAP message received from client |
|
| 447 | + * |
|
| 448 | + * @param array $headers The HTTP headers |
|
| 449 | + * @param string $data unprocessed request data from client |
|
| 450 | + * @return mixed value of the message, decoded into a PHP type |
|
| 451 | + * @access private |
|
| 452 | + */ |
|
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | - $this->requestAttachments = array(); |
|
| 456 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | - $this->debug('Decode multipart/related');
|
|
| 458 | - $input = ''; |
|
| 459 | - foreach ($headers as $k => $v) {
|
|
| 460 | - $input .= "$k: $v\r\n"; |
|
| 461 | - } |
|
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 463 | - $params['include_bodies'] = true; |
|
| 464 | - $params['decode_bodies'] = true; |
|
| 465 | - $params['decode_headers'] = true; |
|
| 466 | - |
|
| 467 | - $structure = Mail_mimeDecode::decode($params); |
|
| 468 | - |
|
| 469 | - foreach ($structure->parts as $part) {
|
|
| 470 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | - $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | - $info['data'] = $part->body; |
|
| 476 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | - $info['cid'] = $part->headers['content-id']; |
|
| 479 | - $this->requestAttachments[] = $info; |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - if (isset($return)) {
|
|
| 484 | - return $return; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - $this->setError('No root part found in multipart/related content');
|
|
| 488 | - return; |
|
| 489 | - } |
|
| 490 | - $this->debug('Not multipart/related');
|
|
| 491 | - return parent::parseRequest($headers, $data); |
|
| 492 | - } |
|
| 454 | + $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | + $this->requestAttachments = array(); |
|
| 456 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | + $this->debug('Decode multipart/related');
|
|
| 458 | + $input = ''; |
|
| 459 | + foreach ($headers as $k => $v) {
|
|
| 460 | + $input .= "$k: $v\r\n"; |
|
| 461 | + } |
|
| 462 | + $params['input'] = $input . "\r\n" . $data; |
|
| 463 | + $params['include_bodies'] = true; |
|
| 464 | + $params['decode_bodies'] = true; |
|
| 465 | + $params['decode_headers'] = true; |
|
| 466 | + |
|
| 467 | + $structure = Mail_mimeDecode::decode($params); |
|
| 468 | + |
|
| 469 | + foreach ($structure->parts as $part) {
|
|
| 470 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | + $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | + $info['data'] = $part->body; |
|
| 476 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | + $info['cid'] = $part->headers['content-id']; |
|
| 479 | + $this->requestAttachments[] = $info; |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + if (isset($return)) {
|
|
| 484 | + return $return; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + $this->setError('No root part found in multipart/related content');
|
|
| 488 | + return; |
|
| 489 | + } |
|
| 490 | + $this->debug('Not multipart/related');
|
|
| 491 | + return parent::parseRequest($headers, $data); |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /* |
@@ -208,6 +208,8 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | /** |
| 210 | 210 | * Gives a list of people online now (and in the last $valid minutes) |
| 211 | + * @param integer $from |
|
| 212 | + * @param integer $time_limit |
|
| 211 | 213 | * @return array For each line, a list of user IDs and login dates, or FALSE on error or empty results |
| 212 | 214 | */ |
| 213 | 215 | function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false) |
@@ -424,6 +426,9 @@ discard block |
||
| 424 | 426 | } |
| 425 | 427 | } |
| 426 | 428 | |
| 429 | +/** |
|
| 430 | + * @param integer $uid |
|
| 431 | + */ |
|
| 427 | 432 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 428 | 433 | { |
| 429 | 434 | if (empty($coursecode)) { |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - //This query will show all registered users. Only for dev purposes. |
|
| 294 | - /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 293 | + //This query will show all registered users. Only for dev purposes. |
|
| 294 | + /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 295 | 295 | GROUP by u.id |
| 296 | 296 | ORDER BY $column $direction |
| 297 | 297 | LIMIT $from, $number_of_items";*/ |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | } else { |
| 318 | 318 | $time_limit = intval($time_limit); |
| 319 | 319 | } |
| 320 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | - $online_time = time() - $time_limit * 60; |
|
| 324 | - $current_date = api_get_utc_datetime($online_time); |
|
| 325 | - |
|
| 326 | - if ($friends) { |
|
| 327 | - // who friends from social network is online |
|
| 328 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 320 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | + $online_time = time() - $time_limit * 60; |
|
| 324 | + $current_date = api_get_utc_datetime($online_time); |
|
| 325 | + |
|
| 326 | + if ($friends) { |
|
| 327 | + // who friends from social network is online |
|
| 328 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 329 | 329 | FROM $track_online_table INNER JOIN $friend_user_table |
| 330 | 330 | ON (friend_user_id = login_user_id) |
| 331 | 331 | WHERE |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | friend_user_id <> '".api_get_user_id()."' AND |
| 334 | 334 | relation_type='".USER_RELATION_TYPE_FRIEND."' AND |
| 335 | 335 | user_id = '".api_get_user_id()."' "; |
| 336 | - } else { |
|
| 337 | - // All users online |
|
| 338 | - $query = "SELECT count(login_id) as count |
|
| 336 | + } else { |
|
| 337 | + // All users online |
|
| 338 | + $query = "SELECT count(login_id) as count |
|
| 339 | 339 | FROM $track_online_table track INNER JOIN $table_user u |
| 340 | 340 | ON (u.id=track.login_user_id) |
| 341 | 341 | WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date' "; |
| 342 | - } |
|
| 343 | - |
|
| 344 | - if (api_get_multiple_access_url()) { |
|
| 345 | - $access_url_id = api_get_current_access_url_id(); |
|
| 346 | - if ($access_url_id != -1) { |
|
| 347 | - if ($friends) { |
|
| 348 | - // friends from social network is online |
|
| 349 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + if (api_get_multiple_access_url()) { |
|
| 345 | + $access_url_id = api_get_current_access_url_id(); |
|
| 346 | + if ($access_url_id != -1) { |
|
| 347 | + if ($friends) { |
|
| 348 | + // friends from social network is online |
|
| 349 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 350 | 350 | FROM $track_online_table track |
| 351 | 351 | INNER JOIN $friend_user_table ON (friend_user_id = login_user_id) |
| 352 | 352 | WHERE |
@@ -354,29 +354,29 @@ discard block |
||
| 354 | 354 | login_date >= '".$current_date."' AND |
| 355 | 355 | friend_user_id <> '".api_get_user_id()."' AND |
| 356 | 356 | relation_type='".USER_RELATION_TYPE_FRIEND."' "; |
| 357 | - } else { |
|
| 358 | - // all users online |
|
| 359 | - $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 357 | + } else { |
|
| 358 | + // all users online |
|
| 359 | + $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 360 | 360 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 361 | 361 | WHERE |
| 362 | 362 | u.status != ".ANONYMOUS." AND |
| 363 | 363 | track.access_url_id = $access_url_id AND |
| 364 | 364 | login_date >= '$current_date' "; |
| 365 | - } |
|
| 366 | - } |
|
| 367 | - } |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | // Dev purposes show all users online |
| 370 | 370 | /*$table_user = Database::get_main_table(TABLE_MAIN_USER); |
| 371 | 371 | $query = "SELECT count(*) as count FROM ".$table_user;*/ |
| 372 | 372 | |
| 373 | - $result = Database::query($query); |
|
| 374 | - if (Database::num_rows($result) > 0) { |
|
| 375 | - $row = Database::fetch_array($result); |
|
| 376 | - return $row['count']; |
|
| 377 | - } else { |
|
| 378 | - return false; |
|
| 379 | - } |
|
| 373 | + $result = Database::query($query); |
|
| 374 | + if (Database::num_rows($result) > 0) { |
|
| 375 | + $row = Database::fetch_array($result); |
|
| 376 | + return $row['count']; |
|
| 377 | + } else { |
|
| 378 | + return false; |
|
| 379 | + } |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | |
@@ -404,52 +404,52 @@ discard block |
||
| 404 | 404 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 405 | 405 | $course_code = Database::escape_string($course_code); |
| 406 | 406 | $courseInfo = api_get_course_info($course_code); |
| 407 | - $courseId = $courseInfo['real_id']; |
|
| 407 | + $courseId = $courseInfo['real_id']; |
|
| 408 | 408 | |
| 409 | 409 | $from = intval($from); |
| 410 | 410 | $number_of_items = intval($number_of_items); |
| 411 | 411 | |
| 412 | - $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 412 | + $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 413 | 413 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' |
| 414 | 414 | LIMIT $from, $number_of_items "; |
| 415 | 415 | |
| 416 | - $result = Database::query($query); |
|
| 417 | - if ($result) { |
|
| 418 | - $users_online = array(); |
|
| 416 | + $result = Database::query($query); |
|
| 417 | + if ($result) { |
|
| 418 | + $users_online = array(); |
|
| 419 | 419 | |
| 420 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 420 | + while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 421 | 421 | $users_online[] = $login_user_id; |
| 422 | - } |
|
| 423 | - return $users_online; |
|
| 424 | - } else { |
|
| 425 | - return false; |
|
| 426 | - } |
|
| 422 | + } |
|
| 423 | + return $users_online; |
|
| 424 | + } else { |
|
| 425 | + return false; |
|
| 426 | + } |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 430 | 430 | { |
| 431 | - if (empty($coursecode)) { |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 435 | - $time_limit = Database::escape_string($time_limit); |
|
| 431 | + if (empty($coursecode)) { |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 435 | + $time_limit = Database::escape_string($time_limit); |
|
| 436 | 436 | |
| 437 | 437 | $online_time = time() - $time_limit * 60; |
| 438 | 438 | $current_date = api_get_utc_datetime($online_time); |
| 439 | - $courseId = api_get_course_int_id($coursecode); |
|
| 439 | + $courseId = api_get_course_int_id($coursecode); |
|
| 440 | 440 | |
| 441 | - if (empty($courseId)) { |
|
| 442 | - return false; |
|
| 443 | - } |
|
| 441 | + if (empty($courseId)) { |
|
| 442 | + return false; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - $query = "SELECT count(login_user_id) as count |
|
| 445 | + $query = "SELECT count(login_user_id) as count |
|
| 446 | 446 | FROM $track_online_table |
| 447 | 447 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' "; |
| 448 | - $result = Database::query($query); |
|
| 449 | - if (Database::num_rows($result) > 0) { |
|
| 450 | - $row = Database::fetch_array($result); |
|
| 451 | - return $row['count']; |
|
| 452 | - } else { |
|
| 453 | - return false; |
|
| 454 | - } |
|
| 448 | + $result = Database::query($query); |
|
| 449 | + if (Database::num_rows($result) > 0) { |
|
| 450 | + $row = Database::fetch_array($result); |
|
| 451 | + return $row['count']; |
|
| 452 | + } else { |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 455 | 455 | } |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $login_date = api_get_utc_datetime(); |
| 34 | 34 | $access_url_id = 1; |
| 35 | - if (api_get_multiple_access_url() && api_get_current_access_url_id()!=-1) { |
|
| 35 | + if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) { |
|
| 36 | 36 | $access_url_id = api_get_current_access_url_id(); |
| 37 | 37 | } |
| 38 | 38 | $session_id = api_get_session_id(); |
| 39 | 39 | // if the $_course array exists this means we are in a course and we have to store this in the who's online table also |
| 40 | 40 | // to have the x users in this course feature working |
| 41 | - if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) { |
|
| 42 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 41 | + if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) { |
|
| 42 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 43 | 43 | VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; |
| 44 | 44 | } else { |
| 45 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 45 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 46 | 46 | VALUES ($uid,$uid,'$login_date','$user_ip', 0, '$session_id', '$access_url_id')"; |
| 47 | 47 | } |
| 48 | 48 | Database::query($query); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $isFirstLogin = Session::read('first_user_login'); |
| 63 | 63 | if (empty($isFirstLogin)) { |
| 64 | 64 | $sql = "SELECT login_id FROM $table |
| 65 | - WHERE login_user_id = " . $userId . " LIMIT 1"; |
|
| 65 | + WHERE login_user_id = ".$userId." LIMIT 1"; |
|
| 66 | 66 | |
| 67 | 67 | $result = Database::query($sql); |
| 68 | 68 | $loginData = array(); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | ORDER BY login_date DESC |
| 117 | 117 | LIMIT 0,1"; |
| 118 | 118 | $q_last_connection = Database::query($sql); |
| 119 | - if (Database::num_rows($q_last_connection)>0) { |
|
| 119 | + if (Database::num_rows($q_last_connection) > 0) { |
|
| 120 | 120 | $i_id_last_connection = Database::result($q_last_connection, 0, "login_id"); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 168 | 168 | $user_id = intval($user_id); |
| 169 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 169 | + $query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id"; |
|
| 170 | 170 | Database::query($query); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $access_url_id = api_get_current_access_url_id(); |
| 183 | 183 | $time_limit = api_get_setting('time_limit_whosonline'); |
| 184 | 184 | |
| 185 | - $online_time = time() - $time_limit*60; |
|
| 185 | + $online_time = time() - $time_limit * 60; |
|
| 186 | 186 | $limit_date = api_get_utc_datetime($online_time); |
| 187 | 187 | $user_id = intval($user_id); |
| 188 | 188 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $current_date = api_get_utc_datetime($online_time); |
| 240 | 240 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 241 | 241 | $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
| 242 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 242 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 243 | 243 | |
| 244 | 244 | if ($friends) { |
| 245 | 245 | // who friends from social network is online |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | LIMIT $from, $number_of_items"; |
| 256 | 256 | } else { |
| 257 | 257 | $query = "SELECT DISTINCT login_user_id, login_date |
| 258 | - FROM ".$track_online_table ." e |
|
| 259 | - INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
|
| 258 | + FROM ".$track_online_table." e |
|
| 259 | + INNER JOIN ".$table_user." u ON (u.id = e.login_user_id) |
|
| 260 | 260 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 261 | 261 | ORDER BY $column $direction |
| 262 | 262 | LIMIT $from, $number_of_items"; |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | } else { |
| 280 | 280 | // all users online |
| 281 | 281 | $query = "SELECT login_user_id, login_date |
| 282 | - FROM ".$track_online_table ." track |
|
| 283 | - INNER JOIN ".$table_user ." u |
|
| 282 | + FROM ".$track_online_table." track |
|
| 283 | + INNER JOIN ".$table_user." u |
|
| 284 | 284 | ON (u.id=track.login_user_id) |
| 285 | 285 | WHERE u.status != ".ANONYMOUS." AND track.access_url_id = $access_url_id AND |
| 286 | 286 | login_date >= '".$current_date."' |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if ($result) { |
| 418 | 418 | $users_online = array(); |
| 419 | 419 | |
| 420 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 420 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 421 | 421 | $users_online[] = $login_user_id; |
| 422 | 422 | } |
| 423 | 423 | return $users_online; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | -function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
|
| 429 | +function who_is_online_in_this_course_count($uid, $time_limit, $coursecode = null) |
|
| 430 | 430 | { |
| 431 | 431 | if (empty($coursecode)) { |
| 432 | 432 | return false; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Returns the contents of the CSS defined by the plugin |
| 146 | - * @return array |
|
| 146 | + * @return string |
|
| 147 | 147 | */ |
| 148 | 148 | public function get_css() |
| 149 | 149 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Returns an HTML form (generated by FormValidator) of the plugin settings |
| 164 | - * @return string FormValidator-generated form |
|
| 164 | + * @return FormValidator FormValidator-generated form |
|
| 165 | 165 | */ |
| 166 | 166 | public function get_settings_form() |
| 167 | 167 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param boolean $add_tool_link Whether to add a tool link or not |
| 384 | 384 | * (some tools might just offer a configuration section and act on the backend) |
| 385 | 385 | * |
| 386 | - * @return boolean False on error, null otherwise |
|
| 386 | + * @return boolean|null False on error, null otherwise |
|
| 387 | 387 | */ |
| 388 | 388 | public function install_course_fields($courseId, $add_tool_link = true) |
| 389 | 389 | { |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * tool on the course's homepage |
| 492 | 492 | * @param int $courseId |
| 493 | 493 | * |
| 494 | - * @return void |
|
| 494 | + * @return false|null |
|
| 495 | 495 | */ |
| 496 | 496 | public function uninstall_course_fields($courseId) |
| 497 | 497 | { |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param string $tabName |
| 597 | 597 | * @param string $url |
| 598 | 598 | * |
| 599 | - * @return boolean |
|
| 599 | + * @return false|string |
|
| 600 | 600 | */ |
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
@@ -591,13 +591,13 @@ |
||
| 591 | 591 | |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Add a tab to platform |
|
| 596 | - * @param string $tabName |
|
| 597 | - * @param string $url |
|
| 598 | - * |
|
| 599 | - * @return boolean |
|
| 600 | - */ |
|
| 594 | + /** |
|
| 595 | + * Add a tab to platform |
|
| 596 | + * @param string $tabName |
|
| 597 | + * @param string $url |
|
| 598 | + * |
|
| 599 | + * @return boolean |
|
| 600 | + */ |
|
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
| 603 | 603 | $sql = "SELECT * FROM settings_current |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->fields = $settings; |
| 61 | 61 | |
| 62 | 62 | global $language_files; |
| 63 | - $language_files[] = 'plugin_' . $this->get_name(); |
|
| 63 | + $language_files[] = 'plugin_'.$this->get_name(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $settings = $this->get_settings(); |
| 270 | 270 | foreach ($settings as $setting) { |
| 271 | - if ($setting['variable'] == $this->get_name() . '_' . $name) { |
|
| 271 | + if ($setting['variable'] == $this->get_name().'_'.$name) { |
|
| 272 | 272 | |
| 273 | 273 | return $setting['selected_value']; |
| 274 | 274 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if (!empty($this->course_settings)) { |
| 405 | 405 | foreach ($this->course_settings as $setting) { |
| 406 | 406 | $variable = $setting['name']; |
| 407 | - $value =''; |
|
| 407 | + $value = ''; |
|
| 408 | 408 | if (isset($setting['init_value'])) { |
| 409 | 409 | $value = $setting['init_value']; |
| 410 | 410 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | // Avoid Tab Name Spaces |
| 620 | 620 | $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName); |
| 621 | - $subkeytext = "Tabs" . $tabNameNoSpaces; |
|
| 621 | + $subkeytext = "Tabs".$tabNameNoSpaces; |
|
| 622 | 622 | |
| 623 | 623 | // Check if it is already added |
| 624 | 624 | $checkCondition = array( |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // End Check |
| 640 | - $subkey = 'custom_tab_' . $tabNum; |
|
| 640 | + $subkey = 'custom_tab_'.$tabNum; |
|
| 641 | 641 | $attributes = array( |
| 642 | 642 | 'variable' => 'show_tabs', |
| 643 | 643 | 'subkey' => $subkey, |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | // Save the id |
| 657 | 657 | $settings = $this->get_settings(); |
| 658 | - $setData = array ( |
|
| 658 | + $setData = array( |
|
| 659 | 659 | 'comment' => $subkey |
| 660 | 660 | ); |
| 661 | 661 | $whereCondition = array( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | $i = 1; |
| 697 | 697 | foreach ($tabs as $row) { |
| 698 | 698 | $attributes = array( |
| 699 | - 'subkey' => 'custom_tab_' . $i |
|
| 699 | + 'subkey' => 'custom_tab_'.$i |
|
| 700 | 700 | ); |
| 701 | 701 | $this->updateTab($row['subkey'], $attributes); |
| 702 | 702 | $i++; |
@@ -626,7 +626,7 @@ |
||
| 626 | 626 | |
| 627 | 627 | /** |
| 628 | 628 | * Get first SMS plugin name |
| 629 | - * @return string|boolean |
|
| 629 | + * @return string|false |
|
| 630 | 630 | */ |
| 631 | 631 | public function getSMSPluginName() |
| 632 | 632 | { |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | - * @param string $pluginName |
|
| 177 | - * @param int $urlId |
|
| 178 | - */ |
|
| 176 | + * @param string $pluginName |
|
| 177 | + * @param int $urlId |
|
| 178 | + */ |
|
| 179 | 179 | public function uninstall($pluginName, $urlId = null) |
| 180 | 180 | { |
| 181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @param string $region |
|
| 256 | - * @param string $template |
|
| 257 | - * @param bool $forced |
|
| 258 | - * |
|
| 259 | - * @return null|string |
|
| 260 | - */ |
|
| 255 | + * @param string $region |
|
| 256 | + * @param string $template |
|
| 257 | + * @param bool $forced |
|
| 258 | + * |
|
| 259 | + * @return null|string |
|
| 260 | + */ |
|
| 261 | 261 | public function load_region($region, $template, $forced = false) |
| 262 | 262 | { |
| 263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | // Extra options |
| 427 | 427 | $plugin_settings = api_get_settings_params( |
| 428 | 428 | array( |
| 429 | - "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting') |
|
| 429 | + "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') |
|
| 430 | 430 | ) |
| 431 | 431 | ); |
| 432 | 432 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | if (!empty($obj->course_settings)) { |
| 533 | 533 | if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$plugin_name.'.png')) { |
| 534 | 534 | $icon = Display::return_icon( |
| 535 | - $plugin_name . '.png', |
|
| 535 | + $plugin_name.'.png', |
|
| 536 | 536 | Security::remove_XSS($pluginTitle), |
| 537 | 537 | '', |
| 538 | 538 | ICON_SIZE_SMALL |
@@ -548,18 +548,18 @@ discard block |
||
| 548 | 548 | |
| 549 | 549 | $form->addHtml('<div class="panel panel-default">'); |
| 550 | 550 | $form->addHtml(' |
| 551 | - <div class="panel-heading" role="tab" id="heading-' . $plugin_name . '-settings"> |
|
| 551 | + <div class="panel-heading" role="tab" id="heading-' . $plugin_name.'-settings"> |
|
| 552 | 552 | <h4 class="panel-title"> |
| 553 | - <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name . '-settings" aria-expanded="false" aria-controls="collapse-' . $plugin_name . '-settings"> |
|
| 553 | + <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name.'-settings" aria-expanded="false" aria-controls="collapse-'.$plugin_name.'-settings"> |
|
| 554 | 554 | '); |
| 555 | - $form->addHtml($icon . ' ' . $pluginTitle); |
|
| 555 | + $form->addHtml($icon.' '.$pluginTitle); |
|
| 556 | 556 | $form->addHtml(' |
| 557 | 557 | </a> |
| 558 | 558 | </h4> |
| 559 | 559 | </div> |
| 560 | 560 | '); |
| 561 | 561 | $form->addHtml(' |
| 562 | - <div id="collapse-' . $plugin_name . '-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-' . $plugin_name . '-settings"> |
|
| 562 | + <div id="collapse-' . $plugin_name.'-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$plugin_name.'-settings"> |
|
| 563 | 563 | <div class="panel-body"> |
| 564 | 564 | '); |
| 565 | 565 | |
@@ -126,6 +126,7 @@ discard block |
||
| 126 | 126 | * Returns a temporary url to download files and/or folders. |
| 127 | 127 | * |
| 128 | 128 | * @param string|array $ids |
| 129 | + * @param string $tool |
|
| 129 | 130 | * @return string |
| 130 | 131 | */ |
| 131 | 132 | public static function download_url($ids, $tool) |
@@ -293,7 +294,7 @@ discard block |
||
| 293 | 294 | /** |
| 294 | 295 | * The name of the porfolio where to send. |
| 295 | 296 | * |
| 296 | - * @return type |
|
| 297 | + * @return string |
|
| 297 | 298 | */ |
| 298 | 299 | function get_portfolio() |
| 299 | 300 | { |
@@ -391,7 +392,6 @@ discard block |
||
| 391 | 392 | * Create a "send to portfolio" button |
| 392 | 393 | * |
| 393 | 394 | * @param string $tool The name of the tool: document, work. |
| 394 | - * @param int $c_id The id of the course |
|
| 395 | 395 | * @param int $id The id of the object |
| 396 | 396 | * @param array $attributes Html attributes |
| 397 | 397 | * @return \PortfolioShare |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | /** |
| 406 | 406 | * Returns the current secuirty token. Used to avoid see surfing attacks. |
| 407 | 407 | * |
| 408 | - * @return type |
|
| 408 | + * @return string |
|
| 409 | 409 | */ |
| 410 | 410 | static function security_token() |
| 411 | 411 | { |
@@ -420,6 +420,10 @@ discard block |
||
| 420 | 420 | protected $attributes = array(); |
| 421 | 421 | protected $tool = ''; |
| 422 | 422 | |
| 423 | + /** |
|
| 424 | + * @param string $tool |
|
| 425 | + * @param integer $id |
|
| 426 | + */ |
|
| 423 | 427 | function __construct($tool, $id, $attributes = array()) |
| 424 | 428 | { |
| 425 | 429 | $this->tool = $tool; |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | $attributes['z-index'] = 100000; |
| 483 | 483 | $s = ' '; |
| 484 | 484 | foreach ($attributes as $key => $value) { |
| 485 | - $s .= $key . '="' . $value . '" '; |
|
| 485 | + $s .= $key.'="'.$value.'" '; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | $result = array(); |
| 489 | - $result[] = '<span ' . $s . ' >'; |
|
| 489 | + $result[] = '<span '.$s.' >'; |
|
| 490 | 490 | $result[] = '<span class="dropdown" >'; |
| 491 | 491 | $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">'; |
| 492 | - $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>'; |
|
| 492 | + $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL).'<b class="caret"></b>'; |
|
| 493 | 493 | $result[] = '</a>'; |
| 494 | 494 | $result[] = '<ul class="dropdown-menu">'; |
| 495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | $parameters[PortfolioController::PARAM_TOOL] = $tool; |
| 506 | 506 | $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; |
| 507 | 507 | $result[] = '<li>'; |
| 508 | - $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>'; |
|
| 508 | + $result[] = '<a href="'.$url.'">'.$portfolio->get_title().'</a>'; |
|
| 509 | 509 | $result[] = '</li>'; |
| 510 | 510 | } |
| 511 | 511 | $result[] = '</ul>'; |
@@ -564,8 +564,8 @@ discard block |
||
| 564 | 564 | */ |
| 565 | 565 | public function __construct($portfolio) |
| 566 | 566 | { |
| 567 | - $this->name = md5(__CLASS__) . '_' . $portfolio->get_name(); |
|
| 568 | - $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo') . ' ' . $portfolio->get_name(); |
|
| 567 | + $this->name = md5(__CLASS__).'_'.$portfolio->get_name(); |
|
| 568 | + $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo').' '.$portfolio->get_name(); |
|
| 569 | 569 | $this->portfolio = $portfolio; |
| 570 | 570 | } |
| 571 | 571 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @return array |
|
| 132 | + * @return string[] |
|
| 133 | 133 | */ |
| 134 | 134 | public function get_status_list() |
| 135 | 135 | { |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | /** |
| 273 | 273 | * @param int $id |
| 274 | 274 | * |
| 275 | - * @return bool |
|
| 275 | + * @return null|false |
|
| 276 | 276 | */ |
| 277 | 277 | public function delete($id) |
| 278 | 278 | { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | case 'updated_at': |
| 64 | 64 | break; |
| 65 | 65 | case 'name': |
| 66 | - $val .= ' ' . get_lang('CopyLabelSuffix'); |
|
| 66 | + $val .= ' '.get_lang('CopyLabelSuffix'); |
|
| 67 | 67 | $new[$key] = $val; |
| 68 | 68 | break; |
| 69 | 69 | case 'created_at': |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | break; |
| 73 | 73 | case 'career_id': |
| 74 | 74 | if (!empty($career_id)) { |
| 75 | - $val = (int)$career_id; |
|
| 75 | + $val = (int) $career_id; |
|
| 76 | 76 | } |
| 77 | 77 | $new[$key] = $val; |
| 78 | 78 | break; |
@@ -160,22 +160,22 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | // Action links |
| 162 | 162 | echo '<div class="actions" style="margin-bottom:20px">'; |
| 163 | - echo '<a href="career_dashboard.php">' . Display::return_icon('back.png', |
|
| 164 | - get_lang('Back'), '', '32') . '</a>'; |
|
| 165 | - echo '<a href="' . api_get_self() . '?action=add">' . |
|
| 163 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', |
|
| 164 | + get_lang('Back'), '', '32').'</a>'; |
|
| 165 | + echo '<a href="'.api_get_self().'?action=add">'. |
|
| 166 | 166 | Display::return_icon( |
| 167 | 167 | 'new_promotion.png', |
| 168 | 168 | get_lang('Add'), |
| 169 | 169 | '', |
| 170 | 170 | '32' |
| 171 | - ) . '</a>'; |
|
| 172 | - echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_add.php">' . |
|
| 171 | + ).'</a>'; |
|
| 172 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'. |
|
| 173 | 173 | Display::return_icon( |
| 174 | 174 | 'new_session.png', |
| 175 | 175 | get_lang('AddSession'), |
| 176 | 176 | '', |
| 177 | 177 | '32' |
| 178 | - ) . '</a>'; |
|
| 178 | + ).'</a>'; |
|
| 179 | 179 | echo '</div>'; |
| 180 | 180 | echo Display::grid_html('promotions'); |
| 181 | 181 | } |
@@ -15,6 +15,10 @@ |
||
| 15 | 15 | |
| 16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
| 17 | 17 | // thus default return value is always true |
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @param string $handler |
|
| 21 | + */ |
|
| 18 | 22 | public static function hasRight($handler) { |
| 19 | 23 | if (array_key_exists($handler, self::$rights_cache)) |
| 20 | 24 | return self::$rights_cache[$handler]; |
@@ -5,42 +5,42 @@ |
||
| 5 | 5 | * @deprecated Don't use this class |
| 6 | 6 | */ |
| 7 | 7 | class Rights { |
| 8 | - private static $rights_cache = array(); |
|
| 9 | - private static $rights = array ( |
|
| 10 | - 'show_tabs:reports' => |
|
| 11 | - array ( |
|
| 12 | - 'type' => 'const', |
|
| 13 | - 'const' => 'true' ) |
|
| 14 | - ); |
|
| 8 | + private static $rights_cache = array(); |
|
| 9 | + private static $rights = array ( |
|
| 10 | + 'show_tabs:reports' => |
|
| 11 | + array ( |
|
| 12 | + 'type' => 'const', |
|
| 13 | + 'const' => 'true' ) |
|
| 14 | + ); |
|
| 15 | 15 | |
| 16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
| 17 | - // thus default return value is always true |
|
| 18 | - public static function hasRight($handler) { |
|
| 19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | - return self::$rights_cache[$handler]; |
|
| 16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
| 17 | + // thus default return value is always true |
|
| 18 | + public static function hasRight($handler) { |
|
| 19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | + return self::$rights_cache[$handler]; |
|
| 21 | 21 | |
| 22 | - if (!array_key_exists($handler, self::$rights)) |
|
| 23 | - return true; // handler does not exists |
|
| 22 | + if (!array_key_exists($handler, self::$rights)) |
|
| 23 | + return true; // handler does not exists |
|
| 24 | 24 | |
| 25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
| 26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
| 27 | - if (Database::num_rows($result) > 0) |
|
| 28 | - $result = true; |
|
| 29 | - else |
|
| 30 | - $result = false; |
|
| 31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | - $result = self::$rights[$handler]['const']; |
|
| 33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | - $result = self::$rights[$handler]['func'](); |
|
| 35 | - else // handler type not implemented |
|
| 36 | - return true; |
|
| 37 | - self::$rights_cache[$handler] = $result; |
|
| 38 | - return $result; |
|
| 39 | - } |
|
| 25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
| 26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
| 27 | + if (Database::num_rows($result) > 0) |
|
| 28 | + $result = true; |
|
| 29 | + else |
|
| 30 | + $result = false; |
|
| 31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | + $result = self::$rights[$handler]['const']; |
|
| 33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | + $result = self::$rights[$handler]['func'](); |
|
| 35 | + else // handler type not implemented |
|
| 36 | + return true; |
|
| 37 | + self::$rights_cache[$handler] = $result; |
|
| 38 | + return $result; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public static function hasRightClosePageWithError($handler) { |
|
| 42 | - if (hasRight($handler) == false) |
|
| 43 | - die("You are not allowed here"); //FIXME |
|
| 44 | - } |
|
| 41 | + public static function hasRightClosePageWithError($handler) { |
|
| 42 | + if (hasRight($handler) == false) |
|
| 43 | + die("You are not allowed here"); //FIXME |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class Rights { |
| 8 | 8 | private static $rights_cache = array(); |
| 9 | - private static $rights = array ( |
|
| 9 | + private static $rights = array( |
|
| 10 | 10 | 'show_tabs:reports' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'type' => 'const', |
| 13 | 13 | 'const' => 'true' ) |
| 14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
| 16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
| 17 | 17 | // thus default return value is always true |
| 18 | 18 | public static function hasRight($handler) { |
| 19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
| 20 | - return self::$rights_cache[$handler]; |
|
| 19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
| 20 | + return self::$rights_cache[$handler]; |
|
| 21 | + } |
|
| 21 | 22 | |
| 22 | - if (!array_key_exists($handler, self::$rights)) |
|
| 23 | - return true; // handler does not exists |
|
| 23 | + if (!array_key_exists($handler, self::$rights)) { |
|
| 24 | + return true; |
|
| 25 | + } |
|
| 26 | + // handler does not exists |
|
| 24 | 27 | |
| 25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
| 26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
| 27 | - if (Database::num_rows($result) > 0) |
|
| 28 | - $result = true; |
|
| 29 | - else |
|
| 30 | - $result = false; |
|
| 31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
| 32 | - $result = self::$rights[$handler]['const']; |
|
| 33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
| 34 | - $result = self::$rights[$handler]['func'](); |
|
| 35 | - else // handler type not implemented |
|
| 30 | + if (Database::num_rows($result) > 0) { |
|
| 31 | + $result = true; |
|
| 32 | + } else { |
|
| 33 | + $result = false; |
|
| 34 | + } |
|
| 35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
| 36 | + $result = self::$rights[$handler]['const']; |
|
| 37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
| 38 | + $result = self::$rights[$handler]['func'](); |
|
| 39 | + } else { |
|
| 40 | + // handler type not implemented |
|
| 36 | 41 | return true; |
| 42 | + } |
|
| 37 | 43 | self::$rights_cache[$handler] = $result; |
| 38 | 44 | return $result; |
| 39 | 45 | } |
| 40 | 46 | |
| 41 | 47 | public static function hasRightClosePageWithError($handler) { |
| 42 | - if (hasRight($handler) == false) |
|
| 43 | - die("You are not allowed here"); //FIXME |
|
| 48 | + if (hasRight($handler) == false) { |
|
| 49 | + die("You are not allowed here"); |
|
| 50 | + } |
|
| 51 | + //FIXME |
|
| 44 | 52 | } |
| 45 | 53 | |
| 46 | 54 | } |
@@ -71,6 +71,10 @@ |
||
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Get the terms stored at database |
| 74 | + * @param string $prefix |
|
| 75 | + * @param string $course_code |
|
| 76 | + * @param string $tool_id |
|
| 77 | + * @param integer $ref_id |
|
| 74 | 78 | * @return array Array of terms |
| 75 | 79 | */ |
| 76 | 80 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * code |
| 9 | 9 | */ |
| 10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
| 10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
| 11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
| 40 | 40 | return FALSE; |
| 41 | 41 | |
| 42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
| 42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
| 43 | 43 | |
| 44 | 44 | // compare terms |
| 45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // save it to search engine |
| 57 | 57 | foreach ($missing_terms as $term) { |
| 58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
| 58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
| 59 | 59 | } |
| 60 | 60 | foreach ($deprecated_terms as $term) { |
| 61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
| 61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return array Array of terms |
| 75 | 75 | */ |
| 76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
| 77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
| 78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
| 79 | 79 | $prefix_terms = array(); |
| 80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
| 37 | 37 | |
| 38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
| 39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
| 40 | - return FALSE; |
|
| 39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
| 40 | + return FALSE; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
| 43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | $doc = $this->get_document($search_did); |
| 46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
| 47 | 48 | $xterms = array(); |
| 48 | - foreach ($xapian_terms as $xapian_term) |
|
| 49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
| 49 | + foreach ($xapian_terms as $xapian_term) { |
|
| 50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $dterms = $terms; |
| 52 | 54 | |
@@ -23,6 +23,9 @@ discard block |
||
| 23 | 23 | return chamilo_preprocess_results($results); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | +/** |
|
| 27 | + * @param string $query_string |
|
| 28 | + */ |
|
| 26 | 29 | function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
| 27 | 30 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
| 28 | 31 | } |
@@ -30,7 +33,7 @@ discard block |
||
| 30 | 33 | /** |
| 31 | 34 | * Wrapper for getting boolean queries |
| 32 | 35 | * |
| 33 | - * @param string $query_string The term string |
|
| 36 | + * @param string $term |
|
| 34 | 37 | */ |
| 35 | 38 | function chamilo_get_boolean_query($term) { |
| 36 | 39 | return xapian_get_boolean_query($term); |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | * @param array extra Extra queries to join with. Optional |
| 19 | 19 | * @return array |
| 20 | 20 | */ |
| 21 | -function chamilo_query_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
| 21 | +function chamilo_query_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
| 22 | 22 | list($count, $results) = xapian_query($query_string, NULL, $offset, $length, $extra); |
| 23 | 23 | return chamilo_preprocess_results($results); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
| 26 | +function chamilo_query_simple_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
| 27 | 27 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | function chamilo_preprocess_results($results) { |
| 43 | 43 | // group by toolid |
| 44 | 44 | $results_by_tool = array(); |
| 45 | - if (count($results)>0) { |
|
| 45 | + if (count($results) > 0) { |
|
| 46 | 46 | |
| 47 | 47 | foreach ($results as $key => $row) { |
| 48 | 48 | $results_by_tool[$row['toolid']][] = $row; |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $processed_results = array(); |
| 52 | 52 | foreach ($results_by_tool as $toolid => $rows) { |
| 53 | - $tool_processor_class = $toolid .'_processor'; |
|
| 54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
| 53 | + $tool_processor_class = $toolid.'_processor'; |
|
| 54 | + $tool_processor_path = api_get_path(LIBRARY_PATH).'search/tool_processors/'.$tool_processor_class.'.class.php'; |
|
| 55 | 55 | if (file_exists($tool_processor_path)) { |
| 56 | 56 | require_once($tool_processor_path); |
| 57 | 57 | $tool_processor = new $tool_processor_class($rows); |
@@ -71,6 +71,6 @@ discard block |
||
| 71 | 71 | * @param string $op |
| 72 | 72 | * @return XapianQuery query joined |
| 73 | 73 | */ |
| 74 | -function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
|
| 74 | +function chamilo_join_queries($query1, $query2 = NULL, $op = 'or') { |
|
| 75 | 75 | return xapian_join_queries($query1, $query2, $op); |
| 76 | 76 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param string $query_string The term string |
| 34 | 34 | */ |
| 35 | 35 | function chamilo_get_boolean_query($term) { |
| 36 | - return xapian_get_boolean_query($term); |
|
| 36 | + return xapian_get_boolean_query($term); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,22 +44,22 @@ discard block |
||
| 44 | 44 | $results_by_tool = array(); |
| 45 | 45 | if (count($results)>0) { |
| 46 | 46 | |
| 47 | - foreach ($results as $key => $row) { |
|
| 48 | - $results_by_tool[$row['toolid']][] = $row; |
|
| 49 | - } |
|
| 47 | + foreach ($results as $key => $row) { |
|
| 48 | + $results_by_tool[$row['toolid']][] = $row; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $processed_results = array(); |
|
| 52 | - foreach ($results_by_tool as $toolid => $rows) { |
|
| 53 | - $tool_processor_class = $toolid .'_processor'; |
|
| 54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
| 55 | - if (file_exists($tool_processor_path)) { |
|
| 56 | - require_once($tool_processor_path); |
|
| 57 | - $tool_processor = new $tool_processor_class($rows); |
|
| 58 | - $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
| 59 | - } |
|
| 60 | - } |
|
| 51 | + $processed_results = array(); |
|
| 52 | + foreach ($results_by_tool as $toolid => $rows) { |
|
| 53 | + $tool_processor_class = $toolid .'_processor'; |
|
| 54 | + $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
| 55 | + if (file_exists($tool_processor_path)) { |
|
| 56 | + require_once($tool_processor_path); |
|
| 57 | + $tool_processor = new $tool_processor_class($rows); |
|
| 58 | + $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return array(count($processed_results), $processed_results); |
|
| 62 | + return array(count($processed_results), $processed_results); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -72,5 +72,5 @@ discard block |
||
| 72 | 72 | * @return XapianQuery query joined |
| 73 | 73 | */ |
| 74 | 74 | function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
| 75 | - return xapian_join_queries($query1, $query2, $op); |
|
| 75 | + return xapian_join_queries($query1, $query2, $op); |
|
| 76 | 76 | } |