Changeset 12169
- Timestamp:
- 09/12/07 13:35:55 (1 year ago)
- Files:
-
- trunk/midcom/net.nehmer.account/config/config.inc (modified) (1 diff)
- trunk/midcom/net.nehmer.account/handler/invitation.php (modified) (9 diffs)
- trunk/midcom/net.nehmer.account/handler/register.php (modified) (4 diffs)
- trunk/midcom/net.nehmer.account/locale/default.en.txt (modified) (1 diff)
- trunk/midcom/net.nehmer.account/style/invitation-email-body.php (modified) (1 diff)
- trunk/midcom/net.nehmer.account/viewer.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/net.nehmer.account/config/config.inc
r12069 r12169 45 45 'account_activation_timeout' => 7, // days 46 46 'publish_all_on_activation' => false, 47 48 'relocate_after_activation' => false, 47 49 48 50 // Avatar Sizes trunk/midcom/net.nehmer.account/handler/invitation.php
r11935 r12169 38 38 $persons = $qb->execute(); 39 39 40 if ( $persons)40 if (count($persons) > 0) 41 41 { 42 42 return $persons; … … 44 44 else 45 45 { 46 return false;46 return false; 47 47 } 48 48 } … … 51 51 * Adds a buddy 52 52 */ 53 function _add_as_buddy($buddy_user_guid) 54 { 55 if (!$_MIDCOM->componentloader->is_loaded('net.nehmer.buddylist')) 56 { 57 if ($_MIDCOM->componentloader->load_graceful('net.nehmer.buddylist')) 58 { 59 $_MIDCOM->auth->require_valid_user(); 60 61 // Setup. 62 $buddy_user =& $_MIDCOM->auth->get_user($buddy_user_guid); 63 if (!$buddy_user) 64 { 65 $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The user guid {$buddy_user} is unknown."); 66 } 67 68 if (net_nehmer_buddylist_entry::is_on_buddy_list($buddy_user)) 69 { 70 $this->_processing_msg_raw = 'user already on your buddylist.'; 71 } 72 else 73 { 74 $entry = new net_nehmer_buddylist_entry(); 75 $entry->account = $_MIDCOM->auth->user->guid; 76 $entry->buddy = $this->_buddy_user->guid; 77 $entry->create(); 78 $this->_processing_msg_raw = 'buddy request sent.'; 79 } 80 } 81 } 82 } 83 84 function _send_email_invitation() 53 function _add_as_buddy($buddy_user_guid) 54 { 55 if (!$_MIDCOM->componentloader->is_loaded('net.nehmer.buddylist')) 56 { 57 if ($_MIDCOM->componentloader->load_graceful('net.nehmer.buddylist')) 58 { 59 $_MIDCOM->auth->require_valid_user(); 60 61 // Setup. 62 $buddy_user =& $_MIDCOM->auth->get_user($buddy_user_guid); 63 if (!$buddy_user) 64 { 65 //$_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The user guid {$buddy_user} is unknown."); 66 debug_add("The user guid {$buddy_user} is unknown."); 67 } 68 69 if (net_nehmer_buddylist_entry::is_on_buddy_list($buddy_user)) 70 { 71 $this->_processing_msg_raw = 'user already on your buddylist.'; 72 } 73 else 74 { 75 $entry = new net_nehmer_buddylist_entry(); 76 $entry->account = $_MIDCOM->auth->user->guid; 77 $entry->buddy = $buddy_user->guid; 78 $entry->create(); 79 $this->_processing_msg_raw = 'buddy request sent.'; 80 } 81 } 82 } 83 } 84 85 function _send_email_invitation($email, $name=false) 85 86 { 86 87 /** 87 88 * Sending invitations 88 89 */ 90 debug_add("Sending email to {$email}, {$name}"); 89 91 $this->_mail = new org_openpsa_mail(); 90 $this->_mail->to = $ _POST["net_nehmer_invitation_invitee_name{$i}"];92 $this->_mail->to = $email; 91 93 $this->_mail->from = $_MIDCOM->auth->user->_storage->email; 92 94 $this->_mail->subject = $this->_l10n->get($this->_config->get('email_subject')); 93 95 // This may be a hack, but it allows us tons more control in rendering the email 94 96 $_MIDCOM->style->enter_context(0); 97 $this->_request_data['sender_username'] = $_MIDCOM->auth->user->_storage->username; 95 98 $this->_request_data['user_message'] = $this->_user_defined_message; 96 99 ob_start(); … … 144 147 function _handler_invite($handler_id, $args, &$data) 145 148 { 146 //echo "<pre>";147 //print_r($_POST); 148 //echo "</pre>";149 149 debug_push_class(__CLASS__, __FUNCTION__); 150 151 $_MIDCOM->auth->require_valid_user(); 152 150 153 if (isset($_POST['net_nehmer_accounts_invitation_submit'])) 151 154 { … … 154 157 if ($i >= $this->_config->get('email_fields') && !isset($_POST["net_nehmer_accounts_invitation_invitee_selected_{$i}"])) 155 158 { 156 echo "Continuing";159 //echo "Continuing"; 157 160 continue; 158 161 } … … 178 181 $this->_invite->email = $_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"]; 179 182 $this->_invite->buddy = $_MIDCOM->auth->user->guid; 180 181 $persons = $this->_is_person_registered($_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"]); 182 183 if ( $persons) 183 184 debug_print_r("Creating invite: ",$this->_invite); 185 186 $allready_registered = $this->_is_person_registered($_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"]); 187 188 debug_print_r("persons with email ".$_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"].":",$allready_registered); 189 190 if ($allready_registered) 184 191 { 185 foreach ($ personsas $person)192 foreach ($allready_registered as $person) 186 193 { 187 194 $this->_add_as_buddy($person->guid); 188 195 } 189 196 190 $_MIDCOM->relocate('sent_invites');197 continue; 191 198 } 192 199 else … … 196 203 debug_add("Could not create invite object ID " . $this->_invite->id); 197 204 } 205 debug_print_r("Created invite: ",$this->_invite); 198 206 } 199 207 200 208 $this->_request_data['hash'] = $this->_invite->hash; 201 209 202 $this->_send_email_invitation(); 210 $this->_send_email_invitation( 211 $_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"], 212 $_POST["net_nehmer_accounts_invitation_invitee_name_{$i}"] 213 ); 203 214 } 204 215 205 216 } 217 debug_pop(); 206 218 $_MIDCOM->relocate('sent_invites'); 207 219 } … … 227 239 $qb->add_constraint('metadata.creator', '=', $_MIDCOM->auth->user->guid); 228 240 229 $invites = $qb->execute();241 $invites = $qb->execute(); 230 242 231 243 $current_time = time(); 232 $keep_sent_invites = $this->_config->get('keep_sent_invites');244 $keep_sent_invites = $this->_config->get('keep_sent_invites'); 233 245 234 246 /** 235 * Removing expired invites236 */237 foreach($invites as $invite)238 {247 * Removing expired invites 248 */ 249 foreach($invites as $invite) 250 { 239 251 if ($current_time > ($invite->metadata->created + $keep_sent_invites * 86400)) 240 {252 { 241 253 $invite->delete(); 242 }243 244 }245 246 $this->_sent_invites = $qb->execute();254 } 255 256 } 257 258 $this->_sent_invites = $qb->execute(); 247 259 248 260 return true; … … 254 266 255 267 foreach ($this->_sent_invites as $invite) 256 {257 $this->_request_data['invite'] = $invite;268 { 269 $this->_request_data['invite'] = $invite; 258 270 midcom_show_style('invites-list-item'); 259 }271 } 260 272 261 273 midcom_show_style('invites-list-footer'); trunk/midcom/net.nehmer.account/handler/register.php
r12123 r12169 1022 1022 $this->_person->delete_parameter('net.nehmer.account', 'activation_hash_created'); 1023 1023 1024 // Trigger post-activation hooks 1025 $this->_auto_publish_account_details(); 1026 $this->_invoke_account_activation_callback(); 1027 1028 $_MIDCOM->auth->drop_sudo(); 1024 // $_MIDCOM->auth->drop_sudo(); 1029 1025 1030 1026 $auto_login_sitegroup = $this->_config->get('auto_login_on_activation'); … … 1041 1037 { 1042 1038 debug_push_class(__CLASS__, __FUNCTION__); 1043 debug_add("Failed to login automatically with username '{$this->_person->username}' '.", MIDCOM_LOG_ERROR);1039 debug_add("Failed to login automatically with username '{$this->_person->username}'.", MIDCOM_LOG_ERROR); 1044 1040 debug_pop(); 1045 1041 } 1046 1042 } 1043 1044 // $this->_send_welcome_mail(); 1045 1046 // $_MIDCOM->auth->request_sudo('net.nehmer.account'); 1047 1048 // Trigger post-activation hooks 1049 $this->_auto_publish_account_details(); 1050 $this->_invoke_account_activation_callback(); 1051 1052 // $_MIDCOM->auth->drop_sudo(); 1047 1053 1048 1054 $this->_send_welcome_mail(); 1049 1055 1050 $_MIDCOM->auth->request_sudo('net.nehmer.account');1056 // $_MIDCOM->auth->request_sudo('net.nehmer.account'); 1051 1057 1052 1058 // Check for a custom return_url … … 1060 1066 $_MIDCOM->auth->drop_sudo(); 1061 1067 1062 1068 $relocate_to = $this->_config->get('relocate_after_activation'); 1069 if ($relocate_to) 1070 { 1071 $_MIDCOM->relocate($relocate_to); 1072 } 1063 1073 } 1064 1074 … … 1098 1108 * This function invokes the callback set in the component configuration upon 1099 1109 * activation of an account. It will be executed at the end of the activation 1100 * with sudo privil geges.1110 * with sudo privileges. 1101 1111 * 1102 1112 * Configuration syntax: trunk/midcom/net.nehmer.account/locale/default.en.txt
r11719 r12169 384 384 ---STRINGEND 385 385 386 ---STRING registration completed 387 Registration completed 388 ---STRINGEND 389 390 ---STRING registration completed successfully 391 Registration was completed successfully 392 ---STRINGEND 393 386 394 ---STRING reject 387 395 Reject trunk/midcom/net.nehmer.account/style/invitation-email-body.php
r11472 r12169 15 15 &(register_link); 16 16 17 18 19 trunk/midcom/net.nehmer.account/viewer.php
r12124 r12169 227 227 'fixed_args' => Array('register'), 228 228 ); 229 $this->_request_switch['register_finish'] = Array230 (231 'handler' => Array('net_nehmer_account_handler_register', 'finish'),232 'fixed_args' => Array('register','finish'),233 );234 229 $this->_request_switch['register'] = Array 235 230 ( … … 250 245 'variable_args' => 1, 251 246 ); 252 247 $this->_request_switch['register_finish'] = Array 248 ( 249 'handler' => Array('net_nehmer_account_handler_register', 'finish'), 250 'fixed_args' => Array('register','finish'), 251 ); 252 253 253 // Pending registrations 254 254 if ($this->_config->get('require_activation'))
