Logo Search packages:      
Sourcecode: nag2 version File versions  Download package

Nag_Driver_sql::add ( name,
desc,
due = 0,
priority = 0,
completed = 0,
category = '',
alarm = 0,
uid = null 
)

Add a task to the backend storage.

Parameters:
string$nameThe name (short) of the task.
string$descThe description (long) of the task.
integer$dueThe due date of the task.
integer$priorityThe priority of the task.
integer$completedThe completion state of the task.
string$categoryThe category of the task.
integer$completedThe alarm associated with the task.
string$uidA Unique Identifier for the task.
Returns:
string The Nag ID of the new task.

Definition at line 147 of file sql.php.

References _connect(), Nag_Driver::generateUID(), and Nag_Driver::singleton().

    {
        /* Make sure we have a valid database connection. */
        $this->_connect();

        $taskId = md5(uniqid(mt_rand(), true));
        if (is_null($uid)) {
            $uid = $this->generateUID();
        }

        $query = sprintf(
            'INSERT INTO %s (task_owner, task_id, task_name, task_uid, ' .
            'task_desc, task_due, task_priority, task_completed, ' .
            'task_category, task_alarm) ' .
            'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
            $this->_params['table']);
        $values = array($this->_tasklist,
                        $taskId,
                        String::convertCharset($name, NLS::getCharset(), $this->_params['charset']),
                        String::convertCharset($uid, NLS::getCharset(), $this->_params['charset']),
                        String::convertCharset($desc, NLS::getCharset(), $this->_params['charset']),
                        (int)$due,
                        (int)$priority,
                        (int)$completed,
                        String::convertCharset($category, NLS::getCharset(), $this->_params['charset']),
                        (int)$alarm);

        /* Log the query at a DEBUG log level. */
        Horde::logMessage(sprintf('Nag_Driver_sql::add(): %s', $query),
                          __FILE__, __LINE__, PEAR_LOG_DEBUG);

        /* Attempt the insertion query. */
        $result = $this->_db->query($query, $values);

        /* Return an error immediately if the query failed. */
        if (is_a($result, 'PEAR_Error')) {
            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
            return $result;
        }

        /* Log the creation of this item in the history log. */
        $history = &Horde_History::singleton();
        $history->log('nag:' . $this->_tasklist . ':' . $uid, array('action' => 'add'), true);

        return $taskId;
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index