Example #1
0
    /**

     * Delete User

     *

     * @param string $usrUid Unique id of User

     *

     * return void

     */

    public function delete($usrUid)

    {

        try {

            //Verify data

            $this->throwExceptionIfNotExistsUser($usrUid, $this->arrayFieldNameForException["usrUid"]);



            \G::LoadClass('case');

            $oProcessMap = new \Cases();

            $USR_UID = $usrUid;

            $total = 0;

            $history = 0;

            $c = $oProcessMap->getCriteriaUsersCases('TO_DO', $USR_UID);

            $total += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('DRAFT', $USR_UID);

            $total += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID);

            $history += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);

            $history += \ApplicationPeer::doCount($c);

            if ($total > 0) {

                throw new \Exception(\G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID)));

            } else {

                $UID = $usrUid;

                \G::LoadClass('tasks');

                $oTasks = new \Tasks();

                $oTasks->ofToAssignUserOfAllTasks($UID);

                \G::LoadClass('groups');

                $oGroups = new \Groups();

                $oGroups->removeUserOfAllGroups($UID);

                $this->changeUserStatus($UID, 'CLOSED');

                $_GET['USR_USERNAME'] = '';

                $this->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']), '');

                require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");

                $oUser = new \Users();

                $aFields = $oUser->load($UID);

                $aFields['USR_STATUS'] = 'CLOSED';

                $aFields['USR_USERNAME'] = '';

                $oUser->update($aFields);

                //Delete Dashboard

                require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashletInstance.php");

                $criteria = new \Criteria( 'workflow' );

                $criteria->add( \DashletInstancePeer::DAS_INS_OWNER_UID, $UID );

                $criteria->add( \DashletInstancePeer::DAS_INS_OWNER_TYPE , 'USER');

                \DashletInstancePeer::doDelete( $criteria );

            }

        } catch (\Exception $e) {

            throw $e;

        }

    }
Example #2
0
     $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID);
     $history += ApplicationPeer::doCount($c);
     $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);
     $history += ApplicationPeer::doCount($c);
     $response = '{success: true, candelete: ';
     $response .= $total > 0 ? 'false' : 'true';
     $response .= ', hashistory: ';
     $response .= $history > 0 ? 'true' : 'false';
     $response .= '}';
     echo $response;
     break;
 case 'deleteUser':
     $UID = $_POST['USR_UID'];
     G::LoadClass('tasks');
     $oTasks = new Tasks();
     $oTasks->ofToAssignUserOfAllTasks($UID);
     G::LoadClass('groups');
     $oGroups = new Groups();
     $oGroups->removeUserOfAllGroups($UID);
     $RBAC->changeUserStatus($UID, 'CLOSED');
     $_GET['USR_USERNAME'] = '';
     $RBAC->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']), '');
     require_once 'classes/model/Users.php';
     $oUser = new Users();
     $aFields = $oUser->load($UID);
     $aFields['USR_STATUS'] = 'CLOSED';
     $aFields['USR_USERNAME'] = '';
     $oUser->update($aFields);
     //Delete Dashboard
     require_once 'classes/model/DashletInstance.php';
     $criteria = new Criteria('workflow');
Example #3
0
            die;
            break;
    }
    if ($_GET['USR_UID'] == '00000000000000000000000000000001') {
        G::SendTemporalMessage('ID_CANNOT_CHANGE_STATUS_ADMIN_USER', 'error', 'usersLabels');
        G::header('location: ' . $_SERVER['HTTP_REFERER']);
        die;
    }
    /*$RBAC->removeUser($_GET['USR_UID']);
      require_once 'classes/model/Users.php';
      $oUser = new Users();
      $oUser->remove($_GET['USR_UID']);*/
    //print_r($_GET['USR_UID']); die
    G::LoadClass('tasks');
    $oTasks = new Tasks();
    $oTasks->ofToAssignUserOfAllTasks($_GET['USR_UID']);
    G::LoadClass('groups');
    $oGroups = new Groups();
    $oGroups->removeUserOfAllGroups($_GET['USR_UID']);
    $RBAC->changeUserStatus($_GET['USR_UID'], 'CLOSED');
    $_GET['USR_USERNAME'] = '';
    $RBAC->updateUser(array('USR_UID' => $_GET['USR_UID'], 'USR_USERNAME' => $_GET['USR_USERNAME']), '');
    require_once 'classes/model/Users.php';
    $oUser = new Users();
    $aFields = $oUser->load($_GET['USR_UID']);
    $aFields['USR_STATUS'] = 'CLOSED';
    $aFields['USR_USERNAME'] = '';
    $oUser->update($aFields);
    G::header('location: users_List');
} catch (Exception $oException) {
    die($oException->getMessage());