Example #1
0
 /**
  * query if editable for current user
  */
 static function getEditableById($id)
 {
     if ($c = File::getById(intval($id))) {
         if ($p = Project::getById($c->project)) {
             if ($p->validateEditItem($c, false)) {
                 return $c;
             }
         }
     }
     return NULL;
 }
Example #2
0
 public static function getNumPics()
 {
     $database = cbSQLConnect::connect('object');
     $result = array();
     if (isset($database)) {
         $num_pics = $database->QuerySingle("SELECT * FROM person WHERE `profile_pic` IS NOT NULL;");
         if ($num_pics) {
             $result[0] = "success";
             $result[1] = count($num_pics);
             $result[2] = array();
             $count = 0;
             foreach ($num_pics as $individual) {
                 $result[2][$count] = File::getById($individual->profile_pic);
                 $result[2][$count]->individual_id = $individual->id;
                 $count++;
             }
             return $result;
         } else {
             return null;
         }
     }
 }
Example #3
0
function handleFileAPI($args, $that)
{
    $session = mySession::getInstance();
    // if ($that->method === 'POST') {
    if ($that->method === 'DELETE' && $session->isLoggedIn() && $session->isAdmin()) {
        $id = intval(array_shift($args));
        if ($id && is_numeric($id)) {
            $file = File::getById($id);
            return $file->delete();
        }
    } else {
        if ($that->method === 'POST' && $session->isLoggedIn() && $session->isAdmin()) {
            if ($that->verb === 'update') {
                $file = $that->file;
                return Dropzone::updateFile($file);
            } else {
                if (!empty($_POST)) {
                    $info = json_decode($_POST['info']);
                } else {
                    $info = null;
                }
                if ($info) {
                    $ds = DIRECTORY_SEPARATOR;
                    $storeFolder = 'uploads';
                    if (!empty($_FILES)) {
                        $file = recast('Dropzone', $info);
                        $file->file = new stdClass();
                        $file->file->error = $_FILES['uploadfile']['error'][0];
                        $file->file->name = $_FILES['uploadfile']['name'][0];
                        $file->file->size = $_FILES['uploadfile']['size'][0];
                        $file->file->tmp_name = $_FILES['uploadfile']['tmp_name'][0];
                        $file->file->type = $_FILES['uploadfile']['type'][0];
                        return $file->save();
                    } else {
                        return false;
                    }
                }
            }
            return false;
        } else {
            if ($that->method === 'GET') {
                if ($that->verb === 'getAll' && $session->isAdmin()) {
                    return File::getAll();
                } else {
                    if ($that->verb === 'getTypeahead') {
                        $type = isset($args[1]) ? $args[1] : 'person';
                        $limit = isset($args[2]) ? $args[2] : true;
                        $val = $args[0];
                        if ($val === 'object' && $type === 'place') {
                            $val = json_decode($_GET['place']);
                            if (isset($val) && !empty($val)) {
                                $val = $val[0];
                            }
                        }
                        return File::getByTagType($val, $type, $limit);
                        return $type;
                    } else {
                        if ($that->verb === "getTags") {
                            // Get all edit information required for file edits.
                            $id = intval($args[0]);
                            if (isset($id) && is_numeric($id)) {
                                return Tag::getByFileId($id);
                            }
                            return false;
                        } else {
                            if ($that->verb === "") {
                                // Get all edit information required for file edits.
                                $id = intval($args[0]);
                                if (isset($id) && is_numeric($id)) {
                                    $file = File::getById($id);
                                    return $file;
                                }
                                return false;
                            }
                        }
                    }
                }
            }
        }
    }
    return "Only accepts GET AND POSTS requests";
}
Example #4
0
             echo json_encode($data);
             exit;
         } else {
             echo "Failure";
             exit;
         }
     }
     echo "Failure";
     exit;
 }
 if ($action == 'getProfilePic') {
     $id = getRequest("id");
     if ($id) {
         $person = Person::getById($id);
         if ($person->profile_pic) {
             $response = File::getById($person->profile_pic);
             if ($response) {
                 echo json_encode($response);
             } else {
                 echo json_encode(false);
             }
         } else {
             echo json_encode(false);
         }
         exit;
     } else {
         echo json_encode(false);
     }
     exit;
 }
 if ($action == 'setProfilePic') {
Example #5
0
function handleIndividualAPI($args, $that)
{
    $session = mySession::getInstance();
    if ($that->method === 'GET') {
        if ($that->verb === '') {
            $id = intval(array_shift($args));
            if ($id && is_numeric($id)) {
                $session = mySession::getInstance();
                if ($id > -1) {
                    $person = Person::getById($id);
                    if ($person) {
                        $person->appendNames();
                        $person->birth = Birth::getById($id);
                        if ($person->birth) {
                            $person->birth->birthPlace = Place::getById($person->birth->place);
                        }
                        $person->death = Death::getById($id);
                        if ($person->death) {
                            $person->death->deathPlace = Place::getById($person->death->place);
                        }
                        $person->burial = Burial::getById($id);
                        if ($person->burial) {
                            $person->burial->burialPlace = Place::getById($person->burial->place);
                        }
                        $person->parents = Parents::getParentsOf($id);
                        $person->children = Parents::getChildrenOf($id);
                        $person->spouse = Spouse::getById($id);
                        $person->profilePicture = File::getById($person->profile_pic);
                        return $person;
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        } else {
            if ($that->verb === 'submissions') {
                $user = User::current_user();
                $submissions = Person::getSubmissions($user);
                return $submissions;
            } else {
                if ($that->verb === 'allSubmissions' && $session->isAdmin()) {
                    $submissions = Person::getSubmissions();
                    return $submissions;
                } else {
                    if ($that->verb === 'children') {
                        if (count($args) > 2 || count($args) < 2) {
                            return array();
                        } else {
                            $id = intval(array_shift($args));
                            $spouseid = intval(array_shift($args));
                            if ($id && is_numeric($id) && $spouseid && is_numeric($spouseid)) {
                                $children = Person::getChildrenByParents($id, $spouseid);
                                $result = array();
                                if ($children && is_array($children) && count($children)) {
                                    foreach ($children as $child) {
                                        $person = Person::getById($child->child);
                                        $person->appendNames();
                                        $person->profilePicture = File::getById($person->profile_pic);
                                        $result[] = $person;
                                    }
                                }
                                return $result;
                            } else {
                                return array();
                            }
                        }
                    } else {
                        if ($that->verb === 'families') {
                            if (!empty($args)) {
                                $letter = array_shift($args);
                            } else {
                                $letter = 'a';
                            }
                            $all = array_shift($args);
                            $all = $all === "true" ? true : false;
                            $names = array();
                            $families = Person::getLastNames($letter, $all);
                            if ($families) {
                                foreach ($families as $key) {
                                    $names[] = $key['lastName'];
                                }
                            }
                            return $names;
                        } else {
                            if ($that->verb === 'family') {
                                $id = intval(array_shift($args));
                                if ($id && is_numeric($id)) {
                                    $person = Person::getById($id);
                                    $person->appendNames();
                                    $family = new stdClass();
                                    $family->self = $person;
                                    $family->parents = array();
                                    // $family->siblings = array();
                                    $children = $person->getChildren();
                                    $family->children = array();
                                    foreach ($children as $child) {
                                        $temp = Person::getById($child->child);
                                        $temp->appendNames();
                                        $family->children[] = $temp;
                                    }
                                    $spouses = $person->getSpouse();
                                    $family->spouses = array();
                                    foreach ($spouses as $spouse) {
                                        $temp = Person::getById($spouse->spouse);
                                        $temp->appendNames();
                                        $family->spouses[] = $temp;
                                    }
                                    $siblings = array();
                                    $tempsiblings = array();
                                    $person->getParentsGen(4);
                                    $family->parents = $person->parents;
                                    // foreach ($parents as $key) {
                                    //   $parent = Person::getById($key->parentId);
                                    //   $parent->appendNames();
                                    //   $family->parents[] = $parent;
                                    //   // $siblings[] = $parent->getChildren();
                                    // }
                                    // foreach ($siblings as $sibling) {
                                    //   foreach ($sibling as $key) {
                                    //     $test = true;
                                    //     foreach ($tempsiblings as $value) {
                                    //       if ($key->child === $value->child) {
                                    //         $test = false;
                                    //       }
                                    //     }
                                    //     if ($test) {
                                    //       $tempsiblings[] = $key;
                                    //     }
                                    //   }
                                    // }
                                    // foreach ($tempsiblings as $sibling) {
                                    //   if ($sibling->child !== $person->id) {
                                    //     $family->siblings[] = Person::getById($sibling->child);
                                    //   }
                                    // }
                                    // foreach ($family->parents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->grandParents[] = $temp;
                                    //   }
                                    // }
                                    // foreach ($family->grandParents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->greatGrandParents[] = $temp;
                                    //   }
                                    // }
                                    // foreach ($family->greatGrandParents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->greatGreatGrandParents[] = $temp;
                                    //   }
                                    // }
                                    return $family;
                                } else {
                                    return new stdClass();
                                }
                            } else {
                                if ($that->verb === 'familyNames') {
                                    if (!empty($args)) {
                                        $lastName = array_shift($args);
                                    } else {
                                        $lastName = 'Law';
                                    }
                                    $all = array_shift($args);
                                    $all = $all === "true" ? true : false;
                                    $names = array();
                                    $user = User::current_user();
                                    $familyNames = Person::getFirstNames($lastName, $all, $user);
                                    if ($familyNames) {
                                        foreach ($familyNames as $key) {
                                            $key = recast('Person', arrayToObject($key));
                                            $key->appendNames();
                                            $names[] = $key;
                                        }
                                    }
                                    return $names;
                                } else {
                                    if ($that->verb === 'pictures') {
                                        $id = intval(array_shift($args));
                                        if ($id && is_numeric($id)) {
                                            $session = mySession::getInstance();
                                            if ($id > -1) {
                                                $person = Person::getById($id);
                                                if ($person) {
                                                    return File::getByInd($person->id, 'image');
                                                }
                                            }
                                        } else {
                                            return false;
                                        }
                                    } else {
                                        if ($that->verb === 'documents') {
                                            $id = intval(array_shift($args));
                                            if ($id && is_numeric($id)) {
                                                $session = mySession::getInstance();
                                                if ($id > -1) {
                                                    $person = Person::getById($id);
                                                    if ($person) {
                                                        return File::getByInd($person->id, 'document');
                                                    }
                                                }
                                            } else {
                                                return false;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // } else {
        // return false;
        // }
    } else {
        if ($that->method === 'DELETE' && $session->isLoggedIn() && $session->isAdmin()) {
            // } else if ($that->method === 'DELETE'){
            $id = intval($args[0]);
            if (is_numeric($id)) {
                $person = Person::getById($id);
                if ($person) {
                    $birth = Birth::getById($id);
                    if ($birth) {
                        $birth = recast('Birth', $birth);
                        $birth->delete();
                        //delete
                    }
                    $death = Death::getById($id);
                    if ($death) {
                        $death = recast('Death', $death);
                        $death->delete();
                        //delete
                    }
                    $burial = Burial::getById($id);
                    if ($burial) {
                        $burial = recast('Burial', $burial);
                        $burial->delete();
                        //delete
                    }
                    $parents = Parents::getParentsOf($id);
                    if ($parents) {
                        foreach ($parents as $parent) {
                            $parent = recast('Parents', $parent);
                            $parent->delete();
                            //delete $parent
                        }
                    }
                    $children = Parents::getChildrenOf($id);
                    if ($children) {
                        foreach ($children as $child) {
                            $child = recast('Parents', $child);
                            $child->delete();
                            //delete $child
                        }
                    }
                    $mySpouse = Spouse::getById($id);
                    if ($mySpouse) {
                        foreach ($mySpouse as $spouse) {
                            $spouse = recast('Spouse', $spouse);
                            $theirSpouse = Spouse::getById($spouse->personId);
                            if ($theirSpouse) {
                                foreach ($theirSpouse as $otherSpouse) {
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                    //delete $otherSpouse
                                }
                            }
                            $spouse->delete();
                            //delete $spouse
                        }
                    }
                    $tags = Tag::getByIndId($id);
                    if ($tags) {
                        foreach ($tags as $tag) {
                            $tag = recast('Tag', $tag);
                            $tag->delete();
                        }
                    }
                    $person->delete();
                    return true;
                } else {
                    return true;
                }
            }
            return false;
        } else {
            if (($that->method === 'POST' || $that->method === 'PUT') && $session->isLoggedIn()) {
                $user = User::current_user();
                if (!$user->id) {
                    return false;
                }
                $result = $that->file;
                if (empty($result) || empty($result->person) || empty($result->birth) || empty($result->death)) {
                    return 'we failed on check1';
                    return false;
                }
                // return $result;
                $person = recast('Person', $result->person);
                if ($person->id) {
                    $tempPerson = Person::getById($person->id);
                    $person->submitter = $tempPerson->submitter;
                    $person->status = $tempPerson->status;
                    if ($person->submitter !== $user->id && !($user->rights === 'super' || $user->rights === 'admin')) {
                        return 'we failed on check2';
                        return false;
                    }
                }
                if (!empty($person)) {
                    $personId = $person->save($user);
                } else {
                    return false;
                }
                if (!!$personId) {
                    $person->id = $personId;
                    $birth = recast('Birth', $result->birth);
                    $birth->personId = $personId;
                    $birthId = $birth->save();
                    $birth->id = $birthId;
                    $death = recast('Death', $result->death);
                    $death->personId = $personId;
                    $deathId = $death->save();
                    $death->id = $deathId;
                    if ($result->burial) {
                        $burial = recast('Burial', $result->burial);
                        $burial->personId = $personId;
                        $burialId = $burial->save();
                        $burial->id = $burialId;
                    } else {
                        $burial = false;
                    }
                    if (empty($personId) || empty($birthId) || empty($deathId)) {
                        return 'test';
                        return false;
                    }
                    if ($result->birthPlace) {
                        $birthPlace = recast('Place', $result->birthPlace);
                        $birthPlace->ft_name = "birth";
                        $birthPlace->fkey = $birthId;
                        $birth->place = $birthPlace->save();
                        $birth->save();
                    } else {
                        $birth->place = null;
                        $birth->save();
                    }
                    if ($result->deathPlace) {
                        $deathPlace = recast('Place', $result->deathPlace);
                        $deathPlace->ft_name = "death";
                        $deathPlace->fkey = $deathId;
                        $death->place = $deathPlace->save();
                        $death->save();
                    } else {
                        $death->place = null;
                        $death->save();
                    }
                    if ($burial) {
                        if ($result->burialPlace) {
                            $burialPlace = recast('Place', $result->burialPlace);
                            $burialPlace->ft_name = "burial";
                            $burialPlace->fkey = $burial->id;
                            $burial->place = $burialPlace->save();
                            $burial->save();
                        } else {
                            $burial->place = null;
                            $burial->save();
                        }
                    } else {
                        $burial = Burial::getById($person->id);
                        if ($burial && $burial->id) {
                            $burial = recast('Burial', $burial);
                            $burial->delete();
                        }
                    }
                    if ($result->parents) {
                        if ($person->id) {
                            $parents = Parents::getParentsOf($person->id);
                            if ($parents) {
                                $missing = array();
                                foreach ($parents as $parent) {
                                    if (!objectListContains($result->parents, 'id', $parent->parentId)) {
                                        $missing[] = $parent;
                                    }
                                }
                                foreach ($missing as $parent) {
                                    $parent = recast('Parents', $parent);
                                    $parent->delete();
                                }
                                foreach ($result->parents as $key) {
                                    if (!objectListContains($parents, 'parentId', $key->id)) {
                                        $newPadre = new Parents();
                                        $newPadre->child = $person->id;
                                        $newPadre->gender = $key->sex === 'male' ? 'father' : 'mother';
                                        $newPadre->parentId = $key->id;
                                        $newPadre->save();
                                    }
                                }
                            } else {
                                foreach ($result->parents as $key) {
                                    $newPadre = new Parents();
                                    $newPadre->child = $person->id;
                                    $newPadre->gender = $key->sex === 'male' ? 'father' : 'mother';
                                    $newPadre->parentId = $key->id;
                                    $newPadre->save();
                                }
                            }
                        } else {
                            return 'We have an error';
                        }
                    } else {
                        $parents = Parents::getParentsOf($person->id);
                        if ($parents) {
                            foreach ($parents as $parent) {
                                $parent = recast('Parents', $parent);
                                $parent->delete();
                            }
                        }
                    }
                    if ($result->spouse) {
                        $spouses = Spouse::getAllSpousesById($person->id);
                        if ($spouses) {
                            $missing = array();
                            foreach ($spouses as $spouse) {
                                if (!objectListContains($result->spouse, 'id', $spouse->spouse)) {
                                    $missing[] = $spouse;
                                }
                            }
                            foreach ($missing as $spouse) {
                                $spouse = recast('Spouse', $spouse);
                                $place = Place::getById($spouse->place);
                                if ($place) {
                                    $place = recast('Place', $place);
                                    $place->delete();
                                }
                                $otherSpouse = Spouse::getByPair($spouse->personId, $spouse->spouse);
                                if ($otherSpouse) {
                                    $place = Place::getById($otherSpouse->place);
                                    if ($place) {
                                        $place = recast('Place', $place);
                                        $place->delete();
                                    }
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                }
                                $spouse->delete();
                            }
                            foreach ($result->spouse as $spouse) {
                                if (!objectListContains($spouses, 'spouse', $spouse->id)) {
                                    Spouse::addSpouse($spouse, $person->id, $spouse->id);
                                    Spouse::addSpouse($spouse, $spouse->id, $person->id);
                                } else {
                                    Spouse::updateSpouse($spouse, $spouse->id, $person->id);
                                    Spouse::updateSpouse($spouse, $person->id, $spouse->id);
                                }
                            }
                        } else {
                            foreach ($result->spouse as $spouse) {
                                Spouse::addSpouse($spouse, $person->id, $spouse->id);
                                Spouse::addSpouse($spouse, $spouse->id, $person->id);
                            }
                        }
                    } else {
                        $spouses = Spouse::getAllSpousesById($person->id);
                        if ($spouses) {
                            foreach ($spouses as $spouse) {
                                $spouse = recast('Spouse', $spouse);
                                $place = Place::getById($spouse->place);
                                if ($place) {
                                    $place = recast('Place', $place);
                                    $place->delete();
                                }
                                $otherSpouse = Spouse::getByPair($spouse->personId, $spouse->spouse);
                                if ($otherSpouse) {
                                    $place = Place::getById($otherSpouse->place);
                                    if ($place) {
                                        $place = recast('Place', $place);
                                        $place->delete();
                                    }
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                }
                                $spouse->delete();
                            }
                        }
                    }
                    return $person;
                }
                return false;
            } else {
                return "Only accepts POST and GET requests";
            }
        }
    }
}
Example #6
0
 public static function updateFile($data = NULL)
 {
     $file = File::getById($data->id);
     $file->type = isset($data->type) ? $data->type : NULL;
     $file->comments = isset($data->comments) ? $data->comments : NULL;
     $file->author = isset($data->author) ? $data->author : NULL;
     $file->title = isset($data->title) ? $data->title : NULL;
     if (isset($data->tags)) {
         if (isset($data->tags->person) && $file->tags['person'] !== NULL) {
             foreach ($data->tags->person as $key => $tag) {
                 $check = false;
                 foreach ($file->tags['person'] as $datakey => $value) {
                     if (isset($tag->id) && isset($value->id) && $tag->id === $value->id) {
                         $check = true;
                     }
                 }
                 if (!$check) {
                     $tempTag = new Tag();
                     $tempTag->fileid = $file->id;
                     $tempTag->text = NULL;
                     $tempTag->foreignid = $tag->id;
                     $tempTag->enum = 'person';
                     $tempTag->save();
                 }
             }
         }
         if (isset($data->tags->place) && $file->tags['place'] !== NULL) {
             foreach ($data->tags->place as $key => $tag) {
                 $place = Place::getByAll($tag);
                 if ($place) {
                     $check = false;
                     foreach ($file->tags['place'] as $datakey => $value) {
                         if (isset($place->id) && isset($value->id) && $place->id === $value->id) {
                             $check = true;
                         }
                     }
                     if (!$check) {
                         $tempTag = new Tag();
                         $tempTag->fileid = $file->id;
                         $tempTag->text = NULL;
                         $tempTag->foreignid = $place->id;
                         $tempTag->enum = 'place';
                         $tempTag->save();
                     }
                 } else {
                     $place = recast('Place', $tag);
                     $placeId = $place->save();
                     $tempTag = new Tag();
                     $tempTag->fileid = $file->id;
                     $tempTag->text = NULL;
                     $tempTag->foreignid = $placeId;
                     $tempTag->enum = 'place';
                     $tempTag->save();
                 }
             }
         }
         if (isset($data->tags->other) && $file->tags['other'] !== NULL) {
             foreach ($data->tags->other as $key => $tag) {
                 $check = false;
                 foreach ($file->tags['other'] as $datakey => $value) {
                     if (isset($tag->id) && isset($value->id) && $tag->id === $value->id) {
                         $check = true;
                     }
                 }
                 if (!$check) {
                     if (isset($tag->id)) {
                         $tag = recast('Tag', $tag);
                         $tag->id = NULL;
                         $tag->fileid = $file->id;
                         $tag->foreignid = NULL;
                         $tag->enum = 'other';
                     } else {
                         $text = $tag->text;
                         $tag = new Tag();
                         $tag->fileid = $file->id;
                         $tag->foreignid = NULL;
                         $tag->enum = 'other';
                         $tag->text = $text;
                     }
                     $tag->save();
                 }
             }
         }
         if (isset($file->tags['person']) && $file->tags['person'] !== NULL) {
             foreach ($file->tags['person'] as $key => $tag) {
                 $check = false;
                 foreach ($data->tags->person as $datakey => $value) {
                     if (isset($tag->id) && isset($value->id) && $tag->id === $value->id) {
                         $check = true;
                     }
                 }
                 if (!$check) {
                     $tempTag = new Tag();
                     $tempTag->fileid = $file->id;
                     $tempTag->text = NULL;
                     $tempTag->foreignid = $tag->id;
                     $tempTag->enum = 'person';
                     $temp = Tag::getTagByData($tempTag);
                     if ($temp) {
                         $temp = recast('Tag', $temp);
                         $temp->delete();
                     }
                     // convert a person into a tag;
                     unset($file->tags['person'][$key]);
                 }
             }
         }
         if (isset($file->tags['place']) && $file->tags['place'] !== NULL) {
             foreach ($file->tags['place'] as $key => $tag) {
                 $check = true;
                 foreach ($data->tags->place as $datakey => $value) {
                     $place = Place::getByAll($value);
                     if ($place) {
                         if ($tag->id && $tag->id === $place->id) {
                             $check = false;
                         }
                     }
                 }
                 if ($check) {
                     $tempTag = new Tag();
                     $tempTag->fileid = $file->id;
                     $tempTag->text = NULL;
                     $tempTag->foreignid = $tag->id;
                     $tempTag->enum = 'place';
                     $temp = Tag::getTagByData($tempTag);
                     if ($temp) {
                         $temp = recast('Tag', $temp);
                         $temp->delete();
                     }
                     // convert a place into a tag;
                     unset($file->tags['place'][$key]);
                 }
             }
         }
         if (isset($file->tags['other']) && $file->tags['other'] !== NULL) {
             foreach ($file->tags['other'] as $key => $tag) {
                 if (!in_array($tag, $data->tags->other, true)) {
                     $temp = recast('Tag', $tag);
                     $temp->delete();
                     unset($file->tags['other'][$key]);
                 }
             }
         }
     }
     // return $file;
     return $file->save();
 }
?>
">
	<div>
	<?php 
echo $form->checkbox($controller->field('fileIDs') . "[]", $fileID, true);
?>
	<?php 
if ($templType == "js") {
    ?>
		<?php 
    echo $fileThumb;
    ?>

	<?php 
} elseif ($templType == "inline") {
    $image = File::getById($fileID);
    $ih = Loader::Helper('image');
    $ext = $image->getExtension();
    if (in_array($ext, ['jpeg', 'png', 'gif', 'jpg'])) {
        $thumb = $ih->getThumbnail($image, 32, 32, true);
        echo "<img src='{$thumb->src}'>";
    } elseif (file_exists(DIR_AL_ICONS . "/{$ext}.png")) {
        $path = \Core::getApplicationRelativePath() . "/concrete/images/icons/filetypes/{$ext}.png";
        echo "<img width='32' height='32' src='{$path}'>";
    }
    ?>
		
	<?php 
}
?>
	<span>
Example #8
0
 }
 unset($data);
 $data = $database->QuerySingle("SELECT *, MATCH(firstName, middleName, lastName) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) AS score FROM `person` WHERE MATCH(firstName, middleName, lastName) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) ORDER BY score DESC");
 //$results[] = $data;
 if (count($data) == 0) {
     //echo "Search found nothing in Person\n";
 } else {
     foreach ($data as $instance) {
         $temp = recast("Person", arrayToObject($instance));
         $parents = $temp->getParents();
         $temp->parents = array();
         $temp->profilePic = File::getById($temp->profile_pic);
         foreach ($parents as $parent) {
             $tempParent = Person::getById($parent->parentId);
             $tempParent = recast("Person", $tempParent);
             $tempParent->profilePic = File::getById($tempParent->profile_pic);
             $tempParent->dName = $tempParent->displayName();
             $temp->parents[] = $tempParent;
         }
         $temp->dName = $temp->displayName();
         $search_result_people[] = $temp;
     }
 }
 unset($data);
 $data = $database->QuerySingle("SELECT *, MATCH(town, county, state, country, cemetary) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) AS score FROM `place` WHERE MATCH(town, county, state, country, cemetary) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) ORDER BY score DESC");
 //$results[] = $data;
 if (count($data) == 0) {
     //echo "Search found nothing in Place\n";
 } else {
     foreach ($data as $instance) {
         $temp = recast("Place", arrayToObject($instance));
Example #9
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$content = $controller->getContent();
$leftImage = \File::getById($controller->getLeftImage());
$rightImage = \File::getById($controller->getRightImage());
?>


<?php 
echo $content;
if ($leftImage) {
    echo $leftImage->getRelativePath();
}
if ($rightImage) {
    echo $leftImage->getRelativePath();
}
Example #10
0
 protected function profilePic($args)
 {
     $session = mySession::getInstance();
     if ($this->method === 'GET') {
         if ($this->verb == "") {
             $id = intval(array_shift($args));
             if ($id && is_numeric($id)) {
                 $pic = File::getById($id);
                 return $pic;
             }
         } else {
             if ($this->verb === 'person') {
                 $id = intval(array_shift($args));
                 if ($id && is_numeric($id)) {
                     $person = Person::getById($id);
                     if (!empty($person->profile_pic)) {
                         $pic = File::getById($person->profile_pic);
                         return $pic;
                     }
                 }
             }
         }
     } else {
         if ($this->method === 'POST') {
             if ($session->isLoggedIn() && $session->isAdmin()) {
                 $id = intval(array_shift($args));
                 $picId = intval(array_shift($args));
                 if ($id && is_numeric($id) && $picId && is_numeric($picId)) {
                     $person = Person::getById($id);
                     $person->setProfilePic($picId);
                     return true;
                 }
             }
         }
     }
     return false;
 }
 /**
  * @depends testSaveNew
  */
 public function testGetById($object)
 {
     $at = getenv("BB_ACCESS_TOKEN");
     $object = File::getById($at, $object->id);
     $this->assertInstanceOf('\\ClausConrad\\BillysBilling\\File', $object, 'Getting object by ID returns instance of correct type');
 }
Example #12
0
             $temp[1] = "" . $temp_spouse->lastName . ", " . $temp_spouse->firstName . " " . $temp_spouse->middleName . " || Born: " . $temp_spouse->yearBorn . ", Death: " . $temp_spouse->yearDead . " || " . $temp_spouse->id;
             $temp[2] = $spo->day . "/" . $spo->month . "/" . $spo->year;
             $temp[3] = $spo->yearM;
             $temp[4] = array_values(get_object_vars(Place::getById($spo->place)));
             $spouses[] = $temp;
         }
         $result[] = $spouses;
         echo json_encode($result);
     }
     exit;
 }
 //this will get us the individual's data
 if ($action == 'getFileData') {
     $id = getRequest('id');
     if ($id) {
         $result['file'] = $file = File::getById($id);
         $result['tags'] = $tags = File::getTagsById($id);
         echo json_encode($result);
     }
     exit;
 }
 //this will make the changes for us
 if ($action == 'makeChanges') {
     if (isset($_REQUEST['formtype'])) {
         $formtype = $_REQUEST['formtype'];
     }
     if (isset($formtype)) {
         if ($formtype == 'individual') {
             $check = $_REQUEST['individual'];
             $temp = Person::createInstance($_REQUEST);
             if ($check == "") {
Example #13
0
function deleteFile()
{
    if (!($file = File::getById((int) $_GET['fileId']))) {
        header("Location: admin.php?error=fileNotFound");
        return;
    }
    $file->delete();
    header("Location: admin.php?action=listFiles&status=fileDeleted");
}