Ejemplo n.º 1
0
 $fileUpdate->setFaculty(issetOrBlank($_POST['file-faculty']));
 $fileUpdate->setExpiry(trim($_POST['file-expiry']) == "" ? "0000-00-00 00:00:00" : date('Y-m-d H:i:s', strtotime($_POST['file-expiry'])));
 ///0000-00-00 00:00:00
 $fileUpdate->setDescription($_POST['file-description']);
 if (issetOrBlank($_POST['file-tags']) != $file->getTags()) {
     //sort the tags
     $tags = array_filter(array_map('trim', explode(',', issetOrBlank($_POST['file-tags']))));
     asort($tags);
     $tags = implode(', ', $tags);
     $fileUpdate->setTags($tags);
     $query = "SELECT `option` FROM `options` WHERE `group_id` = 4 order by `sort`";
     $Otags = $conn->query($query);
     $Otags->execute();
     $Otags = $Otags->fetchAll(PDO::FETCH_COLUMN);
     //echo $tags;
     $newTags = explode(",", $fileUpdate->getTags());
     $addTags = array_diff($newTags, $Otags);
     $pos = sizeof($Otags);
     foreach ($addTags as $tag) {
         $pos++;
         $newTag = $conn->prepare("INSERT INTO `fileupload`.`options` (`group_id`, `option`, `sort`) VALUES ('4', :tag, :pos)");
         $newTag->bindParam(':tag', $tag);
         $newTag->bindParam(':pos', $pos);
         $newTag->execute();
     }
 } else {
     $fileUpdate->setTags($file->getTags());
 }
 $fileUpdate->setType(issetOrBlank($_POST['file-type']));
 $fileUpdate->setUploadDate($file->getUploadDate());
 //see if active has changed