[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /** 3 * Mnemo external API interface. 4 * 5 * $Horde: mnemo/lib/api.php,v 1.52 2004/09/14 04:27:07 chuck Exp $ 6 * 7 * This file defines Mnemo's external API interface. Other 8 * applications can interact with Mnemo through this API. 9 * 10 * @package Mnemo 11 */ 12 13 $_services['list'] = array( 14 'args' => array(), 15 'type' => 'stringArray' 16 ); 17 18 $_services['listBy'] = array( 19 'args' => array('action', 'timestamp'), 20 'type' => 'stringArray' 21 ); 22 23 $_services['import'] = array( 24 'args' => array('content', 'contentType'), 25 'type' => 'integer' 26 ); 27 28 $_services['search'] = array( 29 'args' => array('content', 'contentType'), 30 'type' => 'integer' 31 ); 32 33 $_services['export'] = array( 34 'args' => array('guid', 'contentType'), 35 'type' => 'string' 36 ); 37 38 $_services['delete'] = array( 39 'args' => array('guid'), 40 'type' => 'boolean' 41 ); 42 43 $_services['replace'] = array( 44 'args' => array('guid', 'content', 'contentType'), 45 'type' => 'boolean' 46 ); 47 48 49 /** 50 * Returns an array of GUIDs for all notes that the current user is 51 * authorized to see. 52 * 53 * @return array An array of GUIDs for all notes the user can access. 54 */ 55 function _egwsiftaskssync_list() 56 { 57 $guids = array(); 58 59 #Horde::logMessage("SymcML: egwsiftaskssync list ", __FILE__, __LINE__, PEAR_LOG_DEBUG); 60 61 $searchFilter = array 62 ( 63 'order' => 'info_datemodified', 64 'sort' => 'DESC', 65 'filter' => 'my', // filter my: entries user is responsible for, filter own: entries the user own or is responsible for 66 // todo add a filter to limit how far back entries from the past get synced 67 'col_filter' => Array 68 ( 69 'info_type' => 'task', 70 ), 71 ); 72 73 $tasks = ExecMethod('infolog.boinfolog.search',$searchFilter); 74 #Horde::logMessage("SymcML: egwsiftasknssync list found: ".count($tasks), __FILE__, __LINE__, PEAR_LOG_DEBUG); 75 foreach((array)$tasks as $task) 76 { 77 $guids[] = $GLOBALS['egw']->common->generate_uid('infolog_task',$task['info_id']); 78 } 79 80 return $guids; 81 } 82 83 /** 84 * Returns an array of GUIDs for notes that have had $action happen 85 * since $timestamp. 86 * 87 * @param string $action The action to check for - add, modify, or delete. 88 * @param integer $timestamp The time to start the search. 89 * 90 * @return array An array of GUIDs matching the action and time criteria. 91 */ 92 function &_egwsiftaskssync_listBy($action, $timestamp) 93 { 94 #Horde::logMessage("SymcML: egwnotessync listBy action: $action timestamp: $timestamp", __FILE__, __LINE__, PEAR_LOG_DEBUG); 95 96 $allChangedItems = $GLOBALS['egw']->contenthistory->getHistory('infolog_task', $action, $timestamp); 97 98 if($action == 'delete') 99 { 100 return $allChangedItems; // InfoLog has no further info about deleted entries 101 } 102 $boInfolog =& CreateObject('infolog.boinfolog'); 103 $user = $GLOBALS['egw_info']['user']['account_id']; 104 105 $readAbleItems = array(); 106 foreach($allChangedItems as $guid) 107 { 108 $uid = $GLOBALS['egw']->common->get_egwId($guid); 109 110 if(($info = $boInfolog->read($uid)) && // checks READ rights too and returns false if none 111 // for filter my = all items the user is responsible for: 112 ($user == $info['info_owner'] && !count($info['info_responsible']) || in_array($user,$info['info_responsible']))) 113 // for filter own = all items the user own or is responsible for: 114 //($user == $info['info_owner'] || in_array($user,$info['info_responsible']))) 115 { 116 $readAbleItems[] = $guid; 117 } 118 } 119 return $readAbleItems; 120 } 121 122 /** 123 * Import a memo represented in the specified contentType. 124 * 125 * @param string $content The content of the memo. 126 * @param string $contentType What format is the data in? Currently supports: 127 * text/plain 128 * text/x-vnote 129 * @param string $notepad (optional) The notepad to save the memo on. 130 * 131 * @return string The new GUID, or false on failure. 132 */ 133 function _egwsiftaskssync_import($content, $contentType, $notepad = null) 134 { 135 switch ($contentType) { 136 case 'text/x-s4j-sift': 137 $sifInfolog =& CreateObject('infolog.sifinfolog'); 138 139 $taskID = $sifInfolog->addSIF($content,-1,'task'); 140 141 break; 142 143 default: 144 return PEAR::raiseError(_("Unsupported Content-Type.")); 145 } 146 147 if (is_a($taskID, 'PEAR_Error')) { 148 return $taskID; 149 } 150 151 Horde::logMessage("SymcML: egwtaskssync import imported: ".$GLOBALS['egw']->common->generate_uid('infolog_task',$taskID), __FILE__, __LINE__, PEAR_LOG_DEBUG); 152 return $GLOBALS['egw']->common->generate_uid('infolog_task',$taskID); 153 } 154 155 /** 156 * Import a memo represented in the specified contentType. 157 * 158 * @param string $content The content of the memo. 159 * @param string $contentType What format is the data in? Currently supports: 160 * text/plain 161 * text/x-vnote 162 * @param string $notepad (optional) The notepad to save the memo on. 163 * 164 * @return string The new GUID, or false on failure. 165 */ 166 function _egwsiftaskssync_search($content, $contentType) 167 { 168 switch ($contentType) { 169 case 'text/x-s4j-sift': 170 $sifInfolog =& CreateObject('infolog.sifinfolog'); 171 $taskID = $sifInfolog->searchSIF($content,'task'); 172 break; 173 174 default: 175 return PEAR::raiseError(_("Unsupported Content-Type.")); 176 } 177 178 if (is_a($taskID, 'PEAR_Error')) { 179 return $taskID; 180 } 181 182 #error_log("SymcML: egwsiftaskssync search found: $taskID"); 183 #Horde::logMessage("SymcML: egwsiftaskssync import imported: ".$GLOBALS['egw']->common->generate_uid('infolog_task',$taskID), __FILE__, __LINE__, PEAR_LOG_DEBUG); 184 if(!$taskID) { 185 return false; 186 } else { 187 return $GLOBALS['egw']->common->generate_uid('infolog_task',$taskID); 188 } 189 } 190 191 /** 192 * Export a memo, identified by GUID, in the requested contentType. 193 * 194 * @param string $guid Identify the memo to export. 195 * @param mixed $contentType What format should the data be in? 196 * Either a string with one of: 197 * 'text/plain' 198 * 'text/x-vnote' 199 * or an array with options: 200 * 'ContentType': as above 201 * 'ENCODING': (optional) character encoding 202 * for strings fields 203 * 'CHARSET': (optional) charset. Like UTF-8 204 * 205 * @return string The requested data. 206 */ 207 function _egwsiftaskssync_export($guid, $contentType) 208 { 209 if (is_array($contentType)) { 210 $options = $contentType; 211 $contentType = $options['ContentType']; 212 unset($options['ContentType']); 213 } else { 214 $options = array(); 215 } 216 217 $taskID = $GLOBALS['egw']->common->get_egwId($guid); 218 219 switch ($contentType) { 220 case 'text/x-s4j-sift': 221 $sifInfolog =& CreateObject('infolog.sifinfolog'); 222 if($task = $sifInfolog->getSIF($taskID, 'task')) 223 { 224 return $task; 225 } 226 else 227 { 228 return PEAR::raiseError(_("Access Denied")); 229 } 230 231 break; 232 233 default: 234 #Horde::logMessage("SymcML: export unsupported", __FILE__, __LINE__, PEAR_LOG_DEBUG); 235 return PEAR::raiseError(_("Unsupported Content-Type.")); 236 } 237 } 238 239 /** 240 * Delete a memo identified by GUID. 241 * 242 * @param string | array $guid Identify the note to delete, either a 243 * single GUID or an array. 244 * 245 * @return boolean Success or failure. 246 */ 247 function _egwsiftaskssync_delete($guid) 248 { 249 // Handle an arrray of GUIDs for convenience of deleting multiple 250 // contacts at once. 251 if (is_array($guid)) { 252 foreach ($guid as $g) { 253 $result = _egwsiftaskssync_delete($g); 254 if (is_a($result, 'PEAR_Error')) { 255 return $result; 256 } 257 } 258 259 return true; 260 } 261 262 return ExecMethod('infolog.boinfolog.delete',$GLOBALS['egw']->common->get_egwId($guid)); 263 } 264 265 /** 266 * Replace the memo identified by GUID with the content represented in 267 * the specified contentType. 268 * 269 * @param string $guid Idenfity the memo to replace. 270 * @param string $content The content of the memo. 271 * @param string $contentType What format is the data in? Currently supports: 272 * text/plain 273 * text/x-vnote 274 * 275 * @return boolean Success or failure. 276 */ 277 function _egwsiftaskssync_replace($guid, $content, $contentType) 278 { 279 Horde::logMessage("SymcML: egwsiftaskssync replace content: $content contenttype: $contentType", __FILE__, __LINE__, PEAR_LOG_DEBUG); 280 281 $taskID = $GLOBALS['egw']->common->get_egwId($guid); 282 283 284 switch ($contentType) { 285 case 'text/x-s4j-sift': 286 $sifInfolog =& CreateObject('infolog.sifinfolog'); 287 288 return $sifInfolog->addSIF($content, $taskID, 'task'); 289 290 break; 291 292 default: 293 return PEAR::raiseError(_("Unsupported Content-Type.")); 294 } 295 } 296
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |