コード例 #1
0
ファイル: syskeys.class.php プロジェクト: joly/web2project
 public function store()
 {
     $this->w2PTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     $values = parseFormatSysval($this->sysval_value, $this->sysval_key_id);
     //lets delete the old values
     $q = new DBQuery();
     if ($this->sysval_key_id && $this->sysval_title) {
         $q->setDelete('sysvals');
         $q->addWhere('sysval_key_id = ' . (int) $this->sysval_key_id);
         $q->addWhere('sysval_title = \'' . $this->sysval_title . '\'');
         if (!$q->exec()) {
             $q->clear();
             return get_class($this) . '::store failed: ' . db_error();
         }
     }
     foreach ($values as $key => $value) {
         $q->addTable('sysvals');
         $q->addInsert('sysval_key_id', $this->sysval_key_id);
         $q->addInsert('sysval_title', $this->sysval_title);
         $q->addInsert('sysval_value_id', $key);
         $q->addInsert('sysval_value', $value);
         if (!$q->exec()) {
             $q->clear();
             return get_class($this) . '::store failed: ' . db_error();
         }
         $q->clear();
     }
     return null;
 }
コード例 #2
0
ファイル: setup.php プロジェクト: illuminate3/dotproject
 function install()
 {
     $ok = true;
     $q = new DBQuery();
     $sql = "(\n\t\t\tresource_id integer not null auto_increment,\n\t\t\tresource_name varchar(255) not null default '',\n\t\t\tresource_key varchar(64) not null default '',\n\t\t\tresource_type integer not null default 0,\n\t\t\tresource_note text not null default '',\n\t\t\tresource_max_allocation integer not null default 100,\n\t\t\tprimary key (resource_id),\n\t\t\tkey (resource_name),\n\t\t\tkey (resource_type)\n\t\t)";
     $q->createTable('resources');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $sql = "(\n\t\t\tresource_type_id integer not null auto_increment,\n\t\t\tresource_type_name varchar(255) not null default '',\n\t\t\tresource_type_note text,\n\t\t\tprimary key (resource_type_id)\n\t\t)";
     $q->createTable('resource_types');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $sql = "(\n\t\t\tresource_id integer not null default 0,\n\t\t\ttask_id integer not null default 0,\n\t\t\tpercent_allocated integer not null default 100,\n\t\t\tkey (resource_id),\n\t\t\tkey (task_id, resource_id)\n\t\t)";
     $q->createTable('resource_tasks');
     $q->createDefinition($sql);
     $ok = $ok && $q->exec();
     $q->clear();
     $q->addTable('resource_types');
     $q->addInsert('resource_type_name', 'Equipment');
     $q->exec();
     $q->addInsert('resource_type_name', 'Tool');
     $q->exec();
     $q->addInsert('resource_type_name', 'Venue');
     $ok = $ok && $q->exec();
     if (!$ok) {
         return false;
     }
     return null;
 }
