示例#1
0
    $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"' : '';
        }
        //end foreach
        unset($app->groups[$GLOBALS['EMERGENCY_GROUP']]);
    }
    //end if
});
/**
 * Catch the form's submission
 */
respond('POST', '/', function ($request, $response, $app) {
示例#2
0
 /**
  * validate the carrier
  * @param which number to check (1, 2 or 3)
  * @param boolean indicating whether or not we should lookup the carrier
  */
 private function validateCarrier($which, $lookup = false)
 {
     $carrier = 'mobileCarrier' . $which;
     if (isset($this->{$carrier})) {
         if (!filter_var($this->{$carrier}, FILTER_VALIDATE_INT)) {
             $this->error = 'Carrier number did not validate';
             return false;
         }
         // end if
     }
     // end if
     if ($lookup) {
         try {
             $number = 'mobileNumber' . $which;
             $carrier_xml_obj = \Rave\REST\SiteAdmin::lookupCarrier($this->{$number});
             $this->{$carrier} = $carrier_xml_obj['id'];
         } catch (UnknownCarrier $e) {
             $this->error = 'Unknown carrier';
             return false;
         }
         // end catch
     }
     // end if
     return true;
 }