| Conditions | 11 |
| Paths | 11 |
| Total Lines | 62 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 37 | public function update($event, $entryid, $props) |
||
| 38 | { |
||
| 39 | switch ($event) { |
||
| 40 | case TABLE_SAVE: |
||
| 41 | $data = array(); |
||
| 42 | |||
| 43 | if (isset($props[PR_STORE_ENTRYID])) { |
||
| 44 | $store = $GLOBALS["mapisession"]->openMessageStore($props[PR_STORE_ENTRYID]); |
||
| 45 | |||
| 46 | if (isset($props[PR_ENTRYID])) { |
||
| 47 | $properties = $this->getPropertiesList(); |
||
| 48 | $data = $GLOBALS["operations"]->getMessageProps($store, $GLOBALS["operations"]->openMessage($store, $props[PR_ENTRYID]), $properties); |
||
| 49 | $this->addNotificationActionData("update", array( "item" => array($data) )); |
||
| 50 | } else if (isset($props[PR_PARENT_ENTRYID])) { |
||
| 51 | // An object was created inside this folder for which we don't know the entryid |
||
| 52 | // this can happen when we copy or move a message. Just tell the javascript that |
||
| 53 | // this folder has a new object. |
||
| 54 | $folder = mapi_msgstore_openentry($store, $props[PR_PARENT_ENTRYID]); |
||
| 55 | $folderProps = mapi_getprops($folder, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID, PR_CONTENT_COUNT, PR_CONTENT_UNREAD, PR_DISPLAY_NAME)); |
||
| 56 | |||
| 57 | $data = array( |
||
| 58 | "item" => array( |
||
| 59 | array( |
||
| 60 | "content_count" => $folderProps[PR_CONTENT_COUNT], |
||
| 61 | "content_unread" => $folderProps[PR_CONTENT_UNREAD], |
||
| 62 | // Add store_entryid,entryid of folder and display_name of folder |
||
| 63 | // to JSON data in order to refresh the list. |
||
| 64 | "store_entryid" => bin2hex($folderProps[PR_STORE_ENTRYID]), |
||
| 65 | "parent_entryid" => bin2hex($folderProps[PR_PARENT_ENTRYID]), |
||
| 66 | "entryid" => bin2hex($folderProps[PR_ENTRYID]), |
||
| 67 | "display_name" => $folderProps[PR_DISPLAY_NAME] |
||
| 68 | ) |
||
| 69 | ) |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->addNotificationActionData("newobject", $data); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | break; |
||
| 76 | case TABLE_DELETE: |
||
| 77 | $folderEntryID = isset($props[PR_PARENT_ENTRYID]) ? $props[PR_PARENT_ENTRYID] : false; |
||
| 78 | |||
| 79 | if (isset($props[PR_ENTRYID]) && $folderEntryID) { |
||
| 80 | $data = array(); |
||
| 81 | $data["parent_entryid"] = bin2hex($folderEntryID); |
||
| 82 | |||
| 83 | if (is_array($props[PR_ENTRYID])) { |
||
| 84 | $data["entryid"] = array(); |
||
| 85 | |||
| 86 | foreach ($props[PR_ENTRYID] as $entryid) { |
||
|
|
|||
| 87 | array_push($data["entryid"], bin2hex($entryid)); |
||
| 88 | } |
||
| 89 | } else { |
||
| 90 | $data["entryid"] = bin2hex($props[PR_ENTRYID]); |
||
| 91 | } |
||
| 92 | |||
| 93 | $this->addNotificationActionData("delete", array( "item" => array($data) )); |
||
| 94 | } |
||
| 95 | break; |
||
| 96 | } |
||
| 97 | |||
| 98 | $GLOBALS["bus"]->addData($this->createNotificationResponseData()); |
||
| 99 | } |
||
| 102 |