コード例 #3
0
ファイル: session.php プロジェクト: n2i/xvnkb
function dPsessionWrite($id, $data)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addQuery('count(*) as row_count');
    $q->addTable('sessions');
    $q->addWhere("session_id = '{$id}'");
    if (($qid =& $q->exec()) && (@$qid->fields['row_count'] > 0 || @$qid->fields[0] > 0)) {
        dprint(__FILE__, __LINE__, 11, "Updating session {$id}");
        $q->query = null;
        $q->addUpdate('session_data', $data);
        if (isset($AppUI)) {
            $q->addUpdate('session_user', $AppUI->last_insert_id);
        }
    } else {
        dprint(__FILE__, __LINE__, 11, "Creating new session {$id}");
        $q->query = null;
        $q->where = null;
        $q->addInsert('session_id', $id);
        $q->addInsert('session_data', $data);
        $q->addInsert('session_created', date('Y-m-d H:i:s'));
    }
    $q->exec();
    $q->clear();
    return true;
}
コード例 #4
0
ファイル: session.php プロジェクト: joly/web2project
function w2PsessionWrite($id, $data)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addQuery('count(session_id) as row_count');
    $q->addTable('sessions');
    $q->addWhere('session_id = \'' . $id . '\'');
    if (($qid =& $q->exec()) && ($qid->fields['row_count'] > 0 || $qid->fields[0] > 0)) {
        //dprint(__file__, __line__, 11, "Updating session $id");
        $q->query = null;
        $q->addUpdate('session_data', $data);
        if (isset($AppUI)) {
            $q->addUpdate('session_user', (int) $AppUI->last_insert_id);
        }
    } else {
        //dprint(__file__, __line__, 11, "Creating new session $id");
        $q->query = null;
        $q->where = null;
        $q->addInsert('session_id', $id);
        $q->addInsert('session_data', $data);
        $q->addInsert('session_created', date('Y-m-d H:i:s'));
    }
    $q->exec();
    $q->clear();
    return true;
}
コード例 #5
0
 function testInsertBD()
 {
     $q = new DBQuery();
     $q->addTable('eap');
     $q->addQuery("id,nome,linha,coluna");
     $q->addInsert(nome, 'Build Teste');
     $q->addInsert(linha, 2);
     $q->addInsert(coluna, 3);
     $q->prepareInsert();
     $this->assertEqual($q->exec(), true);
     $q->clear();
 }
コード例 #6
0
 /**
  * Add an event to the queue.
  *
  * The callback can either be the name of a global function or the
  * name of a class
  * @param mixed $callback function to call when this event is due.
  * @param mixed $args Arguments to pass to the callback
  * @param string $module module, or originator of the event
  * @param string $type type of event (to allow searching)
  * @param integer $id id of originating event.
  * @param integer $date Seconds since 1970 to trigger event.
  * @param integer $repeat_interval seconds to repeat
  * @param integer $repeat_count number of times to repeat
  * @return integer queue id
  */
 public function add($caller, &$args, $method = 'execute', $opts = array())
 {
     global $AppUI;
     if (!isset($AppUI)) {
         $user_id = 0;
     } else {
         $user_id = $AppUI->user_id;
     }
     /* Simple expedient, caller should be the $this pointer of the
        calling class, and the class should provide the method getModuleName.
        This also is only a short-term solution, in reality we should align classes
        and modules so we can autoload */
     $class = get_class($caller);
     $full_method = 'EventQueue_' . $method;
     // Set some default values that are overriden with $opts
     $date = 0;
     $repeat_interval = 0;
     $repeat_count = 1;
     $id = 0;
     $type = '';
     $batch = false;
     extract($opts);
     /* Check that we have a callable string */
     if ($batch) {
         if (!is_callable(array($class, $full_method . '_batched')) && !is_callable(array($class, $full_method))) {
             return false;
         }
     } else {
         if (!is_callable(array($class, $full_method . '_immediate')) && !is_callable(array($class, $full_method))) {
             return false;
         }
     }
     $q = new DBQuery();
     $q->addTable($this->table);
     $q->addInsert('queue_owner', $user_id);
     $q->addInsert('queue_start', $date);
     $q->addInsert('queue_callback', $class . '::' . $method);
     $q->addInsert('queue_data', serialize($args));
     $q->addInsert('queue_repeat_interval', $repeat_interval);
     $q->addInsert('queue_repeat_count', $repeat_count);
     $q->addInsert('queue_module', $caller->getModuleName());
     $q->addInsert('queue_type', $type);
     $q->addInsert('queue_origin_id', $id);
     $q->addInsert('queue_batched', $batch ? 1 : 0);
     if ($q->exec()) {
         $return = db_insert_id();
     } else {
         $return = false;
     }
     $q->clear();
     return $return;
 }
