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(&$pObj) {
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_cs(implode(chr(10),t3lib_div::trimExplode(chr(10),$noteRow["note"],1)),50)));
00040 $content.=$pObj->doc->section(
00041 $icon." ".$this->headLink("tx_sysnotepad",0),
00042 '<a href="index.php?SET[function]=tx_sysnotepad" target="list_frame" onClick="this.blur();"><img src="'.$this->backPath.'gfx/edit2.gif" width="11" height="12" hspace=2 border="0" align=top>'.$noteVal.'</a>',1,1,0,1);
00043 return $content;
00044 }
00045 function main() {
00046 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00047
00048 return $this->renderNote();
00049 }
00050
00051
00052
00053
00054
00055 function getQuickNote($be_user_id) {
00056 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'cruser_id='.intval($be_user_id), '', 'crdate', '1');
00057 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00058 return $row;
00059 }
00060
00061
00062
00063
00064
00065
00066 function renderNote() {
00067 global $LANG;
00068
00069 $out = '';
00070
00071
00072 $incoming = t3lib_div::_GP("data");
00073 if (is_array($incoming["sys_notepad"])) {
00074 $dataArr = array();
00075 $key = key($incoming["sys_notepad"]);
00076 if ($key=="NEW") {
00077 $dataArr["note"] = $incoming["sys_notepad"]["NEW"]["note"];
00078 $dataArr["cruser_id"]=$this->BE_USER->user["uid"];
00079 $dataArr["crdate"]=time();
00080 $dataArr["tstamp"]=time();
00081 $this->setQuickNote(0,$dataArr,$this->BE_USER->user["uid"]);
00082 } else {
00083 $uid = intval($key);
00084 $dataArr["note"] = $incoming["sys_notepad"][$uid]["note"];
00085 $dataArr["tstamp"]=time();
00086 $this->setQuickNote($uid,$dataArr,$this->BE_USER->user["uid"]);
00087 }
00088 $out.=$this->loadLeftFrameJS();
00089 }
00090
00091
00092 $note = $this->getQuickNote($this->BE_USER->user["uid"]);
00093 if (!is_array($note)) {
00094 $note["uid"]="NEW";
00095 }
00096
00097 $out.= '<textarea rows=30'.$this->pObj->doc->formWidthText().' name="data[sys_notepad]['.$note["uid"].'][note]">'.t3lib_div::formatForTextarea($note["note"]).'</textarea>';
00098 $out.= '<BR><input type="submit" value="'.$LANG->getLL("lUpdate").'">';
00099
00100
00101 if ($this->BE_USER->uc["helpText"]) {
00102 $out.= '<BR><BR>'.$this->helpBubble().$LANG->getLL("note_helpText");
00103 }
00104
00105 return $this->pObj->doc->section("",$out,0,1);
00106 }
00107 function setQuickNote($uid,$inRow,$be_user_id) {
00108 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'uid='.intval($uid));
00109 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00110 if (is_array($row)) {
00111 if ($be_user_id==$row["cruser_id"]) {
00112 $GLOBALS['TYPO3_DB']->exec_UPDATEquery("sys_notepad", "uid=".intval($uid), $inRow);
00113 }
00114 } else {
00115 $GLOBALS['TYPO3_DB']->exec_INSERTquery("sys_notepad", $inRow);
00116 }
00117 }
00118 }
00119
00120 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]) {
00121 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]);
00122 }
00123
00124 ?>