Example #1
0
* Factories of tribes  
*/
$reltribeuser_factory = new Xoopsyogurt_reltribeuserHandler($xoopsDB);
$tribes_factory = new Xoopsyogurt_tribesHandler($xoopsDB);
$tribe_id = intval($_POST['tribe_id']);
if (!isset($_POST['confirm']) || $_POST['confirm'] != 1) {
    xoops_confirm(array('tribe_id' => $tribe_id, 'confirm' => 1), 'delete_tribe.php', _MD_YOGURT_ASKCONFIRMTRIBEDELETION, _MD_YOGURT_CONFIRMTRIBEDELETION);
} else {
    /**
     * Creating the factory  and the criteria to delete the picture
     * The user must be the owner
     */
    $criteria_tribe_id = new Criteria('tribe_id', $tribe_id);
    $uid = intval($xoopsUser->getVar('uid'));
    $criteria_uid = new Criteria('owner_uid', $uid);
    $criteria = new CriteriaCompo($criteria_tribe_id);
    $criteria->add($criteria_uid);
    /**
     * Try to delete  
     */
    if ($tribes_factory->getCount($criteria) == 1) {
        if ($tribes_factory->deleteAll($criteria)) {
            $criteria_rel_tribe_id = new Criteria('rel_tribe_id', $tribe_id);
            $reltribeuser_factory->deleteAll($criteria_rel_tribe_id);
            redirect_header('tribes.php?uid=' . $uid, 3, _MD_YOGURT_TRIBEDELETED);
        } else {
            redirect_header('tribes.php?uid=' . $uid, 3, _MD_YOGURT_NOCACHACA);
        }
    }
}
include '../../footer.php';