function delete()
 {
     global $dPconfig;
     $this->_message = "deleted";
     addHistory('files', $this->file_id, 'delete', $this->file_name, $this->file_project);
     // remove the file from the file system
     @unlink("{$dPconfig['root_dir']}/files/{$this->file_project}/{$this->file_real_filename}");
     // delete any index entries
     $q = new DBQuery();
     $q->setDelete('files_index');
     $q->addQuery('*');
     $q->addWhere("file_id = {$this->file_id}");
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     // delete the main table reference
     $q->clear();
     $q->setDelete('files');
     $q->addQuery('*');
     $q->addWhere("file_id = {$this->file_id}");
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     $q->clear();
     return NULL;
 }
Exemplo n.º 2
0
/**
 * postsave functions are only called after a succesful save.  They are
 * used to perform database operations after the event.
 */
function resource_postsave()
{
    global $other_resources;
    global $obj;
    $task_id = $obj->task_id;
    dprint(__FILE__, __LINE__, 5, "saving resources, {$other_resources}");
    if (isset($other_resources)) {
        $value = array();
        $reslist = explode(';', $other_resources);
        foreach ($reslist as $res) {
            if ($res) {
                list($resource, $perc) = explode('=', $res);
                $value[] = array($task_id, $resource, $perc);
            }
        }
        // first delete any elements already there, then replace with this
        // list.
        $q = new DBQuery();
        $q->setDelete('resource_tasks');
        $q->addWhere('task_id = ' . $obj->task_id);
        $q->exec();
        $q->clear();
        if (count($value)) {
            foreach ($value as $v) {
                $q->addTable('resource_tasks');
                $q->addInsert('task_id,resource_id,percent_allocated', $v, true);
                $q->exec();
                $q->clear();
            }
        }
    }
}
Exemplo n.º 3
0
 public function remove()
 {
     $q = new DBQuery();
     $q->setDelete('modules');
     $q->addWhere("mod_directory = 'importers'");
     $q->exec();
     return true;
 }
Exemplo n.º 4
0
 function remove()
 {
     $q = new DBQuery();
     $q->dropTable('links');
     $q->exec();
     $q->clear();
     $q->setDelete('sysvals');
     $q->addWhere('sysval_title = \'LinkType\'');
     $q->exec();
 }
Exemplo n.º 5
0
 function testDeleteBD()
 {
     $q = new DBQuery();
     $q->addTable('eap');
     $q->setDelete('eap');
     $q->addWhere("nome ='Build Teste'");
     $q->prepareDelete();
     $this->assertEqual($q->exec(), true);
     $q->clear();
 }
Exemplo n.º 6
0
 function delete()
 {
     $q = new DBQuery();
     $q->setDelete('risks');
     $q->addWhere('risk_id = ' . $this->risk_id);
     if (!$q->exec()) {
         return db_error();
     } else {
         return null;
     }
 }
Exemplo n.º 7
0
 function delete()
 {
     global $dPconfig;
     $this->_message = "deleted";
     // delete the main table reference
     $q = new DBQuery();
     $q->setDelete('links');
     $q->addWhere('link_id = ' . $this->link_id);
     if (!$q->exec()) {
         return db_error();
     }
     return NULL;
 }
Exemplo n.º 8
0
 function delete($oid = NULL)
 {
     $id = $this->user_id;
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
         $q = new DBQuery();
         $q->setDelete('user_preferences');
         $q->addWhere('pref_user = ' . $this->user_id);
         $q->exec();
         $q->clear();
     }
     return $result;
 }
Exemplo n.º 9
0
 public static function unpinUserTask($userId, $taskId)
 {
     $q = new DBQuery();
     $q->setDelete('user_task_pin');
     $q->addWhere('user_id = ' . (int) $userId);
     $q->addWhere('task_id = ' . (int) $taskId);
     if (!$q->exec()) {
         return 'Error unpinning task';
     } else {
         return true;
     }
 }
