Example #1
0
        $db = static::getDb();
        $s = $db->prepare($sql);
        $values = [':name' => $name, ':type_id' => $type_id, ':is_common' => $is_common ? 1 : 0, ':additional' => $additional];
        $s->execute($values);
        return $db->lastInsertId();
    }
    public static function addCommonTask($name, $type_id, $additional)
    {
        return static::addTask($name, $type_id, true, $additional);
    }
    public static function addTaskToGroup($name, $type_id, $group_id, $additional)
    {
        $task_id = static::addTask($name, $type_id, false, $additional);
        if (static::addTaskGroup($task_id, $group_id)) {
            return $task_id;
        } else {
            return ['id' => 0];
        }
    }
    private static function addTaskGroup($task_id, $group_id)
    {
        $s = static::execSql('INSERT INTO task_group VALUES (:t,:g)', [':t' => $task_id, ':g' => $group_id]);
        return $s->errorCode() == "00000";
    }
    public static function logout()
    {
        setcookie(static::LOGIN_COOKIE, '', time() - 3600, "/admin/");
    }
}
CAdmin::init();