Exemplo n.º 1
0
 function isValidForUpdate($release, $group_id)
 {
     $frspf = new FRSPackageFactory();
     $frsrf = new FRSReleaseFactory();
     $frsff = new FRSFileFactory();
     if (isset($release['package_id']) && $release['package_id'] != 'null') {
         if (!isset($release['name']) || !$release['name'] || $release['name'] == '') {
             $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'rel_name_empty'));
         } else {
             //see if this package belongs to this project
             $res1 =& $frsrf->getFRSReleaseFromDb($release['release_id'], $group_id);
             if (!$res1 || count($res1) < 1) {
                 $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'p_rel_not_yours'));
             } else {
                 if ($release['package_id'] != $res1->getPackageID()) {
                     //changing to a different package for this release
                     $res2 = $frspf->getFRSPackageFromDb($release['package_id'], $group_id);
                     if (!$res2 || count($res2) < 1) {
                         //new package_id isn't theirs
                         $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'p_not_yours'));
                     }
                 }
                 //check if release name exists already
                 if ($res1->getPackageID() != $release['package_id'] || $res1->getPackageID() == $release['package_id'] && $res1->getName() != $release['name']) {
                     $release_exists = $frsrf->getReleaseIdByName($release['name'], $release['package_id']);
                 }
                 if (!isset($release_exists) || count($release_exists) < 1) {
                     //now check the date
                     if (!ereg("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}", $release['date'])) {
                         $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'data_not_parsed'));
                     }
                 } else {
                     $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'rel_name_exists'));
                 }
             }
         }
     } else {
         $this->addError($GLOBALS['Language']->getText('file_admin_editreleases', 'create_p_before_rel_status'));
     }
     return count($this->_errors) ? false : true;
 }
Exemplo n.º 2
0
 /**
  * deleteEmptyRelease - Delete an empty release or all empty releases in package package_id in project group_id.
  *
  * @param String  $sessionKey  The session hash associated with the session opened by the person who calls the service
  * @param Integer $group_id    Id of the project in which we want to delete empty releases
  * @param Integer $package_id  Id of the package in which we want to delete empty releases
  * @param Integer $release_id  Id of the release to delete
  * @param Boolean $cleanup_all Set to true to delete all empty releases
  *
  * @return Array list of deleted releases, or a soap fault if:
  *                 - group_id does not match with a valid project
  *                 - the package_id does not match
  *                 - the user does not have permissions to delete releases
  *                 - the system was not able to delete the releases.
  */
 function deleteEmptyRelease($sessionKey, $group_id, $package_id, $release_id, $cleanup_all)
 {
     if (session_continue($sessionKey)) {
         try {
             $pm = ProjectManager::instance();
             $pm->getGroupByIdForSoap($group_id, 'deleteRelease');
         } catch (SoapFault $e) {
             return $e;
         }
         $packageFactory = new FRSPackageFactory();
         $package = $packageFactory->getFRSPackageFromDb($package_id);
         if (!$package || $package->getGroupID() != $group_id) {
             return new SoapFault(invalid_package_fault, 'Invalid Package', 'deleteRelease');
         }
         $releaseFactory = new FRSReleaseFactory();
         $releases = array();
         if ($release_id && !$cleanup_all) {
             $release = $releaseFactory->getFRSReleaseFromDb($release_id);
             if (!$release || $release->getPackageID() != $package_id) {
                 return new SoapFault(invalid_release_fault, 'Invalid Release', 'deleteRelease');
             }
             $releases[] = $release;
         } elseif ($cleanup_all) {
             // retrieve all the releases
             $releases = $releaseFactory->getFRSReleasesFromDb($package_id);
         }
         $deleted = array();
         foreach ($releases as $release) {
             $fileFactory = new FRSFileFactory();
             $files = $fileFactory->getFRSFilesFromDb($release->getReleaseID());
             if (empty($files)) {
                 if ($releaseFactory->userCanUpdate($group_id, $release->getReleaseID())) {
                     if ($releaseFactory->delete_release($group_id, $release->getReleaseID())) {
                         $deleted[] = release_to_soap($release);
                     } else {
                         return new SoapFault(invalid_package_fault, 'Release ' . $release->getReleaseID() . ' could not be deleted', 'deleteRelease');
                     }
                 } else {
                     return new SoapFault(invalid_package_fault, 'You don\'t have permission to delete package ' . $release->getReleaseID(), 'deleteRelease');
                 }
             }
         }
         return $deleted;
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'deleteRelease');
     }
 }
