Пример #1
0
 /**
  * documentation TBD
  */
 function delete($material_id, $version_id = NULL)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $current_user = $this->_environment->getCurrentUserItem();
     $user_id = $current_user->getItemID();
     if (!isset($current_user)) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting material: Deleter is not set', E_USER_ERROR);
     } else {
         $query = 'UPDATE ' . $this->addDatabasePrefix('materials') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '"' . ' WHERE item_id="' . encode(AS_DB, $material_id) . '"';
         if (!is_null($version_id)) {
             $query .= ' AND version_id="' . encode(AS_DB, $version_id) . '"';
         }
         $result = $this->_db_connector->performQuery($query);
         if (!isset($result) or !$result) {
             include_once 'functions/error_functions.php';
             trigger_error('Problems deleting material: "' . $this->_dberror . '" from query: "' . $query . '"', E_USER_WARNING);
         } else {
             if (is_null($version_id)) {
                 parent::delete($material_id);
             }
         }
     }
     unset($current_user);
 }
Пример #2
0
 /**  delete a user item
  *
  * @param cs_user_item the user item to be deleted
  */
 function delete($item_id)
 {
     $user_item = $this->getItem($item_id);
     if ($this->_environment->inPortal()) {
         if (isset($user_item) and !empty($user_item) and $user_item->getContextID() == $this->_environment->getCurrentContextID()) {
             // delete private room - part I
             $private_room_manager = $this->_environment->getPrivateRoomManager();
             $own_room = $private_room_manager->getRelatedOwnRoomForUser($user_item, $this->_environment->getCurrentPortalID());
             if (isset($own_room) and !empty($own_room)) {
                 $room_id = $own_room->getItemID();
                 if (!empty($room_id)) {
                     $delete_own_room = true;
                 } else {
                     $delete_own_room = false;
                 }
             }
             // delete related user in project rooms and community rooms and private room
             $user_list = $user_item->getRelatedUserList();
             if (!$user_list->isEmpty()) {
                 $u_item = $user_list->getFirst();
                 while ($u_item) {
                     $u_item->delete();
                     $u_item = $user_list->getNext();
                 }
             }
             // delete private room - part II
             if (isset($delete_own_room) and $delete_own_room) {
                 $own_room->delete();
             }
         }
     } else {
         if ($this->_environment->inProjectRoom()) {
             if (isset($user_item) and !empty($user_item) and $user_item->getContextID() == $this->_environment->getCurrentContextID()) {
                 // delete related user in group rooms
                 if ($this->_environment->getCurrentPortalItem()->withGrouproomFunctions()) {
                     // get all grouprooms of this user
                     $grouproom_manager = $this->_environment->getGroupRoomManager();
                     $grouproom_list = $grouproom_manager->getUserRelatedGroupListForUser($user_item);
                     if (!$grouproom_list->isEmpty()) {
                         $grouproom_ids = array();
                         $grouproom = $grouproom_list->getFirst();
                         while ($grouproom) {
                             // is a group room of this project room?
                             $project_room = $grouproom->getLinkedProjectItem();
                             if (!empty($project_room)) {
                                 $project_room_id = $project_room->getItemID();
                                 if ($this->_environment->getCurrentContextID() == $project_room_id) {
                                     // add grouproom id to array of ids
                                     $grouproom_ids[] = $grouproom->getItemID();
                                 }
                             }
                             $grouproom = $grouproom_list->getNext();
                         }
                         // delete related users
                         if (!empty($grouproom_ids)) {
                             $user_manager = $this->_environment->getUserManager();
                             $user_manager->resetLimits();
                             $user_manager->setContextArrayLimit($grouproom_ids);
                             $user_manager->setUserIDLimit($user_item->getUserID());
                             $user_manager->setAuthSourceLimit($user_item->getAuthSource());
                             $user_manager->select();
                             $user_list = $user_manager->get();
                             unset($user_manager);
                             if (!$user_list->isEmpty()) {
                                 $user = $user_list->getFirst();
                                 while ($user) {
                                     // delete user
                                     $user->delete();
                                     $user = $user_list->getNext();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // delete hash values
     $hash_manager = $this->_environment->getHashManager();
     $hash_manager->deleteHashesForUser($item_id);
     unset($hash_manager);
     $user_item->deleteAllEntriesOfUser();
     $current_datetime = getCurrentDateTimeInMySQL();
     $current_user = $this->_environment->getCurrentUserItem();
     $user_id = $current_user->getItemID();
     $query = 'UPDATE ' . $this->addDatabasePrefix('user') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting user.', E_USER_WARNING);
     } else {
         unset($result);
         parent::delete($item_id);
         return true;
     }
 }
Пример #3
0
 /**  delete a dates item
  *
  * @param cs_dates_item the dates item to be deleted
  *
  * @access public
  * @author CommSy Development Group
  */
 function delete($item_id)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $current_user = $this->_environment->getCurrentUserItem();
     $user_id = $current_user->getItemID();
     $query = 'UPDATE ' . $this->addDatabasePrefix('dates') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting dates.', E_USER_WARNING);
     } else {
         $link_manager = $this->_environment->getLinkManager();
         $link_manager->deleteLinksBecauseItemIsDeleted($item_id);
         parent::delete($item_id);
         unset($result);
     }
 }
Пример #4
0
 /** delete a task
  * this method deletes a new task
  *
  * @param integer item_id item id of the task
  */
 function delete($item_id)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $current_user = $this->_environment->getCurrentUserItem();
     $user_id = $current_user->getItemID();
     unset($current_user);
     $query = 'UPDATE ' . $this->addDatabasePrefix('tasks') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '",' . 'status="CLOSED"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting tasks from query: "' . $query . '"', E_USER_WARNING);
     } else {
         parent::delete($item_id);
     }
 }
Пример #5
0
 function delete($item_id)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $user_id = $this->_current_user->getItemID();
     $query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting homepage from query: "' . $query . '"', E_USER_WARNING);
     } else {
         parent::delete($item_id);
         $this->_deleteHomepageLinks($item_id);
     }
 }
Пример #6
0
 function delete($item_id)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET ' . 'deletion_date="' . $current_datetime . '"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting portfolio.', E_USER_WARNING);
     } else {
         parent::delete($item_id);
         $this->deletePortfolioTags($item_id);
         $this->deletePortfolioAnnotations($item_id);
         $this->deletePortfolioUsers($item_id);
         $this->deletePortfolioTemplateUsers($item_id);
     }
 }
Пример #7
0
 function delete($item_id)
 {
     $current_datetime = getCurrentDateTimeInMySQL();
     $user_id = $this->_current_user->getItemID();
     $query = 'UPDATE auth_source SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result) or !$result) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems deleting auth_source.', E_USER_WARNING);
     } else {
         parent::delete($item_id);
     }
 }