function outreachToWriteUp($OID)
{
    // if the outreach is over
    if (dbIsOutreachOver($OID)) {
        $outreach = dbGetOutreach($OID);
        $row = array("status" => "doingWriteUp");
        dbUpdateOutreach($OID, $row);
    }
}
Example #2
0
function thumbnailForm_submit($form, $form_state)
{
    $params = drupal_get_query_parameters();
    // getting the inputted info from the fields
    $fields = array("FID");
    $picData = getFields($fields, $form_state['values']);
    $picData = stripTags($picData, '');
    $oldFID = isset($form_state['oldFID']) ? $form_state['oldFID'] : 0;
    if (isset($params["UID"])) {
        // if updating user's profile picture
        $UID = $params["UID"];
        replacePicture($picData['FID'], $oldFID, 'Users');
        dbUpdate("profiles", $picData, "UID", $UID);
        drupal_goto("viewUser", array('query' => array('UID' => $UID)));
    } else {
        if (isset($params["OID"])) {
            // if editing outreach thumbnail
            $OID = $params["OID"];
            replacePicture($picData['FID'], $oldFID, 'Outreach');
            dbUpdateOutreach($OID, $picData);
            drupal_goto("viewOutreach", array('query' => array('OID' => $OID)));
        } else {
            if (isset($params["TID"])) {
                // if editing team thumbnail
                $TID = $params["TID"];
                replacePicture($picData['FID'], $oldFID, 'Teams');
                dbUpdateTeam($TID, $picData);
                drupal_goto("viewTeam", array('query' => array('TID' => $TID)));
            } else {
                drupal_goto("myDashboard");
            }
        }
    }
}
Example #3
0
function outreachForm_submit($form, $form_state)
{
    global $user;
    $UID = $user->uid;
    $TID = $form_state['TID'];
    $outreachFields = array("name", "peopleImpacted", "address", "city", "state", "country", "status", "co_organization", "co_firstName", "co_lastName", "co_email", "co_phoneNumber", "isPublic");
    $outreachData = getFields($outreachFields, $form_state['values']);
    $outreachData = stripTags($outreachData, '');
    // remove all tags
    $outreachData['description'] = stripTags(array($form_state['values']['description']));
    // allow some tags
    $outreachData["TID"] = $TID;
    if ($form_state['new']) {
        $outreachData["UID"] = $UID;
    }
    if (isset($form_state['OID'])) {
        $OID = $form_state['OID'];
        $oldOutreachData = dbGetOutreach($OID);
        if ($outreachData["status"] == "doingWriteUp" && $oldOutreachData["isWriteUpApproved"] == true) {
            $outreachData["writeUpUID"] = null;
            $outreachData["isWriteUpSubmitted"] = 0;
            $outreachData["isWriteUpApproved"] = 0;
        }
    }
    if (!$form_state['new']) {
        // updating existing event
        $OID = $form_state['OID'];
        $result = dbUpdateOutreach($OID, $outreachData);
        if ($result) {
            // if db call was successful
            for ($i = 0; $i < $form_state['numRows']; $i++) {
                // loop through date rows
                $TOID = isset($form_state['fields']['dates']["TOID-{$i}"]) ? $form_state['fields']['dates']["TOID-{$i}"] : 0;
                $timeData['startTime'] = dbDatePHP2SQL(strtotime($form_state['values']["startTime-{$i}"]));
                dpm($timeData['startTime']);
                $timeData['endTime'] = dbDatePHP2SQL(strtotime($form_state['values']["endTime-{$i}"]));
                if ($timeData['startTime'] != null && $timeData['endTime'] != null) {
                    // if row isn't empty
                    if ($TOID != 0) {
                        // update existing record
                        dbUpdateTimesForOutreach($TOID, $timeData);
                    } else {
                        // add a new time record if there wasn't one previously
                        $timeData['OID'] = $OID;
                        dbAddTimesToOutreach($timeData);
                    }
                } else {
                    // remove time record if empty
                    dbRemoveTimeFromOutreach($TOID);
                }
            }
            for ($i = $form_state['numRows']; $i < $form_state['initialNumTimes']; $i++) {
                // executes if times were deleted
                dbRemoveTimeFromOutreach($form_state['fields']['dates']["TOID-{$i}"]);
            }
            $notification = array();
            $userName = dbGetUserName($user->uid);
            $outName = dbGetOutreachName($OID);
            $notification['dateCreated'] = dbDatePHP2SQL(time());
            $notification['dateTargeted'] = dbDatePHP2SQL(time());
            $notification['message'] = "{$userName} has updated outreach {$outName}.";
            $notification['bttnTitle'] = 'View';
            $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
            $notification['TID'] = $TID;
            notifyUsersByRole($notification, 'moderator');
            // handle tags
            if (!empty($form_state['values']['tags'])) {
                $newTags = $form_state['values']['tags'];
                $previous = dbGetTagsForOutreach($OID, true);
                // the "true" means this will return only OTID's
                if ($previous == false) {
                    // if there aren't any tags
                    $previous = array();
                }
                $deleted = array_diff($previous, $newTags);
                $added = array_diff($newTags, $previous);
                foreach ($deleted as $delete) {
                    // $delete is the OTID to be removed from the outreach
                    if (!empty($delete)) {
                        dbRemoveTagFromOutreach($delete, $OID);
                    }
                }
                foreach ($added as $add) {
                    // $add is the OTID to be added to the outreach
                    if (!empty($add)) {
                        dbAddTagToOutreach($add, $OID);
                    }
                }
            }
            drupal_set_message("Outreach updated!");
        } else {
            drupal_set_message("Outreach not updated.");
        }
    } else {
        // adding new event
        $outreachData['logDate'] = dbDatePHP2SQL(time());
        $OID = dbCreateOutreach($outreachData);
        if ($OID != false) {
            dbAddUserAsOwnerOfOutreach($UID, $OID);
            dbAssignUserToOutreach($UID, $OID, 'owner');
            // handle times
            if ($outreachData['status'] != 'isIdea') {
                for ($i = 0; $i < $form_state['numRows']; $i++) {
                    $time = array("startTime-{$i}", "endTime-{$i}");
                    $timeData = getFields($time, $form_state['values']);
                    if ($timeData["startTime-{$i}"] != null && $timeData["endTime-{$i}"] != null) {
                        // rename array keys to match columns
                        $timeData['startTime'] = dbDatePHP2SQL(strtotime($timeData["startTime-{$i}"]));
                        $timeData['endTime'] = dbDatePHP2SQL(strtotime($timeData["endTime-{$i}"]));
                        unset($timeData["endTime-{$i}"], $timeData["startTime-{$i}"]);
                        $timeData['OID'] = $OID;
                        dbAddTimesToOutreach($timeData);
                    }
                }
            }
            // handle tags
            if (!empty($form_state['values']['tags'])) {
                foreach ($form_state['values']['tags'] as $OTID) {
                    dbAddTagToOutreach($OTID, $OID);
                }
            }
            // create notification
            $notification = array();
            $userName = dbGetUserName($user->uid);
            $outName = dbGetOutreachName($OID);
            $notification['dateCreated'] = dbDatePHP2SQL(time());
            $notification['dateTargeted'] = dbDatePHP2SQL(time());
            $notification['message'] = "{$userName} has created outreach {$outName}.";
            $notification['bttnTitle'] = 'View';
            $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
            $notification['TID'] = $TID;
            notifyUsersByRole($notification, 'moderator');
            drupal_set_message("Outreach created!");
        } else {
            // if the $OID IS false
            form_set_error("Outreach not created successfully");
        }
    }
    if (dbIsOutreachOver($OID)) {
        drupal_set_message("It appears you are logging an old event. Don't forget to <a href=\"?q=logHours&OID={$OID}\"><b>log old hours</b></a>!");
    }
    drupal_goto('viewOutreach', array('query' => array('OID' => $OID)));
}
Example #4
0
function reject($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $TID = getCurrentTeam()['TID'];
    $OID = $params["OID"];
    $outreachData = dbGetOutreach($OID);
    $writeUpUpdate['status'] = "doingWriteUp";
    $writeUpUpdate['writeUpUID'] = null;
    $writeUpUpdate['isWriteUpSubmitted'] = 0;
    $result = dbUpdateOutreach($OID, $writeUpUpdate);
    $notification = array();
    $userName = dbGetUserName($user->uid);
    $outName = dbGetOutreachName($OID);
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    $notification['dateTargeted'] = dbDatePHP2SQL(time());
    $notification['message'] = "{$userName} has rejected a write up for {$outName}.";
    $notification['bttnTitle'] = 'Redo Write Up';
    $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
    $notification['TID'] = $TID;
    $notification['UID'] = $outreachData['writeUpUID'];
    dbAddNotification($notification);
    drupal_set_message("Write Up Rejected.");
    drupal_goto('viewOutreach', array('query' => array('OID' => $OID)));
}