Exemplo n.º 10
0
 function store()
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     if ($this->project_id) {
         $ret = db_updateObject('projects', $this, 'project_id', false);
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
     } else {
         $ret = db_insertObject('projects', $this, 'project_id');
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $department) {
             $q->addTable('project_departments');
             $q->addInsert('project_id', $this->project_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     return !$ret ? get_class($this) . '::store failed <br />' . db_error() : NULL;
 }
Exemplo n.º 11
0
 public function delete()
 {
     $q = new DBQuery();
     $q->setDelete('forum_visits');
     $q->addWhere('visit_message = ' . (int) $this->message_id);
     $q->exec();
     // No error if this fails, it is not important.
     $q->clear();
     $q->addTable('forum_messages');
     $q->addQuery('message_forum');
     $q->addWhere('message_id = ' . (int) $this->message_id);
     $forumId = $q->loadResult();
     $q->clear();
     $q->setDelete('forum_messages');
     $q->addWhere('message_id = ' . (int) $this->message_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         $result = null;
     }
     $q->clear();
     $q->addTable('forum_messages');
     $q->addQuery('COUNT(message_id)');
     $q->addWhere('message_forum = ' . (int) $forumId);
     $messageCount = $q->loadResult();
     $q->clear();
     $q->addTable('forums');
     $q->addUpdate('forum_message_count', $messageCount);
     $q->addWhere('forum_id = ' . (int) $forumId);
     $q->exec();
     $q->clear();
     return $result;
 }
Exemplo n.º 12
0
 /**
  *	Default delete method
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 function delete($oid = null, $history_desc = '', $history_proj = 0)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere($this->_tbl_key . " = '" . $this->{$k} . "'");
     $result = !$q->exec() ? db_error() : null;
     if (!$result) {
         // only record history if deletion actually occurred
         addHistory($this->_tbl, $this->{$k}, 'delete', $history_desc, $history_proj);
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 13
0
$cols = 13;
/****
// Let's figure out which tasks are selected
*/
$q = new DBQuery();
$pinned_only = intval(w2PgetParam($_GET, 'pinned', 0));
if (isset($_GET['pin'])) {
    $pin = intval(w2PgetParam($_GET, 'pin', 0));
    $msg = '';
    // load the record data
    if ($pin) {
        $q->addTable('user_task_pin');
        $q->addInsert('user_id', $AppUI->user_id);
        $q->addInsert('task_id', $task_id);
    } else {
        $q->setDelete('user_task_pin');
        $q->addWhere('user_id = ' . (int) $AppUI->user_id);
        $q->addWhere('task_id = ' . (int) $task_id);
    }
    if (!$q->exec()) {
        $AppUI->setMsg('ins/del err', UI_MSG_ERROR, true);
    } else {
        $q->clear();
    }
    $AppUI->redirect('', -1);
}
$AppUI->savePlace();
$durnTypes = w2PgetSysVal('TaskDurationType');
$taskPriority = w2PgetSysVal('TaskPriority');
$task_project = $project_id;
$task_sort_item1 = w2PgetParam($_GET, 'task_sort_item1', '');
Exemplo n.º 14
0
 function updateAssigned($assigned)
 {
     // First remove the assigned from the user_events table
     global $AppUI;
     $q = new DBQuery();
     $q->setDelete('user_events');
     $q->addWhere('event_id = ' . $this->event_id);
     $q->exec();
     $q->clear();
     if (is_array($assigned) && count($assigned)) {
         foreach ($assigned as $uid) {
             if ($uid) {
                 $q->addTable('user_events', 'ue');
                 $q->addInsert('event_id', $this->event_id);
                 $q->addInsert('user_id', $uid);
                 $q->exec();
                 $q->clear();
             }
         }
         if ($msg = db_error()) {
             $AppUI->setMsg($msg, UI_MSG_ERROR);
         }
     }
 }
 function delete()
 {
     $q = new DBQuery();
     $q->setDelete('custom_fields_lists');
     $q->addWhere("field_id = {$this->field_id}");
     $q->exec();
     $q->clear();
 }
Exemplo n.º 16
0
 function delete()
 {
     $q = new DBQuery();
     $q->addTable('departments', 'dep');
     $q->addQuery('dep.*');
     $q->addWhere('dep.dept_parent = ' . $this->dept_id);
     $res = $q->exec();
     if (db_num_rows($res)) {
         $q->clear();
         return "deptWithSub";
     }
     $q->clear();
     $q->addTable('projects', 'p');
     $q->addQuery('p.*');
     $q->addWhere('p.project_department = ' . $this->dept_id);
     $res = $q->exec();
     if (db_num_rows($res)) {
         $q->clear();
         return "deptWithProject";
     }
     // $sql = "DELETE FROM departments WHERE dept_id = $this->dept_id";
     $q->clear();
     $q->addQuery('*');
     $q->setDelete('departments');
     $q->addWhere('dept_id = ' . $this->dept_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         $result = NULL;
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 17
0
 function commit_updates()
 {
     $q = new DBQuery();
     if (count($this->delete_list)) {
         $q->setDelete($this->table);
         $q->addWhere("queue_id in (" . implode(',', $this->delete_list) . ")");
         $q->exec();
         $q->clear();
     }
     $this->delete_list = array();
     foreach ($this->update_list as $fields) {
         $q->addTable($this->table);
         $q->addUpdate('queue_repeat_count', $fields['queue_repeat_count']);
         $q->addUpdate('queue_start', $fields['queue_start']);
         $q->addWhere('queue_id = ' . $fields['queue_id']);
         $q->exec();
         $q->clear();
     }
     $this->update_list = array();
 }
Exemplo n.º 18
0
 protected function commit_updates($batched = false)
 {
     $q = new DBQuery();
     if (count($this->delete_list)) {
         $q->setDelete($this->table);
         $q->addWhere("queue_id in (" . implode(',', $this->delete_list) . ")");
         $q->exec();
         $q->clear();
     }
     $this->delete_list = array();
     foreach ($this->update_list as $fields) {
         $q->addTable($this->table);
         $q->addUpdate('queue_repeat_count', $fields['queue_repeat_count']);
         $q->addUpdate('queue_start', $fields['queue_start']);
         $q->addWhere('queue_id = ' . $fields['queue_id']);
         $q->exec();
         $q->clear();
     }
     $this->update_list = array();
     /**
      * Finally notify the batch handlers that the batch has been terminated.
      * This is done by calling the method EventQueue_<method_name>_batchTerminate.
      * Note that at this stage we will have all of the classes loaded, as we will
      * have executed the class methods to handle the batch requests.
      */
     if ($batched) {
         foreach ($this->batch_list as $batcher) {
             $method = 'EventQueue_' . $batcher['method'] . '_terminateBatch';
             if (method_exists($batcher['class'], $method)) {
                 $batcher['object']->{$method}();
             }
         }
     }
     $this->batch_list = array();
 }
Exemplo n.º 19
0
 function delete()
 {
     $q = new DBQuery();
     $q->setDelete('forum_visits');
     $q->addWhere('visit_message = ' . $this->message_id);
     $q->exec();
     // No error if this fails, it is not important.
     $q->clear();
     $q->setDelete('forum_messages');
     $q->addWhere('message_id = ' . $this->message_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         $result = NULL;
     }
     $q->clear();
     return $result;
 }
function dPsessionGC($maxlifetime)
{
    global $dPconfig;
    global $AppUI;
    dprint(__FILE__, __LINE__, 11, "Session Garbage collection running");
    $now = time();
    $max = dPsessionConvertTime('max_lifetime');
    $idle = dPsessionConvertTime('idle_time');
    // Find all the session
    $q = new DBQuery();
    $q->setDelete('sessions');
    $q->addWhere("UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) > {$idle} OR UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) > {$max}");
    $q->exec();
    $q->clear();
    if (isset($dPconfig['session_gc_scan_queue']) && $dPconfig['session_gc_scan_queue']) {
        // We need to scan the event queue.  If $AppUI isn't created yet
        // And it isn't likely that it will be, we create it and run the
        // queue scanner.
        if (!isset($AppUI)) {
            $AppUI = new CAppUI();
            $queue = new EventQueue();
            $queue->scan();
        }
    }
    return true;
}
Exemplo n.º 21
0
function dPsessionGC($maxlifetime)
{
    global $AppUI;
    dprint(__FILE__, __LINE__, 11, 'Session Garbage collection running');
    $now = time();
    $max = dPsessionConvertTime('max_lifetime');
    $idle = dPsessionConvertTime('idle_time');
    // First pass is to kill any users that are logged in at the time of the session.
    $where = 'UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) > ' . $idle . ' OR UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) > ' . $max;
    $q = new DBQuery();
    $q->addTable('sessions');
    $q->addQuery('session_user');
    $q->addWhere($where);
    $sql2 = $q->prepare(true);
    $q->addTable('user_access_log');
    $q->addUpdate('date_time_out', date('Y-m-d H:i:s'));
    $q->addWhere('user_access_log_id IN (' . $sql2 . ')');
    $q->exec();
    $q->clear();
    // Now we simply delete the expired sessions.
    $q->setDelete('sessions');
    $q->addWhere($where);
    $q->exec();
    $q->clear();
    if (dPgetConfig('session_gc_scan_queue')) {
        // We need to scan the event queue.  If $AppUI isn't created yet
        // And it isn't likely that it will be, we create it and run the
        // queue scanner.
        if (!isset($AppUI)) {
            $AppUI = new CAppUI();
            $queue = new EventQueue();
            $queue->scan();
        }
    }
    return true;
}
Exemplo n.º 22
0
         } else {
             $upd_task->task_parent = $bulk_task_parent;
             $upd_task->store();
         }
     }
 }
 //Action: Change dependency
 if (isset($_POST['bulk_task_dependency']) && $bulk_task_dependency != '') {
     if ($upd_task->task_id) {
         //If parent is self task
         //print_r($bulk_task_dependency);die;
         if ($bulk_task_dependency == '0') {
             $upd_task->task_dynamic = 0;
             $upd_task->store();
             $q = new DBQuery();
             $q->setDelete('task_dependencies');
             $q->addWhere('dependencies_task_id=' . $upd_task->task_id);
             $q->exec();
         } elseif (!($bulk_task_dependency == $upd_task->task_id)) {
             $upd_task->task_dynamic = 31;
             $upd_task->store();
             $q = new DBQuery();
             $q->addTable('task_dependencies');
             $q->addReplace('dependencies_task_id', $upd_task->task_id);
             $q->addReplace('dependencies_req_task_id', $bulk_task_dependency);
             $q->exec();
             //Lets recalc the dependency
             $dep_task = new CTask();
             $dep_task->load($bulk_task_dependency);
             if ($dep_task->task_id) {
                 $dep_task->shiftDependentTasks();
Exemplo n.º 23
0
 public function delete($oid = null)
 {
     global $AppUI;
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg, $oid ? $oid : $this->file_folder_id)) {
         return $msg;
     }
     $this->{$k} = $this->{$k} ? $this->{$k} : intval($oid ? $oid : $this->file_folder_id);
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere($this->_tbl_key . ' = ' . $this->{$k});
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     } else {
         $q->clear();
         return null;
     }
 }
Exemplo n.º 24
0
 /**
  *	Default delete method
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 public function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere($this->_tbl_key . ' = \'' . $this->{$k} . '\'');
     $result = !$q->exec() ? db_error() : null;
     if (!$result) {
         // only record history if deletion actually occurred
         addHistory($this->_tbl, $this->{$k}, 'delete');
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 25
0
 function updateAssigned($cslist, $perc_assign, $del = true, $rmUsers = false)
 {
     $q = new DBQuery();
     // process assignees
     $tarr = explode(',', $cslist);
     // delete all current entries from $cslist
     if ($del == true && $rmUsers == true) {
         foreach ($tarr as $user_id) {
             $user_id = (int) $user_id;
             if (!empty($user_id)) {
                 $this->removeAssigned($user_id);
             }
         }
         return false;
     } else {
         if ($del == true) {
             // delete all users assigned to this task (to properly update)
             $q->setDelete('user_tasks');
             $q->addWhere('task_id = ' . $this->task_id);
             $q->exec();
             $q->clear();
         }
     }
     // get Allocation info in order to check if overAssignment occurs
     $alloc = $this->getAllocation('user_id');
     $overAssignment = false;
     foreach ($tarr as $user_id) {
         if (intval($user_id) > 0) {
             $perc = $perc_assign[$user_id];
             /*
             if (dPgetConfig('check_overallocation') 
             	&& $perc > $alloc[$user_id]['freeCapacity']) {
             	// add Username of the overAssigned User
             	$overAssignment .= ' ' . $alloc[$user_id]['userFC'];
             } 
             else {
             */
             $q->addTable('user_tasks');
             $q->addReplace('user_id', $user_id);
             $q->addReplace('task_id', $this->task_id);
             $q->addReplace('perc_assignment', $perc);
             $q->exec();
             $q->clear();
             // }
         }
     }
     return $overAssignment;
 }
