mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
check function pass to setCallback() and addCallback() is callable, remove createDump()
This commit is contained in:
parent
59c16b3ce4
commit
2789e017eb
|
@ -3292,62 +3292,55 @@ class SeedDMS_Core_DMS {
|
|||
/**
|
||||
* Set a callback function
|
||||
*
|
||||
* The function passed in $func must be a callable and $name may not be empty.
|
||||
*
|
||||
* Setting a callback with the method will remove all priorly set callbacks.
|
||||
*
|
||||
* @param string $name internal name of callback
|
||||
* @param mixed $func function name as expected by {call_user_method}
|
||||
* @param mixed $params parameter passed as the first argument to the
|
||||
* callback
|
||||
* @return bool true if adding the callback succeeds otherwise false
|
||||
*/
|
||||
function setCallback($name, $func, $params=null) { /* {{{ */
|
||||
if($name && $func)
|
||||
if($name && $func && is_callable($func)) {
|
||||
$this->callbacks[$name] = array(array($func, $params));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add a callback function
|
||||
*
|
||||
* The function passed in $func must be a callable and $name may not be empty.
|
||||
*
|
||||
* @param string $name internal name of callback
|
||||
* @param mixed $func function name as expected by {call_user_method}
|
||||
* @param mixed $params parameter passed as the first argument to the
|
||||
* callback
|
||||
* @return bool true if adding the callback succeeds otherwise false
|
||||
*/
|
||||
function addCallback($name, $func, $params=null) { /* {{{ */
|
||||
if($name && $func)
|
||||
if($name && $func && is_callable($func)) {
|
||||
$this->callbacks[$name][] = array($func, $params);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create an sql dump of the complete database
|
||||
* Check if a callback with the given has been set
|
||||
*
|
||||
* @param string $filename name of dump file
|
||||
* @return bool
|
||||
* @param string $name internal name of callback
|
||||
* @return bool true a callback exists otherwise false
|
||||
*/
|
||||
function createDump($filename) { /* {{{ */
|
||||
$h = fopen($filename, "w");
|
||||
if(!$h)
|
||||
return false;
|
||||
|
||||
$tables = $this->db->TableList('TABLES');
|
||||
foreach($tables as $table) {
|
||||
$query = "SELECT * FROM `".$table."`";
|
||||
$records = $this->db->getResultArray($query);
|
||||
fwrite($h,"\n-- TABLE: ".$table."--\n\n");
|
||||
foreach($records as $record) {
|
||||
$values="";
|
||||
$i = 1;
|
||||
foreach ($record as $column) {
|
||||
if (is_numeric($column)) $values .= $column;
|
||||
else $values .= $this->db->qstr($column);
|
||||
|
||||
if ($i<(count($record))) $values .= ",";
|
||||
$i++;
|
||||
}
|
||||
|
||||
fwrite($h, "INSERT INTO `".$table."` VALUES (".$values.");\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($h);
|
||||
return true;
|
||||
function hasCallback($name) { /* {{{ */
|
||||
if($name && !empty($this->callbacks[$name]))
|
||||
return true;
|
||||
return false;
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user