preserved.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php return array (
  2. 'c9c38ffa1cc58b6aa6fd45efd6acff61' =>
  3. array (
  4. 'criteria' =>
  5. array (
  6. 'name' => 'loglogins',
  7. ),
  8. 'object' =>
  9. array (
  10. 'name' => 'loglogins',
  11. 'path' => '{core_path}components/loglogins/',
  12. 'assets_path' => '',
  13. ),
  14. ),
  15. '7104b87cadd0313492b124c744ad825d' =>
  16. array (
  17. 'criteria' =>
  18. array (
  19. 'category' => 'LogLogins',
  20. ),
  21. 'object' =>
  22. array (
  23. 'id' => 19,
  24. 'parent' => 0,
  25. 'category' => 'LogLogins',
  26. 'rank' => 0,
  27. ),
  28. ),
  29. 'a6a69e423ce77aad3b96c4bfd5e6dbf4' =>
  30. array (
  31. 'criteria' =>
  32. array (
  33. 'name' => 'LogLogins',
  34. ),
  35. 'object' =>
  36. array (
  37. 'id' => 10,
  38. 'source' => 0,
  39. 'property_preprocess' => 0,
  40. 'name' => 'LogLogins',
  41. 'description' => '',
  42. 'editor_type' => 0,
  43. 'category' => 19,
  44. 'cache_type' => 0,
  45. 'plugincode' => '/** @var $modx modX */
  46. $pluginKey = \'loglogins_contexts\';
  47. /* Set action based on event name */
  48. if (strpos($modx->event->name, \'Login\') !== false) {
  49. $act = $modx->lexicon(\'login\');
  50. } else {
  51. $modx->lexicon->load(\'core:default\');
  52. $act = $modx->lexicon(\'logout\');
  53. }
  54. /* Need this because $modx->user is not available in some cases
  55. and MODX uses it for the actor in logManagerActions()*/
  56. if (isset($user)) {
  57. $modx->user =& $user;
  58. }
  59. $allContexts = array();
  60. /* These are from the vars passed to the event on login.
  61. Converted here to a comma-separated string */
  62. $ac = isset($attributes[\'addContexts\'])
  63. ? $attributes[\'addContexts\']
  64. : array();
  65. $lc = isset($attributes[\'loginContext\'])
  66. ? $attributes[\'loginContext\']
  67. : \'\';
  68. if ( (empty($ac))) {
  69. $allContexts[] = $lc;
  70. } else {
  71. $allContexts = $ac;
  72. if (! in_array($lc, $ac)) {
  73. $allContexts[] = $lc;
  74. }
  75. }
  76. $msg = !empty($allContexts)? implode(\',\', $allContexts) : \'\';
  77. /* $msg is always \'mgr\' for manager logins and logouts */
  78. if (strpos($modx->event->name, \'Manager\') !== false) {
  79. $msg = \'mgr\';
  80. }
  81. switch ($modx->event->name) {
  82. /* Save contexts in user setting */
  83. case \'OnWebLogin\':
  84. $setting = $modx->getObject(\'modUserSetting\',
  85. array(
  86. \'user\' => $user->get(\'id\'),
  87. \'key\' => $pluginKey,
  88. ));
  89. if (! $setting) {
  90. /* Create User Setting if it doesn\'t exist */
  91. $setting = $modx->newObject(\'modUserSetting\');
  92. $setting->set(\'user\', $user->get(\'id\'));
  93. $setting->set(\'key\', $pluginKey);
  94. $setting->set(\'namespace\', \'loglogins\');
  95. }
  96. /* Set value to login contexts */
  97. if ($setting) {
  98. $setting->set(\'value\', $msg);
  99. $setting->save();
  100. }
  101. break;
  102. case \'OnWebLogout\':
  103. /* Get contexts from user setting */
  104. $setting = $modx->getObject(\'modUserSetting\',
  105. array(
  106. \'user\' => $user->get(\'id\'),
  107. \'key\' => $pluginKey,
  108. ));
  109. if ($setting) {
  110. $msg = $setting->get(\'value\');
  111. } else {
  112. $msg = \'\';
  113. }
  114. break;
  115. }
  116. $modx->logManagerAction($act, \'modContext\', $msg);
  117. return \'\';',
  118. 'locked' => 0,
  119. 'properties' => 'a:0:{}',
  120. 'disabled' => 1,
  121. 'moduleguid' => '',
  122. 'static' => 0,
  123. 'static_file' => '',
  124. 'content' => '/** @var $modx modX */
  125. $pluginKey = \'loglogins_contexts\';
  126. /* Set action based on event name */
  127. if (strpos($modx->event->name, \'Login\') !== false) {
  128. $act = $modx->lexicon(\'login\');
  129. } else {
  130. $modx->lexicon->load(\'core:default\');
  131. $act = $modx->lexicon(\'logout\');
  132. }
  133. /* Need this because $modx->user is not available in some cases
  134. and MODX uses it for the actor in logManagerActions()*/
  135. if (isset($user)) {
  136. $modx->user =& $user;
  137. }
  138. $allContexts = array();
  139. /* These are from the vars passed to the event on login.
  140. Converted here to a comma-separated string */
  141. $ac = isset($attributes[\'addContexts\'])
  142. ? $attributes[\'addContexts\']
  143. : array();
  144. $lc = isset($attributes[\'loginContext\'])
  145. ? $attributes[\'loginContext\']
  146. : \'\';
  147. if ( (empty($ac))) {
  148. $allContexts[] = $lc;
  149. } else {
  150. $allContexts = $ac;
  151. if (! in_array($lc, $ac)) {
  152. $allContexts[] = $lc;
  153. }
  154. }
  155. $msg = !empty($allContexts)? implode(\',\', $allContexts) : \'\';
  156. /* $msg is always \'mgr\' for manager logins and logouts */
  157. if (strpos($modx->event->name, \'Manager\') !== false) {
  158. $msg = \'mgr\';
  159. }
  160. switch ($modx->event->name) {
  161. /* Save contexts in user setting */
  162. case \'OnWebLogin\':
  163. $setting = $modx->getObject(\'modUserSetting\',
  164. array(
  165. \'user\' => $user->get(\'id\'),
  166. \'key\' => $pluginKey,
  167. ));
  168. if (! $setting) {
  169. /* Create User Setting if it doesn\'t exist */
  170. $setting = $modx->newObject(\'modUserSetting\');
  171. $setting->set(\'user\', $user->get(\'id\'));
  172. $setting->set(\'key\', $pluginKey);
  173. $setting->set(\'namespace\', \'loglogins\');
  174. }
  175. /* Set value to login contexts */
  176. if ($setting) {
  177. $setting->set(\'value\', $msg);
  178. $setting->save();
  179. }
  180. break;
  181. case \'OnWebLogout\':
  182. /* Get contexts from user setting */
  183. $setting = $modx->getObject(\'modUserSetting\',
  184. array(
  185. \'user\' => $user->get(\'id\'),
  186. \'key\' => $pluginKey,
  187. ));
  188. if ($setting) {
  189. $msg = $setting->get(\'value\');
  190. } else {
  191. $msg = \'\';
  192. }
  193. break;
  194. }
  195. $modx->logManagerAction($act, \'modContext\', $msg);
  196. return \'\';',
  197. ),
  198. ),
  199. );