Exemplo n.º 26
0
$task_sort_order2 = intval(dPgetParam($_GET, 'task_sort_order2', 0));
// if task priority set and items selected, do some work
$task_priority = dPgetParam($_POST, 'task_priority', 99);
$selected = dPgetParam($_POST, 'selected_task', 0);
$q = new DBQuery();
if (is_array($selected) && count($selected)) {
    foreach ($selected as $key => $val) {
        if ($task_priority == 'c') {
            // mark task as completed
            $q->addTable('tasks');
            $q->addUpdate('task_percent_complete', "'100'");
            $q->addWhere('task_id=' . $val);
        } else {
            if ($task_priority == 'd') {
                // delete task
                $q->setDelete('tasks');
                $q->addWhere('task_id=' . $val);
            } else {
                if ($task_priority > -2 && $task_priority < 2) {
                    // set priority
                    $q->addTable('tasks');
                    $q->addUpdate('task_priority', $task_priority);
                    $q->addWhere('task_id=' . $val);
                }
            }
        }
        db_exec($q->prepare(true));
        echo db_error();
    }
}
$AppUI->savePlace();
Exemplo n.º 27
0
if (isset($_POST['forcewatch']) && isset($_POST['forcesubmit'])) {
    // insert row into forum_watch for forcing Watch
    $q->addTable('forum_watch');
    $q->addInsert('watch_user', 0);
    $q->addInsert('watch_forum', 0);
    $q->addInsert('watch_topic', 0);
    if (!$q->exec()) {
        $AppUI->setMsg(db_error(), UI_MSG_ERROR);
    } else {
        $AppUI->setMsg("Watch Forced", UI_MSG_OK);
    }
    $q->clear();
    $AppUI->redirect('m=forums&a=configure');
} elseif (isset($_POST['forcesubmit']) && !isset($_POST['forcewatch'])) {
    // delete row from forum_watch for unorcing Watch
    $q->setDelete('forum_watch');
    $q->addWhere('watch_user = 0');
    $q->addWhere('watch_forum = 0');
    $q->addWhere('watch_topic = 0');
    if (!$q->exec()) {
        $AppUI->setMsg(db_error(), UI_MSG_ERROR);
    } else {
        $AppUI->setMsg("Watch Unforced", UI_MSG_OK);
    }
    $q->clear();
    $AppUI->redirect('m=forums&a=configure');
}
// SQL-Query to check if the message should be delivered to all users (forced) (checkbox)
$q->addTable('forum_watch');
$q->addQuery('*');
$q->addWhere('watch_user = 0');
Exemplo n.º 28
0
 public function unregisterModule($module_value)
 {
     if ($module_value != '') {
         $q = new DBQuery();
         $q->setDelete('gacl_axo');
         $q->addWhere("value = '{$module_value}'");
         $q->exec();
     }
 }