コード例 #7
0
ファイル: setup.php プロジェクト: slawekmikula/dotproject
    function install()
    {
        $q = new DBQuery();
        $q->createTable('risks');
        $sql = '(
			`risk_id` int(10) unsigned NOT NULL auto_increment,
			`risk_name` varchar(50) default NULL,
			`risk_description` text,
			`risk_probability` tinyint(3) default 100,
			`risk_status` text default NULL,
			`risk_owner` int(10) default NULL,
			`risk_project` int(10) default NULL,
			`risk_task` int(10) default NULL,
			`risk_impact` int(10) default NULL,
			`risk_duration_type` tinyint(10) default 1,
			`risk_notes` text,
			PRIMARY KEY  (`risk_id`),
			UNIQUE KEY `risk_id` (`risk_id`),
			KEY `risk_id_2` (`risk_id`))
			TYPE=MyISAM';
        $q->createDefinition($sql);
        $q->exec();
        $q->clear();
        $q->createTable('risk_notes');
        $sql = '(
			`risk_note_id` int(11) NOT NULL auto_increment,
			`risk_note_risk` int(11) NOT NULL default \'0\',
			`risk_note_creator` int(11) NOT NULL default \'0\',
			`risk_note_date` datetime NOT NULL default \'0000-00-00 00:00:00\',
			`risk_note_description` text NOT NULL,
			PRIMARY KEY  (`risk_note_id`)
			) TYPE=MyISAM';
        $q->createDefinition($sql);
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskProbability');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Low\n2|Medium\n3|High");
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskStatus');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Open\n2|Closed\n3|Not Applicable");
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'RiskImpact');
        $q->addInsert('sysval_value', "0|Not Specified\n1|Low\n2|Medium\n3|High\n4|Super High");
        $q->exec();
        $q->clear();
        return true;
    }
コード例 #8
0
ファイル: setup.php プロジェクト: 222elm/dotprojectFrame
 function install()
 {
     $q = new DBQuery();
     $q->createTable('links');
     $q->createDefinition("(\n`link_id` int(11) NOT NULL AUTO_INCREMENT ,\n`link_url` varchar(255) NOT NULL default '',\n`link_project` int(11) NOT NULL default '0',\n`link_task` int(11) NOT NULL default '0',\n`link_name` varchar(255) NOT NULL default '',\n`link_parent` int(11) default '0',\n`link_description` text,\n`link_owner` int(11) default '0',\n`link_date` datetime default NULL ,\n`link_icon` varchar(20) default 'obj/',\n`link_category` int(11) NOT NULL default '0',\nPRIMARY KEY (`link_id`) ,\nKEY `idx_link_task` (`link_task`) ,\nKEY `idx_link_project` (`link_project`) ,\nKEY `idx_link_parent` (`link_parent`) \n) DEFAULT CHARSET utf8");
     $q->exec($sql);
     $q->clear();
     $q->addTable('sysvals');
     $q->addInsert('sysval_key_id', 1);
     $q->addInsert('sysval_title', 'LinkType');
     $q->addInsert('sysval_value', "0|Unknown\n1|Document\n2|Application");
     $q->exec();
     return NULL;
 }
コード例 #9
0
 function saveNote($riskId, $userId, $riskDescription)
 {
     $q = new DBQuery();
     $q->addTable('risk_notes');
     $q->addInsert('risk_note_risk', $riskId);
     $q->addInsert('risk_note_creator', $userId);
     $q->addInsert('risk_note_date', 'NOW()', false, true);
     $q->addInsert('risk_note_description', $riskDescription);
     if (!$q->exec()) {
         return db_error();
     } else {
         return true;
     }
 }
コード例 #10
0
ファイル: setup.php プロジェクト: joly/web2project
    public function install()
    {
        $ok = true;
        $q = new DBQuery();
        $sql = '(
			resource_id integer not null auto_increment,
			resource_name varchar(255) not null default "",
			resource_key varchar(64) not null default "",
			resource_type integer not null default 0,
			resource_note text not null default "",
			resource_max_allocation integer not null default 100,
			primary key (resource_id),
			key (resource_name),
			key (resource_type)
		)';
        $q->createTable('resources', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $sql = '(
			resource_type_id integer not null auto_increment,
			resource_type_name varchar(255) not null default "",
			resource_type_note text,
			primary key (resource_type_id)
		)';
        $q->createTable('resource_types', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $sql = '(
			resource_id integer not null default 0,
			task_id integer not null default 0,
			percent_allocated integer not null default 100,
			key (resource_id),
			key (task_id, resource_id)
		)';
        $q->createTable('resource_tasks', $sql);
        $ok = $ok && $q->exec();
        $q->clear();
        $q->addTable('resource_types');
        $q->addInsert('resource_type_name', 'Equipment');
        $q->exec();
        $q->addInsert('resource_type_name', 'Tool');
        $q->exec();
        $q->addInsert('resource_type_name', 'Venue');
        $ok = $ok && $q->exec();
        if (!$ok) {
            return false;
        }
        return null;
    }
