00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00031 class tx_sysnotepad extends mod_user_task {
00032
00036 function overview_main() {
00037 $icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath("sys_notepad").'ext_icon.gif" width=18 height=16 class="absmiddle">';
00038 $noteRow = $this->getQuickNote($this->BE_USER->user["uid"]);
00039 $noteVal = nl2br(htmlspecialchars(t3lib_div::fixed_lgd(implode(chr(10),t3lib_div::trimExplode(chr(10),$noteRow["note"],1)),50)));
00040 return $this->mkMenuConfig($icon.$this->headLink("tx_sysnotepad",1),'','<a href="index.php?SET[function]=tx_sysnotepad" onClick="this.blur();"><img src="'.$this->backPath.'gfx/edit2.gif" style="float: left;"></a><div><a href="index.php?SET[function]=tx_sysnotepad" onClick="this.blur();">'.$noteVal.'</a></div>');
00041 }
00042 function main() {
00043 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00044
00045 return $this->renderNote();
00046 }
00047
00048
00049
00050
00051
00052 function getQuickNote($be_user_id) {
00053 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'cruser_id='.intval($be_user_id), '', 'crdate', '1');
00054 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00055 return $row;
00056 }
00057
00058
00059
00060
00061
00062
00063 function renderNote() {
00064 global $LANG;
00065
00066 $out = '';
00067
00068
00069 $incoming = t3lib_div::_GP("data");
00070 if (is_array($incoming["sys_notepad"])) {
00071 $dataArr = array();
00072 $key = key($incoming["sys_notepad"]);
00073 if ($key=="NEW") {
00074 $dataArr["note"] = $incoming["sys_notepad"]["NEW"]["note"];
00075 $dataArr["cruser_id"]=$this->BE_USER->user["uid"];
00076 $dataArr["crdate"]=time();
00077 $dataArr["tstamp"]=time();
00078 $this->setQuickNote(0,$dataArr,$this->BE_USER->user["uid"]);
00079 } else {
00080 $uid = intval($key);
00081 $dataArr["note"] = $incoming["sys_notepad"][$uid]["note"];
00082 $dataArr["tstamp"]=time();
00083 $this->setQuickNote($uid,$dataArr,$this->BE_USER->user["uid"]);
00084 }
00085 }
00086
00087
00088 $note = $this->getQuickNote($this->BE_USER->user["uid"]);
00089 if (!is_array($note)) {
00090 $note["uid"]="NEW";
00091 }
00092
00093 $out.= '<textarea rows=30'.$this->pObj->doc->formWidthText().' name="data[sys_notepad]['.$note["uid"].'][note]">'.t3lib_div::formatForTextarea($note["note"]).'</textarea>';
00094 $out.= '<BR><input type="submit" value="'.$LANG->getLL("lUpdate").'">';
00095
00096
00097 if ($this->BE_USER->uc["helpText"]) {
00098 $out.= '<BR><BR>'.$this->helpBubble().$LANG->getLL("note_helpText");
00099 }
00100
00101 return $this->pObj->doc->section("",$out,0,1);
00102 }
00103 function setQuickNote($uid,$inRow,$be_user_id) {
00104 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'uid='.intval($uid));
00105 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00106 if (is_array($row)) {
00107 if ($be_user_id==$row["cruser_id"]) {
00108 $GLOBALS['TYPO3_DB']->exec_UPDATEquery("sys_notepad", "uid=".intval($uid), $inRow);
00109 }
00110 } else {
00111 $GLOBALS['TYPO3_DB']->exec_INSERTquery("sys_notepad", $inRow);
00112 }
00113 }
00114 }
00115
00116 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]) {
00117 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]);
00118 }
00119
00120 ?>