cc-4304: Temporarily fixed

This commit is contained in:
Rudi Grinberg 2012-09-18 15:26:43 -04:00
parent 66aee1a01b
commit 72e6ee35fa
2 changed files with 21 additions and 9 deletions

View File

@ -109,7 +109,7 @@ class UserController extends Zend_Controller_Action
# TODO : remove this. we only use default for now not to break the UI.
if (!$files_action) { # set default action
$files_action = "reassign_to";
$delId = 1;
$new_owner = Application_Model_User::getFirstAdmin();
}
# only delete when valid action is selected for the owned files
@ -132,8 +132,11 @@ class UserController extends Zend_Controller_Action
if ($files_action == "delete_cascade") {
$user->deleteAllFiles();
} elseif ($files_action == "reassign_to") {
$new_owner = $this->_getParam("new_owner");
$user->reassignTo( $new_owner );
// TODO : fix code to actually use the line below and pick a
// real owner instead of defaulting to the first found admin
//$new_owner_id = $this->_getParam("new_owner");
//$new_owner = new Application_Model_User($new_owner_id);
$user->donateFilesTo( $new_owner );
}
# Finally delete the user
$this->view->entries = $user->delete();

View File

@ -215,7 +215,7 @@ class Application_Model_User
return $user->getCcFilessRelatedByDbOwnerId();
}
public function donateFilesTo($user)
public function donateFilesTo($user) // $user is object not user id
{
$my_files = $this->getOwnedFiles();
foreach ($my_files as $file) {
@ -242,18 +242,27 @@ class Application_Model_User
{
return CcSubjsQuery::create()->filterByDbType($type)->find();
}
public static function getFirstAdminId()
{
public static function getFirstAdmin() {
$admins = Application_Model_User::getUsersOfType('A');
if (count($admins) > 0) { // found admin => pick first one
return $admins[0]->getDbId();
return $admins[0];
} else {
Logging::warn("Warning. no admins found in database");
return null;
}
}
public static function getFirstAdminId()
{
$admin = self::getFirstAdmin();
if ($admin) {
return $admin->getDbId();
} else {
return null;
}
}
public static function getUsers(array $type, $search=null)
{
$con = Propel::getConnection();