| Conditions | 13 |
| Paths | 256 |
| Total Lines | 96 |
| Code Lines | 64 |
| 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 |
||
| 59 | function createReminderFolder($store) |
||
| 60 | { |
||
| 61 | $storeProps = mapi_getprops($store, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SUBTREE_ENTRYID)); |
||
| 62 | $root = mapi_msgstore_openentry($store, null); |
||
| 63 | $rootProps = mapi_getprops($root, array(PR_ADDITIONAL_REN_ENTRYIDS, PR_IPM_DRAFTS_ENTRYID)); |
||
| 64 | |||
| 65 | |||
| 66 | $folders = array(); |
||
| 67 | if (isset($storeProps[PR_IPM_WASTEBASKET_ENTRYID])) |
||
| 68 | $folders[] = $storeProps[PR_IPM_WASTEBASKET_ENTRYID]; |
||
| 69 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS])&&!empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4])) |
||
| 70 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4]; // junk mail |
||
| 71 | if (isset($rootProps[PR_IPM_DRAFTS_ENTRYID])) |
||
| 72 | $folders[] = $rootProps[PR_IPM_DRAFTS_ENTRYID]; |
||
| 73 | if (isset($storeProps[PR_IPM_OUTBOX_ENTRYID])) |
||
| 74 | $folders[] = $storeProps[PR_IPM_OUTBOX_ENTRYID]; |
||
| 75 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS])&&!empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0])) |
||
| 76 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0]; // conflicts |
||
| 77 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS])&&!empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2])) |
||
| 78 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2]; // local failures |
||
| 79 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS])&&!empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][1])) |
||
| 80 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][1]; // sync issues |
||
| 81 | |||
| 82 | $folderRestriction = array(); |
||
| 83 | foreach($folders as $folder){ |
||
| 84 | $folderRestriction[] = array(RES_PROPERTY, |
||
| 85 | array( |
||
| 86 | RELOP => RELOP_NE, |
||
| 87 | ULPROPTAG => $this->properties["parent_entryid"], |
||
| 88 | VALUE => array($this->properties["parent_entryid"] => $folder) |
||
| 89 | ) |
||
| 90 | ); |
||
| 91 | } |
||
| 92 | |||
| 93 | $res = |
||
| 94 | array(RES_AND, |
||
| 95 | array( |
||
| 96 | array(RES_AND, |
||
| 97 | $folderRestriction |
||
| 98 | ), |
||
| 99 | array(RES_AND, |
||
| 100 | array( |
||
| 101 | array(RES_NOT, |
||
| 102 | array( |
||
| 103 | array(RES_AND, |
||
| 104 | array( |
||
| 105 | array(RES_EXIST, |
||
| 106 | array( |
||
| 107 | ULPROPTAG => $this->properties["message_class"] |
||
| 108 | ) |
||
| 109 | ), |
||
| 110 | array(RES_CONTENT, |
||
| 111 | array( |
||
| 112 | FUZZYLEVEL => FL_PREFIX, |
||
| 113 | ULPROPTAG => $this->properties["message_class"], |
||
| 114 | VALUE => array($this->properties["message_class"] => "IPM.Schedule") |
||
| 115 | ) |
||
| 116 | ) |
||
| 117 | ) |
||
| 118 | ) |
||
| 119 | ) |
||
| 120 | ), |
||
| 121 | array(RES_BITMASK, |
||
| 122 | array( |
||
| 123 | ULTYPE => BMR_EQZ, |
||
| 124 | ULPROPTAG => $this->properties["message_flags"], |
||
| 125 | ULMASK => MSGFLAG_SUBMIT |
||
| 126 | ) |
||
| 127 | ), |
||
| 128 | array(RES_OR, |
||
| 129 | array( |
||
| 130 | array(RES_PROPERTY, |
||
| 131 | array( |
||
| 132 | RELOP => RELOP_EQ, |
||
| 133 | ULPROPTAG => $this->properties["reminder"], |
||
| 134 | VALUE => array($this->properties["reminder"] => true) |
||
| 135 | ) |
||
| 136 | ), |
||
| 137 | ) |
||
| 138 | ) |
||
| 139 | ) |
||
| 140 | ) |
||
| 141 | ) |
||
| 142 | ); |
||
| 143 | |||
| 144 | $folder = mapi_folder_createfolder($root, _("Reminders"), "", OPEN_IF_EXISTS, FOLDER_SEARCH); |
||
| 145 | mapi_setprops($folder, array(PR_CONTAINER_CLASS => "Outlook.Reminder")); |
||
| 146 | mapi_savechanges($folder); |
||
| 147 | |||
| 148 | mapi_folder_setsearchcriteria($folder, $res, array($storeProps[PR_IPM_SUBTREE_ENTRYID]), RECURSIVE_SEARCH); |
||
| 149 | $folderProps = mapi_getprops($folder, array(PR_ENTRYID)); |
||
| 150 | |||
| 151 | mapi_setprops($root, array(PR_REM_ONLINE_ENTRYID => $folderProps[PR_ENTRYID])); |
||
| 152 | mapi_savechanges($root); |
||
| 153 | |||
| 154 | return $folderProps[PR_ENTRYID]; |
||
| 155 | } |
||
| 291 |