mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
- added clipboard management
This commit is contained in:
parent
5e97126994
commit
0c22d143eb
|
@ -78,6 +78,10 @@ class LetoDMS_Session {
|
|||
return false;
|
||||
$this->id = $id;
|
||||
$this->data = array('userid'=>$resArr[0]['userID'], 'theme'=>$resArr[0]['theme'], 'lang'=>$resArr[0]['language'], 'id'=>$resArr[0]['id'], 'lastaccess'=>$resArr[0]['lastAccess'], 'flashmsg'=>'');
|
||||
if($resArr[0]['clipboard'])
|
||||
$this->data['clipboard'] = json_decode($resArr[0]['clipboard'], true);
|
||||
else
|
||||
$this->data['clipboard'] = array('docs'=>array(), 'folders'=>array());
|
||||
return $resArr[0];
|
||||
} /* }}} */
|
||||
|
||||
|
@ -101,6 +105,7 @@ class LetoDMS_Session {
|
|||
$this->data = $data;
|
||||
$this->data['id'] = $id;
|
||||
$this->data['lastaccess'] = $lastaccess;
|
||||
$this->data['clipboard'] = array('docs'=>array(), 'folders'=>array());
|
||||
return $id;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -145,7 +150,7 @@ class LetoDMS_Session {
|
|||
/**
|
||||
* Set language of session
|
||||
*
|
||||
* @param $lang language
|
||||
* @param string $lang language
|
||||
*/
|
||||
function setLanguage($lang) { /* {{{ */
|
||||
/* id is only set if load() was called before */
|
||||
|
@ -159,12 +164,84 @@ class LetoDMS_Session {
|
|||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Set language of session
|
||||
* Get language of session
|
||||
*
|
||||
* @param $lang language
|
||||
* @return string language
|
||||
*/
|
||||
function getLanguage() { /* {{{ */
|
||||
return $this->data['lang'];
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Set clipboard of session
|
||||
*
|
||||
* @param array $clipboard list of folders and documents
|
||||
*/
|
||||
function setClipboard($clipboard) { /* {{{ */
|
||||
/* id is only set if load() was called before */
|
||||
if($this->id) {
|
||||
$queryStr = "UPDATE tblSessions SET clipboard = " . json_encode($this->db->qstr($clipboard)) . " WHERE id = " . $this->db->qstr($this->id);
|
||||
if (!$this->db->getResult($queryStr))
|
||||
return false;
|
||||
$this->data['clipboard'] = $clipboard;
|
||||
}
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get clipboard of session
|
||||
*
|
||||
* @return array list of clipboard entries
|
||||
*/
|
||||
function getClipboard() { /* {{{ */
|
||||
return (array) $this->data['clipboard'];
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add to clipboard of session
|
||||
*
|
||||
* @param object $object Document or folder
|
||||
*/
|
||||
function addToClipboard($object) { /* {{{ */
|
||||
/* id is only set if load() was called before */
|
||||
if($this->id) {
|
||||
if(get_class($object) == 'LetoDMS_Core_Document') {
|
||||
if(!in_array($object->getID(), $this->data['clipboard']['docs']))
|
||||
array_push($this->data['clipboard']['docs'], $object->getID());
|
||||
} elseif(get_class($object) == 'LetoDMS_Core_Folder') {
|
||||
if(!in_array($object->getID(), $this->data['clipboard']['folders']))
|
||||
array_push($this->data['clipboard']['folders'], $object->getID());
|
||||
}
|
||||
$queryStr = "UPDATE tblSessions SET clipboard = " . $this->db->qstr(json_encode($this->data['clipboard'])) . " WHERE id = " . $this->db->qstr($this->id);
|
||||
if (!$this->db->getResult($queryStr))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Remove from clipboard
|
||||
*
|
||||
* @param object $object Document or folder to remove
|
||||
*/
|
||||
function removeFromClipboard($object) { /* {{{ */
|
||||
/* id is only set if load() was called before */
|
||||
if($this->id) {
|
||||
if(get_class($object) == 'LetoDMS_Core_Document') {
|
||||
$key = array_search($object->getID(), $this->data['clipboard']['docs']);
|
||||
if($key !== false)
|
||||
unset($this->data['clipboard']['docs'][$key]);
|
||||
} elseif(get_class($object) == 'LetoDMS_Core_Folder') {
|
||||
$key = array_search($object->getID(), $this->data['clipboard']['folders']);
|
||||
if($key !== false)
|
||||
unset($this->data['clipboard']['folders'][$key]);
|
||||
}
|
||||
$queryStr = "UPDATE tblSessions SET clipboard = " . $this->db->qstr(json_encode($this->data['clipboard'])) . " WHERE id = " . $this->db->qstr($this->id);
|
||||
if (!$this->db->getResult($queryStr))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user