コード例 #11
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();
            }
        }
    }
}
コード例 #12
0
function insertCompany($company_name)
{
    $q = new DBQuery();
    $q->addTable("companies");
    $q->addInsert('company_name', $company_name);
    db_exec($q->prepareInsert());
    return db_insert_id();
}
コード例 #13
0
ファイル: tasks.class.php プロジェクト: joly/web2project
 public static function pinUserTask($userId, $taskId)
 {
     $q = new DBQuery();
     $q->addTable('user_task_pin');
     $q->addInsert('user_id', (int) $userId);
     $q->addInsert('task_id', (int) $taskId);
     if (!$q->exec()) {
         return 'Error pinning task';
     } else {
         return true;
     }
 }
コード例 #14
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;
 }
コード例 #15
0
 function store()
 {
     global $db;
     if (!is_array($this->options)) {
         $this->options = array();
     }
     //load the dbs options and compare them with the options
     $q = new DBQuery();
     $q->addTable('custom_fields_lists');
     $q->addWhere('field_id = ' . $this->field_id);
     $q->addOrder('list_value');
     if (!($rs = $q->exec())) {
         $q->clear();
         return $db->ErrorMsg();
     }
     $dboptions = array();
     while ($opt_row = $q->fetchRow()) {
         $dboptions[$opt_row['list_option_id']] = $opt_row['list_value'];
     }
     $q->clear();
     $newoptions = array();
     $newoptions = array_diff($this->options, $dboptions);
     $deleteoptions = array_diff($dboptions, $this->options);
     //insert the new options
     foreach ($newoptions as $opt) {
         $optid = $db->GenID('custom_fields_option_id', 1);
         $q = new DBQuery();
         $q->addTable('custom_fields_lists');
         $q->addInsert('field_id', $this->field_id);
         $q->addInsert('list_option_id', $optid);
         $q->addInsert('list_value', db_escape($opt));
         if (!$q->exec()) {
             $insert_error = $db->ErrorMsg();
         }
         $q->clear();
     }
     //delete the deleted options
     foreach ($deleteoptions as $opt => $value) {
         $q = new DBQuery();
         $q->setDelete('custom_fields_lists');
         $q->addWhere('list_option_id = ' . $opt);
         if (!$q->exec()) {
             $delete_error = $db->ErrorMsg();
         }
         $q->clear();
     }
     return $insert_error . ' ' . $delete_error;
 }
コード例 #16
0
 public function registerModule($module_name, $module_value, $section_value = 'app')
 {
     $q = new DBQuery();
     $q->addTable('gacl_axo');
     $q->addInsert('name', $module_name);
     $q->addInsert('value', $module_value);
     $q->addInsert('section_value', $section_value);
     $q->exec();
 }