Exemplo n.º 3
0
function file_get_package_id_from_release_id($release_id)
{
    $frsrf = new FRSReleaseFactory();
    $res = $frsrf->getFRSReleaseFromDb($release_id);
    return $res->getPackageID();
}
Exemplo n.º 4
0
    $authorized_user = true;
}
$frspf = new FRSPackageFactory();
$frsrf = new FRSReleaseFactory();
$frsff = new FRSFileFactory();
$packages = array();
$num_packages = 0;
// Retain only packages the user is authorized to access, or packages containing releases the user is authorized to access...
$res = $frspf->getFRSPackagesFromDb($group_id);
$user = UserManager::instance()->getCurrentUser();
foreach ($res as $package) {
    if ($frspf->userCanRead($group_id, $package->getPackageID(), $user->getId())) {
        if ($request->existAndNonEmpty('release_id')) {
            if ($request->valid(new Valid_UInt('release_id'))) {
                $release_id = $request->get('release_id');
                $row3 =& $frsrf->getFRSReleaseFromDb($release_id);
            }
        }
        if (!$request->existAndNonEmpty('release_id') || $row3->getPackageID() == $package->getPackageID()) {
            $packages[$package->getPackageID()] = $package;
            $num_packages++;
        }
    }
}
if ($request->valid(new Valid_Pv('pv'))) {
    $pv = $request->get('pv');
} else {
    $pv = false;
}
$pm = ProjectManager::instance();
$params = array('title' => $Language->getText('file_showfiles', 'file_p_for', $pm->getProject($group_id)->getPublicName()), 'pv' => $pv);
Exemplo n.º 5
0
 private function getProjectIdForSystemReference($keyword, $value)
 {
     $ref_gid = null;
     $nature = $this->getSystemReferenceNatureByKeyword($keyword);
     switch ($nature) {
         case self::REFERENCE_NATURE_RELEASE:
             $release_factory = new FRSReleaseFactory();
             $release = $release_factory->getFRSReleaseFromDb($value);
             if ($release) {
                 $ref_gid = $release->getProject()->getID();
             }
             break;
         case self::REFERENCE_NATURE_FILE:
             $file_factory = new FRSFileFactory();
             $file = $file_factory->getFRSFileFromDb($value);
             if ($file) {
                 $ref_gid = $file->getGroup()->getID();
             }
             break;
         case self::REFERENCE_NATURE_FORUM:
             $forum_dao = new ForumDao();
             $forum_group_id_row = $forum_dao->searchByGroupForumId($value)->getRow();
             if ($forum_group_id_row) {
                 $ref_gid = $forum_group_id_row['group_id'];
             }
             break;
         case self::REFERENCE_NATURE_FORUMMESSAGE:
             $forum_dao = new ForumDao();
             $message_group_id_row = $forum_dao->getMessageProjectId($value);
             if ($message_group_id_row) {
                 $ref_gid = $message_group_id_row['group_id'];
             }
             break;
         case self::REFERENCE_NATURE_NEWS:
             $news_dao = new NewsBytesDao();
             $news_group_id_row = $news_dao->searchByForumId($value)->getRow();
             if ($news_group_id_row) {
                 $ref_gid = $news_group_id_row['group_id'];
             }
             break;
     }
     return $ref_gid;
 }
Exemplo n.º 6
0
 /**
  * Returns the HTML content for tooltip when hover a reference with the nature file
  * @returns string HTML content for file tooltip
  */
 function getReferenceTooltip()
 {
     $tooltip = '';
     $rf = new FRSReleaseFactory();
     $pf = new FRSPackageFactory();
     $release_id = $this->getReleaseID();
     $release = $rf->getFRSReleaseFromDb($release_id);
     $package_id = $release->getPackageID();
     $package = $pf->getFRSPackageFromDb($package_id);
     $tooltip .= '<table>';
     $tooltip .= ' <tr>';
     $tooltip .= '  <td><strong>' . $GLOBALS['Language']->getText('file_admin_editreleases', 'filename') . ':</strong></td>';
     $tooltip .= '  <td>' . basename($this->getFileName()) . '</td>';
     $tooltip .= ' </tr>';
     $tooltip .= ' <tr>';
     $tooltip .= '  <td><strong>' . $GLOBALS['Language']->getText('file_ref_tooltip', 'package_release') . ':</strong></td>';
     $tooltip .= '  <td>' . $package->getName() . ' / ' . $release->getName() . '</td>';
     $tooltip .= ' </tr>';
     $tooltip .= ' <tr>';
     $tooltip .= '  <td><strong>' . $GLOBALS['Language']->getText('file_showfiles', 'date') . ':</strong></td>';
     $tooltip .= '  <td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt_short'), $release->getReleaseDate()) . '</td>';
     $tooltip .= ' </tr>';
     $tooltip .= ' <tr>';
     $tooltip .= '  <td><strong>' . $GLOBALS['Language']->getText('file_showfiles', 'size') . ':</strong></td>';
     $tooltip .= '  <td>' . $this->getDisplayFileSize() . '</td>';
     $tooltip .= ' </tr>';
     $tooltip .= '</table>';
     return $tooltip;
 }
Exemplo n.º 7
0
     $release->setStatusId($frsrf->STATUS_ACTIVE);
     $release->setReleaseDate(time());
     frs_display_release_form($is_update = false, $release, $group_id, $Language->getText('file_admin_editreleases', 'create_new_release'), '?func=create&amp;postExpected=&amp;group_id=' . $group_id . '&amp;package_id=' . $package_id);
     break;
 case 'create':
     if ($request->exist('cancel')) {
         $GLOBALS['Response']->addFeedback('info', $Language->getText('file_admin_editreleases', 'create_canceled'));
         $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id);
     } else {
         frs_process_release_form($is_update = false, $request, $group_id, $Language->getText('file_admin_editreleases', 'release_new_file_version'), '?func=create&amp;postExpected=&amp;group_id=' . $group_id . '&amp;package_id=' . $package_id);
     }
     break;
 case 'edit':
     if ($request->valid(new Valid_UInt('id'))) {
         $release_id = $request->get('id');
         if ($release =& $frsrf->getFRSReleaseFromDb($release_id, $group_id)) {
             frs_display_release_form($is_update = true, $release, $group_id, $Language->getText('file_admin_editreleases', 'edit_release'), '?func=update&amp;postExpected=&amp;group_id=' . $group_id . '&amp;package_id=' . $package_id . '&amp;id=' . $release_id);
         } else {
             $GLOBALS['Response']->addFeedback('error', $Language->getText('file_admin_editreleases', 'rel_id_not_found'));
             $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id);
         }
     } else {
         $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id);
     }
     break;
 case 'update':
     if ($request->exist('cancel')) {
         $GLOBALS['Response']->addFeedback('info', $Language->getText('file_admin_editreleases', 'update_canceled'));
         $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id);
     } else {
         if ($request->valid(new Valid_UInt('id'))) {