Пример #1
0
function populateTestData()
{
    dbCreateTeam(array("name" => "Team Appreciate", "number" => "2468", "type" => "FRC", "city" => "1000 Westbank Austin TX 78746", "state" => "Texas", "country" => "United States", "isActive" => true));
    dbCreateTeam(array("name" => "The Poofs", "number" => "254", "isActive" => true));
    dbCreateTeam(array("name" => "RobotTots", "number" => "118", "isActive" => true));
    dbCreateTeam(array("name" => "Katies Team", "number" => "3310", "isActive" => true));
    dbCreateProfile(array("firstName" => "Philip", "lastName" => "Liu", "bio" => "Philip Liu is a sophomore at Westlake High School. He has been highly involved with STEM programs since a young age and has developed many skills such as leadership, communication, and perseverance. In Chap Research, Philip is currently working on two different projects. The first is an all hardware project called the Chap Measuring Press (CMP) while the second is the Chap Research Outreach Management Application (CROMA). He is a member of FRC 2468 Team Appreciate and works in many sub-systems. In addition to working with the robot design, CAD, and manufacturing, he manages the documentation and portfolio for the outreach team. With all these generous opportunities, he uses his knowledge (so far) to mentor FTC teams. Outside of robotics and school, Philip practices TaeKwonDo (a soon-to-be instructor), dances, and plays football, basketball, and fantasy with his friends. In order to balance his time with a laughing and happy manner, his favorite quote is 'where there is a will, there is a way.'", "position" => "CROMA Admin", "phone" => "512-925-2241", "grade" => "10", "gender" => "Male"));
    dbCreateProfile(array("firstName" => "Parker", "lastName" => "Bergen"));
    dbCreateProfile(array("firstName" => "Rachel", "lastName" => "Gardner"));
    dbCreateProfile(array("firstName" => "Lewis", "lastName" => "Jones"));
    dbAssignUserToTeam("2", "1");
    dbAssignUserToTeam("1", "1");
    dbAssignUserToTeam("3", "1");
    dbApproveUser("1", "1");
    dbApproveUser("3", "2");
    dbApproveUser("2", "1");
    dbCreateOutreach(array("name" => "CROMA Prep", "status" => "isOutreach", "logDate" => date("Y-m-d H:i:s", time()), "TID" => "1", "address" => "my house", "description" => "An event"));
    dbCreateOutreach(array("name" => "SXSW", "status" => "isOutreach", "logDate" => time(), "address" => "my house", "description" => "An event"));
    dbCreateOutreach(array("name" => "Barnes and Nobles", "status" => "isOutreach", "logDate" => time(), "address" => "my house", "description" => "An event", "TID" => "1"));
    dbCreateOutreach(array("name" => "CROMA Prep", "status" => "isOutreach", "TID" => "1"));
    dbCreateOutreach(array("name" => "NI Week", "status" => "isIdea", "TID" => "1"));
    dbCreateOutreach(array("name" => "Robot Fair", "description" => "Promoting STEM education to the community", "type" => "Ripple Effect", "status" => "isIdea"));
    dbApproveEvent("1");
    dbAssignUserToOutreach("1", "1");
    dbAssignUserToOutreach("1", "2");
    dbAssignUserToOutreach("1", "3");
    dbAssignUserToOutreach("1", "4");
    dbAssignUserToOutreach("2", "2");
    dbLogHours(array("UID" => "1", "OID" => "1", "numberOfHours" => "12", "type" => "Pre"));
    dbLogHours(array("UID" => "2", "OID" => "1", "numberOfHours" => "15", "type" => "Post"));
    dbAddMedia(array("OID" => null, "title" => "test", "UID" => "1", "description" => "fbsjdfjsdg", "dateEntered" => time(), "link" => "https://pbs.twimg.com/profile_images/447374371917922304/P4BzupWu.jpeg"));
    dbAddMedia(array("OID" => null, "UID" => "1", "description" => "YO HOMEDAWG", "dateEntered" => time(), "link" => "http://croma.chapresearch.com/sites/default/files/CROMA%20Logo%20v1_0.png"));
    dbAddMedia(array("OID" => "1", "UID" => "1", "description" => "Ni Hao", "dateEntered" => time(), "link" => "http://chapresearch.com/wp-content/uploads/2015/08/William-e1439428977920.jpg"));
    dbAddMedia(array("OID" => "2", "description" => "Philip likes Chap Research"));
    dbAddMedia(array("OID" => null, "UID" => "1", "title" => "FUNNY"));
    dbAddEmails("1", array("*****@*****.**"));
    dbAddEmails("1", array("*****@*****.**"));
    dbAddEmails("2", array("*****@*****.**"));
    dbAddEmails("2", array("*****@*****.**"));
    dbAddTimesToOutreach(array("OID" => "1", "startTime" => "5/25/15", "endTime" => "5/26/15"));
    dbAddTimesToOutreach(array("OID" => "2", "startTime" => "1/25/15", "endTime" => "3/26/15"));
    dbAddTimesToOutreach(array("OID" => "2", "startTime" => "9/2/15", "endTime" => "11/12/15"));
    dbAddTimesToOutreach(array("OID" => "4", "startTime" => "1/3/15", "endTime" => "3/28/15"));
    dbAddNotification(array("TID" => "1", "UID" => "1", "date" => "11/10/15", "title" => "Dell Family Day", "message" => "This event will take place on Saturday, November 28th, at the J.W. Marriott hotel in Downtown Austin. We need all Robowranglers to attend."));
    dbAddNotification(array("TID" => "4", "UID" => "1", "date" => "15/4/15", "title" => "Barnes and Noble", "message" => "This event will take place on Saturday, November 7th at the Barnes and Noble in the Hill Country Galleria. See Roger Newton for details."));
    dbAddNotification(array("TID" => "3", "UID" => "1", "date" => "12/1/15", "title" => "Freescale Marathon", "message" => "Informal event... Show up on December 31st to wish the runners at the finish line a Happy New Year!"));
}
Пример #2
0
function profileForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (!isset($params['UID'])) {
        $UID = $user->uid;
    } else {
        $UID = $params['UID'];
    }
    // getting the inputted info from the fields
    $fields = array("firstName", "lastName", "position", "phone", "grade", "gender", "FID", "type");
    $profileData = getFields($fields, $form_state['values']);
    $profileData = stripTags($profileData, '');
    $profileData['UID'] = $UID;
    $profileData['bio'] = stripTags(array($form_state['values']['bio']));
    // allow some tags in the bio only
    if (dbUserHasProfile($profileData['UID']) == false) {
        // if the user doesn't have a profile
        $result = dbCreateProfile($profileData);
        // creating new profile
        if ($result != false) {
            drupal_set_message("Your profile has been created!");
            // if it went through successfully
        } else {
            drupal_set_message("There was an error.");
            // if something "bad" occured during submission
        }
    } else {
        // if the user is simply editing existing profile
        dbUpdate("profiles", $profileData, "UID", $profileData['UID']);
        drupal_set_message("Profile has been updated!");
    }
    if (!empty($form_state['values']['secondaryEmail'])) {
        // user entered value
        if (dbGetSecondaryEmailForUser($profileData['UID']) == false) {
            // the user is adding a new secondary email
            dbAddEmailsToUser($profileData['UID'], array(trim($form_state['values']['secondaryEmail'])));
        } else {
            //  user is updating an old email
            dbUpdate('emailsVsUsers', array('email' => $form_state['values']['secondaryEmail']), "UID", $profileData['UID']);
        }
    } else {
        // user didn't enter value
        dbRemoveEntry('emailsVsUsers', 'UID', $profileData['UID']);
    }
    drupal_goto("viewUser", array('query' => array('UID' => $UID)));
}
Пример #3
0
function createNewUser($form_state)
{
    //This will generate a random password, you could set your own here
    $password = user_password(8);
    $userName = $form_state['values']['firstName'] . ' ' . $form_state['values']['lastName'];
    //set up the user fields
    $fields = array('name' => $form_state['values']['primaryEmail'], 'mail' => $form_state['values']['primaryEmail'], 'pass' => $password, 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'));
    //the first parameter is left blank so a new user is created
    $account = user_save('', $fields);
    // Manually set the password so it appears in the e-mail.
    $account->password = $fields['pass'];
    // Send the e-mail through the user module.
    $params['url'] = user_pass_reset_url($account);
    $params['teamName'] = dbGetTeamName($form_state['TID']);
    drupal_mail('users', 'userCreated', $form_state['values']['primaryEmail'], NULL, $params, '*****@*****.**');
    $fields = array('firstName', 'lastName');
    $profileData = getFields($fields, $form_state['values']);
    $profileData = stripTags($profileData, '');
    $profileData['UID'] = $account->uid;
    dbCreateProfile($profileData);
    // creating new profile
    return $profileData['UID'];
}