Exemplo n.º 29
0
     $q->addInsert('history_action', "add");
     $q->addInsert('history_date', str_replace("'", '', $db->DBTimeStamp(time())));
     $q->addInsert('history_description', $history_description);
     $q->addInsert('history_user', $userid);
     $q->addInsert('history_project', $history_project);
     $okMsg = 'History added';
 } else {
     if ($action == 'update') {
         $q->addTable('history');
         $q->addUpdate('history_description', $history_description);
         $q->addUpdate('history_project', $history_project);
         $q->addWhere('history_id =' . $history_id);
         $okMsg = 'History updated';
     } else {
         if ($action == 'del') {
             $q->setDelete('history');
             $q->addWhere('history_id =' . $history_id);
             $okMsg = 'History deleted';
         }
     }
 }
 if (!$q->exec()) {
     $AppUI->setMsg(db_error());
 } else {
     $AppUI->setMsg($okMsg);
     if ($action == 'add') {
         $q->clear();
     }
     $q->addTable('history');
     $q->addUpdate('history_item = history_id');
     $q->addWhere('history_table = \'history\'');
Exemplo n.º 30
0
 function deleteModuleItems($mod)
 {
     //Declaring the return string
     $ret = null;
     $q = new DBQuery();
     //Fetching module-associated ACL ID's
     $q->addTable('gacl_axo_map');
     $q->addQuery('acl_id');
     $q->addWhere("value = '" . $mod . "'");
     $acls = $q->loadHashList('acl_id');
     $q->clear();
     $tables = array('gacl_aco_map' => 'acl_id', 'gacl_aro_map' => 'acl_id', 'gacl_acl' => 'id');
     foreach ($acls as $acl => $k) {
         //Deleting gacl_aco_map, gacl_aro_map, and gacl_aco_map entries
         foreach ($tables as $acl_table => $acl_tab_key) {
             $q->setDelete($acl_table);
             $q->addWhere($acl_tab_key . ' = ' . $acl);
             if (!$q->exec()) {
                 $ret .= (is_null($ret) ? "\n\t" : '') . db_error();
             }
             $q->clear();
         }
     }
     //Returning null (no error) or database error message (error)
     return $ret;
 }