public function process($num = 50)
 {
     $select = $this->util->select();
     $selected_users = array_chunk($select, $num, true);
     foreach ((array) $selected_users[0] as $wp_id => $script_info) {
         $args = array('primary_field' => 'wp_id', 'primary_field_data' => $wp_id);
         try {
             if ($rave_user = \PSU\Rave\User::create($wp_id)) {
                 $this->util->delete($args);
             } else {
                 $this->util->set_flag($args, 'createfail');
             }
             //end else
         } catch (\Exception $e) {
             $this->util->set_flag($args, 'createfail');
         }
         //end catch
         if ($this->debug) {
             echo ($rave_user ? 'Created: ' : 'Failed to create: ') . $wp_id . "\n";
         }
         //end if
     }
     //end foreach
     return count($this->util->select());
 }
 public function process($num = 50)
 {
     $select = $this->util->select();
     $selected_users = array_chunk($select, $num, true);
     foreach ((array) $selected_users[0] as $wp_id => $script_info) {
         $args = array('primary_field' => 'wp_id', 'primary_field_data' => $wp_id);
         if ($rave_user = \PSU\Rave\User::get($wp_id)) {
             if ($deleted = $rave_user->delete()) {
                 $this->util->delete($args);
             } else {
                 $this->util->set_flag($args, 'deletefail');
             }
             //end else
             if ($this->debug) {
                 echo ($deleted ? 'Removed: ' : 'Failed to remove: ') . $wp_id;
             }
             //end if
         } else {
             // if this user doesn't have a Rave account, delete the util record and move on
             $this->util->delete($args);
         }
         //end else
     }
     //end foreach
     return count($this->util->select());
 }
 public function process($num = 50)
 {
     $select = $this->util->select();
     $selected_users = array_chunk($select, $num, true);
     foreach ((array) $selected_users[0] as $wp_id => $script_info) {
         $args = array('primary_field' => 'wp_id', 'primary_field_data' => $wp_id);
         if ($rave_user = \PSU\Rave\User::get($wp_id)) {
             //If the user exists in Rave, but has no phone numbers, lets add their Banner mobile number unconfirmed
             if ($rave_user->phones()->count() === 0) {
                 $phone_args = array('wp_id' => $wp_id, 'phone' => $script_info['mobile_number']);
                 $phone = new \PSU\Rave\Phone($phone_args);
                 $phone->save('no_confirm');
                 try {
                     if ($rave_user->save()) {
                         $this->util->delete($args);
                     } else {
                         $this->util->set_flag($args, 'savefail');
                     }
                     //end else
                 } catch (\Exception $e) {
                     $this->util->set_flag($args, 'savefail');
                 }
                 //end catch
             }
             //end if
         } else {
             try {
                 $rave_user = \PSU\Rave\User::create($wp_id);
                 $phone_args = array('wp_id' => $wp_id, 'phone' => $script_info['mobile_number']);
                 $phone = new \PSU\Rave\Phone($phone_args);
                 $phone->save('no_confirm');
                 try {
                     if ($rave_user->save()) {
                         $this->util->delete($args);
                     } else {
                         $this->util->set_flag($args, 'savefail');
                     }
                     //end else
                 } catch (\Exception $e) {
                     $this->util->set_flag($args, 'savefail');
                 }
                 //end catch
             } catch (\Exception $e) {
                 $this->util->set_flag($args, 'createfail');
             }
             //end catch
             if ($this->debug) {
                 echo ($rave_user ? 'Created: ' : 'Failed to create: ') . $wp_id . "\n";
             }
             //end if
         }
         // end else
     }
     //end foreach
     return count($this->util->select());
 }
Exemplo n.º 4
0
/**
 * Routing provided by klein.php (https://github.com/chriso/klein.php)
 * Make some objects available elsewhere.
 */
respond(function ($request, $response, $app) {
    // initialize the template
    $app->tpl = new PSUTemplate();
    // get the logged in user
    $app->user = PSUPerson::get($_SESSION['wp_id']);
    $app->groups = array();
    // assign user to template
    $app->tpl->assign('user', $app->user);
    $app->config = new PSU\Config();
    $app->config->load();
    if ('Registered and confirmed' == $app->user->rave_state) {
        $rave_user = \PSU\Rave\User::get($app->user->wpid);
        $app->rave_user = $rave_user;
        // get the rave users groups for the app
        $app->user_groups = array();
        foreach ($app->rave_user->groups() as $group) {
            $app->user_groups[] = $group->attributes()->__toString();
        }
        //end foreach
        // assign all of the groups to the template
        foreach (\Rave\REST\SiteAdmin::getGroups() as $group) {
            $id = $group->attributes()->__toString();
            $app->groups[$id]['id'] = $id;
            $app->groups[$id]['name'] = $group->name->__toString();
            $app->groups[$id]['description'] = $group->description->__toString();
            $app->groups[$id]['subscribed'] = in_array($id, $app->user_groups) ? 'checked="checked"' : '';
        }
Exemplo n.º 5
0
 /**
  * save the number in Rave
  *
  * @param $phone \b phone number
  * @param $option \b the type of Rave manipulation that is being done: (false, opt_out, deferred, resend)
  */
 protected function _rave_save($phone, $option = false)
 {
     $user = \PSU\Rave\User::get($this->wp_id);
     if (!$user) {
         if (!($user = \PSU\Rave\User::create($this->wp_id))) {
             throw new UnexpectedValueException('Could not load user information for ' . $this->wp_id);
         }
         //end if
     }
     // end if
     if (!$phone || $option == 'deferred' || $option == 'opted_out') {
         unset($user->mobileNumber1);
         $confirm = false;
     } else {
         $user->rave_set_phone($phone);
         $confirm = $option != 'no_confirm';
     }
     return $user->save($confirm);
 }