コード例 #17
0
ファイル: setup.php プロジェクト: joly/web2project
    public function install()
    {
        $q = new DBQuery();
        $q->createTable('links');
        $q->createDefinition('(
link_id int( 11 ) NOT NULL AUTO_INCREMENT ,
link_url varchar( 255 ) NOT NULL default "",
link_project int( 11 ) NOT NULL default "0",
link_task int( 11 ) NOT NULL default "0",
link_name varchar( 255 ) NOT NULL default "",
link_parent int( 11 ) default "0",
link_description text,
link_owner int( 11 ) default "0",
link_date datetime default NULL ,
link_icon varchar( 20 ) default "obj/",
link_category int( 11 ) NOT NULL default "0",
PRIMARY KEY ( link_id ) ,
KEY idx_link_task ( link_task ) ,
KEY idx_link_project ( link_project ) ,
KEY idx_link_parent ( link_parent ) 
) TYPE = MYISAM ');
        $q->exec($sql);
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'LinkType');
        $q->addInsert('sysval_value', 'Unknown');
        $q->addInsert('sysval_value_id', '0');
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'LinkType');
        $q->addInsert('sysval_value', 'Document');
        $q->addInsert('sysval_value_id', '1');
        $q->exec();
        $q->clear();
        $q->addTable('sysvals');
        $q->addInsert('sysval_key_id', 1);
        $q->addInsert('sysval_title', 'LinkType');
        $q->addInsert('sysval_value', 'Application');
        $q->addInsert('sysval_value_id', '2');
        $q->exec();
        return null;
    }
