Conflicts:
	application/core/FHC_Controller.php
This commit is contained in:
root
2016-06-21 16:31:06 +02:00
25 changed files with 798 additions and 265 deletions
+10
View File
@@ -68,4 +68,14 @@ class FHC_DB_ACL
{
return $this->_uid = $uid;
}
/** ---------------------------------------------------------------
* get UID
*
* @return string or (bool)false
*/
public function getUID()
{
return $this->_uid;
}
}
+148
View File
@@ -0,0 +1,148 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class FilesystemLib
{
/*
*
*/
public function __construct() {}
/*
*
*/
private function checkParameters($filepath, $filename)
{
if (isset($filepath) && isset($filename) &&
$filepath != '' && $filename != '')
{
return true;
}
else
{
return false;
}
}
/*
*
*/
public function read($filepath, $filename)
{
$result = null;
if ($this->checkParameters($filepath, $filename))
{
$resource = $filepath . DIRECTORY_SEPARATOR . $filename;
if (file_exists($resource) && $fileHandle = fopen($resource, 'r'))
{
$result = '';
while (!feof($fileHandle))
{
$result .= fread($fileHandle, 8192);
}
fclose($fileHandle);
}
}
return $result;
}
/*
*
*/
public function write($filepath, $filename, $content)
{
$result = null;
if ($this->checkParameters($filepath, $filename) && isset($content))
{
$resource = $filepath . DIRECTORY_SEPARATOR . $filename;
if (is_writable($filepath) && $fileHandle = fopen($resource, 'w'))
{
if (fwrite($fileHandle, $content) !== false)
{
$result = true;
}
fclose($fileHandle);
}
}
return $result;
}
/*
*
*/
public function append($filepath, $filename, $content)
{
$result = null;
if ($this->checkParameters($filepath, $filename) && isset($content))
{
$resource = $filepath . DIRECTORY_SEPARATOR . $filename;
if (is_writable($resource) && $fileHandle = fopen($resource, 'a'))
{
if (fwrite($fileHandle, $content) !== false)
{
$result = true;
}
fclose($fileHandle);
}
}
return $result;
}
/*
*
*/
public function remove($filepath, $filename)
{
$result = null;
if ($this->checkParameters($filepath, $filename))
{
if (is_writable($filepath))
{
$resource = $filepath . DIRECTORY_SEPARATOR . $filename;
$result = unlink($resource);
}
}
return $result;
}
/*
*
*/
public function rename($filepath, $filename, $newFilepath, $newFilename)
{
$result = null;
if ($this->checkParameters($filepath, $filename) && $this->checkParameters($newFilepath, $newFilename))
{
$resource = $filepath . DIRECTORY_SEPARATOR . $filename;
if (is_writable($filepath) && is_writable($newFilepath) && file_exists($resource))
{
$destination = $newFilepath . DIRECTORY_SEPARATOR . $newFilename;
$result = rename($resource, $destination);
}
}
return $result;
}
}
+41 -3
View File
@@ -11,13 +11,18 @@ class MessageLib
{
private $recipients = array();
public function __construct()
public function __construct($params)
{
require_once APPPATH.'config/message.php';
$this->ci =& get_instance();
//$this->ci->load->model('person/Person_model', 'PersonModel');
$this->ci->load->model('system/Message_model', 'MessageModel');
if (is_array($params) && isset($params['uid']))
{
$this->ci->MessageModel->setUID($params['uid']);
}
$this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel');
$this->ci->load->model('system/Recipient_model', 'RecipientModel');
$this->ci->load->model('system/Attachment_model', 'AttachmentModel');
@@ -53,6 +58,40 @@ class MessageLib
return $msg;
}
/**
* getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
*
* @param string $uid REQUIRED
* @return array
*/
function getMessagesByUID($uid, $all = false)
{
if (empty($uid))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$msg = $this->ci->MessageModel->getMessagesByUID($uid, $all);
// General Error Occurred
return $msg;
}
/**
* getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
*
* @param bigint $person_id REQUIRED
* @return array
*/
function getMessagesByPerson($person_id, $all = false)
{
if (empty($person_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all);
// General Error Occurred
return $msg;
}
// ------------------------------------------------------------------------
/**
@@ -66,8 +105,7 @@ class MessageLib
if (!is_numeric($msg_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
$msg = $this->getMessage($msg_id);
return $msg;
return $this->getMessage($msg_id);
}
// ------------------------------------------------------------------------