/**
* the global DB object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* the user ID from user management or default
*
- * @var Int
+ * @var integer
*/
protected $userID = 0;
/**
* Doomguy constructor.
*
- * @param object $db The database object
+ * @param mysqli $db The database object
*/
public function __construct($db) {
$this->_DB = $db;
/**
* return the isSignedIn status.
*
- * @return boolean
+ * @return bool
*/
public function isSignedIn() {
return $this->isSignedIn;
* check if the loaded user is in this group
* if the user is in ADMIN_GROUP_ID, the he is automatically "in" every group
*
- * @param int $groupID
+ * @param integer $groupID
* @return bool
*/
public function isInGroup($groupID) {
/**
* Use the user identified by apitoken
*
- * @param $token string
+ * @param string $token
*/
public function authByApiToken($token) {
if(!empty($token)) {
*
* @param string $mode
* @param bool $tableName
- * @return string $str
- * @throws Exception
+ * @return string
*/
public function getSQLRightsString($mode = "read", $tableName=false) {
+ $str = '';
$prefix = '';
+
if(!empty($tableName)) {
$prefix = "`".$tableName."`.";
}
}
}
else {
- throw new Exception("Site User: invalid rights string.");
+ error_log("[ERROR] ".__METHOD__." invalid rights string: ".var_export($this->_rightsArray, true));
}
return $str;
* check if we can use session
* we only use session if we can use cookies with the session
* THIS DOES NOT CHECK IF THE USER HAS COOKIES ACTIVATED !
+ *
+ * @return bool
*/
protected function _checkSession() {
/**
* we have session data available. Now check if those data is valid
+ *
+ * @return bool
*/
protected function _checkAgainstSessionTable() {
$ret = false;
* if so load the user data
*
* @param string $u
- * @return boolean
+ * @return bool
*/
protected function _checkAgainstUserTable($u) {
$ret = false;
/**
* if we have to run some at login
+ *
+ * @return void
*/
protected function _loginActions() {
# @todo:
/**
* load the user and groups
+ *
+ * @return void
*/
protected function _loadUser() {
if(!empty($this->userID)) {
/**
* destroy and remove the current session from SESSION and session table
*
- * @return boolean
+ * @return bool
*/
protected function _destroySession() {
$timeframe = date("Y-m-d H:i:s",time()-SESSION_LIFETIME);
* and a salt
*
* @param bool $salt
- * @return bool
+ * @return bool|array
*/
protected function _createToken($salt=false) {
$ret = false;
/**
* the global DB object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* the current loaded user
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* GoreNest constructor.
*
- * @param $db
- * @param $user
+ * @param mysqli $db
+ * @param Doomguy $user
*/
public function __construct($db, $user) {
$this->_DB = $db;
* This shows only entries which have a category set.
* No category can be used for hidden entries.
*
- * @param $category
+ * @param string $category
* @param bool $reload
* @return array
*/
*
*
* Functionality is the same but modified heavily to remove the does-not-make-sense static helper
- * wich was not static since it depended on the IMDB class. Also some could not be extended or overwritten
+ * which was not static since it depended on the IMDB class. Also some could not be extended or overwritten
*
*/
class IMDB
/**
* The database object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* ManageCollections constructor
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* The id from the collection we are working with
*
- * @param $id integer
+ * @param integer $id
*/
public function setCollection($id) {
if(!empty($id)) {
/**
* Simple comma seperated number string
*
- * @param $string string
+ * @param string $string
* @return bool
*/
public function validateFieldSortString($string) {
}
/**
- * $fieldsSortString have to valided already
+ * $fieldsSortString have to be validated already
*
* @todo remove non existing ones from table
*
- * @param $fieldsSortString string
+ * @param string $fieldsSortString
* @return bool
*/
public function updateFields($fieldsSortString) {
* Get the required SQL information from given field ids
* to create columns in entry table.
*
- * @param $columnIds array sort=>fk_field_id
+ * @param array $columnIds sort=>fk_field_id
* @return array
*/
private function _getSQLForCollectionColumns($columnIds) {
/**
* The database object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* ManageCollections constructor.
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* Load collection info from table. Checks user rights
*
- * @param $id
- * @param string $ritghsMode
+ * @param string $id
+ * @param string $rightsMode
* @return array
*/
- public function getCollection($id,$ritghsMode="read") {
+ public function getCollection($id,$rightsMode="read") {
$ret = array();
if (Summoner::validate($id, 'digit')) {
$queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`
FROM `".DB_PREFIX."_collection` AS c
- WHERE ".$this->_User->getSQLRightsString($ritghsMode, "c")."
+ WHERE ".$this->_User->getSQLRightsString($rightsMode, "c")."
AND `c`.`id` = '".$this->_DB->real_escape_string($id)."'";
try {
$query = $this->_DB->query($queryStr);
}
}
catch (Exception $e) {
- if(DEBUG) error_log("[DEBUG] ".__METHOD__." mysql catch: ".$e->getMessage());
+ error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
if(DEBUG) error_log("[DEBUG] ".__METHOD__." mysql query: ".$queryStr);
}
}
}
/**
- * Fetch all availbale tools based on current user rights
+ * Fetch all available tools based on current user rights
*
* @return array
*/
/**
* Delete collection identified by given id
*
- * @param $id string Number
+ * @param string $id Number
* @return bool
*/
public function deleteCollection($id) {
/**
* Load the tools configured to the given collection
*
- * @param $id
+ * @param string $id Number
* @return array
*/
public function getAvailableTools($id) {
/**
* Check if given name can be used as a new one
*
- * @param $name string
+ * @param string $name
* @return bool
*/
private function _validNewCollectionName($name) {
/**
* Check if given name can be used as a new name for id
*
- * @param $name string
- * @param $id string Number
+ * @param string $name
+ * @param string $id Number
* @return bool
*/
private function _validUpdateCollectionName($name, $id) {
/**
* Update the given colletion ($id) with the given tool array
*
- * @param $id
- * @param $tool
+ * @param string $id Number
+ * @param array $tool
* @return bool
*/
private function _updateToolRelation($id,$tool) {
/**
* The database object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* ManageCollections constructor.
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* Set the collection to manage entries from
*
- * @param $collectionId
+ * @param sring $collectionId Number
*/
public function setCollection($collectionId) {
if(!empty($collectionId)) {
* Load required data for edit. Uses some functions from Mancubus but has
* different data layout. Checks write edit too
*
- * @param $entryId
+ * @param string $entryId Number
* @return array
*/
public function getEditData($entryId) {
* Delete given entryId from currently loaded collection
* Checks userrights too.
*
- * @param $entryId
+ * @param string $entryId Number
* @return bool
*/
public function delete($entryId) {
/**
* Validates that current use can write the given Entry
*
- * @param $entryId
+ * @param string $entryId Number
* @return bool
*/
public function canEditEntry($entryId) {
* Check if given entryid can be deleted from current collection
* and user
*
- * @param $entryId
+ * @param string $entryId Number
* @return bool
*/
private function _canDelete($entryId) {
* In this case only the fields which have a _loadFieldValue_ method
* are loaded. More is not needed here.
*
- * @param $entryData array
- * @param $entryFields array
+ * @param array $entryData
+ * @param array $entryFields
* @return array
*/
private function _mergeEntryWithFields($entryData, $entryFields) {
* lookup function for field type lookupmultiple
*
* @see Mancubus
- * @param Number $entryId
+ * @param string $entryId Number
* @param array $fieldData
* @return array
*/
* lookup function for field type upload
*
* @see Mancubus
- * @param $entryId
- * @param $fieldData
+ * @param string $entryId Number
+ * @param array $fieldData
* @return string
*/
private function _loadFieldValue_upload($entryId, $fieldData) {
* lookup function for field type upload_multiple
*
* @see Mancubus
- * @param $entryId
- * @param $fieldData
+ * @param string $entryId Number
+ * @param array $fieldData
* @return array
*/
private function _loadFieldValue_upload_multiple($entryId, $fieldData) {
* Provide the options for a selection field by processing the $data['value']
* since the values are stored in the entry DB as a list
*
- * @param $data array
+ * @param array $data
* @return array
*/
private function _loadField_selection($data) {
/**
* Load suggestions based on the existing data for this field
*
- * @param $data array Field data
+ * @param array $data Field data
* @return array
*/
private function _loadField_lookupmultiple($data) {
/**
* Create part of the insert statement for field type text
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_text($data, $queryData) {
/**
* Create part of the insert statement for field type text3
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_text3($data, $queryData) {
/**
* Create part of the insert statement for field type textarea
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_textarea($data, $queryData) {
/**
* Create part of the insert statement for field type selection
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_selection($data, $queryData) {
/**
* Create part of the insert statement for field type year
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_year($data, $queryData) {
/**
* Create part of the insert statement for field type lookupmultiple
*
- * @param $data array Field data
- * @param $queryData array Query data array
+ * @param array $data Field data
+ * @param array $queryData Query data array
* @return array
*/
private function _saveField_lookupmultiple($data, $queryData) {
/**
* Single upload field
*
- * @param $data array The data from _FILES
- * @param $queryData array
+ * @param array $data The data from _FILES
+ * @param array $queryData
* @return array
*/
private function _saveField_upload($data, $queryData) {
/**
* Multiple upload field
*
- * @param $data array The data from _FILES
- * @param $queryData array
+ * @param array $data The data from _FILES
+ * @param array $queryData
* @return array
*/
private function _saveField_upload_multiple($data, $queryData) {
/**
* runs the query and throws query execption if false
*
- * @param $queryString
- * @param $insertId
+ * @param string $queryString
+ * @param string $insertId Number
*/
private function _runAfter_query($queryString, $insertId) {
if(!empty($queryString) && !empty($insertId)) {
*
* Also removes the defined uploads from multiple upload field
*
- * @param $uploadData
- * @param $insertId
+ * @param array $uploadData
+ * @param string $insertId Number
* @throws Exception
*/
private function _runAfter_upload($uploadData, $insertId) {
/**
* The database object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* Currently loaded collection to work with
*
- * @var number
+ * @var string Number
*/
private $_collectionId;
/**
* Mancubus constructor.
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* Set the to work with collection id
*
- * @param $collectionId Number
+ * @param string $collectionId Number
*/
public function setCollection($collectionId) {
if(!empty($collectionId)) {
/**
* Get all available collections for display based on current user
*
- * @param int $selections Number of selections
- * @param int $entries Number of entries
+ * @param string $selections Number of selections
+ * @param string $entries Number of entries
* @param string $search Search string to search for
* @return array
*/
}
/**
- * Retrive all the data needed to display the entry for given entryId
- * @param $entryId
+ * Retrieve all the data needed to display the entry for given entryId
+ * @param string $entryId Number
* @return array|mixed
*/
public function getEntry($entryId) {
/**
* Get entries for loaded collection by looking for the given value in given field
*
- * @param Number $fieldId ID of the field to search in
- * @param String $fieldValue Value of the field
+ * @param string $fieldId Number ID of the field to search in
+ * @param string $fieldValue Value of the field
* @return array
*/
public function getEntriesByFieldValue($fieldId, $fieldValue) {
}
/**
- * Get tags for loaded collection. Provide earch term to use match against db search
+ * Get tags for loaded collection. Provide search term to use match against db search
*
* @todo Replace with trite class
*
/**
* Return the storage info for loaded collection
* Used by API
+ *
* @return array|mixed
*/
public function getEntryStructure() {
/**
* Load the fields from the loaded collection
+ *
* @return array
*/
private function _getEntryFields() {
/**
* Merge the loaded information from collection_entry with the given
* configured fields
+ *
* @param array $entryData Loaded entry
* @param array $entryFields Loaded fields
* @return mixed
/**
* Load the values for given $entryId for $fieldData
* lookup function for field type lookupmultiple
- * @param Numer $entryId
+ *
+ * @param string $entryId Number
* @param array $fieldData
* @return array
*/
/**
* Get the single upload file from storage location
* lookup function for field type upload
- * @param $entryId
- * @param $fieldData
+ *
+ * @param string $entryId Number
+ * @param array $fieldData
* @return string
*/
private function _loadFieldValue_upload($entryId, $fieldData) {
/**
* Get the multiple upload files from storage location
* lookup function for field type upload_multiple
- * @param $entryId
- * @param $fieldData
+ *
+ * @param string $entryId Number
+ * @param string $fieldData
* @return array
*/
private function _loadFieldValue_upload_multiple($entryId, $fieldData) {
/**
* Load and prepare the value for a selection field
*
- * @param $data string
+ * @param string $data
* @return array
*/
private function _loadFieldSelection_selection($data) {
/**
* Get the distinct data from a col and optionaml search term
*
- * @param $colname
- * @param $search
+ * @param string $colname
+ * @param string $search
* @return array
*/
private function _loadColAsTagFromEntryTable($colname,$search) {
/**
* set some defaults by init of the class
+ *
+ * @return void
*/
private function _setDefaults() {
// default query options
/**
* the global DB object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
+ /**
+ * Possessed constructor.
+ * @param mysqli $db
+ */
public function __construct($db) {
$this->_DB = $db;
}
/**
* Create or update a user and set the required user releations
*
- * @param $username string
- * @param $login string
- * @param $password string
- * @param $group string Number
+ * @param string $username
+ * @param string $login
+ * @param string $password
+ * @param string $group Number
* @param bool $active
* @return bool
*/
/**
* Update given user id with given data
*
- * @param $id
- * @param $username
- * @param $login
- * @param $password
- * @param $group
+ * @param string $id Number
+ * @param string $username
+ * @param string $login
+ * @param string $password
+ * @param string $group
* @param bool $active
* @param bool $refreshApiToken
* @return bool
/**
* Load the userinformation and groups for given id
*
- * @param $userId string Number
+ * @param string $userId Number
* @return array
*/
public function getEditData($userId) {
/**
* Delete user by given user id
*
- * @param $id string Number
+ * @param string $id Number
* @return bool
*/
public function deleteUser($id) {
}
/**
- * Set user to group releation in database.
+ * Set user to group relation in database.
* clean will delete all existing ones for given userid first.
*
* @param string $userid Number
/**
* Load all the groups the user is in and the information of them
*
- * @param $userId string Number
+ * @param string $userId Number
* @return array
*/
private function _loadUserGroupInfo($userId) {
/**
* the global DB object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
+ /**
+ * Allowed request params
+ *
+ * @var array
+ */
private $_allowedRequests = array('default','list','add','addInfo');
/**
* Spectre constructor.
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* Validate given request string
*
- * @param $request string
+ * @param string $request
* @return bool
*/
public function allowedRequests($request) {
* With given data build the structure to create a add post
* request
*
- * @param $data
+ * @param array $data
* @return array
*/
public function buildAddStructure($data) {
* POST via web frontend creates
* "The problem occurs when you have a form that uses both single file and HTML array feature."
*
- * @param $data
+ * @param array $data
* @return array
*/
public function prepareFilesArray($data) {
* @param string $file relative path from THEME/
* @param string $theme Theme name
* @param string $defaultTheme Default theme name can be overwritten
- * @return boolean|string False of nothing is found
+ * @return bool|string False of nothing is found
*/
static function themefile($file, $theme, $defaultTheme='default') {
$ret = false;
* then create the rights string
* IMPORTANT: keep the order otherwise the rights will be messed up
*
- * @param $rightsArr array
+ * @param array $rightsArr
* @return mixed
*/
static function prepareRightsString($rightsArr) {
/**
* Creates from given rights string the rights array
- * @param $rightsString
+ * @param string $rightsString
* @return array
*/
static function prepareRightsArray($rightsString) {
* with full path to the files
* @param string $directory The absolute path to the directory
* @param array $ignore An Array with strings to ignored
- * @param boolean $recursive If we run a recursive scan or not
+ * @param bool $recursive If we run a recursive scan or not
* @return array
*/
static function readDir($directory,$ignore=array(),$recursive=false) {
* $empty = true => empty the diretory but do not delete it
*
* @param string $directory
- * @param boolean $empty
+ * @param bool $empty
* @param mixed $fTime If not false remove files older then this value in sec.
- * @return boolean
+ * @return bool
*/
static function recursive_remove_directory($directory, $empty=false,$fTime=false) {
// if the path has a slash at the end we remove it here
/**
* execute a curl call to the fiven $url
* @param string $url The request url
- * @param int $port
+ * @param integer $port
* @return bool|string
*/
static function curlCall($url,$port=80) {
if(is_string($do) === true) {
$ret = $do;
}
- else {
- $ret = false;
- }
curl_close($ch);
*
* @param string $haystack
* @param string $needle
- * @return boolean
+ * @return bool
*/
static function startsWith($haystack, $needle) {
$length = strlen($needle);
*
* @param string $haystack
* @param string $needle
- * @return boolean
+ * @return bool
*/
static function endsWith($haystack, $needle) {
$length = strlen($needle);
* @param string $file The absolute path to the image file
* @param number $width
* @param number $height
- * @return boolean
+ * @return bool
*/
static function createThumbnail($file,$width=ADMIN_THUMBNAIL_DEFAULT_WIDTH,$height=ADMIN_THUMBNAIL_DEFAULT_HEIGHT) {
$ret = false;
/**
* based on self::ifset check also the value
*
- * @param $array
- * @param $key
- * @param $value
+ * @param array $array
+ * @param string $key
+ * @param string $value
* @return bool
*/
static function ifsetValue($array,$key,$value) {
}
/**
- * Replace in $heystack the $needle with $replace only once
+ * Replace in $haystack the $needle with $replace only once
*
- * @param $haystack string
- * @param $needle string
- * @param $replace string
+ * @param string $haystack
+ * @param string $needle
+ * @param string $replace
* @return string
*/
static function replaceOnce($haystack, $needle, $replace) {
* modify will add: key AND value not empty
* modify will remove: only key with no value
*
- * @param $array
+ * @param array $array
* @param array $modify
* @return string
*/
/**
* the global DB object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* Tentacle constructor.
*
- * @param $databaseConnectionObject
- * @param $userObj
+ * @param mysqli $databaseConnectionObject
+ * @param Doomguy $userObj
*/
public function __construct($databaseConnectionObject, $userObj) {
$this->_DB = $databaseConnectionObject;
/**
* Validate if given action is a valid tool and if the user has access
*
- * @param $identifier
+ * @param string $identifier
* @return bool
*/
public function validate($identifier) {
$queryStr = "SELECT `name`,`description`,`action`
FROM `".DB_PREFIX."_tool`
- WHERE ".$this->_User->getSQLRightsString("read")."
+ WHERE ".$this->_User->getSQLRightsString()."
AND `action` = '".$this->_DB->real_escape_string($identifier)."'";
try {
$query = $this->_DB->query($queryStr);
/**
* The database object
*
- * @var object
+ * @var mysqli
*/
private $_DB;
/**
* The user object to query with
*
- * @var object
+ * @var Doomguy
*/
private $_User;
/**
* Currently loaded collection to work with
*
- * @var number
+ * @var string
*/
private $_id;
/**
* set some defaults by init of the class
+ *
+ * @return void
*/
private function _setDefaults() {
// default query options