コード例 #18
0
 /**
  * @todo Parent store could be partially used
  */
 function store()
 {
     global $AppUI;
     $q = new DBQuery();
     $this->dPTrimAll();
     $importing_tasks = false;
     $msg = $this->check();
     if ($msg) {
         $return_msg = array(get_class($this) . '::store-check', 'failed', '-');
         if (is_array($msg)) {
             return array_merge($return_msg, $msg);
         } else {
             array_push($return_msg, $msg);
             return $return_msg;
         }
     }
     if ($this->task_id) {
         addHistory('tasks', $this->task_id, 'update', $this->task_name, $this->task_project);
         $this->_action = 'updated';
         // Load and globalize the old, not yet updated task object
         // e.g. we need some info later to calculate the shifting time for depending tasks
         // see function update_dep_dates
         global $oTsk;
         $oTsk = new CTask();
         $oTsk->peek($this->task_id);
         // if task_status changed, then update subtasks
         if ($this->task_status != $oTsk->task_status) {
             $this->updateSubTasksStatus($this->task_status);
         }
         // Moving this task to another project?
         if ($this->task_project != $oTsk->task_project) {
             $this->updateSubTasksProject($this->task_project);
         }
         if ($this->task_dynamic == 1) {
             $this->updateDynamics(true);
         }
         // shiftDependentTasks needs this done first
         $this->check();
         $ret = db_updateObject('tasks', $this, 'task_id', false);
         // Milestone or task end date, or dynamic status has changed,
         // shift the dates of the tasks that depend on this task
         if ($this->task_end_date != $oTsk->task_end_date || $this->task_dynamic != $oTsk->task_dynamic || $this->task_milestone == '1') {
             $this->shiftDependentTasks();
         }
     } else {
         $this->_action = 'added';
         if ($this->task_start_date == '') {
             $this->task_start_date = '0000-00-00 00:00:00';
         }
         if ($this->task_end_date == '') {
             $this->task_end_date = '0000-00-00 00:00:00';
         }
         $ret = db_insertObject('tasks', $this, 'task_id');
         addHistory('tasks', $this->task_id, 'add', $this->task_name, $this->task_project);
         if (!$this->task_parent) {
             $q->addTable('tasks');
             $q->addUpdate('task_parent', $this->task_id);
             $q->addWhere('task_id = ' . $this->task_id);
             $q->exec();
             $q->clear();
         } else {
             // importing tasks do not update dynamics
             $importing_tasks = true;
         }
         // insert entry in user tasks
         $q->addTable('user_tasks');
         $q->addInsert('user_id', $AppUI->user_id);
         $q->addInsert('task_id', $this->task_id);
         $q->addInsert('user_type', '0');
         $q->exec();
         $q->clear();
     }
     //split out related departments and store them seperatly.
     $q->setDelete('task_departments');
     $q->addWhere('task_id=' . $this->task_id);
     $q->exec();
     $q->clear();
     // print_r($this->task_departments);
     if (!empty($this->task_departments)) {
         $departments = explode(',', $this->task_departments);
         foreach ($departments as $department) {
             $q->addTable('task_departments');
             $q->addInsert('task_id', $this->task_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('task_contacts');
     $q->addWhere('task_id=' . $this->task_id);
     $q->exec();
     $q->clear();
     if (!empty($this->task_contacts)) {
         $contacts = explode(',', $this->task_contacts);
         foreach ($contacts as $contact) {
             $q->addTable('task_contacts');
             $q->addInsert('task_id', $this->task_id);
             $q->addInsert('contact_id', $contact);
             $q->exec();
             $q->clear();
         }
     }
     // if is child update parent task
     if ($this->task_parent != $this->task_id) {
         if (!$importing_tasks) {
             $this->updateDynamics(true);
         }
         $pTask = new CTask();
         $pTask->load($this->task_parent);
         $pTask->updateDynamics();
         if ($oTsk->task_parent != $this->task_parent) {
             $old_parent = new CTask();
             $old_parent->load($oTsk->task_parent);
             $old_parent->updateDynamics();
         }
     }
     // update dependencies
     if (!empty($this->task_id)) {
         $this->updateDependencies($this->getDependencies());
     } else {
         // print_r($this);
     }
     if (!$ret) {
         return get_class($this) . '::store failed <br />' . db_error();
     } else {
         return NULL;
     }
 }
コード例 #19
0
ファイル: addedit.php プロジェクト: n2i/xvnkb
/*
// check permissions
if (!$canEdit) {
	$AppUI->setMsg('Access denied', UI_MSG_ERROR);
	$AppUI->redirect();
}
*/
$action = @$_REQUEST["action"];
$q = new DBQuery();
if ($action) {
    $history_description = dPgetParam($_POST, 'history_description', '');
    $history_project = dPgetParam($_POST, 'history_project', '');
    $userid = $AppUI->user_id;
    if ($action == 'add') {
        $q->addTable('history');
        $q->addInsert('history_table', "history");
        $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') {
コード例 #20
0
ファイル: configure.php プロジェクト: juliogallardo1326/proc
<?php

// deny all but system admins
$canEdit = !getDenyEdit('system');
if (!$canEdit) {
    $AppUI->redirect("m=public&a=access_denied");
}
$AppUI->savePlace();
$q = new DBQuery();
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 {
コード例 #21
0
##
$watch = isset($_POST['watch']) ? $_POST['watch'] : 0;
if ($watch) {
    // clear existing watches
    $q = new DBQuery();
    $q->setDelete('forum_watch');
    $q->addWhere('watch_user = '******'';
        $q->clear();
        foreach ($_POST as $k => $v) {
            if (mb_strpos($k, 'forum_') !== FALSE) {
                $q->addTable('forum_watch');
                $q->addInsert('watch_user', $AppUI->user_id);
                $q->addInsert('watch_' . $watch, mb_substr($k, 6));
                if (!$q->exec()) {
                    $AppUI->setMsg(db_error(), UI_MSG_ERROR);
                } else {
                    $AppUI->setMsg("Watch updated", UI_MSG_OK);
                }
                $q->clear();
            }
        }
    }
} else {
    $AppUI->setMsg('Incorrect watch type passed to sql handler.', UI_MSG_ERROR);
}
コード例 #22
0
" onclick="javascript:window.location='./index.php?m=forums&a=viewer&forum_id=<?php 
    echo $forum_id;
    ?>
&message_parent=<?php 
    echo $message_id;
    ?>
&post_message=1';" />
		<input type="button" class="button" value="<?php 
    echo $AppUI->_('New Topic');
    ?>
" onclick="javascript:window.location='./index.php?m=forums&a=viewer&forum_id=<?php 
    echo $forum_id;
    ?>
&message_id=0&post_message=1';" />
	<?php 
}
?>
	</td>
</tr>
</table>
<?php 
// Now we need to update the forum visits with the new messages so they don't show again.
foreach ($new_messages as $msg_id) {
    $q = new DBQuery();
    $q->addTable('forum_visits');
    $q->addInsert('visit_user', $AppUI->user_id);
    $q->addInsert('visit_forum', $forum_id);
    $q->addInsert('visit_message', $msg_id);
    $q->exec();
    $q->clear();
}
コード例 #23
0
ファイル: main_functions.php プロジェクト: n2i/xvnkb
function addHistory($table, $id, $action = 'modify', $description = '', $project_id = 0)
{
    global $AppUI, $dPconfig;
    /*
     * TODO:
     * 1) description should be something like:
     * 		command(arg1, arg2...)
     *  The command should be as module_action
     *  for example:
     * 		forums_new('Forum Name', 'URL')
     *
     * This way, the history module will be able to display descriptions
     * using locale definitions:
     * 		"forums_new" -> "New forum '%s' was created" -> "Se ha creado un nuevo foro llamado '%s'"
     *
     * 2) project_id and module_id should be provided in order to filter history entries
     *
     */
    if (!$dPconfig['log_changes']) {
        return;
    }
    $description = str_replace("'", "\\'", $description);
    //	$hsql = "select * from modules where mod_name = 'History' and mod_active = 1";
    $q = new DBQuery();
    $q->addTable('modules');
    $q->addWhere("mod_name = 'History' and mod_active = 1");
    $qid = $q->exec();
    if (!$qid || db_num_rows($qid) == 0) {
        $AppUI->setMsg("History module is not loaded, but your config file has requested that changes be logged.  You must either change the config file or install and activate the history module to log changes.", UI_MSG_ALERT);
        $q->clear();
        return;
    }
    $q->clear();
    $q->addTable('history');
    $q->addInsert('history_action', $action);
    $q->addInsert('history_item', $id);
    $q->addInsert('history_description', $description);
    $q->addInsert('history_user', $AppUI->user_id);
    $q->addInsert('history_date', 'now()', false, true);
    $q->addInsert('history_project', $project_id);
    $q->addInsert('history_table', $table);
    $q->exec();
    echo db_error();
    $q->clear();
}
コード例 #24
0
ファイル: ui.class.php プロジェクト: klr2003/sourceread
 function registerLogin()
 {
     $q = new DBQuery();
     $q->addTable('user_access_log');
     $q->addInsert('user_id', $this->user_id);
     $q->addInsert('date_time_in', 'now()', false, true);
     $q->addInsert('user_ip', $_SERVER['REMOTE_ADDR']);
     $q->exec();
     $this->last_insert_id = db_insert_id();
     $q->clear();
 }
コード例 #25
0
 function store()
 {
     global $db;
     if (!is_array($this->options)) {
         $this->options = array();
     }
     foreach ($this->options as $opt) {
         $optid = $db->GenID('custom_fields_option_id', 1);
         $q = new DBQuery();
         $q->addTable('custom_fields_lists');
         $q->addInsert('field_id', $this->field_id);
         $q->addInsert('list_option_id', $optid);
         $q->addInsert('list_value', db_escape(strip_tags($opt)));
         if (!$q->exec()) {
             $insert_error = $db->ErrorMsg();
         }
         $q->clear();
     }
     return $insert_error;
 }
コード例 #26
0
 function createsqluser($username, $password, $ldap_attribs = array())
 {
     global $db, $AppUI;
     $hash_pass = MD5($password);
     require_once $AppUI->getModuleClass("contacts");
     if (!count($ldap_attribs) == 0) {
         // Contact information based on the inetOrgPerson class schema
         $c = new CContact();
         $c->contact_first_name = $ldap_attribs["givenname"][0];
         $c->contact_last_name = $ldap_attribs["sn"][0];
         $c->contact_email = $ldap_attribs["mail"][0];
         $c->contact_phone = $ldap_attribs["telephonenumber"][0];
         $c->contact_mobile = $ldap_attribs["mobile"][0];
         $c->contact_city = $ldap_attribs["l"][0];
         $c->contact_country = $ldap_attribs["country"][0];
         $c->contact_state = $ldap_attribs["st"][0];
         $c->contact_zip = $ldap_attribs["postalcode"][0];
         $c->contact_job = $ldap_attribs["title"][0];
         //print_r($c); die();
         db_insertObject('contacts', $c, 'contact_id');
     }
     $contact_id = $c->contact_id == NULL ? "NULL" : $c->contact_id;
     $q = new DBQuery();
     $q->addTable('users');
     $q->addInsert('user_username', $username);
     $q->addInsert('user_password', $hash_pass);
     $q->addInsert('user_type', '1');
     $q->addInsert('user_contact', $c->contact_id);
     $q->exec();
     $user_id = $db->Insert_ID();
     $this->user_id = $user_id;
     $q->clear();
     $acl =& $AppUI->acl();
     $acl->insertUserRole($acl->get_group_id('anon'), $this->user_id);
 }
コード例 #27
0
ファイル: calendar.class.php プロジェクト: klr2003/sourceread
 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);
         }
     }
 }
コード例 #28
0
ファイル: view_messages.php プロジェクト: joly/web2project
&message_parent=<?php 
    echo $message_id;
    ?>
&post_message=1';" />
			<input type="button" class="button" value="<?php 
    echo $AppUI->_('New Topic');
    ?>
" onclick="javascript:window.location='./index.php?m=forums&a=viewer&forum_id=<?php 
    echo $forum_id;
    ?>
&message_id=0&post_message=1';" />
		<?php 
}
?>
		</td>
	</tr>
	</table>
