Changeset 12169

Show
Ignore:
Timestamp:
09/12/07 13:35:55 (1 year ago)
Author:
w_i
Message:

Cleaning

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/net.nehmer.account/config/config.inc

    r12069 r12169  
    4545'account_activation_timeout' => 7, // days 
    4646'publish_all_on_activation' => false, 
     47 
     48'relocate_after_activation' => false, 
    4749 
    4850// Avatar Sizes 
  • trunk/midcom/net.nehmer.account/handler/invitation.php

    r11935 r12169  
    3838        $persons = $qb->execute(); 
    3939 
    40         if ($persons
     40        if (count($persons) > 0
    4141        { 
    4242            return $persons; 
     
    4444        else 
    4545        { 
    46                 return false; 
     46            return false; 
    4747        } 
    4848    } 
     
    5151     * Adds a buddy 
    5252     */ 
    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) 
    8586    { 
    8687    /** 
    8788         * Sending invitations 
    8889         */ 
     90         debug_add("Sending email to {$email}, {$name}"); 
    8991         $this->_mail = new org_openpsa_mail(); 
    90          $this->_mail->to = $_POST["net_nehmer_invitation_invitee_name{$i}"]
     92         $this->_mail->to = $email
    9193         $this->_mail->from = $_MIDCOM->auth->user->_storage->email; 
    9294         $this->_mail->subject = $this->_l10n->get($this->_config->get('email_subject')); 
    9395         // This may be a hack, but it allows us tons more control in rendering the email 
    9496         $_MIDCOM->style->enter_context(0); 
     97         $this->_request_data['sender_username'] = $_MIDCOM->auth->user->_storage->username; 
    9598         $this->_request_data['user_message'] = $this->_user_defined_message; 
    9699         ob_start(); 
     
    144147    function _handler_invite($handler_id, $args, &$data) 
    145148    { 
    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         
    150153        if (isset($_POST['net_nehmer_accounts_invitation_submit'])) 
    151154        { 
     
    154157                if ($i >= $this->_config->get('email_fields') && !isset($_POST["net_nehmer_accounts_invitation_invitee_selected_{$i}"])) 
    155158                { 
    156                     echo "Continuing"; 
     159                    //echo "Continuing"; 
    157160                    continue; 
    158161                } 
     
    178181                    $this->_invite->email = $_POST["net_nehmer_accounts_invitation_invitee_email_{$i}"]; 
    179182                    $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) 
    184191                            { 
    185                                 foreach ($persons as $person) 
     192                                foreach ($allready_registered as $person) 
    186193                        { 
    187194                            $this->_add_as_buddy($person->guid); 
    188195                        } 
    189196 
    190                         $_MIDCOM->relocate('sent_invites')
     197                        continue
    191198                    } 
    192199                    else 
     
    196203                            debug_add("Could not create invite object ID " . $this->_invite->id); 
    197204                        } 
     205                        debug_print_r("Created invite: ",$this->_invite); 
    198206                    } 
    199207 
    200208                    $this->_request_data['hash'] = $this->_invite->hash; 
    201209 
    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                    ); 
    203214                } 
    204215            
    205216            } 
     217            debug_pop(); 
    206218            $_MIDCOM->relocate('sent_invites'); 
    207219            } 
     
    227239        $qb->add_constraint('metadata.creator', '=', $_MIDCOM->auth->user->guid); 
    228240 
    229        $invites = $qb->execute(); 
     241        $invites = $qb->execute(); 
    230242 
    231243        $current_time = time(); 
    232        $keep_sent_invites = $this->_config->get('keep_sent_invites'); 
     244        $keep_sent_invites = $this->_config->get('keep_sent_invites'); 
    233245 
    234246        /** 
    235         * Removing expired invites 
    236         */ 
    237        foreach($invites as $invite) 
    238        
     247        * Removing expired invites 
     248        */ 
     249        foreach($invites as $invite) 
     250       
    239251            if ($current_time > ($invite->metadata->created + $keep_sent_invites * 86400)) 
    240            { 
     252            { 
    241253                $invite->delete(); 
    242            } 
    243              
    244        
    245  
    246        $this->_sent_invites = $qb->execute(); 
     254            } 
     255 
     256       
     257 
     258        $this->_sent_invites = $qb->execute(); 
    247259 
    248260        return true; 
     
    254266 
    255267        foreach ($this->_sent_invites as $invite) 
    256        
    257            $this->_request_data['invite'] = $invite; 
     268       
     269            $this->_request_data['invite'] = $invite; 
    258270            midcom_show_style('invites-list-item'); 
    259        
     271       
    260272 
    261273        midcom_show_style('invites-list-footer'); 
  • trunk/midcom/net.nehmer.account/handler/register.php

    r12123 r12169  
    10221022        $this->_person->delete_parameter('net.nehmer.account', 'activation_hash_created'); 
    10231023 
    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(); 
    10291025 
    10301026        $auto_login_sitegroup = $this->_config->get('auto_login_on_activation'); 
     
    10411037            { 
    10421038                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); 
    10441040                debug_pop(); 
    10451041            } 
    10461042        } 
     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(); 
    10471053         
    10481054        $this->_send_welcome_mail(); 
    10491055 
    1050         $_MIDCOM->auth->request_sudo('net.nehmer.account'); 
     1056        // $_MIDCOM->auth->request_sudo('net.nehmer.account'); 
    10511057 
    10521058        // Check for a custom return_url 
     
    10601066        $_MIDCOM->auth->drop_sudo(); 
    10611067         
    1062          
     1068        $relocate_to = $this->_config->get('relocate_after_activation'); 
     1069        if ($relocate_to) 
     1070        { 
     1071            $_MIDCOM->relocate($relocate_to); 
     1072        } 
    10631073    } 
    10641074     
     
    10981108     * This function invokes the callback set in the component configuration upon 
    10991109     * activation of an account. It will be executed at the end of the activation 
    1100      * with sudo privilgeges. 
     1110     * with sudo privileges. 
    11011111     * 
    11021112     * Configuration syntax: 
  • trunk/midcom/net.nehmer.account/locale/default.en.txt

    r11719 r12169  
    384384---STRINGEND 
    385385 
     386---STRING registration completed 
     387Registration completed 
     388---STRINGEND 
     389 
     390---STRING registration completed successfully 
     391Registration was completed successfully 
     392---STRINGEND 
     393 
    386394---STRING reject 
    387395Reject 
  • trunk/midcom/net.nehmer.account/style/invitation-email-body.php

    r11472 r12169  
    1515&(register_link); 
    1616 
    17  
    18  
    19  
  • trunk/midcom/net.nehmer.account/viewer.php

    r12124 r12169  
    227227                'fixed_args' => Array('register'), 
    228228            ); 
    229             $this->_request_switch['register_finish'] = Array 
    230             ( 
    231                 'handler' => Array('net_nehmer_account_handler_register', 'finish'), 
    232                 'fixed_args' => Array('register','finish'), 
    233             ); 
    234229            $this->_request_switch['register'] = Array 
    235230            ( 
     
    250245                'variable_args' => 1, 
    251246            ); 
    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         
    253253            // Pending registrations 
    254254            if ($this->_config->get('require_activation'))