1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Deferred User & Thread class

Discussion in 'Closed Suggestions' started by xf_phantom, Jul 23, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    Please move this part
    PHP:
    if ($userDw->setExistingData($userId))
           {
             if (
    $userModel->isUserSuperAdmin($userDw->getMergedData()))
             {
               
    // no updating of super admins
               
    continue;
             }

             if (!empty(
    $data['actions']['delete']))
             {
               if (!
    $userDw->get('is_admin') && !$userDw->get('is_moderator'))
               {
                 
    $userDw->delete();
               }
             }
             else
             {
               if (!empty(
    $data['actions']['set_primary_group_id']))
               {
                 
    $userDw->set('user_group_id'$data['actions']['set_primary_group_id']);
               }

               
    $groups explode(','$userDw->get('secondary_group_ids'));

               if (!empty(
    $data['actions']['add_group_id']))
               {
                 
    $groups[] = $data['actions']['add_group_id'];
                 
    $userDw->setSecondaryGroups($groups);
               }

               if (!empty(
    $data['actions']['remove_group_id']))
               {
                 
    $searchKey array_search(intval($data['actions']['remove_group_id']), $groups);
                 if (
    $searchKey !== false)
                 {
                   unset(
    $groups[$searchKey]);
                 }
                 
    $userDw->setSecondaryGroups($groups);
               }

               if (!empty(
    $data['actions']['discourage']))
               {
                 
    $userDw->set('is_discouraged'1);
               }

               if (!empty(
    $data['actions']['undiscourage']))
               {
                 
    $userDw->set('is_discouraged'0);
               }

               if (!empty(
    $data['actions']['remove_avatar']))
               {
                 
    XenForo_Model::create('XenForo_Model_Avatar')->deleteAvatar($userId);
               }

               if (!empty(
    $data['actions']['remove_signature']))
               {
                 
    $userDw->set('signature''');
               }

               if (!empty(
    $data['actions']['remove_homepage']))
               {
                 
    $userDw->set('homepage''');
               }

               if (!empty(
    $data['actions']['custom_title']))
               {
                 
    $userDw->set('custom_title'$data['actions']['custom_title']);
               }

               if (!empty(
    $data['actions']['ban']) && !$userDw->get('is_admin') && !$userDw->get('is_moderator'))
               {
                 if (
    $ban XenForo_Model::create('XenForo_Model_Banning')->getBannedUserById($userId))
                 {
                   
    $existing true;
                 }
                 else
                 {
                   
    $existing false;
                 }

                 
    $userModel->ban($userId0''$existing);
               }

               if (!empty(
    $data['actions']['unban']))
               {
                 
    $userModel->liftBan($userId);
               }

               
    $userDw->save();
             }
    into a own method.

    This way, we could add own actions ( via template admin template user_batch_update_confirm ) and then just use the proxy system to extend the deferred class.

    if the code would be
    PHP:
    foreach ($userIds AS $key => $userId)
         {
           
    $data['count']++;
           
    $data['start'] = $userId;
           unset(
    $userIds[$key]);

           
    /* @var $userDw XenForo_DataWriter_User */
           
    $userDw XenForo_DataWriter::create('XenForo_DataWriter_User'XenForo_DataWriter::ERROR_SILENT);
           if (
    $userDw->setExistingData($userId))
           {
        
           
    $this->runActions($dw);

               
    $userDw->save();
             }
           }

           if (
    $limitTime && microtime(true) - $s $targetRunTime)
           {
             break;
           }
         }
    i could just overwrite runActions with an method calling parent::runActions and attach my own actions ...

    ATM i have to overwrite the WHOLE execute method :/ => impossible to use with more addons....


    The same is also valid for the ThreadAction Deferred Class
     

Share This Page