</td></tr>
</table>
<?php 
// Now we need to update the forum visits with the new messages so they don't show again.
foreach ($new_messages as $msg_id) {
    $q = new DBQuery();
    $q->addTable('forum_visits');
    $q->addInsert('visit_user', $AppUI->user_id);
    $q->addInsert('visit_forum', $forum_id);
    $q->addInsert('visit_message', $msg_id);
    $q->addInsert('visit_date', $date->getDate());
    $q->exec();
    $q->clear();
}
コード例 #29
0
ファイル: vw_projecttask.php プロジェクト: joly/web2project
    $query_string = '?m=' . $m . '&amp;a=' . $a;
}
// Number of columns (used to calculate how many columns to span things through)
$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');
コード例 #30
0
 /**
  * Add an event to the queue.
  *
  * The callback can either be the name of a global function or the
  * name of a class
  * @param mixed $callback function to call when this event is due.
  * @param mixed $args Arguments to pass to the callback
  * @param string $module module, or originator of the event
  * @param string $type type of event (to allow searching)
  * @param integer $id id of originating event.
  * @param integer $date Seconds since 1970 to trigger event.
  * @param integer $repeat_interval seconds to repeat
  * @param integer $repeat_count number of times to repeat
  * @return integer queue id
  */
 function add($callback, &$args, $module, $sysmodule = false, $id = 0, $type = '', $date = 0, $repeat_interval = 0, $repeat_count = 1)
 {
     global $AppUI;
     if (!isset($AppUI)) {
         $user_id = 0;
     } else {
         $user_id = $AppUI->user_id;
     }
     if (is_array($callback)) {
         list($class, $method) = $callback;
         if (is_object($class)) {
             $class = get_class($class);
         }
         $caller = $class . '::' . $method;
     } else {
         $caller = $callback;
     }
     $q = new DBQuery();
     $q->addTable($this->table);
     $q->addInsert('queue_owner', $user_id);
     $q->addInsert('queue_start', $date);
     $q->addInsert('queue_callback', $caller);
     $q->addInsert('queue_data', serialize($args));
     $q->addInsert('queue_repeat_interval', $repeat_interval);
     $q->addInsert('queue_repeat_count', $repeat_count);
     $q->addInsert('queue_module', $module);
     $q->addInsert('queue_type', $type);
     $q->addInsert('queue_origin_id', $id);
     if ($sysmodule) {
         $q->addInsert('queue_module_type', 'system');
     } else {
         $q->addInsert('queue_module_type', 'module');
     }
     if ($q->exec()) {
         $return = db_insert_id();
     } else {
         $return = false;
     }
     $q->clear();
     return $return;
 }